From 97ade9b0cf30aea4c8f509840dfd749a22bc8c6e Mon Sep 17 00:00:00 2001 From: Andrew Hughes Date: Wed, 3 Apr 2024 03:52:04 +0100 Subject: [PATCH] generate_source_tarball.sh: Handle an existing checkout - generate_source_tarball.sh: Sync indentation with java-21-openjdk version Related: RHEL-30937 --- java-1.8.0-openjdk.spec | 2 + scripts/generate_source_tarball.sh | 152 +++++++++++++++-------------- 2 files changed, 79 insertions(+), 75 deletions(-) diff --git a/java-1.8.0-openjdk.spec b/java-1.8.0-openjdk.spec index 39bbd1e..eef5994 100644 --- a/java-1.8.0-openjdk.spec +++ b/java-1.8.0-openjdk.spec @@ -2943,6 +2943,8 @@ cjc.mainProgram(args) - Remove obsolete file generate_singlerepo_source_tarball.sh - Remove obsolete file get_sources.sh - Remove obsolete file update_main_sources.sh +- generate_source_tarball.sh: Handle an existing checkout +- generate_source_tarball.sh: Sync indentation with java-21-openjdk version - Sync patch set with portable build - Related: RHEL-30937 diff --git a/scripts/generate_source_tarball.sh b/scripts/generate_source_tarball.sh index de9818a..84beb87 100755 --- a/scripts/generate_source_tarball.sh +++ b/scripts/generate_source_tarball.sh @@ -180,7 +180,7 @@ else fi if [ "$COMPRESSION" = "" ] ; then -# rhel 5 needs tar.gz + # rhel 5 needs tar.gz COMPRESSION=${COMPRESSION_DEFAULT} fi echo "Creating a tar.${COMPRESSION} archive" @@ -217,84 +217,86 @@ echo -e "\tREPO_ROOT: ${REPO_ROOT}" echo -e "\tJCONSOLE_PATCH: ${JCONSOLE_PATCH}" echo -e "\tBOOT_JDK: ${BOOT_JDK}" -mkdir "${FILE_NAME_ROOT}" +if [ -d "${FILE_NAME_ROOT}" ] ; then + echo "Reusing existing ${FILE_NAME_ROOT}" + STAT_TIME="$(stat --format=%Y "${FILE_NAME_ROOT}")" + TAR_TIME="$(date --date=@"${STAT_TIME}" --iso-8601=seconds)" +else + mkdir "${FILE_NAME_ROOT}" + pushd "${FILE_NAME_ROOT}" + echo "Cloning ${VERSION} root repository from ${REPO_ROOT}" + if realpath -q "${REPO_ROOT}"; then + echo "Local path detected; not adding depth argument"; + else + DEPTH="--depth=1"; + echo "Remote repository detected; adding ${DEPTH}"; + fi + git clone ${DEPTH} -b "${VERSION}" "${REPO_ROOT}" "${VERSION}" + pushd "${VERSION}" + TAR_TIME="$(git log --max-count 1 --format=%cI)" + + # UnderlineTaglet.java has a BSD license with a field-of-use restriction, making it non-Free + if [ -d langtools ] ; then + echo "Removing langtools test case with non-Free license" + rm -vf langtools/test/tools/javadoc/api/basic/TagletPathTest.java + rm -vf langtools/test/tools/javadoc/api/basic/taglets/UnderlineTaglet.java + fi + + if [ -d jdk ]; then + # jconsole.js has a BSD license with a field-of-use restriction, making it non-Free + echo "Removing jconsole-plugin file with non-Free license" + rm -vf jdk/src/share/demo/scripting/jconsole-plugin/src/resources/jconsole.js + fi + + echo "Patching out use of jconsole.js" + git apply --stat --apply -v -p1 "${JCONSOLE_PATCH}" + + find . -name '*.orig' -exec rm -vf '{}' ';' + popd + popd +fi pushd "${FILE_NAME_ROOT}" + # Generate .src-rev so build has knowledge of the revision the tarball was + # created from + mkdir build + pushd build + sh "${PWD}"/../"${VERSION}"/configure --with-boot-jdk="${BOOT_JDK}" + make store-source-revision + popd + rm -rf build -echo "Cloning ${VERSION} root repository from ${REPO_ROOT}" -if realpath -q "${REPO_ROOT}"; then - echo "Local path detected; not adding depth argument"; -else - DEPTH="--depth=1"; - echo "Remote repository detected; adding ${DEPTH}"; -fi -git clone ${DEPTH} -b "${VERSION}" "${REPO_ROOT}" "${VERSION}" + # Remove commit checks + echo "Removing $(find "${VERSION}" -name '.jcheck' -print)" + find "${VERSION}" -name '.jcheck' -print0 | xargs -0 rm -r -pushd "${VERSION}" - -TAR_TIME="$(git log --max-count 1 --format=%cI)" - -# UnderlineTaglet.java has a BSD license with a field-of-use restriction, making it non-Free -if [ -d langtools ] ; then - echo "Removing langtools test case with non-Free license" - rm -vf langtools/test/tools/javadoc/api/basic/TagletPathTest.java - rm -vf langtools/test/tools/javadoc/api/basic/taglets/UnderlineTaglet.java -fi - -if [ -d jdk ]; then - # jconsole.js has a BSD license with a field-of-use restriction, making it non-Free - echo "Removing jconsole-plugin file with non-Free license" - rm -vf jdk/src/share/demo/scripting/jconsole-plugin/src/resources/jconsole.js -fi - -echo "Patching out use of jconsole.js" -git apply --stat --apply -v -p1 "${JCONSOLE_PATCH}" - -find . -name '*.orig' -exec rm -vf '{}' ';' - -popd - -# Generate .src-rev so build has knowledge of the revision the tarball was -# created from -mkdir build -pushd build -sh "${PWD}"/../"${VERSION}"/configure --with-boot-jdk="${BOOT_JDK}" -make store-source-revision -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 '{}' '+' - -echo "Compressing remaining forest" -if [ "$COMPRESSION" = "xz" ] ; then - SWITCH=cJf -else - SWITCH=czf -fi -TARBALL_NAME=${FILE_NAME_ROOT}.tar.${COMPRESSION} -XZ_OPT=${XZ_OPT-"-T0"} \ - tar --mtime="${TAR_TIME}" --owner=root --group=root --sort=name \ - --exclude-vcs -$SWITCH "${TARBALL_NAME}" "${VERSION}" -mv "${TARBALL_NAME}" .. + # 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 '{}' '+' + echo "Compressing remaining forest" + if [ "$COMPRESSION" = "xz" ] ; then + SWITCH=cJf + else + SWITCH=czf + fi + TARBALL_NAME=${FILE_NAME_ROOT}.tar.${COMPRESSION} + XZ_OPT=${XZ_OPT-"-T0"} \ + tar --mtime="${TAR_TIME}" --owner=root --group=root --sort=name \ + --exclude-vcs -$SWITCH "${TARBALL_NAME}" "${VERSION}" + mv "${TARBALL_NAME}" .. popd if [ "$WITH_TEMP" != "" ] ; then echo "Tarball is: $(realpath .)/${TARBALL_NAME}"