Skip to content

Commit

Permalink
Mac, Windows update
Browse files Browse the repository at this point in the history
Signed-off-by: Sophia Guo <[email protected]>
  • Loading branch information
sophia-guo committed Jun 29, 2023
1 parent 0496476 commit 8db6dae
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 12 deletions.
30 changes: 20 additions & 10 deletions tooling/repro_common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,18 @@
# Expand JDK jmods & zips to process binaries within
function expandJDK() {
local JDK_DIR="$1"
mkdir "${JDK_DIR}_CP"
cp -R ${JDK_DIR}/* ${JDK_DIR}_CP
local JDK_ROOT="$1"
local JDK_BIN_DIR="${JDK_ROOT}_CP/bin"
if [[ "$OS" =~ Darwin* ]]; then
JDK_ROOT=`realpath ${JDK_DIR}/../../`
JDK_BIN_DIR="${JDK_ROOT}_CP/Contents/Home/bin"
fi
mkdir "${JDK_ROOT}_CP"
cp -R ${JDK_ROOT}/* ${JDK_ROOT}_CP
echo "Expanding the 'modules' Image to remove signatures from within.."
"${JDK_DIR}_CP/bin/jimage" extract --dir "${JDK_DIR}/lib/modules_extracted" "${JDK_DIR}/lib/modules"
echo "${JDK_BIN_DIR}/jimage extract --dir ${JDK_DIR}/lib/modules_extracted ${JDK_DIR}/lib/modules"
${JDK_BIN_DIR}/jimage extract --dir "${JDK_DIR}/lib/modules_extracted" "${JDK_DIR}/lib/modules"
#/Users/weguo/Downloads/jdk-17.0.8+6/Contents/Home_CP/bin/jimage extract --dir "${JDK_DIR}/lib/modules_extracted" "${JDK_DIR}/lib/modules"
rm "${JDK_DIR}/lib/modules"

echo "Expanding the 'src.zip' to normalize file permissions"
Expand All @@ -34,7 +42,7 @@ function expandJDK() {
dir=$(dirname "$f")
expand_dir="${dir}/expanded_${base}"
mkdir -p "${expand_dir}"
"${JDK_DIR}_CP/bin/jmod" extract --dir "${expand_dir}" "$f"
${JDK_BIN_DIR}/jmod extract --dir "${expand_dir}" "$f"
rm "$f"
done

Expand Down Expand Up @@ -81,7 +89,7 @@ function removeSignatures() {
for f in $FILES
do
echo "Removing signature from $f"
codesign --remove-signature "$f"
codesign --remove-signature "$f" 1> /dev/null
done
fi
}
Expand All @@ -90,7 +98,10 @@ function removeSignatures() {
function tempSign() {
local JDK_DIR="$1"
local OS="$2"

local randomN="${RANDOM:0:2}"
local privatePemFile="privatePemFile_${randomN}"
local pubPemFile="pubPemFile_${randomN}"
#TODO generate temp certificate $SELF_CERT, $SELF_CERT_PASS
if [[ "$OS" =~ CYGWIN* ]]; then
echo "Adding temp Signatures for ${JDK_DIR}"
FILES=$(find "${JDK_DIR}" -type f -path '*.exe' && find "${JDK_DIR}" -type f -path '*.dll')
Expand All @@ -107,15 +118,14 @@ function tempSign() {
elif [[ "$OS" =~ Darwin* ]]; then
MAC_JDK_ROOT="${JDK_DIR}/../../Contents"
echo "Adding temp Signatures for ${MAC_JDK_ROOT}"
openssl genpkey -algorithm RSA -pass pass:test -outform PEM -out privatePemFile -pkeyopt rsa_keygen_bits:2048
echo "public key"
openssl rsa -in ${privatePemFile} -passin pass:test -pubout -out publicPemFile
#TODO Generate locally certificate SELF_CERT

FILES=$(find "${MAC_JDK_ROOT}" \( -type f -and -path '*.dylib' -or -path '*/bin/*' -or -path '*/lib/jspawnhelper' -not -path '*/modules_extracted/*' -or -path '*/jpackageapplauncher*' \))
for f in $FILES
do
echo "Signing $f with a local certificate"
# Sign both with same local Certificate, this adjusts __LINKEDIT vmsize identically
codesign -s "$privatePemFile" --options runtime -f --timestamp "$f"
codesign -s "$SELF_CERT" --options runtime -f --timestamp "$f"
done
fi
}
Expand Down
2 changes: 1 addition & 1 deletion tooling/repro_compare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
################################################################################

