-
Notifications
You must be signed in to change notification settings - Fork 7
/
build
executable file
·118 lines (100 loc) · 6.58 KB
/
build
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/usr/bin/env bash
JVM_VERSION=${JVM_VERSION:-'11'}
ALLOWED_JVM_VERSIONS=("8" "11" "17") # TODO how to handle experimental versions like 16, 17 more gracefully?
if [[ ! " ${ALLOWED_JVM_VERSIONS[@]} " =~ " ${JVM_VERSION} " ]]; then
echo "Unsupported JVM version: ${JVM_VERSION}"
exit 1
fi
ARCHITECTURE=${ARCHITECTURE:-'amd64'}
ALLOWED_ARCHITECTURES=("amd64" "aarch64")
if [[ ! " ${ALLOWED_ARCHITECTURES[@]} " =~ " ${ARCHITECTURE} " ]]; then
echo "Unsupported architecture: ${ARCHITECTURE}"
exit 1
fi
if [[ "8" == $JVM_VERSION ]] && [[ "aarch64" == ${ARCHITECTURE} ]]; then
echo "aarch64 is not supported with JVM 8."
exit 1
fi
export GRAALVM_PACKAGE_NAME=${GRAALVM_PACKAGE_NAME:-"graalvm-ce-java${JVM_VERSION}"}
export GRAALVM_VERSION=${GRAALVM_VERSION:-'22.2.0'}
export RELEASE_VERSION=${RELEASE_VERSION:-'0'}
export GRAALVM_PACKAGE_VERSION=${GRAALVM_PACKAGE_VERSION:-"${GRAALVM_VERSION}-${RELEASE_VERSION}"}
export GRAALVM_ARCHITECTURE=${ARCHITECTURE}
export GRAALVM_PACKAGE_DIRECTORY=${GRAALVM_PACKAGE_NAME}_${GRAALVM_ARCHITECTURE}_${GRAALVM_VERSION}
export GRAALVM_JVM_DIRECTORY=${GRAALVM_PACKAGE_DIRECTORY}/usr/lib/jvm
export GRAALVM_META_DIRECTORY=${GRAALVM_PACKAGE_DIRECTORY}/DEBIAN
export GRAALVM_DEBIAN_PACKAGE=${GRAALVM_PACKAGE_NAME}_${GRAALVM_ARCHITECTURE}_${GRAALVM_PACKAGE_VERSION}.deb
if [[ "${JVM_VERSION}" == "8" ]]; then
export GRAALVM_PACKAGE_PROVIDES='java2-runtime-headless, java5-runtime-headless, java6-runtime-headless, java7-runtime-headless, java8-runtime-headless, java-compiler, java-sdk, java2-sdk, java5-sdk, java6-sdk, java7-sdk, java8-sdk'
elif [[ "${JVM_VERSION}" == "11" ]]; then
export GRAALVM_PACKAGE_PROVIDES='java10-runtime-headless, java11-runtime-headless, java2-runtime-headless, java5-runtime-headless, java6-runtime-headless, java7-runtime-headless, java8-runtime-headless, java9-runtime-headless, java-compiler, java-sdk, java10-sdk, java11-sdk, java2-sdk, java5-sdk, java6-sdk, java7-sdk, java8-sdk, java9-sdk'
else
export GRAALVM_PACKAGE_PROVIDES='java10-runtime-headless, java11-runtime-headless, java12-runtime-headless, java13-runtime-headless, java14-runtime-headless, java15-runtime-headless, java16-runtime-headless, java17-runtime-headless, java2-runtime-headless, java5-runtime-headless, java6-runtime-headless, java7-runtime-headless, java8-runtime-headless, java9-runtime-headless, java-compiler, java-sdk, java10-sdk, java11-sdk, java12-sdk, java13-sdk, java14-sdk, java15-sdk, java16-sdk, java17-sdk, java2-sdk, java5-sdk, java6-sdk, java7-sdk, java8-sdk, java9-sdk'
fi
export GRAALVM_DESCRIPTION=${GRAALVM_DESCRIPTION:-"GraalVM Community Edition (java${JVM_VERSION})"}
echo "Building GRAALVM_DEBIAN_PACKAGE: ${GRAALVM_DEBIAN_PACKAGE}"
echo ""
echo "Build Parameters:"
echo "- GRAALVM_PACKAGE_NAME: ${GRAALVM_PACKAGE_NAME}"
echo "- GRAALVM_PACKAGE_VERSION: ${GRAALVM_PACKAGE_VERSION}"
echo "- GRAALVM_ARCHITECTURE: ${GRAALVM_ARCHITECTURE}"
echo "- GRAALVM_PACKAGE_PROVIDES: ${GRAALVM_PACKAGE_PROVIDES}"
echo "- GRAALVM_DESCRIPTION: ${GRAALVM_DESCRIPTION}"
echo "- GRAALVM_PACKAGE_DIRECTORY: ${GRAALVM_PACKAGE_DIRECTORY}"
echo ""
if [ ! -d "${GRAALVM_PACKAGE_DIRECTORY}" ]; then
echo "Package Directory does not exist: ${GRAALVM_PACKAGE_DIRECTORY}"
mkdir ${GRAALVM_PACKAGE_DIRECTORY}
else
echo "Package Directory already exists: ${GRAALVM_PACKAGE_DIRECTORY}"
fi
if [ ! -f "${GRAALVM_PACKAGE_NAME}-linux-${GRAALVM_ARCHITECTURE}-${GRAALVM_VERSION}.tar.gz" ]; then
echo "Original tarball does not exist: ${GRAALVM_PACKAGE_NAME}-linux-${GRAALVM_ARCHITECTURE}-${GRAALVM_VERSION}.tar.gz"
# Download from https://github.com/graalvm/graalvm-ce-builds/releases
wget "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-${GRAALVM_VERSION}/${GRAALVM_PACKAGE_NAME}-linux-${GRAALVM_ARCHITECTURE}-${GRAALVM_VERSION}.tar.gz"
else
echo "Original tarball already exists: ${GRAALVM_PACKAGE_NAME}-linux-${GRAALVM_ARCHITECTURE}-${GRAALVM_VERSION}.tar.gz"
fi
if [ ! -d "${GRAALVM_META_DIRECTORY}" ]; then
echo "Meta Directory does not exist: ${GRAALVM_META_DIRECTORY}"
mkdir -p ${GRAALVM_META_DIRECTORY}
# Generate debian directory from debian-template
# https://stackoverflow.com/questions/2914220/bash-templating-how-to-build-configuration-files-from-templates-with-bash
cp resources/compat ${GRAALVM_META_DIRECTORY}/compat
cp resources/copyright ${GRAALVM_META_DIRECTORY}/copyright
cp resources/rules ${GRAALVM_META_DIRECTORY}/rules
perl -p -e 's/\$\{([^}]+)\}/defined $ENV{$1} ? $ENV{$1} : $&/eg' resources/changelog-template > ${GRAALVM_META_DIRECTORY}/changelog
perl -p -e 's/\$\{([^}]+)\}/defined $ENV{$1} ? $ENV{$1} : $&/eg' resources/control-template > ${GRAALVM_META_DIRECTORY}/control
perl -p -e 's/\$\{([^}]+)\}/defined $ENV{$1} ? $ENV{$1} : $&/eg' resources/postinst-template > ${GRAALVM_META_DIRECTORY}/postinst
chmod +x ${GRAALVM_META_DIRECTORY}/postinst
perl -p -e 's/\$\{([^}]+)\}/defined $ENV{$1} ? $ENV{$1} : $&/eg' resources/prerm-template > ${GRAALVM_META_DIRECTORY}/prerm
chmod +x ${GRAALVM_META_DIRECTORY}/prerm
echo 'package/* usr/lib/jvm' > ${GRAALVM_META_DIRECTORY}/install
else
echo "Meta Directory already exists: ${GRAALVM_META_DIRECTORY}"
fi
if [ ! -d "${GRAALVM_JVM_DIRECTORY}" ]; then
echo "Resource Directory does not exist: ${GRAALVM_JVM_DIRECTORY}"
mkdir -p ${GRAALVM_JVM_DIRECTORY}
# copy contents
tar zxvf ${GRAALVM_PACKAGE_NAME}-linux-${GRAALVM_ARCHITECTURE}-${GRAALVM_VERSION}.tar.gz -C ${GRAALVM_JVM_DIRECTORY}
mv ${GRAALVM_JVM_DIRECTORY}/${GRAALVM_PACKAGE_NAME}-${GRAALVM_VERSION} ${GRAALVM_JVM_DIRECTORY}/${GRAALVM_PACKAGE_NAME}
# copy additional scripts
cp ./resources/graal-R ${GRAALVM_JVM_DIRECTORY}/${GRAALVM_PACKAGE_NAME}/bin/
cp ./resources/graal-wasm ${GRAALVM_JVM_DIRECTORY}/${GRAALVM_PACKAGE_NAME}/bin/
cp ./resources/graal-node ${GRAALVM_JVM_DIRECTORY}/${GRAALVM_PACKAGE_NAME}/bin/
cp ./resources/graal-npm ${GRAALVM_JVM_DIRECTORY}/${GRAALVM_PACKAGE_NAME}/bin/
cp ./resources/graal-npx ${GRAALVM_JVM_DIRECTORY}/${GRAALVM_PACKAGE_NAME}/bin/
cp ./resources/graal-python ${GRAALVM_JVM_DIRECTORY}/${GRAALVM_PACKAGE_NAME}/bin/
cp ./resources/graal-native-image ${GRAALVM_JVM_DIRECTORY}/${GRAALVM_PACKAGE_NAME}/bin/
cp ./resources/graal-clang ${GRAALVM_JVM_DIRECTORY}/${GRAALVM_PACKAGE_NAME}/bin/
cp ./resources/graal-clang++ ${GRAALVM_JVM_DIRECTORY}/${GRAALVM_PACKAGE_NAME}/bin/
# Add .jinfo
cp ./resources/${GRAALVM_PACKAGE_NAME}.jinfo ${GRAALVM_JVM_DIRECTORY}/
else
echo "Resource Directory already exists: ${GRAALVM_JVM_DIRECTORY}"
fi
# build package
dpkg-deb --root-owner-group -Zgzip -b ${GRAALVM_PACKAGE_DIRECTORY} ${GRAALVM_DEBIAN_PACKAGE}
# sign with default key
debsigs --sign=origin ${GRAALVM_DEBIAN_PACKAGE}