2012-02-08 17:22:20 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
candidate="$1"
|
|
|
|
|
|
|
|
tar=`which $candidate`
|
|
|
|
if [ ! -x "$tar" ]; then
|
|
|
|
tar=`which tar`
|
|
|
|
if [ ! -x "$tar" ]; then
|
|
|
|
# echo nothing: no suitable tar found
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Output of 'tar --version' examples:
|
|
|
|
# tar (GNU tar) 1.15.1
|
|
|
|
# tar (GNU tar) 1.25
|
2014-05-31 00:10:38 +02:00
|
|
|
# bsdtar 2.8.3 - libarchive 2.8.3
|
2012-02-08 17:22:20 +01:00
|
|
|
version=`$tar --version | head -n 1 | sed 's/^.*\s\([0-9]\+\.\S\+\).*$/\1/'`
|
|
|
|
major=`echo "$version" | cut -d. -f1`
|
|
|
|
minor=`echo "$version" | cut -d. -f2`
|
|
|
|
bugfix=`echo "$version" | cut -d. -f3`
|
2014-05-31 00:10:38 +02:00
|
|
|
version_bsd=`$tar --version | grep 'bsdtar'`
|
2018-11-17 18:15:49 +01:00
|
|
|
|
|
|
|
# BSD tar does not have all the command-line options
|
|
|
|
if [ -n "${version_bsd}" ] ; then
|
|
|
|
# echo nothing: no suitable tar found
|
|
|
|
exit 1
|
2014-05-31 00:10:38 +02:00
|
|
|
fi
|
2012-02-08 17:22:20 +01:00
|
|
|
|
check-host-tar.sh: bump minimum tar version to 1.27 for reproducible tar files with long paths
Fixes:
http://autobuild.buildroot.net/results/b18/b187e64a61918f17f69588e2355a03286bc5808e
tar 1.27 subtly changed the tar format when a GNU long link entry is added
(which is done for path elements > 100 characters). The code used to set
the permission mode of the link entry to 0:
header = start_private_header ("././@LongLink", size, time (NULL));
FILL (header->header.mtime, '0');
FILL (header->header.mode, '0');
FILL (header->header.uid, '0');
FILL (header->header.gid, '0');
FILL (header->header.devmajor, 0);
FILL (header->header.devminor, 0);
This got dropped in 1.27 by commit df7b55a8f6354e3 (Fix some problems with
negative and out-of-range integers), so the settings from
start_private_header() are used directly - Which are:
TIME_TO_CHARS (t < 0 ? 0 : min (t, MAX_OCTAL_VAL (header->header.mtime)),
header->header.mtime);
MODE_TO_CHARS (S_IFREG|S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH, header->header.mode);
UID_TO_CHARS (0, header->header.uid);
GID_TO_CHARS (0, header->header.gid);
The end result is that tar >= 1.27 sets mode to 644.
The consequence of this is that we create different tar files when long path
names are encountered (which often happens when a package downloads a
specific sha1 from a git repo) depending on the host tar version used,
causing hash mismatches.
As a workaround, bump our minimum tar version to 1.27. It would be nicer to
only do this if we have packages from bzr/git/hg enabled, but that is an
exercise for later.
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
Acked-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
2018-04-02 11:48:08 +02:00
|
|
|
# Minimal version = 1.27 (previous versions do not correctly unpack archives
|
|
|
|
# containing hard-links if the --strip-components option is used or create
|
|
|
|
# different gnu long link headers for path elements > 100 characters).
|
2012-02-08 17:22:20 +01:00
|
|
|
major_min=1
|
check-host-tar.sh: bump minimum tar version to 1.27 for reproducible tar files with long paths
Fixes:
http://autobuild.buildroot.net/results/b18/b187e64a61918f17f69588e2355a03286bc5808e
tar 1.27 subtly changed the tar format when a GNU long link entry is added
(which is done for path elements > 100 characters). The code used to set
the permission mode of the link entry to 0:
header = start_private_header ("././@LongLink", size, time (NULL));
FILL (header->header.mtime, '0');
FILL (header->header.mode, '0');
FILL (header->header.uid, '0');
FILL (header->header.gid, '0');
FILL (header->header.devmajor, 0);
FILL (header->header.devminor, 0);
This got dropped in 1.27 by commit df7b55a8f6354e3 (Fix some problems with
negative and out-of-range integers), so the settings from
start_private_header() are used directly - Which are:
TIME_TO_CHARS (t < 0 ? 0 : min (t, MAX_OCTAL_VAL (header->header.mtime)),
header->header.mtime);
MODE_TO_CHARS (S_IFREG|S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH, header->header.mode);
UID_TO_CHARS (0, header->header.uid);
GID_TO_CHARS (0, header->header.gid);
The end result is that tar >= 1.27 sets mode to 644.
The consequence of this is that we create different tar files when long path
names are encountered (which often happens when a package downloads a
specific sha1 from a git repo) depending on the host tar version used,
causing hash mismatches.
As a workaround, bump our minimum tar version to 1.27. It would be nicer to
only do this if we have packages from bzr/git/hg enabled, but that is an
exercise for later.
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
Acked-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
2018-04-02 11:48:08 +02:00
|
|
|
minor_min=27
|
2018-02-27 09:55:41 +01:00
|
|
|
|
2020-09-28 23:16:50 +02:00
|
|
|
if [ $major -lt $major_min ]; then
|
2018-02-27 09:55:41 +01:00
|
|
|
# echo nothing: no suitable tar found
|
|
|
|
exit 1
|
2012-02-08 17:22:20 +01:00
|
|
|
fi
|
2018-02-27 09:55:41 +01:00
|
|
|
|
|
|
|
if [ $major -eq $major_min -a $minor -lt $minor_min ]; then
|
|
|
|
# echo nothing: no suitable tar found
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# valid
|
|
|
|
echo $tar
|