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 popd
rm -rf build rm -rf build
# Remove commit checks EA_PART="$(awk -F= \
echo "Removing $(find "${VERSION}" -name '.jcheck' -print)" '/^DEFAULT_PROMOTED_VERSION_PRE/ { if ($2) print "-"$2 }' \
find "${VERSION}" -name '.jcheck' -print0 | xargs -0 rm -r "${VERSION}"/make/conf/version-numbers.conf)"
TARBALL_BASE=${FILE_NAME_ROOT}${EA_PART}.tar
# Remove history and GHA pushd "${VERSION}"
echo "find ${VERSION} -name '.hgtags'" # Omit commit checks, history, and GHA from archive.
find "${VERSION}" -name '.hgtags' -exec rm -v '{}' '+' for skip in .jcheck .hgtags .hgignore .gitattributes .gitignore .github
echo "find ${VERSION} -name '.hgignore'" do
find "${VERSION}" -name '.hgignore' -exec rm -v '{}' '+' echo "${skip}"" export-ignore" >> .git/info/attributes
echo "find ${VERSION} -name '.gitattributes'" done
find "${VERSION}" -name '.gitattributes' -exec rm -v '{}' '+' # Do not bother with --mtime here; specify it to tar below.
echo "find ${VERSION} -name '.gitignore'" # Unforunately, git-archive sorts added files like .src-rev at the end;
find "${VERSION}" -name '.gitignore' -exec rm -v '{}' '+' # retar below to use GNU tar --sort=name ordering which sorts .src-rev
# Work around some Git objects not having write permissions. # at the start.
echo "chmod --recursive u+w ${VERSION}/.git" git archive --output "${TARBALL_BASE}" --prefix="${VERSION}"/ \
chmod --recursive u+w "${VERSION}"/.git --add-file=.src-rev --format=tar "${VERSION}"
echo "find ${VERSION} -name '.git'" popd
find "${VERSION}" -name '.git' -exec rm -rv '{}' '+' mv "${VERSION}" "${VERSION}".git
echo "find ${VERSION} -name '.github'" tar xf "${VERSION}".git/"${TARBALL_BASE}"
find "${VERSION}" -name '.github' -exec rm -rv '{}' '+'
echo "Compressing remaining forest" echo "Compressing remaining forest"
if [ "$COMPRESSION" = "xz" ] ; then if [ "$COMPRESSION" = "xz" ] ; then
SWITCH=cJf SWITCH=cJf
else else
SWITCH=czf SWITCH=czf
fi fi
EA_PART="$(awk -F= \ TARBALL_NAME=${TARBALL_BASE}.${COMPRESSION}
'/^DEFAULT_PROMOTED_VERSION_PRE/ { if ($2) print "-"$2 }' \
"${VERSION}"/make/conf/version-numbers.conf)"
TARBALL_NAME=${FILE_NAME_ROOT}${EA_PART}.tar.${COMPRESSION}
XZ_OPT=${XZ_OPT-"-T0"} \ XZ_OPT=${XZ_OPT-"-T0"} \
tar --mtime="${TAR_TIME}" --owner=root --group=root --sort=name \ 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}" .. mv "${TARBALL_NAME}" ..
popd popd
if [ "$WITH_TEMP" != "" ] ; then 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: Fix whitespace
- generate_source_tarball.sh: Skip -ga tags - generate_source_tarball.sh: Skip -ga tags
- generate_source_tarball.sh: Get -ea suffix from version-numbers.conf - generate_source_tarball.sh: Get -ea suffix from version-numbers.conf
- generate_source_tarball.sh: Use git archive to generate tarball
- Related: RHEL-27133 - Related: RHEL-27133
* Thu Jan 11 2024 Andrew Hughes <gnu.andrew@redhat.com> - 1:17.0.10.0.7-2 * Thu Jan 11 2024 Andrew Hughes <gnu.andrew@redhat.com> - 1:17.0.10.0.7-2