|
1 | 1 | #!/bin/bash
|
| 2 | +# `build-gnu.bash` ~ builds GNU coreutils (from supplied sources) |
| 3 | +# |
| 4 | +# BUILD_PROFILE == 'debug' | 'release' ## build profile for *uutils* build; may be supplied by caller, defaults to 'debug' |
2 | 5 |
|
3 |
| -# spell-checker:ignore (paths) abmon deref discrim eacces getlimits getopt ginstall gnulib inacc infloop inotify reflink ; (misc) INT_OFLOW OFLOW baddecode ; (vars/env) BUILDDIR SRCDIR |
| 6 | +# spell-checker:ignore (paths) abmon deref discrim eacces getlimits getopt ginstall gnulib inacc infloop inotify reflink ; (misc) INT_OFLOW OFLOW baddecode ; (vars/env) BUILD_DIR SRCDIR |
4 | 7 |
|
5 | 8 | set -e
|
6 |
| -if test ! -d ../gnu; then |
7 |
| - echo "Could not find ../gnu" |
8 |
| - echo "git clone https://github.com/coreutils/coreutils.git gnu" |
| 9 | + |
| 10 | +ME="${0}" |
| 11 | +ME_dir="$(dirname -- "$(readlink -fm -- "${ME}")")" |
| 12 | +REPO_main_dir="$(dirname -- "${ME_dir}")" |
| 13 | + |
| 14 | +### * config (from environment with fallback defaults); note: GNU and GNULIB are expected to be sibling repo directories |
| 15 | + |
| 16 | +path_UUTILS=${path_UUTILS:-${REPO_main_dir}} |
| 17 | +path_GNU="$(readlink -fm -- "${path_GNU:-${path_UUTILS}/../gnu}")" |
| 18 | +path_GNULIB="$(readlink -fm -- "${path_GNULIB:-${path_UUTILS}/../gnulib}")" |
| 19 | + |
| 20 | +echo "path_UUTILS='${path_UUTILS}'" |
| 21 | +echo "path_GNU='${path_GNU}'" |
| 22 | +echo "path_GNULIB='${path_GNULIB}'" |
| 23 | + |
| 24 | +### |
| 25 | + |
| 26 | +if test ! -d "${path_GNU}"; then |
| 27 | + echo "Could not find GNU (expected at '${path_GNU}')" |
| 28 | + echo "git clone https://github.com/coreutils/coreutils.git \"${path_GNU}\"" |
9 | 29 | exit 1
|
10 | 30 | fi
|
11 |
| -if test ! -d ../gnulib; then |
12 |
| - echo "Could not find ../gnulib" |
13 |
| - echo "git clone https://github.com/coreutils/gnulib.git gnulib" |
| 31 | +if test ! -d "${path_GNULIB}"; then |
| 32 | + echo "Could not find GnuLib (expected at '${path_GNULIB}')" |
| 33 | + echo "git clone https://github.com/coreutils/gnulib.git \"${path_GNULIB}\"" |
14 | 34 | exit 1
|
15 | 35 | fi
|
16 | 36 |
|
| 37 | +BUILD_PROFILE=${BUILD_PROFILE:-release} |
| 38 | +echo "BUILD_PROFILE='${BUILD_PROFILE}'" |
17 | 39 |
|
18 |
| -pushd "$PWD" |
19 |
| -make PROFILE=release |
20 |
| -BUILDDIR="$PWD/target/release/" |
21 |
| -cp "${BUILDDIR}/install" "${BUILDDIR}/ginstall" # The GNU tests rename this script before running, to avoid confusion with the make target |
22 |
| -# Create *sum binaries |
23 |
| -for sum in b2sum md5sum sha1sum sha224sum sha256sum sha384sum sha512sum |
24 |
| -do |
25 |
| - sum_path="${BUILDDIR}/${sum}" |
26 |
| - test -f "${sum_path}" || cp "${BUILDDIR}/hashsum" "${sum_path}" |
27 |
| -done |
28 |
| -test -f "${BUILDDIR}/[" || cp "${BUILDDIR}/test" "${BUILDDIR}/[" |
29 |
| -popd |
30 |
| -GNULIB_SRCDIR="$PWD/../gnulib" |
31 |
| -pushd ../gnu/ |
| 40 | +BUILD_DIR="${PWD}/target/${BUILD_PROFILE}/" |
| 41 | +echo "BUILD_DIR='${BUILD_DIR}'" |
| 42 | + |
| 43 | +( |
| 44 | + cd "${PWD}" |
| 45 | + make "PROFILE=${BUILD_PROFILE}" |
| 46 | + cp "${BUILD_DIR}/install" "${BUILD_DIR}/ginstall" # The GNU tests rename this script before running, to avoid confusion with the make target |
| 47 | + # Create *sum binaries |
| 48 | + for sum in b2sum md5sum sha1sum sha224sum sha256sum sha384sum sha512sum |
| 49 | + do |
| 50 | + sum_path="${BUILD_DIR}/${sum}" |
| 51 | + test -f "${sum_path}" || cp "${BUILD_DIR}/hashsum" "${sum_path}" |
| 52 | + done |
| 53 | + test -f "${BUILD_DIR}/[" || cp "${BUILD_DIR}/test" "${BUILD_DIR}/[" |
| 54 | +) |
| 55 | + |
| 56 | +## |
32 | 57 |
|
| 58 | +cd "${path_GNU}" |
33 | 59 | # Any binaries that aren't built become `false` so their tests fail
|
34 | 60 | for binary in $(./build-aux/gen-lists-of-programs.sh --list-progs)
|
35 | 61 | do
|
36 |
| - bin_path="${BUILDDIR}/${binary}" |
37 |
| - test -f "${bin_path}" || { echo "'${binary}' was not built with uutils, using the 'false' program"; cp "${BUILDDIR}/false" "${bin_path}"; } |
| 62 | + bin_path="${BUILD_DIR}/${binary}" |
| 63 | + test -f "${bin_path}" || { echo "'${binary}' was not built with uutils, using the 'false' program"; cp "${BUILD_DIR}/false" "${bin_path}"; } |
38 | 64 | done
|
39 | 65 |
|
40 |
| -./bootstrap --gnulib-srcdir="$GNULIB_SRCDIR" |
| 66 | +./bootstrap --gnulib-srcdir="${path_GNULIB}" |
41 | 67 | ./configure --quiet --disable-gcc-warnings
|
42 | 68 | #Add timeout to to protect against hangs
|
43 | 69 | sed -i 's|^"\$@|/usr/bin/timeout 600 "\$@|' build-aux/test-driver
|
44 | 70 | # Change the PATH in the Makefile to test the uutils coreutils instead of the GNU coreutils
|
45 |
| -sed -i "s/^[[:blank:]]*PATH=.*/ PATH='${BUILDDIR//\//\\/}\$(PATH_SEPARATOR)'\"\$\$PATH\" \\\/" Makefile |
| 71 | +sed -i "s/^[[:blank:]]*PATH=.*/ PATH='${BUILD_DIR//\//\\/}\$(PATH_SEPARATOR)'\"\$\$PATH\" \\\/" Makefile |
46 | 72 | sed -i 's| tr | /usr/bin/tr |' tests/init.sh
|
47 | 73 | make -j "$(nproc)"
|
48 | 74 | # Generate the factor tests, so they can be fixed
|
@@ -117,7 +143,7 @@ sed -i -e "s|rm: cannot remove 'a/1'|rm: cannot remove 'a'|g" tests/rm/rm2.sh
|
117 | 143 |
|
118 | 144 | sed -i -e "s|removed directory 'a/'|removed directory 'a'|g" tests/rm/v-slash.sh
|
119 | 145 |
|
120 |
| -test -f "${BUILDDIR}/getlimits" || cp src/getlimits "${BUILDDIR}" |
| 146 | +test -f "${BUILD_DIR}/getlimits" || cp src/getlimits "${BUILD_DIR}" |
121 | 147 |
|
122 | 148 | # When decoding an invalid base32/64 string, gnu writes everything it was able to decode until
|
123 | 149 | # it hit the decode error, while we don't write anything if the input is invalid.
|
|
0 commit comments