build-gnu.sh: Use any profile & cleanup arg

This commit is contained in:
oech3 2025-11-18 16:49:41 +09:00
parent 35f7db96ca
commit ea9feef0f1
3 changed files with 15 additions and 24 deletions

View file

@ -109,7 +109,7 @@ jobs:
run: |
## Build binaries
cd 'uutils'
bash util/build-gnu.sh --release-build
env PROFILE=release-small bash util/build-gnu.sh
### Run tests as user
- name: Run GNU tests
@ -244,7 +244,7 @@ jobs:
### Build
- name: Build binaries
run: |
lima bash -c "cd ~/work/uutils/ && SELINUX_ENABLED=1 bash util/build-gnu.sh --release-build"
lima bash -c "cd ~/work/uutils/ && SELINUX_ENABLED=1 PROFILE=release-small bash util/build-gnu.sh"
### Run tests as user
- name: Generate SELinux tests list

View file

@ -230,7 +230,9 @@ To run uutils against the GNU test suite locally, run the following commands:
```shell
bash util/build-gnu.sh
# Build uutils with release optimizations
bash util/build-gnu.sh --release-build
env PROFILE=release bash util/build-gnu.sh
# Build uutils with SELinux
env SELINUX_ENABLED=1 bash util/build-gnu.sh
bash util/run-gnu-test.sh
# To run a single test:
bash util/run-gnu-test.sh tests/touch/not-owner.sh # for example

View file

@ -14,24 +14,18 @@ NPROC=$(command -v gnproc||command -v nproc)
READLINK=$(command -v greadlink||command -v readlink)
SED=$(command -v gsed||command -v sed)
SYSTEM_TIMEOUT=$(command -v timeout)
SYSTEM_YES=$(command -v yes)
ME="${0}"
ME_dir="$(dirname -- "$("${READLINK}" -fm -- "${ME}")")"
REPO_main_dir="$(dirname -- "${ME_dir}")"
# Default profile is 'debug'
UU_MAKE_PROFILE='debug'
: ${PROFILE:=debug} # default profile
export PROFILE
CARGO_FEATURE_FLAGS=""
for arg in "$@"
do
if [ "$arg" == "--release-build" ]; then
UU_MAKE_PROFILE='release'
break
fi
done
echo "UU_MAKE_PROFILE='${UU_MAKE_PROFILE}'"
### * config (from environment with fallback defaults); note: GNU is expected to be a sibling repo directory
path_UUTILS=${path_UUTILS:-${REPO_main_dir}}
@ -39,11 +33,6 @@ path_GNU="$("${READLINK}" -fm -- "${path_GNU:-${path_UUTILS}/../gnu}")"
###
SYSTEM_TIMEOUT=$(command -v timeout)
SYSTEM_YES=$(command -v yes)
###
release_tag_GNU="v9.9"
# check if the GNU coreutils has been cloned, if not print instructions
@ -71,9 +60,9 @@ echo "path_GNU='${path_GNU}'"
###
if [[ ! -z "$CARGO_TARGET_DIR" ]]; then
UU_BUILD_DIR="${CARGO_TARGET_DIR}/${UU_MAKE_PROFILE}"
UU_BUILD_DIR="${CARGO_TARGET_DIR}/${PROFILE}"
else
UU_BUILD_DIR="${path_UUTILS}/target/${UU_MAKE_PROFILE}"
UU_BUILD_DIR="${path_UUTILS}/target/${PROFILE}"
fi
echo "UU_BUILD_DIR='${UU_BUILD_DIR}'"
@ -105,9 +94,9 @@ fi
cd -
# Pass the feature flags to make, which will pass them to cargo
"${MAKE}" PROFILE="${UU_MAKE_PROFILE}" CARGOFLAGS="${CARGO_FEATURE_FLAGS}"
"${MAKE}" PROFILE="${PROFILE}" CARGOFLAGS="${CARGO_FEATURE_FLAGS}"
# min test for SELinux
[ "${SELINUX_ENABLED}" = 1 ] && touch g && "${UU_MAKE_PROFILE}"/stat -c%C g && rm g
[ "${SELINUX_ENABLED}" = 1 ] && touch g && "${PROFILE}"/stat -c%C g && rm g
cp "${UU_BUILD_DIR}/install" "${UU_BUILD_DIR}/ginstall" # The GNU tests rename this script before running, to avoid confusion with the make target
# Create *sum binaries