Merge pull request #2535 from signalwire/reproducable-src

[UTIL] Generate reproducible source archive.
This commit is contained in:
Andrey Volk 2024-07-22 19:39:53 +03:00 committed by GitHub
commit 56fdaaf33a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 29 additions and 4 deletions

33
debian/util.sh vendored
View File

@ -203,11 +203,16 @@ create_orig () {
done done
shift $(($OPTIND-1)) shift $(($OPTIND-1))
local orig local commit_epoch=$(git log -1 --format=%ct)
local source_date=$(date -u -d @$commit_epoch +'%Y-%m-%d %H:%M:%S')
local orig git_archive_prefix
if $auto_orig; then if $auto_orig; then
orig="../freeswitch_$(debian/version-omit_revision.pl).orig.tar.xz" orig="../freeswitch_$(debian/version-omit_revision.pl).orig.tar.xz"
git_archive_prefix="freeswitch/"
else else
orig="../freeswitch_$(mk_dver "$uver")~$(lsb_release -sc).orig.tar.xz" orig="../freeswitch_$(mk_dver "$uver")~$(lsb_release -sc).orig.tar.xz"
git_archive_prefix="freeswitch-$uver/"
fi fi
mv .gitattributes .gitattributes.orig mv .gitattributes .gitattributes.orig
@ -226,12 +231,32 @@ create_orig () {
git add -f configure.ac .version git add -f configure.ac .version
git commit --allow-empty -m "nightly v$uver" git commit --allow-empty -m "nightly v$uver"
local tmpsrcdir="$(mktemp -d)"
git archive -v \ git archive -v \
--worktree-attributes \ --worktree-attributes \
--format=tar \ --format=tar \
--prefix=freeswitch-$uver/ \ --prefix=$git_archive_prefix \
HEAD \ HEAD | tar --extract --directory="$tmpsrcdir"
| xz -c -${zl}v > $orig
# https://www.gnu.org/software/tar/manual/html_section/Reproducibility.html
tar \
--sort=name \
--format=posix \
--pax-option='exthdr.name=%d/PaxHeaders/%f' \
--pax-option='delete=atime,delete=ctime' \
--clamp-mtime \
--mtime="$source_date" \
--numeric-owner \
--owner=0 \
--group=0 \
--mode='go+u,go-w' \
--create \
--directory="$tmpsrcdir" \
. | xz -v -c -${zl} > "$orig" && \
rm -rf "$tmpsrcdir"
echo "Source archive checksum:"
sha256sum $orig
mv .gitattributes.orig .gitattributes mv .gitattributes.orig .gitattributes