Skip to content

Commit

Permalink
build: add aarch64 target for release
Browse files Browse the repository at this point in the history
  • Loading branch information
DASPRiD committed Oct 22, 2023
1 parent 2c4c86c commit a77bfcd
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 23 deletions.
1 change: 1 addition & 0 deletions .releaserc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ plugins:
- - '@semantic-release/github'
- assets:
- target/arm-unknown-linux-gnueabihf/debian/*.deb
- target/aarch64-unknown-linux-gnu/debian/*.deb
- - '@semantic-release/git'
- assets:
- CHANGELOG.md
Expand Down
6 changes: 5 additions & 1 deletion Cross.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
[target.arm-unknown-linux-gnueabihf.dockerfile]
file = "./cross-rs/Dockerfile"
file = "./cross-rs/Dockerfile.armhf"
context = "./cross-rs/"

[target.aarch64-unknown-linux-gnu.dockerfile]
file = "./cross-rs/Dockerfile.aarch64"
context = "./cross-rs/"
5 changes: 5 additions & 0 deletions cross-rs/Dockerfile.aarch64
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM ghcr.io/cross-rs/aarch64-unknown-linux-gnu:0.2.5

RUN dpkg --add-architecture arm64 && \
apt-get update && \
apt-get install --assume-yes libasound2-dev:arm64
File renamed without changes.
55 changes: 33 additions & 22 deletions semantic-release-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,39 @@ VERSION="$1"

cargo install cross cargo-deb
sed -i '/\[package\]/,/^version = "[^"]*"$/ s/^version = "[^"]*"$/version = "'"$VERSION"'"/' Cargo.toml

cross build --target arm-unknown-linux-gnueabihf --release || exit 1
cross build --target aarch64-unknown-linux-gnu --release || exit 1

cargo-deb -v --no-build --target arm-unknown-linux-gnueabihf --no-strip || exit 1
cargo-deb -v --no-build --target aarch64-unknown-linux-gnu --no-strip || exit 1

fix_deb () {
target="$1"

# This is workaround for https://github.com/kornelski/cargo-deb/issues/47
# Patch the generated DEB to have ./ paths compatible with `unattended-upgrade`:
pushd "target/$target/debian" || exit 1
DEB_FILE_NAME=$(ls -1 *.deb | head -n 1)
DATA_ARCHIVE=$(ar t "${DEB_FILE_NAME}"| grep -E '^data\.tar')
ar x "${DEB_FILE_NAME}" "${DATA_ARCHIVE}"
tar tf "${DATA_ARCHIVE}"

if [[ "${DATA_ARCHIVE}" == *.xz ]]; then
# Install XZ support that will be needed by TAR
apt-get -y install -y xz-utils
EXTRA_TAR_ARGS=J
fi

mkdir tar-hack
tar -C tar-hack -xf "${DATA_ARCHIVE}"
pushd tar-hack || exit 1
tar c${EXTRA_TAR_ARGS}f "../${DATA_ARCHIVE}" --owner=0 --group=0 ./*
popd || exit 1
tar tf "${DATA_ARCHIVE}"
ar r "${DEB_FILE_NAME}" "${DATA_ARCHIVE}"
popd || exit 1
}

# This is workaround for https://github.com/kornelski/cargo-deb/issues/47
# Patch the generated DEB to have ./ paths compatible with `unattended-upgrade`:
pushd target/arm-unknown-linux-gnueabihf/debian || exit 1
DEB_FILE_NAME=$(ls -1 *.deb | head -n 1)
DATA_ARCHIVE=$(ar t "${DEB_FILE_NAME}"| grep -E '^data\.tar')
ar x "${DEB_FILE_NAME}" "${DATA_ARCHIVE}"
tar tf "${DATA_ARCHIVE}"

if [[ "${DATA_ARCHIVE}" == *.xz ]]; then
# Install XZ support that will be needed by TAR
apt-get -y install -y xz-utils
EXTRA_TAR_ARGS=J
fi

mkdir tar-hack
tar -C tar-hack -xf "${DATA_ARCHIVE}"
pushd tar-hack || exit 1
tar c${EXTRA_TAR_ARGS}f "../${DATA_ARCHIVE}" --owner=0 --group=0 ./*
popd || exit 1
tar tf "${DATA_ARCHIVE}"
ar r "${DEB_FILE_NAME}" "${DATA_ARCHIVE}"
popd || exit 1
fix_deb "arm-unknown-linux-gnueabihf"
fix_deb "aarch64-unknown-linux-gnu"

0 comments on commit a77bfcd

Please sign in to comment.