Skip to content

Commit 3aa8338

Browse files
committed
8340075: Autoconf bundle cannot run on read-only filesystem
Reviewed-by: mikael
1 parent 37bf589 commit 3aa8338

File tree

1 file changed

+46
-34
lines changed

1 file changed

+46
-34
lines changed

make/devkit/createAutoconfBundle.sh

Lines changed: 46 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash -e
22
#
3-
# Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
3+
# Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
44
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55
#
66
# This code is free software; you can redistribute it and/or modify it
@@ -25,50 +25,70 @@
2525
#
2626

2727
# Create a bundle in the current directory, containing what's needed to run
28-
# the 'autoconf' program by the OpenJDK build.
28+
# the 'autoconf' program by the OpenJDK build. To override TARGET_PLATFORM
29+
# just set the variable before running this script.
2930

3031
# Autoconf depends on m4, so download and build that first.
3132
AUTOCONF_VERSION=2.69
3233
M4_VERSION=1.4.18
3334

3435
PACKAGE_VERSION=1.0.1
35-
TARGET_PLATFORM=linux_x86
36+
case `uname -s` in
37+
Darwin)
38+
os=macosx
39+
;;
40+
Linux)
41+
os=linux
42+
;;
43+
CYGWIN*)
44+
os=cygwin
45+
;;
46+
esac
47+
case `uname -m` in
48+
arm64|aarch64)
49+
arch=aarch64
50+
;;
51+
amd64|x86_64|x64)
52+
arch=x64
53+
;;
54+
esac
55+
TARGET_PLATFORM=${TARGET_PLATFORM:="${os}_${arch}"}
56+
3657
MODULE_NAME=autoconf-$TARGET_PLATFORM-$AUTOCONF_VERSION+$PACKAGE_VERSION
3758
BUNDLE_NAME=$MODULE_NAME.tar.gz
3859

39-
TMPDIR=`mktemp -d -t autoconfbundle-XXXX`
40-
trap "rm -rf \"$TMPDIR\"" EXIT
60+
SCRIPT_DIR="$(cd "$(dirname $0)" > /dev/null && pwd)"
61+
OUTPUT_ROOT="${SCRIPT_DIR}/../../build/autoconf"
4162

42-
ORIG_DIR=`pwd`
43-
cd $TMPDIR
44-
OUTPUT_DIR=$TMPDIR/$MODULE_NAME
45-
mkdir -p $OUTPUT_DIR/usr
63+
cd $OUTPUT_ROOT
64+
IMAGE_DIR=$OUTPUT_ROOT/$MODULE_NAME
65+
mkdir -p $IMAGE_DIR/usr
4666

4767
# Download and build m4
4868

