generate_source_tarball.sh: Use git archive to generate tarball

- Related: RHEL-27133
This commit is contained in:
Thomas Fitzsimmons 2024-02-01 16:50:11 -05:00 committed by Andrew Hughes
parent 53fdb2b6a8
commit 9dc7cfb1b2
2 changed files with 22 additions and 26 deletions

View File

@ -211,40 +211,35 @@ pushd "${FILE_NAME_ROOT}"
popd
rm -rf build
# Remove commit checks
echo "Removing $(find "${VERSION}" -name '.jcheck' -print)"
find "${VERSION}" -name '.jcheck' -print0 | xargs -0 rm -r
# Remove history and GHA
echo "find ${VERSION} -name '.hgtags'"
find "${VERSION}" -name '.hgtags' -exec rm -v '{}' '+'
echo "find ${VERSION} -name '.hgignore'"
find "${VERSION}" -name '.hgignore' -exec rm -v '{}' '+'
echo "find ${VERSION} -name '.gitattributes'"
find "${VERSION}" -name '.gitattributes' -exec rm -v '{}' '+'
echo "find ${VERSION} -name '.gitignore'"
find "${VERSION}" -name '.gitignore' -exec rm -v '{}' '+'
# Work around some Git objects not having write permissions.
echo "chmod --recursive u+w ${VERSION}/.git"
chmod --recursive u+w "${VERSION}"/.git
echo "find ${VERSION} -name '.git'"
find "${VERSION}" -name '.git' -exec rm -rv '{}' '+'
echo "find ${VERSION} -name '.github'"
find "${VERSION}" -name '.github' -exec rm -rv '{}' '+'
EA_PART="$(awk -F= \
'/^DEFAULT_PROMOTED_VERSION_PRE/ { if ($2) print "-"$2 }' \
"${VERSION}"/make/conf/version-numbers.conf)"
TARBALL_BASE=${FILE_NAME_ROOT}${EA_PART}.tar
pushd "${VERSION}"
# Omit commit checks, history, and GHA from archive.
for skip in .jcheck .hgtags .hgignore .gitattributes .gitignore .github
do
echo "${skip}"" export-ignore" >> .git/info/attributes
done
# Do not bother with --mtime here; specify it to tar below.
# Unforunately, git-archive sorts added files like .src-rev at the end;
# retar below to use GNU tar --sort=name ordering which sorts .src-rev
# at the start.
git archive --output "${TARBALL_BASE}" --prefix="${VERSION}"/ \
--add-file=.src-rev --format=tar "${VERSION}"
popd
mv "${VERSION}" "${VERSION}".git
tar xf "${VERSION}".git/"${TARBALL_BASE}"
echo "Compressing remaining forest"
if [ "$COMPRESSION" = "xz" ] ; then
SWITCH=cJf
else
SWITCH=czf
fi
EA_PART="$(awk -F= \
'/^DEFAULT_PROMOTED_VERSION_PRE/ { if ($2) print "-"$2 }' \
"${VERSION}"/make/conf/version-numbers.conf)"
TARBALL_NAME=${FILE_NAME_ROOT}${EA_PART}.tar.${COMPRESSION}
TARBALL_NAME=${TARBALL_BASE}.${COMPRESSION}
XZ_OPT=${XZ_OPT-"-T0"} \
tar --mtime="${TAR_TIME}" --owner=root --group=root --sort=name \
--exclude-vcs -$SWITCH "${TARBALL_NAME}" "${TO_COMPRESS}"
-$SWITCH "${TARBALL_NAME}" "${TO_COMPRESS}"
mv "${TARBALL_NAME}" ..
popd
if [ "$WITH_TEMP" != "" ] ; then

View File

@ -2493,6 +2493,7 @@ require "copy_jdk_configs.lua"
- generate_source_tarball.sh: Fix whitespace
- generate_source_tarball.sh: Skip -ga tags
- generate_source_tarball.sh: Get -ea suffix from version-numbers.conf
- generate_source_tarball.sh: Use git archive to generate tarball
- Related: RHEL-27133
* Thu Jan 11 2024 Andrew Hughes <gnu.andrew@redhat.com> - 1:17.0.10.0.7-2