Skip to content

Commit

Permalink
ci: build .deb artifact
Browse files Browse the repository at this point in the history
Uses a small script (`debian/build.sh`) to massage the output of
cargo-c's build into a `.deb` that can be installed on Debian/Ubuntu
systems.
  • Loading branch information
cpu committed Dec 22, 2024
1 parent ae38c18 commit 91efb3e
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 3 deletions.
32 changes: 29 additions & 3 deletions .github/workflows/artifacts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- name: Build rusts-ffi
run: |
cargo cinstall --features cert_compression --release --prefix dist --target x86_64-pc-windows-msvc
cargo cinstall --locked --target x86_64-pc-windows-msvc --features cert_compression --release --prefix dist
- name: Upload binaries
uses: actions/upload-artifact@v4
Expand Down Expand Up @@ -68,6 +68,32 @@ jobs:
name: rustls-ffi-x86_64-linux-gnu
path: dist

linux-deb:
runs-on: ubuntu-20.04 # x86_64. Using older Ubuntu for greater GLIBC compat.
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false

- name: Install stable Rust
uses: dtolnay/rust-toolchain@stable

- name: Install cargo-c (Ubuntu)
env:
LINK: https://github.com/lu-zero/cargo-c/releases/latest/download
CARGO_C_FILE: cargo-c-x86_64-unknown-linux-musl.tar.gz
run: |
curl -L $LINK/$CARGO_C_FILE | tar xz -C ~/.cargo/bin
- name: Build deb
run: ./debian/build.sh

- name: Upload deb
uses: actions/upload-artifact@v4
with:
name: librustls_0.15.0_amd64.deb
path: librustls_0.15.0_amd64.deb

macos-binaries-arm64:
runs-on: macos-14 # arm64.
steps:
Expand All @@ -88,7 +114,7 @@ jobs:
- name: Build rusts-ffi
run: |
cargo cinstall --features cert_compression --release --prefix dist
cargo cinstall --locked --features cert_compression --release --prefix dist
- name: Fix rpath
run: |
Expand Down Expand Up @@ -116,7 +142,7 @@ jobs:

- name: Build rusts-ffi
run: |
cargo cinstall --features cert_compression --release --prefix dist
cargo cinstall --locked --features cert_compression --release --prefix dist
- name: Fix rpath
run: |
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ librustls/cmake-build*
.idea
.venv
.vs
debian/usr
debian/DEBIAN
47 changes: 47 additions & 0 deletions debian/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/env bash
set -eu
set -x

cd "$(dirname "$0")"

VERSION=$(sed -n 's/^version = "\(.*\)"$/\1/p' ../librustls/Cargo.toml)
if [ -z "$VERSION" ]; then
echo "Failed to extract version from Cargo.toml" >&2
exit 1
fi

PACKAGE="librustls"
ARCH="amd64"
DIST_DIR="/tmp/dist"
DEB_ROOT="."

CC=clang CXX=clang cargo cinstall --locked --features cert_compression --release --prefix "${DIST_DIR}"

mkdir -p "${DEB_ROOT}/usr/"{lib,include}
mkdir -p "${DEB_ROOT}/DEBIAN"

cp -r "${DIST_DIR}/lib/"* "${DEB_ROOT}/usr/lib/"
cp -r "${DIST_DIR}/include/"* "${DEB_ROOT}/usr/include/"

sed -i "s|prefix=.*|prefix=/usr|" "${DEB_ROOT}/usr/lib/x86_64-linux-gnu/pkgconfig/rustls.pc"

cat > "${DEB_ROOT}/DEBIAN/control" << EOF
Package: ${PACKAGE}
Version: ${VERSION}
Architecture: ${ARCH}
Maintainer: Daniel McCarney <[email protected]>
Description: FFI bindings for the Rustls TLS library
Section: libs
Depends: libc6
Priority: optional
EOF

cat > "${DEB_ROOT}/DEBIAN/postinst" << EOF
#!/bin/sh
set -e
ldconfig
EOF
chmod 755 "${DEB_ROOT}/DEBIAN/postinst"

cd ..
dpkg-deb --build debian "${PACKAGE}_${VERSION}_${ARCH}.deb"

0 comments on commit 91efb3e

Please sign in to comment.