update shell scripts according to shellcheck recommendations and minor cleanup

This commit is contained in:
Linux User 2022-02-01 06:55:11 +00:00
parent dfc661e8b5
commit d762bebc1c
9 changed files with 52 additions and 56 deletions

View file

@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh
rustup target add x86_64-unknown-redox
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys AA12E97F0881517F

View file

@ -15,21 +15,21 @@ ME_parent_dir_abs="$(realpath -mP -- "${ME_parent_dir}")"
# * `gh` available?
unset GH
gh --version 1>/dev/null 2>&1
if [ $? -eq 0 ]; then export GH="gh"; fi
if gh --version 1>/dev/null 2>&1; then
export GH="gh"
else
echo "ERR!: missing \`gh\` (see install instructions at <https://github.com/cli/cli>)" 1>&2
fi
# * `jq` available?
unset JQ
jq --version 1>/dev/null 2>&1
if [ $? -eq 0 ]; then export JQ="jq"; fi
if jq --version 1>/dev/null 2>&1; then
export JQ="jq"
else
echo "ERR!: missing \`jq\` (install with \`sudo apt install jq\`)" 1>&2
fi
if [ -z "${GH}" ] || [ -z "${JQ}" ]; then
if [ -z "${GH}" ]; then
echo 'ERR!: missing `gh` (see install instructions at <https://github.com/cli/cli>)' 1>&2
fi
if [ -z "${JQ}" ]; then
echo 'ERR!: missing `jq` (install with `sudo apt install jq`)' 1>&2
fi
exit 1
fi

View file

@ -8,12 +8,13 @@
FEATURES_OPTION="--features feat_os_unix"
ME_dir="$(dirname -- $(readlink -fm -- "$0"))"
ME_dir="$(dirname -- "$(readlink -fm -- "$0")")"
REPO_main_dir="$(dirname -- "${ME_dir}")"
cd "${REPO_main_dir}"
cd "${REPO_main_dir}" &&
echo "[ \"$PWD\" ]"
#shellcheck disable=SC2086
UTIL_LIST=$("${ME_dir}"/show-utils.sh ${FEATURES_OPTION})
CARGO_INDIVIDUAL_PACKAGE_OPTIONS=""
for UTIL in ${UTIL_LIST}; do
@ -30,10 +31,12 @@ export RUSTC_WRAPPER="" ## NOTE: RUSTC_WRAPPER=='sccache' breaks code covera
export RUSTFLAGS="-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort"
export RUSTDOCFLAGS="-Cpanic=abort"
export RUSTUP_TOOLCHAIN="nightly-gnu"
cargo build ${FEATURES_OPTION}
cargo test --no-run ${FEATURES_OPTION}
cargo test --quiet ${FEATURES_OPTION}
cargo test --quiet ${FEATURES_OPTION} ${CARGO_INDIVIDUAL_PACKAGE_OPTIONS}
#shellcheck disable=SC2086
{ cargo build ${FEATURES_OPTION}
cargo test --no-run ${FEATURES_OPTION}
cargo test --quiet ${FEATURES_OPTION}
cargo test --quiet ${FEATURES_OPTION} ${CARGO_INDIVIDUAL_PACKAGE_OPTIONS}
}
export COVERAGE_REPORT_DIR
if [ -z "${COVERAGE_REPORT_DIR}" ]; then COVERAGE_REPORT_DIR="${REPO_main_dir}/target/debug/coverage-nix"; fi
@ -47,8 +50,7 @@ mkdir -p "${COVERAGE_REPORT_DIR}"
grcov . --output-type lcov --output-path "${COVERAGE_REPORT_DIR}/../lcov.info" --branch --ignore build.rs --ignore '/*' --ignore '[A-Za-z]:/*' --ignore 'C:/Users/*' --excl-br-line '^\s*((debug_)?assert(_eq|_ne)?!|#\[derive\()'
# * build HTML
# -- use `genhtml` if available for display of additional branch coverage information
genhtml --version 2>/dev/null 1>&2
if [ $? -eq 0 ]; then
if genhtml --version 2>/dev/null 1>&2; then
genhtml "${COVERAGE_REPORT_DIR}/../lcov.info" --output-directory "${COVERAGE_REPORT_DIR}" --branch-coverage --function-coverage | grep ": [0-9]"
else
grcov . --output-type html --output-path "${COVERAGE_REPORT_DIR}" --branch --ignore build.rs --ignore '/*' --ignore '[A-Za-z]:/*' --ignore 'C:/Users/*' --excl-br-line '^\s*((debug_)?assert(_eq|_ne)?!|#\[derive\()'

