From b6fd159e440a9badf0cc4631269b83feaebf3312 Mon Sep 17 00:00:00 2001 From: George Holderness Date: Wed, 29 Oct 2025 14:39:55 +0000 Subject: [PATCH 1/2] Add cargo generate-rpm configuration Signed-off-by: George Holderness --- CHANGELOG.md | 1 + Cargo.toml | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ab0c01c..eaceda1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ Status: Available for use ### Added - Set minimum Rust version to 1.80 +- Add configuration for [`cargo generate-rpm`](https://crates.io/crates/cargo-generate-rpm), allowing an RPM for floki to be built using Cargo against the project ### Fixed diff --git a/Cargo.toml b/Cargo.toml index 3a61d13..77c133d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,6 +36,13 @@ shell-words = "1.1.0" [dev-dependencies] tempfile = "3.19.1" +[package.metadata.generate-rpm] +assets = [ + { source = "target/release/floki", dest = "/usr/bin/floki", mode = "0755" }, + { source = "LICENSE", dest = "/usr/share/doc/floki/LICENSE", doc = true, mode = "0644" }, +] +require-sh = false + [profile.release] strip = true # Automatically strip symbols from the binary. opt-level = "z" # Optimize for size. From c12d73985eddb3623992b4b6cf55b49832ba7bdc Mon Sep 17 00:00:00 2001 From: George Holderness Date: Wed, 29 Oct 2025 15:49:44 +0000 Subject: [PATCH 2/2] Test and publish an RPM Signed-off-by: George Holderness --- .github/workflows/ci.yml | 53 ++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 1 + build.sh | 4 +++ 3 files changed, 58 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5f47652..5818794 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -67,12 +67,55 @@ jobs: floki*.zip floki*.tar.gz + + rpm: + name: Build and test RPM using cargo generate-rpm + runs-on: ubuntu-24.04 + needs: build + steps: + - uses: actions/checkout@v5 + - name: Install rust + uses: dtolnay/rust-toolchain@master + with: + toolchain: stable + - name: Install cargo-generate-rpm + run: cargo install cargo-generate-rpm + # Download the ubuntu artifact instead of rebuilding. + - name: Download artifacts + uses: actions/download-artifact@v4 + with: + name: stableartifacts-ubuntu-24.04 + - name: Build RPM + run: | + tar -xzvf floki*.tar.gz + mkdir -p target/release + cp floki target/release/floki + cargo generate-rpm + - name: Debug + run: | + set -ex + + ls -ltR . + ls -l /usr/bin + + - name: Install RPM + run: find . -name "floki*.rpm" | xargs sudo rpm -ivh + - name: Test installation + run: floki -V + - name: Archive artifacts + uses: actions/upload-artifact@v4 + with: + name: rpm + path: | + target/generate-rpm/floki*.rpm + publish: name: Publish release artifact runs-on: ubuntu-latest if: github.ref_type == 'tag' needs: - build + - rpm # Required to publish a release permissions: contents: write @@ -97,6 +140,10 @@ jobs: uses: actions/download-artifact@v5 with: name: stableartifacts-macos-latest + - name: Download RPM + uses: actions/download-artifact@v5 + with: + name: rpm - name: Generate release.txt run: "./changelog.sh" - name: Release @@ -106,6 +153,7 @@ jobs: files: | floki*.zip floki*.tar.gz + floki*.rpm # # Announce the release # - run: "./announce.sh" # env: @@ -117,6 +165,7 @@ jobs: if: github.ref_type != 'tag' needs: - build + - rpm steps: - uses: actions/checkout@v5 - name: Install rust @@ -136,6 +185,10 @@ jobs: uses: actions/download-artifact@v5 with: name: stableartifacts-macos-latest + - name: Download rpm + uses: actions/download-artifact@v5 + with: + name: rpm # Test generating release.txt - name: Generate release.txt run: "./changelog.sh" diff --git a/Cargo.toml b/Cargo.toml index 77c133d..88d3a29 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -42,6 +42,7 @@ assets = [ { source = "LICENSE", dest = "/usr/share/doc/floki/LICENSE", doc = true, mode = "0644" }, ] require-sh = false +auto-req = "no" # Required to stop cargo generate-rpm introducing a dep on the RTLD [profile.release] strip = true # Automatically strip symbols from the binary. diff --git a/build.sh b/build.sh index ba10def..274633f 100755 --- a/build.sh +++ b/build.sh @@ -28,6 +28,10 @@ then # Check that it's statically compiled! ldd floki + # Strip .gnu.hash since floki is statically compiled. + # Required so that cargo-generate-rpm does not introduce a dependency on the RTLD. + strip --remove-section=.gnu.hash floki + tar -cvzf floki-${LABEL}.tar.gz floki else echo "Building release binary"