From dcb5dc7a2197093c52d61cd8d2dcaac4a7c1ad6e Mon Sep 17 00:00:00 2001 From: Andrew Hughes Date: Fri, 29 Mar 2024 17:02:54 +0000 Subject: [PATCH] Make source tarballs reproducible and support construction in a temporary directory. Move to upstream tag style (shenandoah8ux-by) in preparation for eventually moving back to official sources - generate_source_tarball.sh: Add WITH_TEMP environment variable - generate_source_tarball.sh: Multithread xz on all available cores - generate_source_tarball.sh: Add OPENJDK_LATEST environment variable - generate_source_tarball.sh: Update comment about tarball naming - generate_source_tarball.sh: Reformat comment header - generate_source_tarball.sh: Reformat and update help output - generate_source_tarball.sh: Do a shallow clone, for speed - generate_source_tarball.sh: Eliminate some removal prompting - generate_source_tarball.sh: Make tarball reproducible - generate_source_tarball.sh: Prefix temporary directory with temp- - generate_source_tarball.sh: Remove temporary directory exit conditions - generate_source_tarball.sh: Rename JCONSOLE_JS_PATCH{,_DEFAULT} to JCONSOLE_PATCH{,_DEFAULT} for brevity - generate_source_tarball.sh: Adapt OPENJDK_LATEST logic to work with 8u Shenandoah fork - generate_source_tarball.sh: Adapt version logic to work with 8u Related: RHEL-30925 --- .gitignore | 1 + generate_source_tarball.sh | 168 ++++++++++++++++++++++++++----------- java-1.8.0-openjdk.spec | 27 ++++-- sources | 2 +- 4 files changed, 140 insertions(+), 58 deletions(-) diff --git a/.gitignore b/.gitignore index e6b2de5..42e3f29 100644 --- a/.gitignore +++ b/.gitignore @@ -300,3 +300,4 @@ /openjdk-shenandoah-jdk8u-shenandoah-jdk8u402-b05.tar.xz /openjdk-shenandoah-jdk8u-shenandoah-jdk8u402-b06.tar.xz /openjdk-shenandoah-jdk8u-shenandoah-jdk8u412-b01.tar.xz +/shenandoah8u412-b01.tar.xz diff --git a/generate_source_tarball.sh b/generate_source_tarball.sh index 3c31664..5c51361 100755 --- a/generate_source_tarball.sh +++ b/generate_source_tarball.sh @@ -1,33 +1,43 @@ #!/bin/bash # Generates the 'source tarball' for JDK 8 projects. # -# Example: -# When used from local repo set REPO_ROOT pointing to file:// with your repo -# If your local repo follows upstream forests conventions, it may be enough to set OPENJDK_URL +# Example 1: +# When used from local repo set REPO_ROOT pointing to file:// with your repo. +# If your local repo follows upstream forests conventions, it may be enough to +# set OPENJDK_URL. +# +# Example 2: +# This will read the OpenJDK feature version from the spec file, then create a +# tarball from the most recent tag for that version in the upstream Git +# repository. +# +# $ OPENJDK_LATEST=1 ./generate_source_tarball.sh +# [...] +# Tarball is: temp-generated-source-tarball-ujD/openjdk-17.0.10+6-ea.tar.xz +# +# Unless you use OPENJDK_LATEST, you have to set PROJECT_NAME, REPO_NAME and +# VERSION, e.g.: # -# In any case you have to set PROJECT_NAME REPO_NAME and VERSION. eg: # PROJECT_NAME=openjdk # REPO_NAME=shenandoah-jdk8u # VERSION=HEAD # -# They are used to create correct name and are used in construction of sources url (unless REPO_ROOT is set) - -# This script creates a single source tarball out of the repository -# based on the given tag and removes code not allowed in fedora/rhel. For -# consistency, the source tarball will always contain 'openjdk' as the top -# level folder, name is created, based on parameter +# They are used to create correct name and are used in construction of sources +# URL (unless REPO_ROOT is set). # +# This script creates a single source tarball out of the repository based on the +# given tag and removes code not allowed in Fedora/RHEL. SCRIPT_DIR=$(dirname $0) -JCONSOLE_JS_PATCH_DEFAULT=${SCRIPT_DIR}/jconsole-plugin.patch +JCONSOLE_PATCH_DEFAULT=${SCRIPT_DIR}/jconsole-plugin.patch -if [ "x${JCONSOLE_JS_PATCH}" != "x" ] ; then - if [ ! -f "${JCONSOLE_JS_PATCH}" ] ; then - echo "You have specified the jconsole.js patch as ${JCONSOLE_JS_PATCH} but it does not exist. Exiting."; +if [ "x${JCONSOLE_PATCH}" != "x" ] ; then + if [ ! -f "${JCONSOLE_PATCH}" ] ; then + echo "You have specified the jconsole.js patch as ${JCONSOLE_PATCH} but it does not exist. Exiting."; exit 2; fi else - JCONSOLE_JS_PATCH=${JCONSOLE_JS_PATCH_DEFAULT} + JCONSOLE_PATCH=${JCONSOLE_PATCH_DEFAULT} fi set -e @@ -35,43 +45,81 @@ set -e OPENJDK_URL_DEFAULT=https://github.com COMPRESSION_DEFAULT=xz -if [ "x$1" = "xhelp" ] ; then - echo -e "Behaviour may be specified by setting the following variables:\n" - echo "VERSION - the version of the specified OpenJDK project" - echo "PROJECT_NAME -- the name of the OpenJDK project being archived (optional; only needed by defaults)" - echo "REPO_NAME - the name of the OpenJDK repository (optional; only needed by defaults)" - echo "OPENJDK_URL - the URL to retrieve code from (optional; defaults to ${OPENJDK_URL_DEFAULT})" - echo "COMPRESSION - the compression type to use (optional; defaults to ${COMPRESSION_DEFAULT})" - echo "FILE_NAME_ROOT - name of the archive, minus extensions (optional; defaults to PROJECT_NAME-REPO_NAME-VERSION)" - echo "REPO_ROOT - the location of the Git repository to archive (optional; defaults to OPENJDK_URL/PROJECT_NAME/REPO_NAME)" - echo "JCONSOLE_JS_PATCH - the path to a patch to fix non-availiability of jconsole.js (optional; defaults to ${JCONSOLE_JS_PATCH_DEFAULT})" - echo "BOOT_JDK - the bootstrap JDK to satisfy the configure run" +if [ "$1" = "help" ] ; then + echo "Behaviour may be specified by setting the following variables:" + echo + echo "VERSION - the version of the specified OpenJDK project" + echo " (required unless OPENJDK_LATEST is set)" + echo "PROJECT_NAME - the name of the OpenJDK project being archived" + echo " (needed to compute REPO_ROOT and/or" + echo " FILE_NAME_ROOT automatically;" + echo " optional if they are set explicitly)" + echo "REPO_NAME - the name of the OpenJDK repository" + echo " (needed to compute REPO_ROOT automatically;" + echo " optional if REPO_ROOT is set explicitly)" + echo "OPENJDK_URL - the URL to retrieve code from" + echo " (defaults to ${OPENJDK_URL_DEFAULT})" + echo "COMPRESSION - the compression type to use" + echo " (defaults to ${COMPRESSION_DEFAULT})" + echo "FILE_NAME_ROOT - name of the archive, minus extensions" + echo " (defaults to PROJECT_NAME-VERSION)" + echo "REPO_ROOT - the location of the Git repository to archive" + echo " (defaults to OPENJDK_URL/PROJECT_NAME/REPO_NAME.git)" + echo "JCONSOLE_PATCH - the path to a patch to fix non-availiability of" + echo " jconsole.js (optional; defaults to ${JCONSOLE_PATCH_DEFAULT})" + echo "BOOT_JDK - the bootstrap JDK to satisfy the configure run" + echo " (defaults to packaged JDK version)" + echo "WITH_TEMP - run in a temporary directory" + echo " (defaults to disabled)" + echo "OPENJDK_LATEST - deduce VERSION from most recent upstream tag" + echo " (implies WITH_TEMP, computes everything else" + echo " automatically; Note: accesses network to read" + echo " tag list from remote Git repository)" exit 1; fi +if [ "$OPENJDK_LATEST" != "" ] ; then + FEATURE_VERSION=$(echo '%majorver' \ + | rpmspec --shell ./*.spec 2>/dev/null \ + | grep --after-context 1 majorver \ + | tail --lines 1) + PROJECT_NAME=openjdk + REPO_NAME=shenandoah-jdk"${FEATURE_VERSION}"u + # FIXME: Temporarily use private fork until main repository is in sync + VERSION=$(git ls-remote --tags --refs --sort=-version:refname \ + "${OPENJDK_URL_DEFAULT}/gnu-andrew/${REPO_NAME}.git" \ + "shenandoah${FEATURE_VERSION}u*" \ + | head --lines 1 | cut --characters 52-) + FILE_NAME_ROOT=${VERSION} + WITH_TEMP=1 +fi -if [ "x$VERSION" = "x" ] ; then +if [ "$WITH_TEMP" != "" ] ; then + pushd "$(mktemp --directory temp-generated-source-tarball-XXX)" +fi + +if [ "$VERSION" = "" ] ; then echo "No VERSION specified" exit 2 fi echo "Version: ${VERSION}" -NUM_VER=${VERSION##jdk-} -RELEASE_VER=${NUM_VER%%+*} -BUILD_VER=${NUM_VER##*+} -MAJOR_VER=${RELEASE_VER%%.*} +NUM_VER=${VERSION##shenandoah} +RELEASE_VER=${NUM_VER%%-b*} +BUILD_VER=${NUM_VER##*-} +MAJOR_VER=${RELEASE_VER%%u*} echo "Major version is ${MAJOR_VER}, release ${RELEASE_VER}, build ${BUILD_VER}" if [ "x$BOOT_JDK" = "x" ] ; then echo "No boot JDK specified". - BOOT_JDK=/usr/lib/jvm/java-${MAJOR_VER}-openjdk; + BOOT_JDK=/usr/lib/jvm/java-1.${MAJOR_VER}.0-openjdk; echo -n "Checking for ${BOOT_JDK}..."; if [ -d ${BOOT_JDK} -a -x ${BOOT_JDK}/bin/java ] ; then echo "Boot JDK found at ${BOOT_JDK}"; else echo "Not found"; PREV_VER=$((${MAJOR_VER} - 1)); - BOOT_JDK=/usr/lib/jvm/java-${PREV_VER}-openjdk; + BOOT_JDK=/usr/lib/jvm/java-1.${PREV_VER}.0-openjdk; echo -n "Checking for ${BOOT_JDK}..."; if [ -d ${BOOT_JDK} -a -x ${BOOT_JDK}/bin/java ] ; then echo "Boot JDK found at ${BOOT_JDK}"; @@ -128,16 +176,18 @@ echo -e "\tOPENJDK_URL: ${OPENJDK_URL}" echo -e "\tCOMPRESSION: ${COMPRESSION}" echo -e "\tFILE_NAME_ROOT: ${FILE_NAME_ROOT}" echo -e "\tREPO_ROOT: ${REPO_ROOT}" -echo -e "\tJCONSOLE_JS_PATCH: ${JCONSOLE_JS_PATCH}" +echo -e "\tJCONSOLE_PATCH: ${JCONSOLE_PATCH}" echo -e "\tBOOT_JDK: ${BOOT_JDK}" mkdir "${FILE_NAME_ROOT}" pushd "${FILE_NAME_ROOT}" echo "Cloning ${VERSION} root repository from ${REPO_ROOT}" -git clone -b ${VERSION} ${REPO_ROOT} ${VERSION} +git clone --depth=1 -b "${VERSION}" "${REPO_ROOT}" "${VERSION}" -pushd ${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 @@ -153,47 +203,63 @@ if [ -d jdk ]; then fi echo "Patching out use of jconsole.js" -git apply --stat --apply -v -p1 ${JCONSOLE_JS_PATCH} +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 +# 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} +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 +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 '{}' '+' +find "${VERSION}" -name '.hgtags' -exec rm -v '{}' '+' echo "find ${VERSION} -name '.hgignore'" -find ${VERSION} -name '.hgignore' -exec rm -v '{}' '+' +find "${VERSION}" -name '.hgignore' -exec rm -v '{}' '+' echo "find ${VERSION} -name '.gitattributes'" -find ${VERSION} -name '.gitattributes' -exec rm -v '{}' '+' +find "${VERSION}" -name '.gitattributes' -exec rm -v '{}' '+' echo "find ${VERSION} -name '.gitignore'" -find ${VERSION} -name '.gitignore' -exec rm -v '{}' '+' +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 '{}' '+' +find "${VERSION}" -name '.git' -exec rm -rv '{}' '+' echo "find ${VERSION} -name '.github'" -find ${VERSION} -name '.github' -exec rm -rv '{}' '+' +find "${VERSION}" -name '.github' -exec rm -rv '{}' '+' echo "Compressing remaining forest" -if [ "X$COMPRESSION" = "Xxz" ] ; then +if [ "$COMPRESSION" = "xz" ] ; then SWITCH=cJf else SWITCH=czf fi TARBALL_NAME=${FILE_NAME_ROOT}.tar.${COMPRESSION} -tar --exclude-vcs -$SWITCH ${TARBALL_NAME} ${VERSION} -mv ${TARBALL_NAME} .. +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 -echo "Done. You may want to remove the uncompressed version." +if [ "$WITH_TEMP" != "" ] ; then + echo "Tarball is: $(realpath --relative-to=.. .)/${TARBALL_NAME}" + popd +else + echo -n "Done. You may want to remove the uncompressed version" + echo " - $FILE_NAME_ROOT." +fi + +# Local Variables: +# fill-column: 80 +# End: diff --git a/java-1.8.0-openjdk.spec b/java-1.8.0-openjdk.spec index 4f8da75..50ffe24 100644 --- a/java-1.8.0-openjdk.spec +++ b/java-1.8.0-openjdk.spec @@ -297,8 +297,8 @@ # Define version of OpenJDK 8 used %global project openjdk %global repo shenandoah-jdk8u -%global openjdk_revision jdk8u412-b01 -%global shenandoah_revision shenandoah-%{openjdk_revision} +%global openjdk_revision 8u412-b01 +%global shenandoah_revision shenandoah%{openjdk_revision} # Define IcedTea version used for SystemTap tapsets and desktop files %global icedteaver 3.15.0 # Define current Git revision for the FIPS support patches @@ -1314,14 +1314,14 @@ License: ASL 1.1 and ASL 2.0 and BSD and BSD with advertising and GPL+ and GPLv URL: http://openjdk.java.net/ # Shenandoah HotSpot -# aarch64-port/jdk8u-shenandoah contains an integration forest of -# OpenJDK 8u, the aarch64 port and Shenandoah +# openjdk/shenandoah-jdk8u contains an integration forest of +# OpenJDK 8u and the Shenandoah garbage collector # To regenerate, use: # VERSION=%%{shenandoah_revision} -# FILE_NAME_ROOT=%%{project}-%%{repo}-${VERSION} +# FILE_NAME_ROOT=${VERSION} # REPO_ROOT= generate_source_tarball.sh # where the source is obtained from http://github.com/%%{project}/%%{repo} -Source0: %{project}-%{repo}-%{shenandoah_revision}.tar.xz +Source0: %{shenandoah_revision}.tar.xz # Use 'icedtea_sync.sh' to update the following # They are based on code contained in the IcedTea project (3.x). @@ -2648,10 +2648,25 @@ cjc.mainProgram(args) %changelog * Fri Mar 22 2024 Andrew Hughes - 1:1.8.0.412.b01-0.2.ea - Turn off xz multi-threading on i686 as it fails with an out of memory error +- Move to upstream tag style (shenandoah8ux-by) in preparation for eventually moving back to official sources +- generate_source_tarball.sh: Rename JCONSOLE_JS_PATCH{,_DEFAULT} to JCONSOLE_PATCH{,_DEFAULT} for brevity +- generate_source_tarball.sh: Adapt OPENJDK_LATEST logic to work with 8u Shenandoah fork +- generate_source_tarball.sh: Adapt version logic to work with 8u - Related: RHEL-30925 * Fri Mar 22 2024 Thomas Fitzsimmons - 1:1.8.0.412.b01-0.2.ea - Invoke xz in multi-threaded mode +- generate_source_tarball.sh: Add WITH_TEMP environment variable +- generate_source_tarball.sh: Multithread xz on all available cores +- generate_source_tarball.sh: Add OPENJDK_LATEST environment variable +- generate_source_tarball.sh: Update comment about tarball naming +- generate_source_tarball.sh: Reformat comment header +- generate_source_tarball.sh: Reformat and update help output +- generate_source_tarball.sh: Do a shallow clone, for speed +- generate_source_tarball.sh: Eliminate some removal prompting +- generate_source_tarball.sh: Make tarball reproducible +- generate_source_tarball.sh: Prefix temporary directory with temp- +- generate_source_tarball.sh: Remove temporary directory exit conditions - Related: RHEL-30925 * Thu Mar 21 2024 Andrew Hughes - 1:1.8.0.412.b01-0.2.ea diff --git a/sources b/sources index 0a84870..708e0fb 100644 --- a/sources +++ b/sources @@ -1,2 +1,2 @@ SHA512 (tapsets-icedtea-3.15.0.tar.xz) = c752a197cb3d812d50c35e11e4722772be40096c81d2a57933e0d9b8a3c708b9c157b8108a4e33a06ca7bb81648170994408c75d6f69d5ff12785d0c31009671 -SHA512 (openjdk-shenandoah-jdk8u-shenandoah-jdk8u412-b01.tar.xz) = 558a47280e157084be15795f65a3fd3a8a04b9a623735d711d6425ab3ff2ee2111e563c003553111eaf98022aa8bbcd908a8a1937c3630f96bca1ab487173d94 +SHA512 (shenandoah8u412-b01.tar.xz) = 31b27506ced6f1dddbbe6ace81ff8a4a22b60347c763c5bcef5cd5805c335a64bbfde238c97f97b5b079845668cb93ff0f054c3c76c07ee3cbd3ca9c3bebfc3e