enable arm64 builds (#94)
* enable arm64 builds * Add `[skip build-base]` conditional for PRs * only setup arm64 arch in qemu * fix permission java-tools * go default to 1.20 and fix pwsh * exclude lib32z1 for arm64 * increase npm timeout for qemu * Try to speed up npm under qemu * make npm verbose * Use http registry * Another test * Use less build resources * fix dockerhub tag * Fix building
This commit is contained in:
@@ -6,7 +6,12 @@
|
||||
# source: https://github.com/actions/virtual-environments/blob/5ae2170ebe90a53e1cdc9c507ed3e0f1471d6b66/images/linux/scripts/helpers/install.sh
|
||||
|
||||
apt-get update
|
||||
common_packages=$(jq -r ".apt.common_packages[]" "/imagegeneration/toolset.json")
|
||||
# lib32z1 is not available for arm64 remove it via jq
|
||||
case "$(uname -m)" in
|
||||
'x86_64') common_packages_filter="" ;;
|
||||
*) common_packages_filter="del(.apt.common_packages[] | select(. == \"lib32z1\"))" ;;
|
||||
esac
|
||||
common_packages=$(jq -r "$common_packages_filter .apt.common_packages[]" "/imagegeneration/toolset.json")
|
||||
cmd_packages=$(jq -r ".apt.cmd_packages[]" "/imagegeneration/toolset.json")
|
||||
# we depend on re-splitting behaviour here
|
||||
# shellcheck disable=SC2068
|
||||
|
||||
@@ -32,15 +32,29 @@ bash -c "$(curl -sL https://raw.githubusercontent.com/ilikenwf/apt-fast/master/q
|
||||
# echo '* hard stack 16384'
|
||||
# } >>/etc/security/limits.conf
|
||||
|
||||
scripts=(
|
||||
basic
|
||||
pwsh
|
||||
go
|
||||
js
|
||||
rust
|
||||
vcpkg
|
||||
dotnet
|
||||
)
|
||||
case "$(uname -m)" in
|
||||
'aarch64')
|
||||
scripts=(
|
||||
basic
|
||||
pwsh
|
||||
go
|
||||
js
|
||||
dotnet
|
||||
)
|
||||
;;
|
||||
'x86_64')
|
||||
scripts=(
|
||||
basic
|
||||
pwsh
|
||||
go
|
||||
js
|
||||
rust
|
||||
vcpkg
|
||||
dotnet
|
||||
)
|
||||
;;
|
||||
*) exit 1 ;;
|
||||
esac
|
||||
|
||||
for SCRIPT in "${scripts[@]}"; do
|
||||
printf "\n\t🧨 Executing %s.sh 🧨\t\n" "${SCRIPT}"
|
||||
|
||||
@@ -16,11 +16,20 @@ go_arch() {
|
||||
esac
|
||||
}
|
||||
|
||||
toolcache_arch() {
|
||||
case "$(uname -m)" in
|
||||
'aarch64') echo 'arm64' ;;
|
||||
'x86_64') echo 'x64' ;;
|
||||
'armv7l') echo 'armv7l' ;;
|
||||
*) exit 1 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
DEFVER=$(jq -r '.toolcache[] | select(.name == "go") | .default' "/imagegeneration/toolset.json")
|
||||
for V in $(jq -r '.toolcache[] | select(.name == "go") | .versions[]' "/imagegeneration/toolset.json"); do
|
||||
printf "\n\t🐋 Installing GO=%s 🐋\t\n" "${V}"
|
||||
VER=$(jq -r "[.[] | select(.version|test(\"^${V}\"))][0].version" "/tmp/go-toolset.json")
|
||||
GOPATH="$AGENT_TOOLSDIRECTORY/go/${VER}/x64"
|
||||
GOPATH="$AGENT_TOOLSDIRECTORY/go/${VER}/$(toolcache_arch)"
|
||||
|
||||
mkdir -v -m 0777 -p "$GOPATH"
|
||||
DL_VER="${VER}"
|
||||
|
||||
Regular → Executable
+39
-23
@@ -9,6 +9,31 @@
|
||||
. /imagegeneration/installers/helpers/install.sh
|
||||
. /imagegeneration/installers/helpers/etc-environment.sh
|
||||
|
||||
java_arch() {
|
||||
case "$(uname -m)" in
|
||||
'x86_64') echo 'amd64' ;;
|
||||
'aarch64') echo 'arm64' ;;
|
||||
esac
|
||||
}
|
||||
|
||||
toolcache_arch() {
|
||||
case "$(uname -m)" in
|
||||
'aarch64') echo 'arm64' ;;
|
||||
'x86_64') echo 'x64' ;;
|
||||
'armv7l') echo 'armv7l' ;;
|
||||
*) exit 1 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
env_arch() {
|
||||
case "$(uname -m)" in
|
||||
'aarch64') echo 'ARM64' ;;
|
||||
'x86_64') echo 'X64' ;;
|
||||
'armv7l') echo 'ARMV7L' ;;
|
||||
*) exit 1 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
createJavaEnvironmentalVariable() {
|
||||
local JAVA_VERSION=$1
|
||||
local VENDOR_NAME=$2
|
||||
@@ -17,10 +42,10 @@ createJavaEnvironmentalVariable() {
|
||||
case ${VENDOR_NAME} in
|
||||
|
||||
"Adopt" )
|
||||
INSTALL_PATH_PATTERN="/usr/lib/jvm/adoptopenjdk-${JAVA_VERSION}-hotspot-amd64" ;;
|
||||
INSTALL_PATH_PATTERN="/usr/lib/jvm/adoptopenjdk-${JAVA_VERSION}-hotspot-$(java_arch)" ;;
|
||||
|
||||
"Temurin-Hotspot" )
|
||||
INSTALL_PATH_PATTERN="/usr/lib/jvm/temurin-${JAVA_VERSION}-jdk-amd64" ;;
|
||||
INSTALL_PATH_PATTERN="/usr/lib/jvm/temurin-${JAVA_VERSION}-jdk-$(java_arch)" ;;
|
||||
*)
|
||||
echo "Unknown vendor"
|
||||
exit 1
|
||||
@@ -34,8 +59,8 @@ createJavaEnvironmentalVariable() {
|
||||
update-java-alternatives -s ${INSTALL_PATH_PATTERN}
|
||||
fi
|
||||
|
||||
echo "Setting up JAVA_HOME_${JAVA_VERSION}_X64 variable to ${INSTALL_PATH_PATTERN}"
|
||||
addEtcEnvironmentVariable JAVA_HOME_${JAVA_VERSION}_X64 ${INSTALL_PATH_PATTERN}
|
||||
echo "Setting up JAVA_HOME_${JAVA_VERSION}_$(env_arch) variable to ${INSTALL_PATH_PATTERN}"
|
||||
addEtcEnvironmentVariable "JAVA_HOME_${JAVA_VERSION}_$(env_arch)" ${INSTALL_PATH_PATTERN}
|
||||
}
|
||||
|
||||
enableRepositories() {
|
||||
@@ -67,10 +92,10 @@ installOpenJDK() {
|
||||
# Install Java from PPA repositories.
|
||||
if [[ ${VENDOR_NAME} == "Temurin-Hotspot" ]]; then
|
||||
apt-get -y install temurin-${JAVA_VERSION}-jdk=\*
|
||||
javaVersionPath="/usr/lib/jvm/temurin-${JAVA_VERSION}-jdk-amd64"
|
||||
javaVersionPath="/usr/lib/jvm/temurin-${JAVA_VERSION}-jdk-$(java_arch)"
|
||||
elif [[ ${VENDOR_NAME} == "Adopt" ]]; then
|
||||
apt-get -y install adoptopenjdk-${JAVA_VERSION}-hotspot=\*
|
||||
javaVersionPath="/usr/lib/jvm/adoptopenjdk-${JAVA_VERSION}-hotspot-amd64"
|
||||
javaVersionPath="/usr/lib/jvm/adoptopenjdk-${JAVA_VERSION}-hotspot-$(java_arch)"
|
||||
else
|
||||
echo "${VENDOR_NAME} is invalid, valid names are: Temurin-Hotspot and Adopt"
|
||||
exit 1
|
||||
@@ -91,10 +116,10 @@ installOpenJDK() {
|
||||
mkdir -p "${javaToolcacheVersionPath}"
|
||||
|
||||
# Create a complete file
|
||||
touch "${javaToolcacheVersionPath}/x64.complete"
|
||||
touch "${javaToolcacheVersionPath}/$(toolcache_arch).complete"
|
||||
|
||||
# Create symlink for Java
|
||||
ln -s ${javaVersionPath} "${javaToolcacheVersionPath}/x64"
|
||||
ln -s ${javaVersionPath} "${javaToolcacheVersionPath}/$(toolcache_arch)"
|
||||
|
||||
# add extra permissions to be able execute command without sudo
|
||||
chmod -R 777 /usr/lib/jvm
|
||||
@@ -107,25 +132,16 @@ enableRepositories
|
||||
apt-get update
|
||||
|
||||
defaultVersion=$(get_toolset_value '.java.default')
|
||||
defaultVendor=$(get_toolset_value '.java.default_vendor')
|
||||
jdkVendors=($(get_toolset_value '.java.vendors[].name'))
|
||||
jdkVendor="Temurin-Hotspot"
|
||||
jdkVersionsToInstall=($(get_toolset_value ".java.versions[]"))
|
||||
|
||||
for jdkVendor in ${jdkVendors[@]}; do
|
||||
for jdkVersionToInstall in ${jdkVersionsToInstall[@]}; do
|
||||
|
||||
# get vendor-specific versions
|
||||
jdkVersionsToInstall=($(get_toolset_value ".java.vendors[] | select (.name==\"${jdkVendor}\") | .versions[]"))
|
||||
installOpenJDK ${jdkVersionToInstall} ${jdkVendor}
|
||||
|
||||
for jdkVersionToInstall in ${jdkVersionsToInstall[@]}; do
|
||||
isDefaultVersion=False; [[ ${jdkVersionToInstall} == ${defaultVersion} ]] && isDefaultVersion=True
|
||||
|
||||
installOpenJDK ${jdkVersionToInstall} ${jdkVendor}
|
||||
|
||||
isDefaultVersion=False; [[ ${jdkVersionToInstall} == ${defaultVersion} ]] && isDefaultVersion=True
|
||||
|
||||
if [[ ${jdkVendor} == ${defaultVendor} ]]; then
|
||||
createJavaEnvironmentalVariable ${jdkVersionToInstall} ${jdkVendor} ${isDefaultVersion}
|
||||
fi
|
||||
|
||||
done
|
||||
createJavaEnvironmentalVariable ${jdkVersionToInstall} ${jdkVendor} ${isDefaultVersion}
|
||||
done
|
||||
|
||||
# Adopt 12 is only available for Ubuntu 18.04
|
||||
|
||||
@@ -42,11 +42,31 @@ for V in "${versions[@]}"; do
|
||||
"$NODEPATH/bin/node" -v
|
||||
done
|
||||
|
||||
# npm timeout under qemu with defaults
|
||||
set -x
|
||||
npm config set fetch-timeout 120000
|
||||
npm config set fetch-retry-mintimeout 120000
|
||||
npm config set fetch-retry-maxtimeout 120000
|
||||
npm config set prefer-offline true
|
||||
npm config set registry http://registry.npmjs.org/
|
||||
# Otherwise there are no log updates for 10m+ on qemu
|
||||
npm config set loglevel verbose
|
||||
npm config ls -l
|
||||
|
||||
printf "\n\t🐋 Installing JS tools 🐋\t\n"
|
||||
npm install -g npm
|
||||
npm install -g pnpm
|
||||
npm install -g yarn
|
||||
npm install -g grunt gulp n parcel-bundler typescript newman vercel webpack webpack-cli lerna
|
||||
npm install -g grunt
|
||||
npm install -g gulp
|
||||
npm install -g n
|
||||
npm install -g parcel-bundler
|
||||
npm install -g typescript
|
||||
npm install -g newman
|
||||
npm install -g vercel
|
||||
npm install -g webpack
|
||||
npm install -g webpack-cli
|
||||
npm install -g lerna
|
||||
npm install -g --unsafe-perm netlify-cli
|
||||
|
||||
printf "\n\t🐋 Installed NPM 🐋\t\n"
|
||||
@@ -61,4 +81,6 @@ yarn -v
|
||||
printf "\n\t🐋 Cleaning image 🐋\t\n"
|
||||
apt-get clean
|
||||
rm -rf /var/cache/* /var/log/* /var/lib/apt/lists/* /tmp/* || echo 'Failed to delete directories'
|
||||
# remove npm config
|
||||
npm config edit --editor rm
|
||||
printf "\n\t🐋 Cleaned up image 🐋\t\n"
|
||||
|
||||
@@ -32,8 +32,16 @@ rm /tmp/powershell.tar.gz
|
||||
printf "\n\t🐋 Installed PWSH 🐋\t\n"
|
||||
pwsh -v
|
||||
|
||||
case "$(uname -m)" in
|
||||
'aarch64')
|
||||
printf "\n\t🐋 Skip Installing PowerShell modules, due to crash maybe caused by qemu 🐋\t\n"
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
modules=("MarkdownPS" "Pester" "PSScriptAnalyzer")
|
||||
;;
|
||||
esac
|
||||
printf "\n\t🐋 Installing PowerShell modules 🐋\t\n"
|
||||
modules=("MarkdownPS" "Pester" "PSScriptAnalyzer")
|
||||
|
||||
pwsh -nol -nop -c "Set-PSRepository -Name PSGallery -InstallationPolicy Trusted"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user