Skip to content

Commit 12c4c6c

Browse files
aaronpucherttstellar
authored andcommitted
Build reproducible tarballs for releases
Currently the tarballs contain superfluous metadata, like the user name of the packager and via Pax headers even the PID of the tar process that packaged the files. We build the monorepo projects directly from the git repo using "git archive" and for the test-suite we add some flags as recommended by https://reproducible-builds.org/docs/archives/. We don't use numeric owners though to be compatible with "git archive". The advantage of "git archive" is that the releaser doesn't have to download the tar ball and extract it, rather the archive is built directly from the repository. This is probably what GitHub uses internally to produce the tarballs, so I wouldn't expect a difference. Reviewed By: tstellar Differential Revision: https://reviews.llvm.org/D91494 (cherry picked from commit 1a00929)
1 parent fd623ba commit 12c4c6c

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed

llvm/utils/release/export.sh

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
set -e
1515

16-
projects="llvm clang test-suite compiler-rt libcxx libcxxabi libclc clang-tools-extra polly lldb lld openmp libunwind flang"
16+
projects="llvm clang compiler-rt libcxx libcxxabi libclc clang-tools-extra polly lldb lld openmp libunwind flang"
1717

1818
release=""
1919
rc=""
@@ -37,26 +37,34 @@ export_sources() {
3737
tag="$tag-$rc"
3838
fi
3939

40-
llvm_src_dir=llvm-project-$release$rc
41-
mkdir -p $llvm_src_dir
40+
llvm_src_dir=$(readlink -f $(dirname "$(readlink -f "$0")")/../../..)
41+
[ -d $llvm_src_dir/.git ] || ( echo "No git repository at $llvm_src_dir" ; exit 1 )
4242

4343
echo $tag
44-
echo "Fetching LLVM project source ..."
45-
curl -L https://github.com/llvm/llvm-project/archive/$tag.tar.gz | \
46-
tar -C $llvm_src_dir --strip-components=1 -xzf -
44+
target_dir=$(pwd)
4745

4846
echo "Creating tarball for llvm-project ..."
49-
tar -cJf llvm-project-$release$rc.tar.xz $llvm_src_dir
47+
pushd $llvm_src_dir/
48+
git archive --prefix=llvm-project-$release$rc.src/ $tag . | xz >$target_dir/llvm-project-$release$rc.src.tar.xz
49+
popd
5050

51-
echo "Fetching LLVM test-suite source ..."
52-
mkdir -p $llvm_src_dir/test-suite
53-
curl -L https://github.com/llvm/test-suite/archive/$tag.tar.gz | \
54-
tar -C $llvm_src_dir/test-suite --strip-components=1 -xzf -
51+
if [ ! -d test-suite-$release$rc.src ]
52+
then
53+
echo "Fetching LLVM test-suite source ..."
54+
mkdir -p test-suite-$release$rc.src
55+
curl -L https://github.com/llvm/test-suite/archive/$tag.tar.gz | \
56+
tar -C test-suite-$release$rc.src --strip-components=1 -xzf -
57+
fi
58+
echo "Creating tarball for test-suite ..."
59+
tar --sort=name --owner=0 --group=0 \
60+
--pax-option=exthdr.name=%d/PaxHeaders/%f,delete=atime,delete=ctime \
61+
-cJf test-suite-$release$rc.src.tar.xz test-suite-$release$rc.src
5562

5663
for proj in $projects; do
5764
echo "Creating tarball for $proj ..."
58-
mv $llvm_src_dir/$proj $llvm_src_dir/$proj-$release$rc.src
59-
tar -C $llvm_src_dir -cJf $proj-$release$rc.src.tar.xz $proj-$release$rc.src
65+
pushd $llvm_src_dir/$proj
66+
git archive --prefix=$proj-$release$rc.src/ $tag . | xz >$target_dir/$proj-$release$rc.src.tar.xz
67+
popd
6068
done
6169
}
6270

0 commit comments

Comments
 (0)