Skip to content

Instantly share code, notes, and snippets.

@bnjdg
Last active June 15, 2019 11:19
Show Gist options
  • Save bnjdg/4e6226b83371ca94b377ade661a91b18 to your computer and use it in GitHub Desktop.
Save bnjdg/4e6226b83371ca94b377ade661a91b18 to your computer and use it in GitHub Desktop.
Cross Build SpotifyD inside an lxc container for arm64

LXD

First add the new Ubuntu Minimal images simplestreams endpoint:

lxc remote add --protocol simplestreams ubuntu-minimal https://cloud-images.ubuntu.com/minimal/releases/

Launch the Bionic minimal image:

lxc launch ubuntu-minimal:bionic spotifyd-build

Enter a bash shell inside the lxd container

lxc exec spotifyd-build -- /bin/bash

Update the container and proceed to build

apt update
apt-get install -y curl git pkg-config build-essential gcc-aarch64-linux-gnu
apt install -y libssl-dev libasound2-dev

dpkg --add-architecture arm64
sed 's/deb http/deb \[arch=amd64,i386\] http/' -i /etc/apt/sources.list
cat >>/etc/apt/sources.list <<EOF
deb [arch=arm64] http://ports.ubuntu.com/ $(lsb_release -cs) main universe restricted multiverse
deb [arch=arm64] http://ports.ubuntu.com/ $(lsb_release -cs)-updates main universe restricted multiverse
deb [arch=arm64] http://ports.ubuntu.com/ $(lsb_release -cs)-security main universe restricted multiverse
EOF
apt update
apt install libssl-dev:arm64 libasound2-dev:arm64

curl https://sh.rustup.rs -sSf | sh
git clone https://github.com/spotifyd/spotifyd

source $HOME/.cargo/env
rustup target add aarch64-linux-gnu

export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc \
    CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc \
    CXX_aarch64_unknown_linux_gnu=aarch64-linux-gnu-g++

CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc  PKG_CONFIG_PATH=/usr/lib/aarch64-unknown-linux-gnu/pkgconfig PKG_CONFIG_ALLOW_CROSS=1 cargo build --target=aarch64-unknown-linux-gnu --release
history
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment