diff --git a/makejdk-any-platform.1 b/makejdk-any-platform.1 index f718547f5..9ceaaf646 100755 --- a/makejdk-any-platform.1 +++ b/makejdk-any-platform.1 @@ -70,6 +70,9 @@ specify any custom user configuration arguments. .BR \-\-clean-git-repo clean out any 'bad' local git repo you already have. .TP +.BR \-\-create-source-archive +create an archive of the sources which got used to build OpenJDK +.TP .BR \-d ", " \-\-destination " " \fI\fR specify the location for the built binary, e.g. /path/. This is typically used in conjunction with \fB<-T>\fR to create a custom path diff --git a/sbin/build.sh b/sbin/build.sh index 55dd991b5..0002715b7 100755 --- a/sbin/build.sh +++ b/sbin/build.sh @@ -502,7 +502,40 @@ buildTemplatedFile() { -e "s|{makeCommandArg}|${FULL_MAKE_COMMAND}|" >"${BUILD_CONFIG[WORKSPACE_DIR]}/config/configure-and-build.sh" } +createSourceArchive() { + local sourceDir="${BUILD_CONFIG[WORKSPACE_DIR]}/${BUILD_CONFIG[WORKING_DIR]}/${BUILD_CONFIG[OPENJDK_SOURCE_DIR]}" + local sourceArchiveTargetPath="$(getSourceArchivePath)" + local tmpSourceVCS="${BUILD_CONFIG[WORKSPACE_DIR]}/${BUILD_CONFIG[WORKING_DIR]}/tmp-openjdk-git" + local srcArchiveName + if echo ${BUILD_CONFIG[TARGET_FILE_NAME]} | grep -q hotspot; then + # Transform 'OpenJDK11U-jdk_aarch64_linux_hotspot_11.0.12_7.tar.gz' to 'OpenJDK11U-sources_11.0.12_7.tar.gz' + srcArchiveName=$(echo "${BUILD_CONFIG[TARGET_FILE_NAME]//-jdk_*(?)_hotspot_/-sources_}") + else + srcArchiveName=$(echo "${BUILD_CONFIG[TARGET_FILE_NAME]//-jdk/-sources}") + fi + + local oldPwd="${PWD}" + cd "${BUILD_CONFIG[WORKSPACE_DIR]}/${BUILD_CONFIG[WORKING_DIR]}" + echo "Temporarily moving VCS source dir to ${tmpSourceVCS}" + mv "${sourceDir}/.git" "${tmpSourceVCS}" + echo "Temporarily moving source dir to ${sourceArchiveTargetPath}" + mv "${sourceDir}" "${sourceArchiveTargetPath}" + + echo "OpenJDK source archive path will be ${sourceArchiveTargetPath}." + createArchive "${sourceArchiveTargetPath}" "${srcArchiveName}" + + echo "Restoring source dir from ${sourceArchiveTargetPath} to ${sourceDir}" + mv "${sourceArchiveTargetPath}" "${sourceDir}" + echo "Restoring VCS source dir from ${tmpSourceVCS} to ${sourceDir}/.git" + mv "${tmpSourceVCS}" "${sourceDir}/.git" + cd "${oldPwd}" +} + executeTemplatedFile() { + + if [ "${BUILD_CONFIG[CREATE_SOURCE_ARCHIVE]}" == "true" ]; then + createSourceArchive + fi stepIntoTheWorkingDirectory echo "Currently at '${PWD}'" @@ -675,6 +708,11 @@ getTestImageArchivePath() { echo "${jdkArchivePath}-test-image" } +getSourceArchivePath() { + local jdkArchivePath=$(getJdkArchivePath) + echo "${jdkArchivePath}-src" +} + getDebugImageArchivePath() { local jdkArchivePath=$(getJdkArchivePath) echo "${jdkArchivePath}-debug-image" diff --git a/sbin/common/config_init.sh b/sbin/common/config_init.sh index 372cccfa9..479a42929 100755 --- a/sbin/common/config_init.sh +++ b/sbin/common/config_init.sh @@ -48,6 +48,7 @@ COPY_MACOSX_FREE_FONT_LIB_FOR_JDK_FLAG COPY_MACOSX_FREE_FONT_LIB_FOR_JRE_FLAG COPY_TO_HOST CREATE_DEBUG_IMAGE +CREATE_SOURCE_ARCHIVE CUSTOM_CACERTS CROSSCOMPILE DEBUG_DOCKER @@ -234,6 +235,9 @@ function parseConfigurationArguments() { "--create-debug-image" ) BUILD_CONFIG[CREATE_DEBUG_IMAGE]="true";; + "--create-source-archive" ) + BUILD_CONFIG[CREATE_SOURCE_ARCHIVE]=true;; + "--disable-adopt-branch-safety" ) BUILD_CONFIG[DISABLE_ADOPT_BRANCH_SAFETY]=true;; @@ -447,6 +451,9 @@ function configDefaults() { # The default behavior of whether we want to create a separate debug symbols archive BUILD_CONFIG[CREATE_DEBUG_IMAGE]="false" + # The default behavior of whether we want to create a separate source archive + BUILD_CONFIG[CREATE_SOURCE_ARCHIVE]="false" + BUILD_CONFIG[SIGN]="false" BUILD_CONFIG[JDK_BOOT_DIR]=""