diff --git a/.github/workflows/binaries.yml b/.github/workflows/binaries.yml index bb9307cc..16abd322 100644 --- a/.github/workflows/binaries.yml +++ b/.github/workflows/binaries.yml @@ -13,38 +13,48 @@ name: binaries jobs: # release binaries release-bins: - runs-on: ubuntu-latest + runs-on: ${{ matrix.job.os }} env: RUSTFLAGS: "-C target-feature=+crt-static" + BUILD_CMD: cargo strategy: + fail-fast: false matrix: - targets: - - x86_64-unknown-linux-musl - - aarch64-unknown-linux-musl - - arm-unknown-linux-musleabi + job: + - { target: x86_64-unknown-linux-musl, os: ubuntu-latest, use-cross: true } + - { target: aarch64-unknown-linux-musl, os: ubuntu-latest, use-cross: true } + - { target: arm-unknown-linux-musleabi, os: ubuntu-latest, use-cross: true } + - { target: x86_64-apple-darwin, os: macos-12 } steps: - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 - name: Populate cache uses: ./.github/workflows/cache + - name: Overwrite build command env variable + if: matrix.job.use-cross + shell: bash + run: | + echo "BUILD_CMD=cross" >> $GITHUB_ENV + RUSTFLAGS="-C target-feature=-crt-static" cargo install cross --git https://github.com/cross-rs/cross + - uses: dtolnay/rust-toolchain@master with: toolchain: stable - target: ${{ matrix.targets }} - - run: RUSTFLAGS="-C target-feature=-crt-static" cargo install cross --git https://github.com/cross-rs/cross - - run: cross build -p backhand-cli --bin add-backhand --bin replace-backhand --locked --target ${{ matrix.targets }} --profile=dist + target: ${{ matrix.job.target }} + + - run: $BUILD_CMD build -p backhand-cli --bin add-backhand --bin replace-backhand --features xz-static --locked --target ${{ matrix.job.target }} --profile=dist # default features, but replace gzip with gzip-zune-inflate - - run: cross build -p backhand-cli --bin unsquashfs-backhand --locked --target ${{ matrix.targets }} --profile=dist --no-default-features --features zstd,xz,gzip-zune-inflate + - run: $BUILD_CMD build -p backhand-cli --bin unsquashfs-backhand --locked --target ${{ matrix.job.target }} --profile=dist --no-default-features --features zstd,xz-static,gzip-zune-inflate - name: archive run: | - tar -czvf backhand-${{ matrix.targets }}.tar.gz \ - -C target/${{ matrix.targets }}/dist/ $BINS + tar -czvf backhand-${{ matrix.job.target }}.tar.gz \ + -C target/${{ matrix.job.target }}/dist/ $BINS - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 with: - name: backhand-${{ matrix.targets }}.tar.gz - path: backhand-${{ matrix.targets }}.tar.gz + name: backhand-${{ matrix.job.target }}.tar.gz + path: backhand-${{ matrix.job.target }}.tar.gz # check semvar before release! - name: Check semver @@ -61,8 +71,8 @@ jobs: uses: svenstaro/upload-release-action@04733e069f2d7f7f0b4aebc4fbdbce8613b03ccd # v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} - file: backhand-${{ matrix.targets }}.tar.gz - asset_name: backhand-${{ github.ref_name }}-${{ matrix.targets }}.tar.gz + file: backhand-${{ matrix.job.target }}.tar.gz + asset_name: backhand-${{ github.ref_name }}-${{ matrix.job.target }}.tar.gz tag: ${{ github.ref }} prerelease: true overwrite: true diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 985b973f..65e74f0c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -12,21 +12,19 @@ name: ci jobs: # build/test all supported targets for library and bins (skipping slow and squashfs-tools tests) cross-test: - runs-on: ubuntu-latest + runs-on: ${{ matrix.job.os }} env: RUSTFLAGS: "-C target-feature=+crt-static" + BUILD_CMD: cargo strategy: - # By default, this is set to `true`, which means that a single CI job - # failure will cause all outstanding jobs to be canceled. This slows down - # development because it means that errors need to be encountered and - # fixed one at a time. fail-fast: false matrix: - target: - - x86_64-unknown-linux-musl - - aarch64-unknown-linux-musl - - arm-unknown-linux-musleabi - - armv7-unknown-linux-musleabi + job: + - { target: x86_64-unknown-linux-musl, os: ubuntu-latest, use-cross: true } + - { target: aarch64-unknown-linux-musl, os: ubuntu-latest, use-cross: true } + - { target: arm-unknown-linux-musleabi, os: ubuntu-latest, use-cross: true } + - { target: armv7-unknown-linux-musleabi, os: ubuntu-latest, use-cross: true } + - { target: x86_64-apple-darwin, os: macos-12 } toolchain: - stable # msrv of backhand-cli @@ -40,16 +38,20 @@ jobs: - name: Populate cache uses: ./.github/workflows/cache + - name: Overwrite build command env variable + if: matrix.job.use-cross + shell: bash + run: | + echo "BUILD_CMD=cross" >> $GITHUB_ENV + RUSTFLAGS="-C target-feature=-crt-static" cargo install cross --git https://github.com/cross-rs/cross + - uses: dtolnay/rust-toolchain@master with: toolchain: ${{ matrix.toolchain }} - # install cross - - run: RUSTFLAGS="-C target-feature=-crt-static" cargo install cross --git https://github.com/cross-rs/cross # build lib and bins with cross - - run: cross build ${{ matrix.features }} --target ${{ matrix.target }} --release --locked --workspace + - run: $BUILD_CMD build ${{ matrix.features }} --target ${{ matrix.job.target }} --release --locked --workspace --features xz-static # test with cross, skipping slow test and tests that use more then qemu default memory - - run: CROSS_CONTAINER_OPTS="--network host" RUST_LOG=info cross test --workspace --release ${{ matrix.features }} --target ${{ matrix.target }} --locked -- --skip slow --skip no_qemu - + - run: CROSS_CONTAINER_OPTS="--network host" RUST_LOG=info $BUILD_CMD test --workspace --release ${{ matrix.features }} --target ${{ matrix.job.target }} --features xz-static --locked -- --skip slow --skip no_qemu # build/test all supported on native x86_64 arch for library and bins (all tests) build-test-native: runs-on: ubuntu-latest diff --git a/backhand-cli/src/bin/unsquashfs.rs b/backhand-cli/src/bin/unsquashfs.rs index 7289550f..8fe7d96a 100644 --- a/backhand-cli/src/bin/unsquashfs.rs +++ b/backhand-cli/src/bin/unsquashfs.rs @@ -563,11 +563,12 @@ fn extract_all<'a, S: ParallelIterator>>( } InnerNode::CharacterDevice(SquashfsCharacterDevice { device_number }) => { if root_process { + #[allow(clippy::unnecessary_fallible_conversions)] match mknod( &filepath, SFlag::S_IFCHR, Mode::from_bits(mode_t::from(node.header.permissions)).unwrap(), - dev_t::from(*device_number), + dev_t::try_from(*device_number).unwrap(), ) { Ok(_) => { if args.info && !args.quiet { @@ -603,11 +604,12 @@ fn extract_all<'a, S: ParallelIterator>>( } } InnerNode::BlockDevice(SquashfsBlockDevice { device_number }) => { + #[allow(clippy::unnecessary_fallible_conversions)] match mknod( &filepath, SFlag::S_IFBLK, Mode::from_bits(mode_t::from(node.header.permissions)).unwrap(), - dev_t::from(*device_number), + dev_t::try_from(*device_number).unwrap(), ) { Ok(_) => { if args.info && !args.quiet { @@ -649,11 +651,12 @@ fn extract_all<'a, S: ParallelIterator>>( } } InnerNode::Socket => { + #[allow(clippy::unnecessary_fallible_conversions)] match mknod( &filepath, SFlag::S_IFSOCK, Mode::from_bits(mode_t::from(node.header.permissions)).unwrap(), - dev_t::from(0_u64), + dev_t::try_from(0_u64).unwrap(), ) { Ok(_) => { if args.info && !args.quiet {