alemosa
February 29, 2024, 4:35pm
1
Hello,
When building the snap on my Macbook M1 laptop for an arm64 architecture, the variable “$CRAFT_ARCH_TRIPLET_BUILD_FOR” value is “aarch64-linux-gnu”.
But when building it through the github action “https://github.com/snapcore/action-build/tree/v1/ ”, the variable value is “x86_64-linux-gnu”.
This leads to an inconsistency when setting up the env variable “LD_LIBRARY_PATH:” to point to the correct staged libraries… making ffmpeg arguing about missing libraries in my raspberry if installing the snap that was builded with the github action.
This is my snapcraft.yaml:
name: rackety-nuc-script
summary: firmware for rackety nucs
description: firmware that lets nucs connect to the rackety network and record videos
version: 1.0.0
base: core22
grade: stable
confinement: strict
architectures:
- build-on: [amd64, arm64]
build-for: [arm64]
- build-on: [amd64, arm64]
build-for: [amd64]
plugs:
ffmpeg-2204:
interface: content
target: ffmpeg-platform
default-provider: ffmpeg-2204
parts:
rackety-nuc-script:
plugin: python
source: .
stage-packages:
- libxcb-randr0-dev
- libxcb-xtest0-dev
- libxcb-xinerama0-dev
- libxcb-shape0-dev
- libxcb-xkb-dev
- libgl1-mesa-dev
- libxcb1
- libxcb-shm0
- libxcb-xfixes0
- libasound2
- libcaca0
- libv4l-0
- libva-dev
- libfontconfig1
- libvpx-dev
- libvpx7
- libwebpmux3
- librsvg2-2
- librsvg2-dev
- librsvg2-common
- libglu1-mesa
- libopenjp2-7
- freeglut3
- libspeex-dev
- libtheora0
- libtwolame-dev
- libpulse-dev
- libpulse0
- libraw1394-dev
- libxcursor-dev
- libxinerama-dev
- libxrandr-dev
- libxkbcommon-dev
- libarchive-dev
- libmpg123-0
- libsamplerate-dev
- libgomp1
apps:
rackety-nuc-script:
environment:
PATH: $SNAP/ffmpeg-platform/usr/bin:$PATH
LD_LIBRARY_PATH: $SNAP/ffmpeg-platform/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR:$LD_LIBRARY_PATH:$SNAP/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/pulseaudio
command: bin/rackety-nuc-script
plugs:
- network
- network-observe
daemon: simple
1 Like
In github action it’s build in amd64 and in your mac it’s build in arm64. The CRAFT_ARCH_TRIPLET_BUILD_FOR represents the architecture triplet, the snap is built for. If you use github actions it’ll use amd64 only. Use remote-build if you need for arm or local build
alemosa
February 29, 2024, 10:20pm
3
Hello @soumyaDghosh ,
I couldn’t use the remote-build because the code is private for the moment.
I actually found the way to perform the build using github actions for both architectures, thanks to this action https://github.com/marketplace/actions/snapcraft-multiarch-build from @lucyllewy
I will paste the code of the workflow and the snapcraft.yaml file that I used here for anyone that needs this working:
Github Workflow
name: publish to snap store
on: [push]
jobs:
build:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
strategy:
matrix:
platform:
- amd64
- arm64
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v1
- uses: diddlesnaps/snapcraft-multiarch-action@v1
id: snapcraft
with:
architecture: ${{ matrix.platform }}
- uses: snapcore/action-publish@v1
env:
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAP_STORE_LOGIN }}
with:
snap: ${{ steps.snapcraft.outputs.snap }}
release: edge
Snapcraft.yaml
name: rackety-nuc-script
summary: firmware for rackety nucs
description: firmware that lets nucs connect to the rackety network and record videos
version: 1.0.0
base: core22
grade: stable
confinement: strict
architectures:
- build-on: [arm64]
- build-on: [amd64]
plugs:
ffmpeg-2204:
interface: content
target: ffmpeg-platform
default-provider: ffmpeg-2204
parts:
rackety-nuc-script:
plugin: python
source: .
stage-packages:
- libxcb-randr0-dev
- libxcb-xtest0-dev
- libxcb-xinerama0-dev
- libxcb-shape0-dev
- libxcb-xkb-dev
- libgl1-mesa-dev
- libxcb1
- libxcb-shm0
- libxcb-xfixes0
- libasound2
- libcaca0
- libv4l-0
- libva-dev
- libfontconfig1
- libvpx-dev
- libvpx7
- libwebpmux3
- librsvg2-2
- librsvg2-dev
- librsvg2-common
- libglu1-mesa
- libopenjp2-7
- freeglut3
- libspeex-dev
- libtheora0
- libtwolame-dev
- libpulse-dev
- libpulse0
- libraw1394-dev
- libxcursor-dev
- libxinerama-dev
- libxrandr-dev
- libxkbcommon-dev
- libarchive-dev
- libmpg123-0
- libsamplerate-dev
- libgomp1
apps:
rackety-nuc-script:
environment:
PATH: $SNAP/ffmpeg-platform/usr/bin:$PATH
LD_LIBRARY_PATH: $SNAP/ffmpeg-platform/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR:$LD_LIBRARY_PATH:$SNAP/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/pulseaudio
command: bin/rackety-nuc-script
plugs:
- network
- network-observe
daemon: simple
2 Likes
Don’t need this one, if you don’t want to release the file in edge channel of the store
Do we really need QEMU anymore? There is now Arm64 on GitHub Actions: Powering faster, more efficient build systems - The GitHub Blog so official support for ARM in the snap action would be great.
2 Likes
That’s good news to read. When I have some time (currently having loads of work in my company) I will take a look on how to create an arm runner and update the github workflow. I will post it here once I have it!
1 Like
Or in the meantime, you might want to use the CI made by snapcrafters?