I'm siGit, running on siGit Code & Deploy platform, browsing siGit Code coding agent repo.

1 #!/usr/bin/env bash
2 # Builds the release `sigit` for a Linux target inside the manylinux2014 image, so the binary
3 # needs nothing newer than glibc 2.17.
4 #
5 # packaging/linux/build-manylinux.sh x86_64-unknown-linux-gnu
6 #
7 # A plain `cargo build` links against the build host's glibc. v1.7.6 was built on a newer
8 # ubuntu-latest and needed GLIBC_2.43, so it would not start on Ubuntu 24.04 (2.39), the base of
9 # the Code Assurance runner image (#272). 2.17 is the same floor as the PyPI wheels, which
10 # release-pypi already builds in quay.io/pypa/manylinux2014_* through maturin, so this image is
11 # known to handle aws-lc-sys, onig_sys and esaxx-rs.
12 #
13 # This is a script and not a job-level `container:` because actions/checkout and the other
14 # JavaScript actions run Node inside the job container, and that Node needs glibc 2.28, which
15 # CentOS 7 does not have. cargo-zigbuild (`--target x86_64-unknown-linux-gnu.2.17`) would avoid
16 # Docker, but it swaps the C toolchain for every native dependency, while this image is the one
17 # PyPI has been building with since v1.7.4.
18 #
19 # The output lands at target/<target>/release/sigit, the same place `cargo build --target` puts
20 # it, so the packaging steps after it don't change. The host's ~/.cargo/{registry,git} are
21 # mounted so Swatinem/rust-cache still restores and saves them. Check the result with
22 # packaging/linux/check-glibc.sh.
23 set -euo pipefail
24
25 target=${1:?usage: build-manylinux.sh <rust-target>}
26 arch=$(uname -m)
27 case "${target}" in
28 "${arch}"-unknown-linux-gnu) ;;
29 *) echo "build-manylinux.sh: ${target} does not match this ${arch} host" >&2; exit 1 ;;
30 esac
31
32 repo=$(cd "$(dirname "$0")/../.." && pwd)
33 cargo_home=${CARGO_HOME:-$HOME/.cargo}
34 toolchain=$(sed -n 's/^channel = "\(.*\)"/\1/p' "${repo}/rust-toolchain.toml" | head -n 1)
35 [ -n "${toolchain}" ] || { echo "build-manylinux.sh: no channel in rust-toolchain.toml" >&2; exit 1; }
36 image=quay.io/pypa/manylinux2014_${arch}
37
38 mkdir -p "${cargo_home}/registry" "${cargo_home}/git"
39
40 # The container runs as root. Files it creates under target/ and the cargo cache are handed
41 # back to the runner user, which the later steps and rust-cache's post step need to write to.
42 docker run --rm \
43 -v "${repo}:/io" \
44 -v "${cargo_home}/registry:/cargo/registry" \
45 -v "${cargo_home}/git:/cargo/git" \
46 -w /io \
47 -e CARGO_HOME=/cargo \
48 -e RUSTUP_HOME=/rustup \
49 -e CARGO_TERM_COLOR="${CARGO_TERM_COLOR:-auto}" \
50 -e TOOLCHAIN="${toolchain}" \
51 -e TARGET="${target}" \
52 -e OWNER="$(id -u):$(id -g)" \
53 "${image}" \
54 bash -euo pipefail -c '
55 trap "chown -R ${OWNER} /io/target /cargo/registry /cargo/git 2>/dev/null || true" EXIT
56 # Same before-script-linux as release-pypi: aws-lc-sys needs a full Perl.
57 yum install -y -q perl-core
58 curl -sSf https://sh.rustup.rs | sh -s -- -y -q --profile minimal --default-toolchain "${TOOLCHAIN}"
59 export PATH=/cargo/bin:$PATH
60 ldd --version | sed -n 1p
61 cargo build --locked --release -p sigit --target "${TARGET}"
62 '