I am using the override-build step in my snapcraft file as follows:
override-build: |
export JAVA_TO_USE=“/usr/lib/jvm/java-8-openjdk-amd64”
export JAVA_HOME=“$SNAPCRAFT_PART_INSTALL$JAVA_TO_USE”
ant
mkdir $SNAPCRAFT_PART_INSTALL/jar
mv $SNAPCRAFT_PART_BUILD/target/*.jar $SNAPCRAFT_PART_INSTALL/jar
However now I want to build multi architecture support (for armhf and amd64) into my snapcraft file. The JAVA_TO_USE env variable will be different for each platform. So what is the correct syntax for that in the yaml file.
I have tried using - on armhf like this:
> override-build: |
-on amd64: export JAVA_TO_USE="/usr/lib/jvm/java-8-openjdk-amd64"
-on armhf: export JAVA_TO_USE="/usr/lib/jvm/java-8-openjdk-armhf"
export JAVA_HOME="$SNAPCRAFT_PART_INSTALL$JAVA_TO_USE"
ant
mkdir $SNAPCRAFT_PART_INSTALL/jar
mv $SNAPCRAFT_PART_BUILD/target/*.jar $SNAPCRAFT_PART_INSTALL/jar
and other variations.
Any suggestions as to how to achieve this.
ogra
October 14, 2020, 9:37pm
2
you could try build-environment:
to set the vars i think that should support the “- on <arch>” syntax…
see “plugin variables” at the bottom of:
Yes I am trying that but I am not sure I have the correct syntax yet:
I have tried:
build-environment:
- JAVA_TO_USE:
- on amd64: “/usr/lib/jvm/java-8-openjdk-amd64”
Also
build-environment:
- on amd64:
- JAVA_TO_USE: “/usr/lib/jvm/java-8-openjdk-amd64”
Any more suggestions?
ogra
October 15, 2020, 12:24pm
4
hmm, not sure perhaps i’m hoping for too much intelligence here … @sergiusens should using the on/to syntax work with build-environment:
yet ?
(FWIW: i’d expect the latter example to work if snapcraft supports this yet)
cjp256
October 15, 2020, 2:52pm
5
I do not believe build-environment
supports that syntax yet. The best best it to do it with a little scripting in override-build for now (e.g. using conditional if
statements). We do want to extend advanced grammar in the near future.
2 Likes
Thank you. I got sorted with use if else conditional in override-build.
I have moved on to a new challenge now.
I have a multi-arch snapcraft file with a part that uses the dump plugin. I would need a different organise keyword value depending on the architecture.
This is the relevant section:
move-rxtx:
plugin: dump
source:
- on armhf: ./ext-lib/rasp-pi
- on amd64: ./ext-lib/amd64
organize:
RXTXcomm.jar: ext-lib/RXTXcomm.jar
librxtxSerial.so: usr/lib/jvm/java-8-openjdk-amd64/jre/lib/amd64/librxtxSerial.so
For my armhf architecture the last line should be:
librxtxSerial.so: usr/lib/jvm/java-8-openj…
Appreciate any feedback.