View file

@ -15,7 +15,7 @@ if test ! -d ../gnulib; then
fi
pushd $(pwd)
pushd "$PWD"
make PROFILE=release
BUILDDIR="$PWD/target/release/"
cp "${BUILDDIR}/install" "${BUILDDIR}/ginstall" # The GNU tests rename this script before running, to avoid confusion with the make target
@ -49,7 +49,7 @@ make -j "$(nproc)"
# Used to be 36. Reduced to 20 to decrease the log size
for i in {00..20}
do
make tests/factor/t${i}.sh
make "tests/factor/t${i}.sh"
done
# strip the long stuff

View file

@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh
set -e
ARG=""
@ -6,26 +6,21 @@ if test "$1" != "--do-it"; then
ARG="--dry-run --allow-dirty"
fi
cd src/uucore/
cargo publish $ARG
cd -
sleep 2s
cd src/uucore_procs/
cargo publish $ARG
cd -
sleep 2s
cd src/uu/stdbuf/src/libstdbuf/
cargo publish $ARG
cd -
sleep 2s
for dir in src/uucore/ src/uucore_procs/ src/uu/stdbuf/src/libstdbuf/ ; do
( cd "$dir"
#shellcheck disable=SC2086
cargo publish $ARG
)
sleep 2s
done
PROGS=$(ls -1d src/uu/*/)
for p in $PROGS; do
cd $p
( cd "$p"
#shellcheck disable=SC2086
cargo publish $ARG
cd -
)
done
#shellcheck disable=SC2086
cargo publish $ARG

View file

@ -1,6 +1,6 @@
#!/bin/bash
# spell-checker:ignore (env/vars) BUILDDIR GNULIB SUBDIRS
cd "$(dirname "${BASH_SOURCE[0]}")/../.."
cd "$(dirname -- "$(readlink -fm -- "$0")")/../.."
set -e
BUILDDIR="${PWD}/uutils/target/release"
GNULIB_DIR="${PWD}/gnulib"
@ -13,4 +13,5 @@ if test -n "$1"; then
export RUN_TEST="TESTS=$1"
fi
#shellcheck disable=SC2086
timeout -sKILL 2h make -j "$(nproc)" check $RUN_TEST SUBDIRS=. RUN_EXPENSIVE_TESTS=yes RUN_VERY_EXPENSIVE_TESTS=yes VERBOSE=no || : # Kill after 4 hours in case something gets stuck in make

View file

@ -2,15 +2,14 @@
# spell-checker:ignore (vars) OSID
ME_dir="$(dirname -- $(readlink -fm -- "$0"))"
ME_dir="$(dirname -- "$(readlink -fm -- "$0")")"
REPO_main_dir="$(dirname -- "${ME_dir}")"
export COVERAGE_REPORT_DIR="${REPO_main_dir}/target/debug/coverage-nix"
"${ME_dir}/build-code_coverage.sh"
if [ $? -ne 0 ]; then exit 1 ; fi
if ! "${ME_dir}/build-code_coverage.sh"; then exit 1 ; fi
case ";$OSID_tags;" in
*";wsl;"* ) powershell.exe -c $(wslpath -w "${COVERAGE_REPORT_DIR}"/index.html) ;;
*";wsl;"* ) powershell.exe -c "$(wslpath -w "${COVERAGE_REPORT_DIR}"/index.html)" ;;
* ) xdg-open --version >/dev/null 2>&1 && xdg-open "${COVERAGE_REPORT_DIR}"/index.html || echo "report available at '\"${COVERAGE_REPORT_DIR}\"/index.html'" ;;
esac ;

View file

@ -15,17 +15,13 @@ default_utils="base32 base64 basename cat cksum comm cp cut date dircolors dirna
project_main_dir="${ME_parent_dir_abs}"
# printf 'project_main_dir="%s"\n' "${project_main_dir}"
cd "${project_main_dir}"
cd "${project_main_dir}" &&
# `jq` available?
unset JQ
jq --version 1>/dev/null 2>&1
if [ $? -eq 0 ]; then export JQ="jq"; fi
if [ -z "${JQ}" ]; then
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 ! jq --version 1>/dev/null 2>&1; then
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"
else
cargo metadata $* --format-version 1 | jq -r "[.resolve.nodes[] | { id: .id, deps: [.deps[] | { name:.name, pkg:.pkg }] }] | .[] | select(.id|startswith(\"coreutils\")) | [.deps[] | select((.name|startswith(\"uu_\")) or (.pkg|startswith(\"uu_\")))] | [.[].pkg | match(\"^\\\w+\";\"g\")] | [.[].string | sub(\"^uu_\"; \"\")] | sort | join(\" \")"
# cargo metadata $* --format-version 1 | jq -r "[.resolve.nodes[] | { id: .id, deps: [.deps[] | { name:.name, pkg:.pkg }] }] | .[] | select(.id|startswith(\"coreutils\")) | [.deps[] | select((.name|startswith(\"uu_\")) or (.pkg|startswith(\"uu_\")))] | [.[].pkg | match(\"^\\\w+\";\"g\")] | [.[].string] | sort | join(\" \")"
cargo metadata "$*" --format-version 1 | jq -r "[.resolve.nodes[] | { id: .id, deps: [.deps[] | { name:.name, pkg:.pkg }] }] | .[] | select(.id|startswith(\"coreutils\")) | [.deps[] | select((.name|startswith(\"uu_\")) or (.pkg|startswith(\"uu_\")))] | [.[].pkg | match(\"^\\\w+\";\"g\")] | [.[].string | sub(\"^uu_\"; \"\")] | sort | join(\" \")"
# cargo metadata "$*" --format-version 1 | jq -r "[.resolve.nodes[] | { id: .id, deps: [.deps[] | { name:.name, pkg:.pkg }] }] | .[] | select(.id|startswith(\"coreutils\")) | [.deps[] | select((.name|startswith(\"uu_\")) or (.pkg|startswith(\"uu_\")))] | [.[].pkg | match(\"^\\\w+\";\"g\")] | [.[].string] | sort | join(\" \")"
fi

View file

@ -1,10 +1,10 @@
#!/bin/bash
#!/bin/sh
# This is a stupid helper. I will mass replace all versions (including other crates)
# So, it should be triple-checked
# How to ship a new release:
# 1) update this script
# 2) run it: bash util/update-version.sh
# 2) run it: sh util/update-version.sh
# 3) Do a spot check with "git diff"
# 4) cargo test --release --features unix
# 5) Run util/publish.sh in dry mode (it will fail as packages needs more recent version of uucore)
@ -23,6 +23,7 @@ UUCORE_TO="0.0.11"
PROGS=$(ls -1d src/uu/*/Cargo.toml src/uu/stdbuf/src/libstdbuf/Cargo.toml Cargo.toml src/uu/base64/Cargo.toml)
# update the version of all programs
#shellcheck disable=SC2086
sed -i -e "s|version = \"$FROM\"|version = \"$TO\"|" $PROGS
# Update uucore_procs
@ -35,6 +36,8 @@ sed -i -e "s|= { optional=true, version=\"$FROM\", package=\"uu_|= { optional=tr
# Update uucore itself
sed -i -e "s|version = \"$UUCORE_FROM\"|version = \"$UUCORE_TO\"|" src/uucore/Cargo.toml
# Update crates using uucore
#shellcheck disable=SC2086
sed -i -e "s|uucore = { version=\">=$UUCORE_FROM\",|uucore = { version=\">=$UUCORE_TO\",|" $PROGS
# Update crates using uucore_procs
#shellcheck disable=SC2086
sed -i -e "s|uucore_procs = { version=\">=$UUCORE_PROCS_FROM\",|uucore_procs = { version=\">=$UUCORE_PROCS_TO\",|" $PROGS