From ca78ee83247f4e48af295435136db6b95a4a7bd7 Mon Sep 17 00:00:00 2001 From: oech3 <79379754+oech3@users.noreply.github.com> Date: Tue, 29 Sep 2026 18:48:05 +0900 Subject: [PATCH] show-utils.sh: remove dependency on jq --- .github/workflows/freebsd.yml | 8 +++----- .github/workflows/openbsd.yml | 4 ++-- .github/workflows/wasi.yml | 4 +--- util/show-utils.sh | 26 ++++++++++++-------------- 4 files changed, 18 insertions(+), 24 deletions(-) diff --git a/.github/workflows/freebsd.yml b/.github/workflows/freebsd.yml index 95a80c29893..cd649266d75 100644 --- a/.github/workflows/freebsd.yml +++ b/.github/workflows/freebsd.yml @@ -40,11 +40,10 @@ jobs: usesh: true sync: rsync copyback: false - # We need jq and GNU coreutils to run show-utils.sh and bash to use inline shell string replacement - prepare: pkg install -y rust sudo jaq coreutils bash python3 + # We need jq-compat util and bash to use inline shell string replacement + prepare: pkg install -y rust sudo jaq bash python3 run: | ## Prepare, build, and test - sudo ln -s $(command -v jaq) /usr/local/bin/jq # implementation modelled after ref: # * NOTE: All steps need to be run in this block, otherwise, we are operating back on the mac host set -e @@ -134,7 +133,6 @@ jobs: prepare: pkg install -y gmake nextest rust sudo jaq run: | ## Prepare, build, and test - sudo ln -s $(command -v jaq) /usr/local/bin/jq # implementation modelled after ref: # * NOTE: All steps need to be run in this block, otherwise, we are operating back on the mac host set -e @@ -185,7 +183,7 @@ jobs: if (test -z "\$FAULT"); then cargo nextest run --hide-progress-bar --profile ci --features '${{ matrix.job.features }}' || FAULT=1 ; fi # There is no systemd-logind on FreeBSD, so test all features except feat_systemd_logind ( https://github.com/rust-lang/cargo/issues/3126#issuecomment-2523441905 ) if (test -z "\$FAULT"); then - UUCORE_FEATURES=\$(cargo metadata --format-version=1 --no-deps | jq -r '.packages[] | select(.name == "uucore") | .features | keys | .[]' | grep -v "feat_systemd_logind" | paste -s -d "," -) + UUCORE_FEATURES=\$(cargo metadata --format-version=1 --no-deps | jaq -r '.packages[] | select(.name == "uucore") | .features | keys | .[]' | grep -v "feat_systemd_logind" | paste -s -d "," -) cargo nextest run --hide-progress-bar --profile ci --features "\$UUCORE_FEATURES" -p uucore || FAULT=1 fi # Test building with make diff --git a/.github/workflows/openbsd.yml b/.github/workflows/openbsd.yml index 73120728818..c0158f7c655 100644 --- a/.github/workflows/openbsd.yml +++ b/.github/workflows/openbsd.yml @@ -41,13 +41,13 @@ jobs: sync: rsync copyback: false mem: 4096 - # We need jq and GNU coreutils to run show-utils.sh and bash to use inline shell string replacement + # We need jq and bash to use inline shell string replacement # Use sudo-- to get the default sudo package without ambiguity # Install rust and cargo from OpenBSD packages prepare: | # Clean up disk space before installing packages df -h - pkg_add curl sudo-- jq coreutils bash rust rust-clippy rust-rustfmt python3 + pkg_add curl sudo-- jq bash rust rust-clippy rust-rustfmt python3 rm -rf /usr/share/relink/* /usr/X11R6/* /usr/share/doc/* /usr/share/man/* & # Clean up package cache after installation pkg_delete -a & diff --git a/.github/workflows/wasi.yml b/.github/workflows/wasi.yml index b6fa143e1ee..35a607bfed1 100644 --- a/.github/workflows/wasi.yml +++ b/.github/workflows/wasi.yml @@ -43,9 +43,7 @@ jobs: CARGO_TARGET_WASM32_WASIP1_RUNNER: wasmtime CARGO_TARGET_WASM32_WASIP2_RUNNER: wasmtime run: | - # Get all utilities and exclude ones that don't compile for ${{ matrix.job.target }} - EXCLUDE="df|du|env|more" - UTILS=$(./util/show-utils.sh | tr ' ' '\n' | grep -vE "^($EXCLUDE)$" | sed 's/^/-p uu_/' | tr '\n' ' ') + UTILS=$(./util/show-utils.sh --features=feat_wasm | sed 's/^/-p uu_/' | tr '\n' ' ') cargo test --target ${{ matrix.job.target }} --no-default-features $UTILS - name: Run integration tests via wasmtime if: matrix.job.target == 'wasm32-wasip1' diff --git a/util/show-utils.sh b/util/show-utils.sh index c25be5968f3..870d2395d7c 100755 --- a/util/show-utils.sh +++ b/util/show-utils.sh @@ -1,22 +1,20 @@ #!/usr/bin/env bash set -eo pipefail -# spell-checker:ignore (jq) deps startswith cd -- "$(dirname -- "$0")/.." -# `jq` available? -if ! jq --version 1>/dev/null 2>&1; then - # refs: , - # default utility list - default_utils=$(cargo tree --depth 1 --features feat_common_core --format "{lib}" --prefix none | sed -n 's/^uu_//p') - echo "WARN: missing \`jq\` (install with \`sudo apt install jq\`); falling back to default (only fully cross-platform) utility list" 1>&2 - echo "$default_utils" +if test "$*";then + _args=("$@") else - # Find 'coreutils' id with regex - # with cargo v1.76.0, id = "coreutils 0.0.26 (path+file://)" - # with cargo >= v1.77.0 - # - if local path != '<...>/coreutils' id = "path+file://#coreutils@0.0.26" - # - if local path == '<...>/coreutils' id = "path+file:///coreutils#0.0.26" - cargo metadata "$@" --format-version 1 | jq -r '[.resolve.nodes[] | select(.id|match(".*coreutils[ |@|#]\\d+\\.\\d+\\.\\d+")) | .deps[] | select(.pkg|match("uu_")) | .name | sub("^uu_"; "")] | sort | join(" ")' + export CARGO_BUILD_TARGET="${CARGO_BUILD_TARGET:-$(rustc --print host-tuple)}" + case "$CARGO_BUILD_TARGET" in + *windows*) _args=("--features=windows");; + *wasip*) _args=("--features=feat_wasm");; + # unix is default since we don't support too many non-unix + *) _args=("--features=unix");; + esac fi +# refs: , +# default utility list +cargo tree --depth 1 --format "{lib}" "${_args[@]}" --prefix none | sed -n 's/^uu_//p'