Skip to content

Commit

Permalink
Merge pull request #37 from kpcyrd/vendored
Browse files Browse the repository at this point in the history
Introduce `vendored` cargo feature for static binary support
  • Loading branch information
kpcyrd authored Nov 12, 2024
2 parents 37e17d4 + 108afaf commit 220d9e1
Show file tree
Hide file tree
Showing 8 changed files with 179 additions and 71 deletions.
80 changes: 61 additions & 19 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@ jobs:
build:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up cargo cache
uses: actions/cache@v3
continue-on-error: false
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
Expand All @@ -31,7 +30,7 @@ jobs:
restore-keys: ${{ runner.os }}-cargo-release-

- name: Install dependencies (apt)
run: sudo apt-get install libpcsclite-dev nettle-dev
run: sudo apt-get install libpcsclite-dev

- name: Build
run: cargo build --release --verbose
Expand All @@ -45,11 +44,10 @@ jobs:
build-macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up cargo cache
uses: actions/cache@v3
continue-on-error: false
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
Expand All @@ -60,11 +58,56 @@ jobs:
key: ${{ runner.os }}-cargo-release-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-release-

- name: Install dependencies
run: brew install pkg-config zstd
- name: Build
run: cargo build --release --verbose --no-default-features -F vendored

build-windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4

- name: Set up cargo cache
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-release-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-release-

- name: Build
run: cargo build --release --verbose
run: cargo build --release --verbose --no-default-features -F vendored
env:
AWS_LC_SYS_PREBUILT_NASM: 1

build-static:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4

- name: Set up cargo cache
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-musl-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-musl-

- name: Install dependencies (apt)
run: sudo apt-get install musl-tools

- name: Setup rust for musl target
run: rustup target add x86_64-unknown-linux-musl

- name: Build
run: cargo build --release --verbose --target x86_64-unknown-linux-musl --no-default-features -F vendored

integration-test:
needs: build
Expand Down Expand Up @@ -101,10 +144,10 @@ jobs:
name: ${{ matrix.plot.path }}
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/download-artifact@v3
- name: Install dependencies (apt)
run: sudo apt-get install libpcsclite-dev nettle-dev
run: sudo apt-get install libpcsclite-dev
- name: Setup environment
run: ${{ matrix.plot.setup }}
if: ${{ matrix.plot.setup }}
Expand All @@ -115,10 +158,10 @@ jobs:
needs: build
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/download-artifact@v3
- name: Install dependencies (apt)
run: sudo apt-get install libpcsclite-dev nettle-dev
run: sudo apt-get install libpcsclite-dev
- name: Setup rust for musl target
run: rustup target add x86_64-unknown-linux-musl
- name: Compile all plots
Expand All @@ -127,11 +170,10 @@ jobs:
unit-test:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up cargo cache
uses: actions/cache@v3
continue-on-error: false
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
Expand All @@ -143,7 +185,7 @@ jobs:
restore-keys: ${{ runner.os }}-cargo-debug-

- name: Install dependencies (apt)
run: sudo apt-get install libpcsclite-dev nettle-dev sq
run: sudo apt-get install libpcsclite-dev sq

- name: Run clippy
run: cargo clippy -- -D warnings
Expand All @@ -153,6 +195,6 @@ jobs:
fmt:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Run cargo fmt
run: cargo fmt --all -- --check
54 changes: 37 additions & 17 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 9 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ categories = ["command-line-utilities"]
readme = "README.md"
edition = "2021"

[features]
default = ["hsm", "zstd/pkg-config"] # https://github.com/gyscos/zstd-rs/pull/309
hsm = ["pcsc", "talktosc"]
vendored = ["openssl/vendored", "xz2/static"]

[dependencies]
anyhow = "1.0.63"
ar = "0.9.0"
Expand Down Expand Up @@ -42,20 +47,19 @@ oci-spec = { version = "0.7", features = ["image"], default-features = false }
once_cell = "1.15.0"
openssl = "0.10.60"
osshkeys = { version = "0.7", features = ["rustcrypto-cipher"], default-features = false }
pcsc = "2.7.0"
pcsc = { version = "2.7.0", optional = true }
peekread = "0.1.1"
rcgen = { version = "0.13", features = ["aws_lc_rs"] }
regex = "1.7.0"
reqwest = { version = "0.11.12", features = ["json", "stream"] }
rust-lzma = "0.6"
sequoia-openpgp = { version = "1.21.0", default-features = false, features = ["compression", "crypto-openssl"] }
serde = { version = "1.0.144", features = ["derive"] }
serde_json = "1.0.85"
serde_yaml = "0.9.13"
sha1 = "0.10.5"
sha2 = "0.10.6"
shell-escape = "0.1.5"
talktosc = "0.2"
talktosc = { version = "0.2", optional = true }
tar = "0.4.38"
tempfile = "3.3.0"
termcolor = "1.1.3"
Expand All @@ -65,9 +69,10 @@ unicase = "2.6.0"
url = { version = "2.3.1", features = ["serde"] }
warp = { version = "0.3.2", features = ["tls"] }
warp-reverse-proxy = "1"
xz2 = "0.1.7"
yash-syntax = "0.12"
zip = { version = "2", default-features = false, features = ["deflate", "bzip2", "zstd"] }
zstd = { version = "0.13", features = ["pkg-config"] }
zstd = "0.13"

[dev-dependencies]
semver = "1.0.17"
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
FROM rust:1-alpine3.20 as build
ENV RUSTFLAGS="-C target-feature=-crt-static"
RUN --mount=type=cache,target=/var/cache/apk ln -vs /var/cache/apk /etc/apk/cache && \
apk add clang-dev musl-dev nettle-dev pcsc-lite-dev openssl-dev shared-mime-info xz-dev zstd-dev && \
apk add clang-dev musl-dev pcsc-lite-dev openssl-dev shared-mime-info xz-dev zstd-dev && \
rm /etc/apk/cache
WORKDIR /app
COPY ./ /app
Expand All @@ -17,7 +17,7 @@ RUN strip sh4d0wup
FROM alpine:3.20 as basic
# install dependencies
RUN --mount=type=cache,target=/var/cache/apk ln -vs /var/cache/apk /etc/apk/cache && \
apk add clang-libs libgcc nettle pcsc-lite-libs openssl shared-mime-info xz zstd-libs && \
apk add clang-libs libgcc pcsc-lite-libs openssl shared-mime-info xz zstd-libs && \
rm /etc/apk/cache

FROM basic as smol
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Have you ever wondered if the update you downloaded is the same one everybody el
There's a pre-built binary in the Arch Linux [extra] repository. To build the binary from source on a Debian based system use this (tested with ubuntu 22.04):

```sh
apt-get install curl git build-essential clang pkg-config libssl-dev libzstd-dev libpcsclite-dev nettle-dev liblzma-dev
apt-get install curl git build-essential clang pkg-config libssl-dev libzstd-dev libpcsclite-dev liblzma-dev
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
source "$HOME/.cargo/env"
git clone https://github.com/kpcyrd/sh4d0wup
Expand Down
Loading

0 comments on commit 220d9e1

Please sign in to comment.