4969
if test "x$TARGET_PLATFORM" = xcygwin_x64; then
5070
# On cygwin 64-bit, just copy the cygwin .exe file
51-
mkdir -p $OUTPUT_DIR/usr/bin
52-
cp /usr/bin/m4 $OUTPUT_DIR/usr/bin
71+
mkdir -p $IMAGE_DIR/usr/bin
72+
cp /usr/bin/m4 $IMAGE_DIR/usr/bin
5373
elif test "x$TARGET_PLATFORM" = xcygwin_x86; then
5474
# On cygwin 32-bit, just copy the cygwin .exe file
55-
mkdir -p $OUTPUT_DIR/usr/bin
56-
cp /usr/bin/m4 $OUTPUT_DIR/usr/bin
75+
mkdir -p $IMAGE_DIR/usr/bin
76+
cp /usr/bin/m4 $IMAGE_DIR/usr/bin
5777
elif test "x$TARGET_PLATFORM" = xlinux_x64; then
5878
M4_VERSION=1.4.13-5
5979
wget http://yum.oracle.com/repo/OracleLinux/OL6/latest/x86_64/getPackage/m4-$M4_VERSION.el6.x86_64.rpm
60-
cd $OUTPUT_DIR
61-
rpm2cpio ../m4-$M4_VERSION.el6.x86_64.rpm | cpio -d -i
80+
cd $IMAGE_DIR
81+
rpm2cpio $OUTPUT_ROOT/m4-$M4_VERSION.el6.x86_64.rpm | cpio -d -i
6282
elif test "x$TARGET_PLATFORM" = xlinux_x86; then
6383
M4_VERSION=1.4.13-5
6484
wget http://yum.oracle.com/repo/OracleLinux/OL6/latest/i386/getPackage/m4-$M4_VERSION.el6.i686.rpm
65-
cd $OUTPUT_DIR
66-
rpm2cpio ../m4-$M4_VERSION.el6.i686.rpm | cpio -d -i
85+
cd $IMAGE_DIR
86+
rpm2cpio $OUTPUT_ROOT/m4-$M4_VERSION.el6.i686.rpm | cpio -d -i
6787
else
6888
wget https://ftp.gnu.org/gnu/m4/m4-$M4_VERSION.tar.gz
6989
tar xzf m4-$M4_VERSION.tar.gz
7090
cd m4-$M4_VERSION
71-
./configure --prefix=$OUTPUT_DIR/usr
91+
./configure --prefix=$IMAGE_DIR/usr CFLAGS="-w -Wno-everything"
7292
make
7393
make install
7494
cd ..
@@ -79,15 +99,14 @@ fi
7999
wget https://ftp.gnu.org/gnu/autoconf/autoconf-$AUTOCONF_VERSION.tar.gz
80100
tar xzf autoconf-$AUTOCONF_VERSION.tar.gz
81101
cd autoconf-$AUTOCONF_VERSION
82-
./configure --prefix=$OUTPUT_DIR/usr M4=$OUTPUT_DIR/usr/bin/m4
102+
./configure --prefix=$IMAGE_DIR/usr M4=$IMAGE_DIR/usr/bin/m4
83103
make
84104
make install
85105
cd ..
86106

87-
perl -pi -e "s!$OUTPUT_DIR/!./!" $OUTPUT_DIR/usr/bin/auto* $OUTPUT_DIR/usr/share/autoconf/autom4te.cfg
88-
cp $OUTPUT_DIR/usr/share/autoconf/autom4te.cfg $OUTPUT_DIR/autom4te.cfg
107+
perl -pi -e "s!$IMAGE_DIR/!./!" $IMAGE_DIR/usr/bin/auto* $IMAGE_DIR/usr/share/autoconf/autom4te.cfg
89108

90-
cat > $OUTPUT_DIR/autoconf << EOF
109+
cat > $IMAGE_DIR/autoconf << EOF
91110
#!/bin/bash
92111
# Get an absolute path to this script
93112
this_script_dir=\`dirname \$0\`
@@ -100,17 +119,10 @@ export AUTOHEADER="\$this_script_dir/usr/bin/autoheader"
100119
export AC_MACRODIR="\$this_script_dir/usr/share/autoconf"
101120
export autom4te_perllibdir="\$this_script_dir/usr/share/autoconf"
102121
103-
autom4te_cfg=\$this_script_dir/usr/share/autoconf/autom4te.cfg
104-
cp \$this_script_dir/autom4te.cfg \$autom4te_cfg
105-
106-
echo 'begin-language: "M4sugar"' >> \$autom4te_cfg
107-
echo "args: --prepend-include '"\$this_script_dir/usr/share/autoconf"'" >> \$autom4te_cfg
108-
echo 'end-language: "M4sugar"' >> \$autom4te_cfg
122+
PREPEND_INCLUDE="--prepend-include \$this_script_dir/usr/share/autoconf"
109123
110-
exec \$this_script_dir/usr/bin/autoconf "\$@"
124+
exec \$this_script_dir/usr/bin/autoconf \$PREPEND_INCLUDE "\$@"
111125
EOF
112-
chmod +x $OUTPUT_DIR/autoconf
113-
cd $OUTPUT_DIR
114-
tar -cvzf ../$BUNDLE_NAME *
115-
cd ..
116-
cp $BUNDLE_NAME "$ORIG_DIR"
126+
chmod +x $IMAGE_DIR/autoconf
127+
cd $IMAGE_DIR
128+
tar -cvzf $OUTPUT_ROOT/$BUNDLE_NAME *

0 commit comments

Comments
 (0)