From 92b800cc1aa98c9dc19e35aebc51558ca2b0dc36 Mon Sep 17 00:00:00 2001 From: Ed Maste Date: Wed, 15 Nov 2017 18:03:31 +0000 Subject: [PATCH] Sort pkgbase mtree metadata, for reproducible builds Packaged base packages are created by running the stageworld and stagekernel targets with -DNO_ROOT, and converting the resulting mtree file into a set of pkg plists. If stage* is run with multiple processes the order of entries in the mtree file may be nondeterministic, and the resulting package tbz also had nondeterministic file ordering. The mtree file generated by -DNO_ROOT builds consists of one line per file, with the filename starting in the first column, so is easily sorted. There's one exception: the first line of the mtree file is a comment, but the # character sorts before the filenames anyhow and needs no special treatment. PR: 223673 Reviewed by: bapt, gjb Sponsored by: The Linux Foundation, Core Infrastructure Initiative Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D13103 --- Makefile.inc1 | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Makefile.inc1 b/Makefile.inc1 index 8c5ba9407c24..c4042e109953 100644 --- a/Makefile.inc1 +++ b/Makefile.inc1 @@ -1613,8 +1613,8 @@ create-packages: .PHONY create-packages-world create-packages-kernel create-world-packages: _pkgbootstrap .PHONY @rm -f ${WSTAGEDIR}/*.plist 2>/dev/null || : @cd ${WSTAGEDIR} ; \ - awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \ - ${WSTAGEDIR}/METALOG + env -i LC_COLLATE=C sort ${WSTAGEDIR}/METALOG | \ + awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk @for plist in ${WSTAGEDIR}/*.plist; do \ plist=$${plist##*/} ; \ pkgname=$${plist%.plist} ; \ @@ -1658,9 +1658,9 @@ _debug=-debug create-kernel-packages: create-kernel-packages-flavor${flavor:C,^""$,${_default_flavor},} create-kernel-packages-flavor${flavor:C,^""$,${_default_flavor},}: _pkgbootstrap .PHONY @cd ${KSTAGEDIR}/${DISTDIR} ; \ + env -i LC_COLLATE=C sort ${KSTAGEDIR}/kernel.meta | \ awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \ - -v kernel=yes -v _kernconf=${INSTALLKERNEL} \ - ${KSTAGEDIR}/kernel.meta ; \ + -v kernel=yes -v _kernconf=${INSTALLKERNEL} ; \ cap_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VCAP_MKDB_ENDIAN` ; \ pwd_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VPWD_MKDB_ENDIAN` ; \ sed -e "s/%VERSION%/${PKG_VERSION}/" \ @@ -1693,9 +1693,9 @@ _debug=-debug create-kernel-packages: create-kernel-packages-extra-flavor${flavor:C,^""$,${_default_flavor},}-${_kernel} create-kernel-packages-extra-flavor${flavor:C,^""$,${_default_flavor},}-${_kernel}: _pkgbootstrap .PHONY @cd ${KSTAGEDIR}/kernel.${_kernel} ; \ + env -i LC_COLLATE=C sort ${KSTAGEDIR}/kernel.${_kernel}.meta | \ awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \ - -v kernel=yes -v _kernconf=${_kernel} \ - ${KSTAGEDIR}/kernel.${_kernel}.meta ; \ + -v kernel=yes -v _kernconf=${_kernel} ; \ cap_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VCAP_MKDB_ENDIAN` ; \ pwd_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VPWD_MKDB_ENDIAN` ; \ sed -e "s/%VERSION%/${PKG_VERSION}/" \