|
@@ -1,5 +1,10 @@
|
|
#!/usr/bin/env bash
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
+# NOTE: if the output of this backend has to change (e.g. we change what gets
|
|
|
|
+# included in the archive (e.g. LFS), or we change the format of the archive
|
|
|
|
+# (e.g. tar options, compression ratio or method)), we MUST update the format
|
|
|
|
+# version in the variable BR_FMT_VERSION_git, in package/pkg-download.mk.
|
|
|
|
+
|
|
# We want to catch any unexpected failure, and exit immediately
|
|
# We want to catch any unexpected failure, and exit immediately
|
|
set -E
|
|
set -E
|
|
|
|
|
|
@@ -16,6 +21,8 @@ set -E
|
|
# Environment:
|
|
# Environment:
|
|
# GIT : the git command to call
|
|
# GIT : the git command to call
|
|
|
|
|
|
|
|
+. "${0%/*}/helpers"
|
|
|
|
+
|
|
# Save our path and options in case we need to call ourselves again
|
|
# Save our path and options in case we need to call ourselves again
|
|
myname="${0}"
|
|
myname="${0}"
|
|
declare -a OPTS=("${@}")
|
|
declare -a OPTS=("${@}")
|
|
@@ -170,8 +177,8 @@ _git checkout -f -q "'${cset}'"
|
|
_git clean -ffdx
|
|
_git clean -ffdx
|
|
|
|
|
|
# Get date of commit to generate a reproducible archive.
|
|
# Get date of commit to generate a reproducible archive.
|
|
-# %cD is RFC2822, so it's fully qualified, with TZ and all.
|
|
|
|
-date="$( _git log -1 --pretty=format:%cD )"
|
|
|
|
|
|
+# %ci is ISO 8601, so it's fully qualified, with TZ and all.
|
|
|
|
+date="$( _git log -1 --pretty=format:%ci )"
|
|
|
|
|
|
# There might be submodules, so fetch them.
|
|
# There might be submodules, so fetch them.
|
|
if [ ${recurse} -eq 1 ]; then
|
|
if [ ${recurse} -eq 1 ]; then
|
|
@@ -191,24 +198,12 @@ if [ ${recurse} -eq 1 ]; then
|
|
done
|
|
done
|
|
fi
|
|
fi
|
|
|
|
|
|
-# Generate the archive, sort with the C locale so that it is reproducible.
|
|
|
|
|
|
+popd >/dev/null
|
|
|
|
+
|
|
|
|
+# Generate the archive.
|
|
# We do not want the .git dir; we keep other .git files, in case they are the
|
|
# We do not want the .git dir; we keep other .git files, in case they are the
|
|
# only files in their directory.
|
|
# only files in their directory.
|
|
# The .git dir would generate non reproducible tarballs as it depends on
|
|
# The .git dir would generate non reproducible tarballs as it depends on
|
|
# the state of the remote server. It also would generate large tarballs
|
|
# the state of the remote server. It also would generate large tarballs
|
|
# (gigabytes for some linux trees) when a full clone took place.
|
|
# (gigabytes for some linux trees) when a full clone took place.
|
|
-find . -not -type d \
|
|
|
|
- -and -not -path "./.git/*" >"${output}.list"
|
|
|
|
-LC_ALL=C sort <"${output}.list" >"${output}.list.sorted"
|
|
|
|
-
|
|
|
|
-# Create GNU-format tarballs, since that's the format of the tarballs on
|
|
|
|
-# sources.buildroot.org and used in the *.hash files
|
|
|
|
-tar cf - --transform="s#^\./#${basename}/#" \
|
|
|
|
- --numeric-owner --owner=0 --group=0 --mtime="${date}" --format=gnu \
|
|
|
|
- -T "${output}.list.sorted" >"${output}.tar"
|
|
|
|
-gzip -6 -n <"${output}.tar" >"${output}"
|
|
|
|
-
|
|
|
|
-rm -f "${output}.list"
|
|
|
|
-rm -f "${output}.list.sorted"
|
|
|
|
-
|
|
|
|
-popd >/dev/null
|
|
|
|
|
|
+mk_tar_gz "${git_cache}" "${basename}" "${date}" "${output}" ".git/*"
|