...
grade: stable
confinement: strict # use 'strict' once you have the right plugs and slots
architectures:
- build-on: amd64
run-on: arm64
apps:
snapname:
environment:
JAVA_HOME: $SNAP/usr/lib/jvm/java-11-openjdk-arm64
parts:
snapname:
stage-packages:
- openjdk-11-jre-headless
So basically i think i am just not giving snapcraft the right package name for Java JRE headless arm64.
These are the stage package names i tried:
jdk-11.0.11+9-jre
openjdk-11-jre-headless
openjdk-11-jre-headless-arm64
There is also a way to choose another repository or own hosted repository besides http://security.ubuntu.com/ubuntu/, which is the standard repo when snapcraft installs packages during building process. I guess.
Test results: no test results since i wasnt able to find the key-id (gpg) of the package.
NOTE:
I directed at any of these approaches the java jre into the $SNAP/usr/lib/jvm path. Which is the supposed place for a java runtime enviroment.
you will need to do a bit more here to make sure the foreign arches fully supported by the build environment … here is a (very hackish but for inspiration) example that would get you an arm64 java binary built on a PC:
name: javatest
base: core20
version: '0.1'
summary: test java
description: |
test java
grade: stable
confinement: strict
architectures:
- build-on: amd64
run-on: arm64
apps:
javatest:
command: usr/lib/jvm/java-11-openjdk-arm64/bin/java
environment:
JAVA_HOME: $SNAP/usr/lib/jvm/java-8-openjdk-arm64
PATH: $JAVA_HOME/bin:$PATH
parts:
init-multiarch:
plugin: nil
override-pull: |
# add foreign architecture to hosts apt setup
dpkg --add-architecture arm64
# wipe original sources.lists
echo "" >/etc/apt/sources.list
rm -rf /etc/apt/sources.list.d/*
# add arm64 support
cat > /etc/apt/sources.list << EOF
deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports focal main restricted universe multiverse
deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports focal-updates main restricted universe multiverse
deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports focal-security main restricted universe multiverse
EOF
# force arm64 as default apt arch
echo 'APT::Architecture "arm64";' >/etc/apt/apt.conf.d/00default-arch
apt update
jre:
after: [ init-multiarch ]
plugin: nil
stage-packages:
- openjdk-11-jre-headless:arm64
(do never use that with --destructive-mode on an actual host, it really breaks the build environment for good)
if you want to ship some jar file etc from another part you should actually add parts before these two parts above, because many plugins (i.e. “dump”) will not work anymore after the modification that “init-multiarch” does …