From 96d5b9b87d5b769be6b2fb0c0c732fcbd3175037 Mon Sep 17 00:00:00 2001 From: Clement Tsang <34804052+ClementTsang@users.noreply.github.com> Date: Sat, 28 May 2022 16:14:25 -0400 Subject: [PATCH] deployment: add aarch64/armv7 gnu .deb generation (#739) Adds .deb generation for aarch64 and armv7 gnu targets in the nightly and deploy workflows. --- .github/workflows/deployment.yml | 56 ++++++++++++++++++++++---------- .github/workflows/nightly.yml | 56 ++++++++++++++++++++++---------- Cargo.toml | 8 ++++- Cross.toml | 2 ++ README.md | 12 +++++-- build.rs | 4 +-- 6 files changed, 98 insertions(+), 40 deletions(-) create mode 100644 Cross.toml diff --git a/.github/workflows/deployment.yml b/.github/workflows/deployment.yml index 02670e55..6906f15c 100644 --- a/.github/workflows/deployment.yml +++ b/.github/workflows/deployment.yml @@ -54,6 +54,7 @@ jobs: container: ${{ matrix.triple.container }} env: RUST_BACKTRACE: 1 + BTM_GENERATE: true strategy: fail-fast: false matrix: @@ -162,11 +163,6 @@ jobs: args: --release --verbose --locked --target=${{ matrix.triple.target }} --features deploy use-cross: ${{ matrix.triple.cross }} - - name: Build autocompletion and manpage - shell: bash - run: | - GENERATE=true cargo build - - name: Bundle release and completion (Windows) if: matrix.triple.os == 'windows-2019' shell: bash @@ -287,8 +283,26 @@ jobs: name: build-deb needs: [initialize-release-job] runs-on: "ubuntu-18.04" + strategy: + fail-fast: false + matrix: + tuple: + - { target: "x86_64-unknown-linux-gnu", cross: false, dpkg: amd64 } + - { + target: "aarch64-unknown-linux-gnu", + cross: true, + dpkg: arm64, + container: "ghcr.io/clementtsang/cargo-deb-aarch64-unknown-linux-gnu", + } + - { + target: "armv7-unknown-linux-gnueabihf", + cross: true, + dpkg: armhf, + container: "ghcr.io/clementtsang/cargo-deb-armv7-unknown-linux-gnueabihf", + } env: RUST_BACKTRACE: 1 + BTM_GENERATE: true steps: - name: Checkout repository uses: actions/checkout@v2 @@ -317,38 +331,46 @@ jobs: profile: minimal toolchain: stable override: true - target: x86_64-unknown-linux-gnu + target: ${{ matrix.tuple.target }} - uses: Swatinem/rust-cache@cb2cf0cc7c5198d3364b9630e2c3d457f160790c # 1.4.0 - with: - key: x86_64-unknown-linux-gnu-deb - name: Build uses: actions-rs/cargo@v1 with: command: build - args: --release --locked --verbose --features deploy + args: --release --locked --verbose --features deploy --target ${{ matrix.tuple.target }} + use-cross: ${{ matrix.tuple.cross }} - - name: Build autocompletion and manpage + - name: Zip manpage shell: bash run: | - GENERATE=true cargo build gzip ./manpage/btm.1 - - name: Build Debian release + - name: Build Debian release (x86-64) + if: matrix.tuple.cross == false run: | - cargo install cargo-deb --version 1.37.0 --locked - cargo deb --no-build - cp ./target/debian/bottom_*.deb ./bottom_${{ env.RELEASE_VERSION }}_amd64.deb + cargo install cargo-deb --version 1.38.0 --locked + cargo deb --no-build --target ${{ matrix.tuple.target }} + cp ./target/${{ matrix.tuple.target }}/debian/bottom_*.deb ./bottom_${{ matrix.tuple.target }}.deb + + - name: Build Debian release (ARM) + if: matrix.tuple.cross == true + run: | + docker pull ${{ matrix.tuple.container }} + docker run -t --rm --mount type=bind,source="$(pwd)",target=/volume ${{ matrix.tuple.container }} "--variant ${{ matrix.tuple.dpkg }} --target ${{ matrix.tuple.target }} --no-build" "/volume" + cp ./target/${{ matrix.tuple.target }}/debian/bottom-*.deb ./bottom_${{ matrix.tuple.target }}.deb - name: Test Debian release - run: sudo dpkg -i ./bottom_${{ env.RELEASE_VERSION }}_amd64.deb + run: | + dpkg -I ./bottom_${{ matrix.tuple.target }}.deb + dpkg -I ./bottom_${{ matrix.tuple.target }}.deb | grep ${{ matrix.tuple.dpkg }} && echo "Found correct architecture" - name: Create release directory for artifact, move file shell: bash run: | mkdir release - mv bottom_${{ env.RELEASE_VERSION }}_amd64.deb release/ + mv bottom_${{ matrix.tuple.target }}.deb release/ - name: Save release as artifact uses: actions/upload-artifact@v2 diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 37b26cae..fdbf1ce4 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -50,6 +50,7 @@ jobs: container: ${{ matrix.triple.container }} env: RUST_BACKTRACE: 1 + BTM_GENERATE: true strategy: fail-fast: false matrix: @@ -158,11 +159,6 @@ jobs: args: --release --locked --verbose --target=${{ matrix.triple.target }} --features deploy use-cross: ${{ matrix.triple.cross }} - - name: Build autocompletion and manpage - shell: bash - run: | - GENERATE=true cargo build - - name: Bundle release and completion (Windows) if: matrix.triple.os == 'windows-2019' shell: bash @@ -281,8 +277,26 @@ jobs: name: build-deb needs: [initialize-job] runs-on: "ubuntu-18.04" + strategy: + fail-fast: false + matrix: + tuple: + - { target: "x86_64-unknown-linux-gnu", cross: false, dpkg: amd64 } + - { + target: "aarch64-unknown-linux-gnu", + cross: true, + dpkg: arm64, + container: "ghcr.io/clementtsang/cargo-deb-aarch64-unknown-linux-gnu", + } + - { + target: "armv7-unknown-linux-gnueabihf", + cross: true, + dpkg: armhf, + container: "ghcr.io/clementtsang/cargo-deb-armv7-unknown-linux-gnueabihf", + } env: RUST_BACKTRACE: 1 + BTM_GENERATE: true steps: - name: Checkout repository uses: actions/checkout@v2 @@ -311,38 +325,46 @@ jobs: profile: minimal toolchain: stable override: true - target: x86_64-unknown-linux-gnu + target: ${{ matrix.tuple.target }} - uses: Swatinem/rust-cache@cb2cf0cc7c5198d3364b9630e2c3d457f160790c # 1.4.0 - with: - key: x86_64-unknown-linux-gnu-deb - name: Build uses: actions-rs/cargo@v1 with: command: build - args: --release --locked --verbose --features deploy + args: --release --locked --verbose --features deploy --target ${{ matrix.tuple.target }} + use-cross: ${{ matrix.tuple.cross }} - - name: Build autocompletion and manpage + - name: Zip manpage shell: bash run: | - GENERATE=true cargo build gzip ./manpage/btm.1 - - name: Build Debian release + - name: Build Debian release (x86-64) + if: matrix.tuple.cross == false run: | - cargo install cargo-deb --version 1.37.0 --locked - cargo deb --no-build - cp ./target/debian/bottom_*.deb ./bottom_${{ env.RELEASE_VERSION }}_amd64.deb + cargo install cargo-deb --version 1.38.0 --locked + cargo deb --no-build --target ${{ matrix.tuple.target }} + cp ./target/${{ matrix.tuple.target }}/debian/bottom_*.deb ./bottom_${{ matrix.tuple.target }}.deb + + - name: Build Debian release (ARM) + if: matrix.tuple.cross == true + run: | + docker pull ${{ matrix.tuple.container }} + docker run -t --rm --mount type=bind,source="$(pwd)",target=/volume ${{ matrix.tuple.container }} "--variant ${{ matrix.tuple.dpkg }} --target ${{ matrix.tuple.target }} --no-build" "/volume" + cp ./target/${{ matrix.tuple.target }}/debian/bottom-*.deb ./bottom_${{ matrix.tuple.target }}.deb - name: Test Debian release - run: sudo dpkg -i ./bottom_${{ env.RELEASE_VERSION }}_amd64.deb + run: | + dpkg -I ./bottom_${{ matrix.tuple.target }}.deb + dpkg -I ./bottom_${{ matrix.tuple.target }}.deb | grep ${{ matrix.tuple.dpkg }} && echo "Found correct architecture" - name: Create release directory for artifact, move file shell: bash run: | mkdir release - mv bottom_${{ env.RELEASE_VERSION }}_amd64.deb release/ + mv bottom_${{ matrix.tuple.target }}.deb release/ - name: Save Debian file as artifacts uses: actions/upload-artifact@v2 diff --git a/Cargo.toml b/Cargo.toml index fc529251..f82ba4b5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -115,10 +115,16 @@ extended-description = """\ A customizable cross-platform graphical process/system monitor for the terminal. Supports Linux, macOS, and Windows. By default, bottom will look for a config file in ~/.config/bottom/bottom.toml. -If one is not specified it will fall back to defaults. If a config file does not +If one is not specified it will fall back to defaults. If a config file does not exist at the specified or default location, a blank one will be created for the user. """ +[package.metadata.deb.variants.arm64] +depends = "libc6:arm64 (>= 2.28)" + +[package.metadata.deb.variants.armhf] +depends = "libc6:armhf (>= 2.28)" + [package.metadata.wix] output = "bottom_x86_64_installer.msi" diff --git a/Cross.toml b/Cross.toml new file mode 100644 index 00000000..f6e8648d --- /dev/null +++ b/Cross.toml @@ -0,0 +1,2 @@ +[build.env] +passthrough = ["RUST_BACKTRACE", "BTM_GENERATE"] diff --git a/README.md b/README.md index a2a5c6e9..7b3aa938 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ - [Installation](#installation) - [Cargo](#cargo) - [Arch Linux](#arch-linux) - - [Debian/Ubuntu (x86-64)](#debianubuntu-x86-64) + - [Debian/Ubuntu](#debianubuntu) - [Snap](#snap) - [Fedora/CentOS](#fedoracentos) - [Gentoo](#gentoo) @@ -126,15 +126,21 @@ There is an official package that can be installed with `pacman`: sudo pacman -Syu bottom ``` -### Debian/Ubuntu (x86-64) +### Debian/Ubuntu -A `.deb` file is provided on each [release](https://github.com/ClementTsang/bottom/releases/latest): + + +A `.deb` file is provided on each [release](https://github.com/ClementTsang/bottom/releases/latest) (currently only for x86-64): ```bash curl -LO https://github.com/ClementTsang/bottom/releases/download/0.6.8/bottom_0.6.8_amd64.deb sudo dpkg -i bottom_0.6.8_amd64.deb ``` +For ARM (aarch64 and armv7), for now, releases are currently only provided on +[nightly builds](https://github.com/ClementTsang/bottom/releases/tag/nightly), but will be provided alongside the +x86-64 builds in future releases. + ### Snap bottom is available as a [snap](https://snapcraft.io/install/bottom/ubuntu): diff --git a/build.rs b/build.rs index fce34b48..5e069fb5 100644 --- a/build.rs +++ b/build.rs @@ -23,7 +23,7 @@ fn create_dir(dir: &Path) -> Result<()> { } fn main() -> Result<()> { - if env::var_os("GENERATE").is_some() { + if env::var_os("BTM_GENERATE").is_some() { // OUT_DIR is where extra build files are written to for Cargo. let completion_out_dir = PathBuf::from("completion"); let manpage_out_dir = PathBuf::from("manpage"); @@ -49,7 +49,7 @@ fn main() -> Result<()> { println!("cargo:rerun-if-changed=build.rs"); println!("cargo:rerun-if-changed=./src/clap.rs"); - println!("cargo:rerun-if-env-changed=GENERATE"); + println!("cargo:rerun-if-env-changed=BTM_GENERATE"); Ok(()) }