Skip to content

Commit

Permalink
Bump toolchain to 1.78.0; add arm compile step to CI, add upgrade and…
Browse files Browse the repository at this point in the history
… rpm uninstall notes to README.md; add find-requires script (not implemented yet, waiting for changes to cargo-generate-rpm);
  • Loading branch information
xenago committed Jun 1, 2024
1 parent a1fa873 commit 5213573
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 27 deletions.
46 changes: 35 additions & 11 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,14 @@ on:
- '[0-9].[0-9].[0-9]'

jobs:
build_release:
name: build and release
runs-on: ubuntu-20.04 # Build on Debian-based distro
build:
name: build
runs-on: ubuntu-20.04
container: quay.io/pypa/manylinux2014_x86_64 # Use a container with glibc 2.17
steps:

- name: Show GLIBC # Confirm glibc version
run: ldd --version

- name: Checkout # Clone repository
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand All @@ -33,24 +30,51 @@ jobs:
toolchain: stable
override: true

- name: Cargo build # Release build
- name: Cargo build # Build for release
run: |
cargo build --release --verbose
ls -lah target/release
- name: Cargo deb # deb package
- name: Cargo deb # Package deb
run: |
cargo install --version 1.44.1 cargo-deb
cargo deb --verbose
cargo deb --no-build --verbose
ls -lah target/debian
- name: Cargo rpm # RPM package
- name: Cargo rpm # Package RPM
run: |
cargo install --version 0.14.0 cargo-generate-rpm
strip -s target/release/libnss_shim.so
cargo generate-rpm --payload-compress none
ls -lah target/generate-rpm
- uses: uraimo/run-on-arch-action@v2 # Cross-build (arm64/aarch64)
name: Cross-build (arm64/aarch64)
with:
base_image: quay.io/pypa/manylinux2014_aarch64
env: |
VERSION: ${{github.ref_name}}
# Mount the working directory as /libnss_shim in the container, and run commands there
dockerRunArgs: |
--volume "${PWD}:/libnss_shim"
-w "/libnss_shim"
# Speeds up builds
githubToken: ${{ github.token }}
# Prepare cached dependencies
setup: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
. "$HOME/.cargo/env"
cargo install --version 1.44.1 cargo-deb
cargo install --version 0.14.0 cargo-generate-rpm
run: |
. "$HOME/.cargo/env"
cargo build --release --verbose
ls -lah target/release
cargo deb --no-build --verbose
ls -lah target/debian
cargo generate-rpm --payload-compress none
ls -lah target/generate-rpm
- name: Release # Publish GitHub release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/') # Presumably redundant due to the `on: push: tags:` filter, but kept for safety
Expand Down
32 changes: 18 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ can print to `stdout` in a supported format to be used with NSS.
as described in `Cargo.toml` prior to running the `debian/postinst` script, but this has not been tested extensively.
- To request support for a different configuration, please create a GitHub Issue

### Installation steps
### Install/Upgrade

1. Prepare the commands/software that will be triggered by `libnss_shim` (see the Commands section for details).

