Skip to content

Commit 91efb3e

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 ae38c18 commit 91efb3e

File tree

3 files changed

+78
-3
lines changed

3 files changed

+78
-3
lines changed

.github/workflows/artifacts.yaml

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
2929
- name: Build rusts-ffi
3030
run: |
31-
cargo cinstall --features cert_compression --release --prefix dist --target x86_64-pc-windows-msvc
31+
cargo cinstall --locked --target x86_64-pc-windows-msvc --features cert_compression --release --prefix dist
3232
3333
- name: Upload binaries
3434
uses: actions/upload-artifact@v4
@@ -68,6 +68,32 @@ jobs:
6868
name: rustls-ffi-x86_64-linux-gnu
6969
path: dist
7070

71+
linux-deb:
72+
runs-on: ubuntu-20.04 # x86_64. Using older Ubuntu for greater GLIBC compat.
73+
steps:
74+
- uses: actions/checkout@v4
75+
with:
76+
persist-credentials: false
77+
78+
- name: Install stable Rust
79+
uses: dtolnay/rust-toolchain@stable
80+
81+
- name: Install cargo-c (Ubuntu)
82+
env:
83+
LINK: https://github.com/lu-zero/cargo-c/releases/latest/download
84+
CARGO_C_FILE: cargo-c-x86_64-unknown-linux-musl.tar.gz
85+
run: |
86+
curl -L $LINK/$CARGO_C_FILE | tar xz -C ~/.cargo/bin
87+
88+
- name: Build deb
89+
run: ./debian/build.sh
90+
91+
- name: Upload deb
92+
uses: actions/upload-artifact@v4
93+
with:
94+
name: librustls_0.15.0_amd64.deb
95+
path: librustls_0.15.0_amd64.deb
96+
7197
macos-binaries-arm64:
7298
runs-on: macos-14 # arm64.
7399
steps:
@@ -88,7 +114,7 @@ jobs:
88114
89115
- name: Build rusts-ffi
90116
run: |
91-
cargo cinstall --features cert_compression --release --prefix dist
117+
cargo cinstall --locked --features cert_compression --release --prefix dist
92118
93119
- name: Fix rpath
94120
run: |
@@ -116,7 +142,7 @@ jobs:
116142

117143
- name: Build rusts-ffi
118144
run: |
119-
cargo cinstall --features cert_compression --release --prefix dist
145+
cargo cinstall --locked --features cert_compression --release --prefix dist
120146
121147
- name: Fix rpath
122148
run: |

.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="."
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 <[email protected]>
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 debian "${PACKAGE}_${VERSION}_${ARCH}.deb"

0 commit comments

Comments
 (0)