Skip to content

Commit e2757da

Browse files
authored
build-gnu.sh: Hijack hardcoded coreutils of GnuTests
1 parent 356567e commit e2757da

1 file changed

Lines changed: 13 additions & 9 deletions

File tree

util/build-gnu.sh

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -91,29 +91,28 @@ cd -
9191
export CARGOFLAGS # tell to make
9292
if [ "${SELINUX_ENABLED}" = 1 ];then
9393
# Build few utils for SELinux for faster build. MULTICALL=y fails...
94-
make UTILS="cat chcon chmod cp cut dd echo env groups id install ln ls mkdir mkfifo mknod mktemp mv printf rm rmdir runcon seq stat test touch tr true uname wc whoami"
94+
UTILS="cat chcon chmod cp cut dd echo env groups id install ln ls mkdir mkfifo mknod mktemp mv printf rm rmdir runcon seq stat test touch tr true uname wc whoami"
95+
export UTILS
96+
make
9597
else
9698
# Use MULTICALL=y for faster build
9799
make MULTICALL=y SKIP_UTILS=more
98-
for binary in $("${UU_BUILD_DIR}"/coreutils --list)
99-
do [ -e "${UU_BUILD_DIR}/${binary}" ] || ln -vf "${UU_BUILD_DIR}/coreutils" "${UU_BUILD_DIR}/${binary}"
100+
UTILS=$("${UU_BUILD_DIR}"/coreutils --list)
101+
for binary in "${UTILS}"
102+
do ln -sf "${UU_BUILD_DIR}/coreutils" "${UU_BUILD_DIR}/${binary}"
100103
done
101104
fi
102-
[ -e "${UU_BUILD_DIR}/ginstall" ] || ln -vf "${UU_BUILD_DIR}/install" "${UU_BUILD_DIR}/ginstall" # The GNU tests use ginstall
105+
ln -sf "${UU_BUILD_DIR}/install" "${UU_BUILD_DIR}/ginstall" # The GNU tests use ginstall
103106
##
104107

105108
cd "${path_GNU}" && echo "[ pwd:'${PWD}' ]"
106109

107110
# Any binaries that aren't built become `false` to make tests failure
108111
for binary in $(./build-aux/gen-lists-of-programs.sh --list-progs); do
109112
bin_path="${UU_BUILD_DIR}/${binary}"
110-
test -f "${bin_path}" || cp -v /usr/bin/false "${bin_path}"
113+
test -f "${bin_path}" || ln -sv /usr/bin/false "${bin_path}"
111114
done
112115

113-
# Always update the PATH to test the uutils coreutils instead of the GNU coreutils
114-
# This ensures the correct path is used even if the repository was moved or rebuilt in a different location
115-
sed -i "s/^[[:blank:]]*PATH=.*/ PATH='${UU_BUILD_DIR//\//\\/}\$(PATH_SEPARATOR)'\"\$\$PATH\" \\\/" tests/local.mk
116-
117116
if test -f gnu-built; then
118117
echo "GNU build already found. Skip"
119118
echo "'rm -f $(pwd)/{gnu-built,src/getlimits}' to force the build"
@@ -160,6 +159,11 @@ else
160159
touch gnu-built
161160
fi
162161

162+
# Hijack coreutils
163+
for binary in "${UTILS}"
164+
do ln -sf "${UU_BUILD_DIR}/${binary}" src/"${binary}"
165+
done
166+
163167
grep -rl 'path_prepend_' tests/* | xargs -r "${SED}" -i 's| path_prepend_ ./src||'
164168
# path_prepend_ sets $abs_path_dir_: set it manually instead.
165169
grep -rl '\$abs_path_dir_' tests/*/*.sh | xargs -r "${SED}" -i "s|\$abs_path_dir_|${UU_BUILD_DIR//\//\\/}|g"

0 commit comments

Comments
 (0)