Expand All @@ -61,18 +61,18 @@ can print to `stdout` in a supported format to be used with NSS.
wget https://github.com/xenago/libnss_shim/releases/download/1.1.0/libnss_shim-1.1.0-1.x86_64.rpm
```
3. Install it directly `dpkg` or `rpm`.
3. Install or upgrade it directly with `dpkg` or `rpm`.
**deb:**
```
sudo dpkg -i libnss_shim_1.1.0_amd64.deb
```
**RPM:**
```
sudo rpm -i ./libnss_shim-1.1.0-1.x86_64.rpm
sudo rpm -Uvh ./libnss_shim-1.1.0-1.x86_64.rpm
```
4. Configure the shim by importing a custom `config.json`:
4. Configure the shim by importing a custom `config.json`.
```
sudo cp custom_config.json /etc/libnss_shim/config.json
```
Expand Down Expand Up @@ -102,17 +102,19 @@ can print to `stdout` in a supported format to be used with NSS.
## Uninstallation
1. To remove `libnss_shim`, use either `dpkg` or `apt`:
```
dpkg -r libnss_shim
```
or
```
sudo apt remove libnss_shim
```
1. To remove `libnss_shim`, run the same tool used for installation.
**deb:**
```
dpkg -r libnss_shim
```
**RPM:**
```
sudo sudo rpm -e libnss_shim
```
2. If removal/deletion is performed, restarting affected applications is required. A system reboot is an effective way
to do this:
to do this.
```
sudo reboot
```
Expand Down Expand Up @@ -359,7 +361,9 @@ I generally find it easiest to run `build.sh` inside a temporary container:
3. Run the build script inside a temporary container, setting `LIBNSS_SHIM_VERSION` and the cloned repo path as desired:
sudo docker run -e "LIBNSS_SHIM_VERSION=0.0.0" -v /path/to/cloned/libnss_shim:/libnss_shim --rm -it quay.io/pypa/manylinux2014_x86_64:latest bash /libnss_shim/build.sh
sudo docker run -e "LIBNSS_SHIM_VERSION=0.0.0" -v /path/to/cloned/libnss_shim:/libnss_shim -v /var/run/docker.sock:/var/run/docker.sock --rm -it quay.io/pypa/manylinux2014_x86_64:latest bash /libnss_shim/build.sh
Note that this requires
4. The build script will output packages in the following subdirectories of the cloned repo:
Expand Down
23 changes: 22 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ ls -lah target/release

echo "BUILD: Packaging deb"
cargo install --version 1.44.1 cargo-deb
cargo deb --verbose
cargo deb --verbose --no-build
echo "BUILD: deb packaged"
ls -lah target/debian

Expand All @@ -27,3 +27,24 @@ strip -s target/release/libnss_shim.so
cargo generate-rpm --payload-compress none
echo "BUILD: RPM packaged"
ls -lah target/generate-rpm

# TODO: enable local cross-build with docker-in-docker

#echo "BUILD: Cross-building for release (arm64/aarch64)"
#cargo install --version 0.2.5 cross
#env CROSS_CONTAINER_IN_CONTAINER=true cross build --release --target aarch64-unknown-linux-gnu
#echo "BUILD: built for release (arm64/aarch64)"
#ls -lah target/aarch64-unknown-linux-gnu/release
#
#echo "BUILD: Packaging deb (arm64/aarch64)"
#cargo deb --target=aarch64-unknown-linux-gnu --no-build --verbose
#echo "BUILD: deb packaged (arm64/aarch64)"
#ls -lah target/aarch64-unknown-linux-gnu/debian
#
#echo "BUILD: Packaging RPM (arm64/aarch64)"
## FIXME: use script when possible for --auto-req
## See https://github.com/cat-in-136/cargo-generate-rpm/issues/107
## --auto-req "cross/find-requires.sh"
#cargo generate-rpm --payload-compress none --target aarch64-unknown-linux-gnu --auto-req disabled
#echo "BUILD: RPM packaged (arm64/aarch64)"
#ls -lah target/aarch64-unknown-linux-gnu/generate-rpm
5 changes: 5 additions & 0 deletions changelog/CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@
- Required change: 64-bit integer types to platform-dependent `size` pointer types
- Remove `lazy_static` dependency
- Add additional resource, update formatting of `README.md`
- Bump toolchain to 1.78.0
- Add ARM compile step to CI
- Adjust README.md to clarify install/upgrade are the same process
- Add RPM uninstall notes to README.md
- Add find-requires script for build (not yet implemented)
10 changes: 10 additions & 0 deletions cross/find-requires.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh

# Fail fast on any error
set -e

# This is designed to replicate the output from the `find-requires` RPM script
# http://ftp.rpm.org/max-rpm/s1-rpm-depend-auto-depend.html
# That script uses `ldd`, which doesn't seem to work with cross-compiled binaries
# https://github.com/cat-in-136/cargo-generate-rpm/issues/107
objdump -x "$1" | grep NEEDED | awk '{print $NF}'
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[toolchain]
channel = "1.75.0"
channel = "1.78.0"

0 comments on commit 5213573

Please sign in to comment.