From 9dc7cfb1b2b3bf14f03074f79ef75dec3a35ee92 Mon Sep 17 00:00:00 2001 From: Thomas Fitzsimmons Date: Thu, 1 Feb 2024 16:50:11 -0500 Subject: [PATCH] generate_source_tarball.sh: Use git archive to generate tarball - Related: RHEL-27133 --- generate_source_tarball.sh | 47 +++++++++++++++++--------------------- java-17-openjdk.spec | 1 + 2 files changed, 22 insertions(+), 26 deletions(-) diff --git a/generate_source_tarball.sh b/generate_source_tarball.sh index 2132d89..82f37f2 100755 --- a/generate_source_tarball.sh +++ b/generate_source_tarball.sh @@ -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 diff --git a/java-17-openjdk.spec b/java-17-openjdk.spec index 18fe123..80cf3e0 100644 --- a/java-17-openjdk.spec +++ b/java-17-openjdk.spec @@ -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 - 1:17.0.10.0.7-2