@@ -829,7 +829,22 @@ sstate_create_package () {
mkdir --mode=0775 -p `dirname ${SSTATE_PKG}`
TFILE=`mktemp ${SSTATE_PKG}.XXXXXXXX`
- OPT="-cS"
+ # Notice, that if you create an archive in POSIX format (see section GNU tar and POSIX tar) and the environment variable POSIXLY_CORRECT is set,
+ # then the two archives created using the same options on the same set of files will not be byte-to-byte equivalent even with the above option.
+ # This is because the posix default for extended header names includes the PID of the tar process, which is different at each run. To produce
+ # byte-to-byte equivalent archives in this case, either unset POSIXLY_CORRECT, or use the following option:
+ #
+ # --pax-option=exthdr.name=%d/PaxHeaders/%f,atime:=0,ctime:=0
+ #
+ # https://www.gnu.org/software/tar/manual/html_node/PAX-keywords.html
+ MTIME_ARGS="--mtime=@${SOURCE_DATE_EPOCH:-$(date +%s)} --pax-option=exthdr.name=%d/PaxHeaders/%f,atime:=0,ctime:=0"
+ # --clamp-mtime requires tar > 1.28. Only use it if SOURCE_DATE_EPOCH is set, to avoid having a generic case dependency on tar > 1.28.
+ # this setting will make sure files generated at build time have consistent mtimes, for reproducible builds.
+ if [ ! -z "$SOURCE_DATE_EPOCH" ]; then
+ MTIME_ARGS="$MTIME_ARGS --clamp-mtime"
+ fi
+
+ OPT="--format=posix ${@bb.utils.contains('DISTRO_FEATURES', 'acl', '--acls', '', d)} ${@bb.utils.contains('DISTRO_FEATURES', 'xattr', '--xattrs', '', d)} --numeric-owner ${MTIME_ARGS} -cS"
ZSTD="zstd -${SSTATE_ZSTD_CLEVEL} -T${ZSTD_THREADS}"
# Use pzstd if available
if [ -x "$(command -v pzstd)" ]; then
@@ -895,7 +910,7 @@ sstate_unpack_package () {
ZSTD="pzstd -p ${ZSTD_THREADS}"
fi
- tar -I "$ZSTD" -xvpf ${SSTATE_PKG}
+ tar -I "$ZSTD" --format=posix ${@bb.utils.contains('DISTRO_FEATURES', 'acl', '--acls', '', d)} ${@bb.utils.contains('DISTRO_FEATURES', 'xattr', '--xattrs', '', d)} -xvpf ${SSTATE_PKG}
# update .siginfo atime on local/NFS mirror if it is a symbolic link
[ ! -h ${SSTATE_PKG}.siginfo ] || [ ! -e ${SSTATE_PKG}.siginfo ] || touch -a ${SSTATE_PKG}.siginfo 2>/dev/null || true
# update each symbolic link instead of any referenced file
Extend `tar` command, with additional parameters, depending on choosen package class and target distro features, in order to support ACLs and xattr. Additionaly set archive posix format, in order to preserve milliseconds in timestamps for reproducibility tests. Currently only `package_ipk` supports fully ACLs and xattr. Signed-off-by: Piotr Łobacz <p.lobacz@welotec.com> --- meta/classes-global/sstate.bbclass | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-)