support/download/helpers: adjust for older coreutils versions

The -z option for head was only added in coreutils 8.25, but some older
enterprise-grade distributions (e.g. the oldest still maintained RHEL 7)
only have nothing more recent than coreutils 8.22.

We fix that by using sed to remove everything that starts with the first
NULL byte, \x00.

Signed-off-by: Clayton Shotwell <clayton.shotwell@collins.com>
[yann.morin.1998@free.fr: hex is \xHH, not \xH, reword commit log]
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
This commit is contained in:
Clayton Shotwell 2022-02-10 17:23:27 -06:00 committed by Yann E. MORIN
parent 618c5f7671
commit 6e40891a66

View file

@ -79,7 +79,7 @@ post_process_unpack() {
mkdir "${dest}"
tar -C "${dest}" --strip-components=1 -xzf "${tarball}"
one_file="$(find "${dest}" -type f -print0 |LC_ALL=C sort -z |head -z -n1 |tr -d "\0")"
one_file="$(find "${dest}" -type f -print0 |LC_ALL=C sort -z |sed 's/\x0.*//')"
touch -r "${one_file}" "${dest}.timestamp"
}