Debian Codegraph @

util/build-gnu.sh

raw
1 #!/usr/bin/env bash
2 # `build-gnu.bash` ~ builds GNU coreutils (from supplied sources)
3 #
4
5 # spell-checker:ignore (paths) abmon deref discrim eacces getopt ginstall inacc infloop inotify reflink ; (misc) INT_OFLOW OFLOW
6 # spell-checker:ignore baddecode submodules xstrtol distros ; (vars/env) SRCDIR vdir rcexp xpart dired OSTYPE ; (utils) greadlink gsed multihardlink texinfo CARGOFLAGS
7 # spell-checker:ignore openat TOCTOU CFLAGS tmpfs gnproc
8
9 set -e
10
11 # Use GNU make, readlink and sed on *BSD and macOS
12 command -v gmake && make(){ gmake "$@";}
13 command -v greadlink && readlink(){ greadlink "$@";} # todo: use our readlink for less deps
14 command -v gsed && sed(){ gsed "$@";}
15 SED=$(command -v gsed||command -v sed) # for find...exec...
16
17 SYSTEM_TIMEOUT=$(command -v timeout)
18
19 ME="${0}"
20 ME_dir="$(dirname -- "$(readlink -fm -- "${ME}")")"
21 REPO_main_dir="$(dirname -- "${ME_dir}")"
22
23
24 : ${PROFILE:=debug} # default profile
25 export PROFILE # tell to make
26 unset CARGOFLAGS
27
28 ### * config (from environment with fallback defaults); note: GNU is expected to be a sibling repo directory
29
30 path_UUTILS=${path_UUTILS:-${REPO_main_dir}}
31 path_GNU="$(readlink -fm -- "${path_GNU:-${path_UUTILS}/../gnu}")"
32
33 ###
34
35 # check if the GNU coreutils has been cloned, if not print instructions
36 # note: the ${path_GNU} might already exist, so we check for the configure
37 if test ! -f "${path_GNU}/configure"; then
38 echo "Could not find the GNU coreutils (expected at '${path_GNU}')"
39 echo "Download them to the expected path:"
40 echo " (mkdir -p '${path_GNU}' && cd '${path_GNU}' && bash '${path_UUTILS}/util/fetch-gnu.sh')"
41 echo "You can edit fetch-gnu.sh to change the tag"
42 exit 1
43 fi
44
45 ###
46
47 echo "ME='${ME}'"
48 echo "ME_dir='${ME_dir}'"
49 echo "REPO_main_dir='${REPO_main_dir}'"
50
51 echo "path_UUTILS='${path_UUTILS}'"
52 echo "path_GNU='${path_GNU}'"
53
54 ###
55
56 if [[ ! -z "$CARGO_TARGET_DIR" ]]; then
57 UU_BUILD_DIR="${CARGO_TARGET_DIR}/${PROFILE}"
58 else
59 UU_BUILD_DIR="${path_UUTILS}/target/${PROFILE}"
60 fi
61 echo "UU_BUILD_DIR='${UU_BUILD_DIR}'"
62
63 cd "${path_UUTILS}" && echo "[ pwd:'${PWD}' ]"
64
65 export SELINUX_ENABLED # Run this script with=1 for testing SELinux
66 [ "${SELINUX_ENABLED}" = 1 ] && CARGOFLAGS="${CARGOFLAGS} selinux"
67
68 # Trim leading whitespace from feature flags
69 CARGOFLAGS="$(echo "${CARGOFLAGS}" | sed -e 's/^[[:space:]]*//')"
70
71 # If we have feature flags, format them correctly for cargo
72 if [ ! -z "${CARGOFLAGS}" ]; then
73 CARGOFLAGS="--features ${CARGOFLAGS}"
74 echo "Building with cargo flags: ${CARGOFLAGS}"
75 fi
76
77 # Set up quilt for patch management
78 export QUILT_PATCHES="${ME_dir}/gnu-patches/"
79 cd "$path_GNU"
80
81 # Check if all patches are already applied
82 if [ "$(quilt applied | wc -l)" -eq "$(quilt series | wc -l)" ]; then
83 echo "All patches are already applied"
84 else
85 # Push all patches
86 quilt push -a || { echo "Failed to apply patches"; exit 1; }
87 fi
88 cd -
89
90 export CARGOFLAGS # tell to make
91 if [ "${SELINUX_ENABLED}" = 1 ];then
92 # Build few utils for SELinux for faster build. MULTICALL=y fails...
93 make UTILS="cat chcon chmod cp cut dd echo env groups id install ln ls mkdir mkfifo mknod mktemp mv printf realpath rm rmdir runcon seq stat test touch tr true uname wc whoami"
94 else
95 # Use MULTICALL=y for faster build
96 make MULTICALL=y SKIP_UTILS=more
97 for binary in $("${UU_BUILD_DIR}"/coreutils --list)
98 do ln -vf "${UU_BUILD_DIR}/coreutils" "${UU_BUILD_DIR}/${binary}"
99 done
100 ln -vf "${UU_BUILD_DIR}"/deps/libstdbuf.* -t "${UU_BUILD_DIR}"
101 fi
102 ln -vf "${UU_BUILD_DIR}/install" "${UU_BUILD_DIR}/ginstall" # The GNU tests use ginstall
103 ##
104
105 cd "${path_GNU}" && echo "[ pwd:'${PWD}' ]"
106
107 # Any binaries that aren't built become `false` to make tests failure
108 for binary in $(./build-aux/gen-lists-of-programs.sh --list-progs); do
109 bin_path="${UU_BUILD_DIR}/${binary}"
110 test -f "${bin_path}" || cp -v /usr/bin/false "${bin_path}"
111 done
112
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
117 # Use GNU nproc for *BSD and macOS
118 NPROC="$(command -v nproc||command -v gnproc)"
119
120 if test -f gnu-built; then
121 echo "GNU build already found. Skip"
122 echo "'rm -f $(pwd)/{gnu-built,src/getlimits}' to force the build"
123 echo "Note: the customization of the tests will still happen"
124 else
125 autoreconf
126 # Disable useless checks
127 sed -i 's|check-texinfo: $(syntax_checks)|check-texinfo:|' doc/local.mk
128 # Stop manpage generation for cleaner log
129 : > man/local.mk
130 # Use CFLAGS for best build time since we discard GNU coreutils
131 CFLAGS="${CFLAGS} -pipe -O0 -s" ./configure -C --quiet --disable-gcc-warnings --disable-nls --disable-dependency-tracking --disable-bold-man-page-references \
132 --enable-single-binary=hardlinks --enable-install-program="arch,kill,uptime,hostname" \
133 "$([ "${SELINUX_ENABLED}" = 1 ] && echo --with-selinux || echo --without-selinux)"
134 #Add timeout to to protect against hangs
135 sed -i 's|^"\$@|'"${SYSTEM_TIMEOUT}"' 600 "\$@|' build-aux/test-driver
136 # Use a better diff
137 sed -i 's|diff -c|diff -u|g' tests/Coreutils.pm
138
139 # Skip make if possible. The SELinux job does not build the GNU tree at all;
140 # the block after this "if" builds the one program its tests need.
141 if [ "${SELINUX_ENABLED}" != 1 ]; then
142 test -x src/getlimits || make -j "$("${NPROC}")"
143 fi
144
145 # Handle generated factor tests
146 t_first=00
147 t_max=40
148 seq=$(
149 i=${t_first}
150 while test "${i}" -le "${t_max}"; do
151 printf '%02d ' ${i}
152 i=$((i + 1))
153 done
154 )
155 for i in ${seq}; do
156 echo "strip t${i}.sh from Makefile and tests/local.mk"
157 sed -i -e "s/\$(tf)\/t${i}.sh//g" Makefile tests/local.mk
158 done
159 # Remove LD_PRELOAD implementation of no-mtab-status-masked-proc. not compatible with our binary
160 sed -i '/tests\/df\/no-mtab-status.sh/ D' Makefile
161 # Remove tests checking for --version & --help
162 # Not really interesting for us and logs are too big
163 sed -i '/tests\/help\/help-version.sh/ D' Makefile
164 touch gnu-built
165 fi
166
167 # Keep Makefile.in newer than the local.mk files we just modified,
168 # and Makefile newer than Makefile.in, so make won't re-run
169 # automake or config.status and undo our edits.
170 touch Makefile.in Makefile
171
172 # The GNU shell and Perl tests call getlimits_, so getlimits has to be a real
173 # program on PATH, also when reusing an existing GNU build directory. An earlier
174 # version of this script left an empty, non-executable stub behind under
175 # SELINUX_ENABLED, hence the test for an executable rather than for a file.
176 # Build only that program, plus the generated sources that the "all" target
177 # would otherwise pull in, so the SELinux job still skips the rest of the tree.
178 # This has to come after the touch above: stripping the factor tests leaves
179 # tests/local.mk with a trailing backslash that automake rejects, so a make that
180 # still sees it as newer than Makefile.in dies in the remake rule.
181 if ! test -x src/getlimits; then
182 rm -f src/getlimits
183 printf 'built-sources: $(BUILT_SOURCES)\n' |
184 make -f Makefile -f - -j "$("${NPROC}")" built-sources || true
185 make -j "$("${NPROC}")" src/getlimits || true
186 fi
187 if test -x src/getlimits; then
188 # Remove the destination first: cp keeps the permissions of an existing
189 # file, so a leftover stub there would stay non-executable.
190 rm -f "${UU_BUILD_DIR}/getlimits"
191 cp -f src/getlimits "${UU_BUILD_DIR}"
192 else
193 echo "WARNING: could not build getlimits; tests calling getlimits_ will fail" >&2
194 fi
195
196 # Patch the Makefile PATH to point to uutils build dir instead of GNU src/
197 sed -i "s/^[[:blank:]]*PATH=.*/ PATH='${UU_BUILD_DIR//\//\\/}\$(PATH_SEPARATOR)'\"\$\$PATH\" \\\/" Makefile
198 # Prevent make check from rebuilding the GNU binaries over the uutils ones
199 sed -i 's/^check-am: all-am/check-am:/' Makefile
200
201 grep -rl 'path_prepend_' tests/* | xargs -r "${SED}" -i 's| path_prepend_ ./src||'
202 # path_prepend_ sets $abs_path_dir_: set it manually instead.
203 grep -rl '\$abs_path_dir_' tests/*/*.sh | xargs -r "${SED}" -i "s|\$abs_path_dir_|${UU_BUILD_DIR//\//\\/}|g"
204 # Some tests use $abs_top_builddir/src for shebangs: point them to the uutils build dir.
205 grep -rl '\$abs_top_builddir/src' tests/*/*.sh tests/*/*.pl | xargs -r "${SED}" -i "s|\$abs_top_builddir/src|${UU_BUILD_DIR//\//\\/}|g"
206 grep -rl '\$ENV{abs_top_builddir}/src' tests/*/*.pl | xargs -r "${SED}" -i "s|\$ENV{abs_top_builddir}/src|${UU_BUILD_DIR//\//\\/}|g"
207
208 # We can't build runcon and chcon without libselinux. But GNU no longer builds dummies of them. So consider they are SELinux specific.
209 sed -i 's/^print_ver_.*/require_selinux_/' tests/runcon/runcon-compute.sh
210 sed -i 's/^print_ver_.*/require_selinux_/' tests/runcon/runcon-no-reorder.sh
211 sed -i 's/^print_ver_.*/require_selinux_/' tests/chcon/chcon-fail.sh
212
213 # We use coreutils yes
214 sed -i "s|--coreutils-prog=||g" tests/misc/coreutils.sh
215
216 # Use the system coreutils where the test fails due to error in a util that is not the one being tested
217 sed -i "s|grep '^#define HAVE_CAP 1' \$CONFIG_HEADER > /dev/null|true|" tests/ls/capability.sh
218
219 # our messages are better
220 sed -i "s|cp: cannot stat 'symlink': .*|cp: not writing through dangling symlink 'symlink'|" tests/cp/fail-perm.sh
221 sed -i "s|cp: target directory 'symlink': .*|cp: 'symlink' is not a directory|" tests/cp/fail-perm.sh
222
223 # Our message is a bit better
224 sed -i "s|cannot create regular file 'no-such/': Not a directory|'no-such/' is not a directory|" tests/mv/trailing-slash.sh
225
226 # Our message is better
227 sed -i "s|warning: unrecognized escape|warning: incomplete hex escape|" tests/stat/stat-printf.pl
228
229 # Remove dup of /usr/bin/ and /usr/local/bin/ when executed several times
230 grep -rlE '/usr/bin/\s?/usr/bin' init.cfg tests/* | xargs -r "${SED}" -Ei 's|/usr/bin/\s?/usr/bin/|/usr/bin/|g'
231 grep -rlE '/usr/local/bin/\s?/usr/local/bin' init.cfg tests/* | xargs -r "${SED}" -Ei 's|/usr/local/bin/\s?/usr/local/bin/|/usr/local/bin/|g'
232
233 #### Adjust tests to make them work with Rust/coreutils
234 # in some cases, what we are doing in rust/coreutils is good (or better)
235 # we should not regress our project just to match what GNU is going.
236 # So, do some changes on the fly
237
238 sed -i -e "s|removed directory 'a/'|removed directory 'a'|g" tests/rm/v-slash.sh
239
240 # 'rel' doesn't exist. Our implementation is giving a better message.
241 sed -i -e "s|rm: cannot remove 'rel': \$EACCES|rm: cannot remove 'rel': No such file or directory|g" tests/rm/inaccessible.sh
242
243 # Our implementation shows "Directory not empty" for directories that can't be accessed due to lack of execute permissions
244 # This is actually more accurate than "Permission denied" since the real issue is that we can't empty the directory
245 sed -i -e "s|rm: cannot remove 'a/1': Permission denied|rm: cannot remove 'a/1/2': Permission denied|g" -e "s|rm: cannot remove 'b': Permission denied|rm: cannot remove 'a': Directory not empty\nrm: cannot remove 'b/3': Permission denied|g" tests/rm/rm2.sh
246
247 # overlay-headers.sh test intends to check for inotify events,
248 # however there's a bug because `---dis` is an alias for: `---disable-inotify`
249 sed -i -e "s|---dis ||g" tests/tail/overlay-headers.sh
250
251 # Patch inotify-race tests to use Rust source lines for gdb breakpoints.
252 # GNU test checks for race between initial read and watch setup. Rust sets up
253 # watchers before initial read, so no exact equivalent exists. We break at
254 # watch_with_parent as the closest semantic match. -iex suppresses Rust debug
255 # script auto-load warnings that would cause the test to skip.
256 sed -i \
257 -e "s|break_src=\"\$abs_top_srcdir/src/tail.c\"|break_src=\"${path_UUTILS}/src/uu/tail/src/follow/watch.rs\"|" \
258 -e 's|break_line=$(grep -n ^tail_forever_inotify "$break_src")|break_line=$(grep -n "watcher_rx.watch_with_parent" "$break_src")|' \
259 -e 's|gdb -nx --batch-silent|gdb -nx --batch-silent -iex "set auto-load no"|g' \
260 tests/tail/inotify-race.sh tests/tail/inotify-race2.sh
261
262 # Do not FAIL, just do a regular ERROR
263 sed -i -e "s|framework_failure_ 'no inotify_add_watch';|fail=1;|" tests/tail/inotify-rotate-resources.sh
264
265 # pr-tests.pl: Override the comparison function to suppress diff output
266 # This prevents the test from overwhelming logs while still reporting failures
267 sed -i '/^my $fail = run_tests/i no warnings "redefine"; *Coreutils::_compare_files = sub { my ($p, $t, $io, $a, $e) = @_; my $d = File::Compare::compare($a, $e); warn "$p: test $t: mismatch\\n" if $d; return $d; };' tests/pr/pr-tests.pl
268
269 # We don't have the same error message and no need to be that specific
270 sed -i -e "s|invalid suffix in --pages argument|invalid --pages argument|" \
271 -e "s|--pages argument '\$too_big' too large|invalid --pages argument '\$too_big'|" \
272 -e "s|invalid page range|invalid --pages argument|" tests/misc/xstrtol.pl
273
274 # When decoding an invalid base32/64 string, gnu writes everything it was able to decode until
275 # it hit the decode error, while we don't write anything if the input is invalid.
276 sed -i "s/\(baddecode.*OUT=>\"\).*\"/\1\"/g" tests/basenc/base64.pl
277 sed -i "s/\(\(b2[ml]_[69]\|z85_8\|z85_35\).*OUT=>\)[^}]*\(.*\)/\1\"\"\3/g" tests/basenc/basenc.pl
278
279 # add "error: " to the expected error message
280 sed -i "s/\$prog: invalid input/\$prog: error: invalid input/g" tests/basenc/basenc.pl
281
282 # basenc: swap out error message for unexpected arg
283 sed -i "s/ {ERR=>\"\$prog: foobar\\\\n\" \. \$try_help }/ {ERR=>\"error: unexpected argument '--foobar' found\n\n tip: to pass '--foobar' as a value, use '-- --foobar'\n\nUsage: basenc [OPTION]... [FILE]\n\nFor more information, try '--help'.\n\"}]/" tests/basenc/basenc.pl
284 sed -i "s/ {ERR_SUBST=>\"s\/(unrecognized|unknown) option \[-' \]\*foobar\[' \]\*\/foobar\/\"}],//" tests/basenc/basenc.pl
285
286 # exit early for the selinux check. The first is enough for us.
287 sed -i "s|# Independent of whether SELinux|return 0\n #|g" init.cfg
288
289 # Some tests are executed with the "nobody" user.
290 # The check to verify if it works is based on the GNU coreutils version
291 # making it too restrictive for us
292 sed -i "s|\$PACKAGE_VERSION|[0-9]*|g" tests/rm/fail-2eperm.sh tests/mv/sticky-to-xpart.sh init.cfg
293
294 # usage_vs_refs.sh checks that all options appear in GNU's texi docs.
295 # we have some extra options
296 sed -i '1s/^/Exit 77\n/' tests/misc/usage_vs_refs.sh
297
298 # usage_vs_getopt.sh is heavily modified as it runs all the binaries
299 # with the option -/ is used, clap is returning a better error than GNU's. Adjust the GNU test
300 sed -i -e "s~ grep \" '\*/'\*\" err || framework_failure_~ grep \" '*-/'*\" err || framework_failure_~" tests/misc/usage_vs_getopt.sh
301 sed -i -e "s~ sed -n \"1s/'\\\/'/'OPT'/p\" < err >> pat || framework_failure_~ sed -n \"1s/'-\\\/'/'OPT'/p\" < err >> pat || framework_failure_~" tests/misc/usage_vs_getopt.sh
302 # Ignore runcon, it needs some extra attention
303 # For all other tools, we want drop-in compatibility, and that includes the exit code.
304 sed -i -e "s/rcexp=1$/rcexp=1\n case \"\$prg\" in runcon|stdbuf) return;; esac/" tests/misc/usage_vs_getopt.sh
305 # GNU has option=[SUFFIX], clap is <SUFFIX>
306 sed -i -e "s/cat opts/sed -i -e \"s| <.\*$||g\" opts/" tests/misc/usage_vs_getopt.sh
307 # for some reasons, some stuff are duplicated, strip that
308 sed -i -e "s/provoked error./provoked error\ncat pat |sort -u > pat/" tests/misc/usage_vs_getopt.sh
309
310 # install verbose messages shows ginstall as command
311 sed -i -e "s/ginstall: creating directory/install: creating directory/g" tests/install/basic-1.sh
312
313 # GNU doesn't support padding < -LONG_MAX
314 # disable this test case
315 sed -i -Ez "s/\n([^\n#]*pad-3\.2[^\n]*)\n([^\n]*)\n([^\n]*)/\n# uutils\/numfmt supports padding = LONG_MIN\n#\1\n#\2\n#\3/" tests/numfmt/numfmt.pl
316
317 # Update the GNU error message to match the one generated by clap
318 sed -i -e "s/\$prog: multiple field specifications/error: the argument '--field <FIELDS>' cannot be used multiple times\n\nUsage: numfmt [OPTION]... [NUMBER]...\n\nFor more information, try '--help'./g" tests/numfmt/numfmt.pl
319 sed -i -e "s/Try 'mv --help' for more information/For more information, try '--help'/g" -e "s/mv: missing file operand/error: the following required arguments were not provided:\n <files>...\n\nUsage: mv [OPTION]... [-T] SOURCE DEST\n mv [OPTION]... SOURCE... DIRECTORY\n mv [OPTION]... -t DIRECTORY SOURCE...\n/g" -e "s/mv: missing destination file operand after 'no-file'/error: The argument '<files>...' requires at least 2 values, but only 1 was provided\n\nUsage: mv [OPTION]... [-T] SOURCE DEST\n mv [OPTION]... SOURCE... DIRECTORY\n mv [OPTION]... -t DIRECTORY SOURCE...\n/g" tests/mv/diag.sh
320
321 # GNU doesn't support width > INT_MAX
322 # disable these test cases
323 sed -i -E "s|^([^#]*2_31.*)$|#\1|g" tests/printf/printf-cov.pl
324
325 sed -i -e "s/du: invalid -t argument/du: invalid --threshold argument/" -e "s/du: option requires an argument/error: a value is required for '--threshold <SIZE>' but none was supplied/" -e "s/Try 'du --help' for more information./\nFor more information, try '--help'./" tests/du/threshold.sh
326
327 # Remove the extra output check
328 sed -i -e "s|Try '\$prog --help' for more information.\\\n||" tests/du/files0-from.pl
329 sed -i -e "s|-: No such file or directory|cannot access '-': No such file or directory|g" tests/du/files0-from.pl
330
331 # Skip the move-dir-while-traversing test - our implementation uses safe traversal with openat()
332 # which avoids the TOCTOU race condition that this test tries to trigger. The test uses inotify
333 # to detect when du opens a directory path and moves it to cause an error, but our openat-based
334 # implementation doesn't trigger inotify events on the full path, preventing the race condition.
335 # This is actually better behavior - we're immune to this class of filesystem race attacks.
336 sed -i '1s/^/exit 0 # Skip test - uutils du uses safe traversal that prevents this race condition\n/' tests/du/move-dir-while-traversing.sh
337
338 awk 'BEGIN {count=0} /compare exp out2/ && count < 6 {sub(/compare exp out2/, "grep -q \"cannot be used with\" out2"); count++} 1' tests/df/df-output.sh > tests/df/df-output.sh.tmp && mv tests/df/df-output.sh.tmp tests/df/df-output.sh
339
340 # small difference in the error message
341 sed -i -e "s/ls: invalid argument 'XX' for 'time style'/ls: invalid --time-style argument 'XX'/" \
342 -e "s/Valid arguments are:/Possible values are:/" \
343 -e "s/Try 'ls --help' for more information./\nFor more information try --help/" \
344 tests/ls/time-style-diag.sh
345
346 # disable two kind of tests:
347 # "hostid BEFORE --help" doesn't fail for GNU. we fail. we are probably doing better
348 # "hostid BEFORE --help AFTER " same for this
349 sed -i -e "s/env \$prog \$BEFORE \$opt > out2/env \$prog \$BEFORE \$opt > out2 #/" -e "s/env \$prog \$BEFORE \$opt AFTER > out3/env \$prog \$BEFORE \$opt AFTER > out3 #/" -e "s/compare exp out2/compare exp out2 #/" -e "s/compare exp out3/compare exp out3 #/" tests/help/help-version-getopt.sh
350
351 # Add debug info + we have less syscall then GNU's. Adjust our check.
352 sed -i -e '/test \$n_stat1 = \$n_stat2 \\/c\
353 echo "n_stat1 = \$n_stat1"\n\
354 echo "n_stat2 = \$n_stat2"\n\
355 test \$n_stat1 -ge \$n_stat2 \\' tests/ls/stat-free-color.sh
356
357 # for clap
358 sed -i -e "s|Try 'md5sum --help' for more information.\\\n||" tests/cksum/md5sum.pl
359
360 # Our ls command always outputs ANSI color codes prepended with a zero. However,
361 # in the case of GNU, it seems inconsistent. Nevertheless, it looks like it
362 # doesn't matter whether we prepend a zero or not.
363 sed -i -E 's/\^\[\[([1-9]m)/^[[0\1/g; s/\^\[\[m/^[[0m/g' tests/ls/color-norm.sh
364 # It says in the test itself that having more than one reset is a bug, so we
365 # don't need to replicate that behavior.
366 sed -i -E 's/(\^\[\[0m)+/\^\[\[0m/g' tests/ls/color-norm.sh
367
368 # GNU's ls seems to output color codes in the order given in the environment
369 # variable, but our ls seems to output them in a predefined order. Nevertheless,
370 # the order doesn't matter, so it's okay.
371 sed -i 's/44;37/37;44/' tests/ls/multihardlink.sh
372
373 # Just like mentioned in the previous patch, GNU's ls output color codes in the
374 # same way it is specified in the environment variable, but our ls emits them
375 # differently. In this case, the color code is set to 0;31;42, and our ls would
376 # ignore the 0; part. This would have been a bug if we output color codes
377 # individually, for example, ^[[31^[[42 instead of ^[[31;42, but we don't do
378 # that anywhere in our implementation, and it looks like GNU's ls also doesn't
379 # do that. So, it's okay to ignore the zero.
380 sed -i "s/color_code='0;31;42'/color_code='31;42'/" tests/ls/color-clear-to-eol.sh
381
382 # patching this because of the same reason as the last one.
383 sed -i "s/color_code='0;31;42'/color_code='31;42'/" tests/ls/quote-align.sh
384
385 # Slightly different error message
386 sed -i 's/not supported/unexpected argument/' tests/mv/mv-exchange.sh
387
388 # upstream doesn't having the program name in the error message
389 # but we do. We should keep it that way.
390 sed -i 's/echo "changing security context/echo "chcon: changing security context/' tests/chcon/chcon.sh
391
392 # Disable this test, it is not relevant for us:
393 # * the selinux crate is handling errors
394 # * the test says "maybe we should not fail when no context available"
395 sed -i -e "s|returns_ 1||g" tests/cp/no-ctx.sh