Skip to content

Commit 19eb9bc

Browse files
committed
ci: build .deb artifact
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.
1 parent 445abd7 commit 19eb9bc

File tree

3 files changed

+76
-0
lines changed

3 files changed

+76
-0
lines changed

.github/workflows/artifacts.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,33 @@ jobs:
7070
name: rustls-ffi-x86_64-linux-gnu
7171
path: dist
7272

73+
linux-deb:
74+
name: Linux (x86-64 GNU Deb)
75+
runs-on: ubuntu-20.04 # x86_64. Using older Ubuntu for greater GLIBC compat.
76+
steps:
77+
- uses: actions/checkout@v4
78+
with:
79+
persist-credentials: false
80+
81+
- name: Install stable Rust
82+
uses: dtolnay/rust-toolchain@stable
83+
84+
- name: Install cargo-c
85+
env:
86+
LINK: https://github.com/lu-zero/cargo-c/releases/latest/download
87+
CARGO_C_FILE: cargo-c-x86_64-unknown-linux-musl.tar.gz
88+
run: |
89+
curl -L $LINK/$CARGO_C_FILE | tar xz -C ~/.cargo/bin
90+
91+
- name: Build deb
92+
run: ./debian/build.sh
93+
94+
- name: Upload deb
95+
uses: actions/upload-artifact@v4
96+
with:
97+
name: librustls_0.15.0_amd64.deb
98+
path: librustls_0.15.0_amd64.deb
99+
73100
macos-binaries:
74101
name: MacOS (Arm64 and x86_64)
75102
runs-on: macos-14 # arm64.

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ librustls/cmake-build*
44
.idea
55
.venv
66
.vs
7+
debian/usr
8+
debian/DEBIAN

debian/build.sh

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/usr/bin/env bash
2+
set -eu
3+
set -x
4+
5+
cd "$(dirname "$0")"
6+
7+
VERSION=$(sed -n 's/^version = "\(.*\)"$/\1/p' ../librustls/Cargo.toml)
8+
if [ -z "$VERSION" ]; then
9+
echo "Failed to extract version from Cargo.toml" >&2
10+
exit 1
11+
fi
12+
13+
PACKAGE="librustls"
14+
ARCH="amd64"
15+
DIST_DIR="/tmp/dist"
16+
DEB_ROOT="/tmp/deb"
17+
18+
CC=clang CXX=clang cargo cinstall --locked --features cert_compression --release --prefix "${DIST_DIR}"
19+
20+
mkdir -p "${DEB_ROOT}/usr/"{lib,include}
21+
mkdir -p "${DEB_ROOT}/DEBIAN"
22+
23+
cp -r "${DIST_DIR}/lib/"* "${DEB_ROOT}/usr/lib/"
24+
cp -r "${DIST_DIR}/include/"* "${DEB_ROOT}/usr/include/"
25+
26+
sed -i "s|prefix=.*|prefix=/usr|" "${DEB_ROOT}/usr/lib/x86_64-linux-gnu/pkgconfig/rustls.pc"
27+
28+
cat > "${DEB_ROOT}/DEBIAN/control" << EOF
29+
Package: ${PACKAGE}
30+
Version: ${VERSION}
31+
Architecture: ${ARCH}
32+
Maintainer: Daniel McCarney <daniel@binaryparadox.net>
33+
Description: FFI bindings for the Rustls TLS library
34+
Section: libs
35+
Depends: libc6
36+
Priority: optional
37+
EOF
38+
39+
cat > "${DEB_ROOT}/DEBIAN/postinst" << EOF
40+
#!/bin/sh
41+
set -e
42+
ldconfig
43+
EOF
44+
chmod 755 "${DEB_ROOT}/DEBIAN/postinst"
45+
46+
cd ..
47+
dpkg-deb --build ${DEB_ROOT} "${PACKAGE}_${VERSION}_${ARCH}.deb"

0 commit comments

Comments
 (0)