source repro_common.sh

BLD_TYPE1="$1"
Expand Down Expand Up @@ -48,6 +47,7 @@ done


files1=$(find "${JDK_DIR1}" -type f | wc -l)
echo "Number of files: ${files1}"
rc=0
output="repro_diff.out"
echo "Comparing ${JDK_DIR1} with ${JDK_DIR2} ... output to file: ${output}"
Expand Down
53 changes: 53 additions & 0 deletions tooling/repro_diff.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
Only in /Users/weguo/Downloads/jdk-17.0.8+6/Contents/Home/jmods: expanded_java.datatransfer.jmod
Only in /Users/weguo/Downloads/jdk-17.0.8+6/Contents/Home/jmods: expanded_java.desktop.jmod
Only in /Users/weguo/Downloads/jdk-17.0.8+6/Contents/Home/jmods: expanded_java.instrument.jmod
Only in /Users/weguo/Downloads/jdk-17.0.8+6/Contents/Home/jmods: expanded_java.logging.jmod
Only in /Users/weguo/Downloads/jdk-17.0.8+6/Contents/Home/jmods: expanded_java.management.jmod
Only in /Users/weguo/Downloads/jdk-17.0.8+6/Contents/Home/jmods: expanded_java.management.rmi.jmod
Only in /Users/weguo/Downloads/jdk-17.0.8+6/Contents/Home/jmods: expanded_java.naming.jmod
Only in /Users/weguo/Downloads/jdk-17.0.8+6/Contents/Home/jmods: expanded_java.net.http.jmod
Only in /Users/weguo/Downloads/jdk-17.0.8+6/Contents/Home/jmods: expanded_java.prefs.jmod
Only in /Users/weguo/Downloads/jdk-17.0.8+6/Contents/Home/jmods: expanded_java.rmi.jmod
Only in /Users/weguo/Downloads/jdk-17.0.8+6/Contents/Home/jmods: expanded_java.scripting.jmod
Only in /Users/weguo/Downloads/jdk-17.0.8+6/Contents/Home/jmods: expanded_java.security.jgss.jmod
Only in /Users/weguo/Downloads/jdk-17.0.8+6/Contents/Home/jmods: expanded_java.transaction.xa.jmod
Only in /Users/weguo/Downloads/jdk-17.0.8+6/Contents/Home/jmods: expanded_java.xml.crypto.jmod
Only in /Users/weguo/Downloads/jdk-17.0.8+6/Contents/Home/jmods: expanded_java.xml.jmod
Only in /Users/weguo/Downloads/jdk-17.0.8+6/Contents/Home/jmods: expanded_jdk.accessibility.jmod
Only in /Users/weguo/Downloads/jdk-17.0.8+6/Contents/Home/jmods: expanded_jdk.attach.jmod
Only in /Users/weguo/Downloads/jdk-17.0.8+6/Contents/Home/jmods: expanded_jdk.charsets.jmod
Only in /Users/weguo/Downloads/jdk-17.0.8+6/Contents/Home/jmods: expanded_jdk.compiler.jmod
Only in /Users/weguo/Downloads/jdk-17.0.8+6/Contents/Home/jmods: expanded_jdk.crypto.cryptoki.jmod
Only in /Users/weguo/Downloads/jdk-17.0.8+6/Contents/Home/jmods: expanded_jdk.crypto.ec.jmod
Only in /Users/weguo/Downloads/jdk-17.0.8+6/Contents/Home/jmods: expanded_jdk.dynalink.jmod
Only in /Users/weguo/Downloads/jdk-17.0.8+6/Contents/Home/jmods: expanded_jdk.editpad.jmod
Only in /Users/weguo/Downloads/jdk-17.0.8+6/Contents/Home/jmods: expanded_jdk.httpserver.jmod
Only in /Users/weguo/Downloads/jdk-17.0.8+6/Contents/Home/jmods: expanded_jdk.internal.ed.jmod
Only in /Users/weguo/Downloads/jdk-17.0.8+6/Contents/Home/jmods: expanded_jdk.internal.le.jmod
Only in /Users/weguo/Downloads/jdk-17.0.8+6/Contents/Home/jmods: expanded_jdk.internal.opt.jmod
Only in /Users/weguo/Downloads/jdk-17.0.8+6/Contents/Home/jmods: expanded_jdk.internal.vm.ci.jmod
Only in /Users/weguo/Downloads/jdk-17.0.8+6/Contents/Home/jmods: expanded_jdk.internal.vm.compiler.jmod
Only in /Users/weguo/Downloads/jdk-17.0.8+6/Contents/Home/jmods: expanded_jdk.internal.vm.compiler.management.jmod
Only in /Users/weguo/Downloads/jdk-17.0.8+6/Contents/Home/jmods: expanded_jdk.javadoc.jmod
Only in /Users/weguo/Downloads/jdk-17.0.8+6/Contents/Home/jmods: expanded_jdk.jcmd.jmod
Only in /Users/weguo/Downloads/jdk-17.0.8+6/Contents/Home/jmods: expanded_jdk.jconsole.jmod
Only in /Users/weguo/Downloads/jdk-17.0.8+6/Contents/Home/jmods: expanded_jdk.jdi.jmod
Only in /Users/weguo/Downloads/jdk-17.0.8+6/Contents/Home/jmods: expanded_jdk.jlink.jmod
Only in /Users/weguo/Downloads/jdk-17.0.8+6/Contents/Home/jmods: expanded_jdk.jpackage.jmod
Only in /Users/weguo/Downloads/jdk-17.0.8+6/Contents/Home/jmods: expanded_jdk.jshell.jmod
Only in /Users/weguo/Downloads/jdk-17.0.8+6/Contents/Home/jmods: expanded_jdk.jsobject.jmod
Only in /Users/weguo/Downloads/jdk-17.0.8+6/Contents/Home/jmods: expanded_jdk.localedata.jmod
Only in /Users/weguo/Downloads/jdk-17.0.8+6/Contents/Home/jmods: expanded_jdk.management.agent.jmod
Only in /Users/weguo/Downloads/jdk-17.0.8+6/Contents/Home/jmods: expanded_jdk.management.jfr.jmod
Only in /Users/weguo/Downloads/jdk-17.0.8+6/Contents/Home/jmods: expanded_jdk.management.jmod
Only in /Users/weguo/Downloads/jdk-17.0.8+6/Contents/Home/jmods: expanded_jdk.naming.dns.jmod
Only in /Users/weguo/Downloads/jdk-17.0.8+6/Contents/Home/jmods: expanded_jdk.naming.rmi.jmod
Only in /Users/weguo/Downloads/jdk-17.0.8+6/Contents/Home/jmods: expanded_jdk.net.jmod
Only in /Users/weguo/Downloads/jdk-17.0.8+6/Contents/Home/jmods: expanded_jdk.nio.mapmode.jmod
Only in /Users/weguo/Downloads/jdk-17.0.8+6/Contents/Home/jmods: expanded_jdk.random.jmod
Only in /Users/weguo/Downloads/jdk-17.0.8+6/Contents/Home/jmods: expanded_jdk.sctp.jmod
Only in /Users/weguo/Downloads/jdk-17.0.8+6/Contents/Home/jmods: expanded_jdk.security.auth.jmod
Only in /Users/weguo/Downloads/jdk-17.0.8+6/Contents/Home/jmods: expanded_jdk.security.jgss.jmod
Only in /Users/weguo/Downloads/jdk-17.0.8+6/Contents/Home/jmods: expanded_jdk.unsupported.desktop.jmod
Only in /Users/weguo/Downloads/jdk-17.0.8+6/Contents/Home/jmods: expanded_jdk.unsupported.jmod
Only in /Users/weguo/Downloads/jdk-17.0.8+6/Contents/Home/jmods: expanded_jdk.xml.dom.jmod
3 changes: 2 additions & 1 deletion tooling/repro_process.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ OS="$2"

expandJDK "$JDK_DIR"


if [[ "$OS" =~ CYGWIN* ]] || [[ "$OS" =~ Darwin* ]]; then
# Remove existing signature
removeSignatures "$JDK_DIR" "$OS"
Expand All @@ -30,7 +31,7 @@ if [[ "$OS" =~ CYGWIN* ]] || [[ "$OS" =~ Darwin* ]]; then
tempSign "$JDK_DIR" "$OS"

# Remove temporary SELF_SIGN signature, which will then normalize binary length
# removeSignatures "$JDK_DIR" "$OS"
removeSignatures "$JDK_DIR" "$OS"
fi

patchManifests "${JDK_DIR}"
Expand Down

0 comments on commit 8db6dae

Please sign in to comment.