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
This commit is contained in:
emaste 2017-11-15 18:03:31 +00:00
parent ddc1563caa
commit 0dfd9255c7

View File

@ -1613,8 +1613,8 @@ create-packages: .PHONY create-packages-world create-packages-kernel
create-world-packages: _pkgbootstrap .PHONY create-world-packages: _pkgbootstrap .PHONY
@rm -f ${WSTAGEDIR}/*.plist 2>/dev/null || : @rm -f ${WSTAGEDIR}/*.plist 2>/dev/null || :
@cd ${WSTAGEDIR} ; \ @cd ${WSTAGEDIR} ; \
awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \ env -i LC_COLLATE=C sort ${WSTAGEDIR}/METALOG | \
${WSTAGEDIR}/METALOG awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk
@for plist in ${WSTAGEDIR}/*.plist; do \ @for plist in ${WSTAGEDIR}/*.plist; do \
plist=$${plist##*/} ; \ plist=$${plist##*/} ; \
pkgname=$${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: create-kernel-packages-flavor${flavor:C,^""$,${_default_flavor},}
create-kernel-packages-flavor${flavor:C,^""$,${_default_flavor},}: _pkgbootstrap .PHONY create-kernel-packages-flavor${flavor:C,^""$,${_default_flavor},}: _pkgbootstrap .PHONY
@cd ${KSTAGEDIR}/${DISTDIR} ; \ @cd ${KSTAGEDIR}/${DISTDIR} ; \
env -i LC_COLLATE=C sort ${KSTAGEDIR}/kernel.meta | \
awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \ awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
-v kernel=yes -v _kernconf=${INSTALLKERNEL} \ -v kernel=yes -v _kernconf=${INSTALLKERNEL} ; \
${KSTAGEDIR}/kernel.meta ; \
cap_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VCAP_MKDB_ENDIAN` ; \ cap_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VCAP_MKDB_ENDIAN` ; \
pwd_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VPWD_MKDB_ENDIAN` ; \ pwd_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VPWD_MKDB_ENDIAN` ; \
sed -e "s/%VERSION%/${PKG_VERSION}/" \ 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: create-kernel-packages-extra-flavor${flavor:C,^""$,${_default_flavor},}-${_kernel}
create-kernel-packages-extra-flavor${flavor:C,^""$,${_default_flavor},}-${_kernel}: _pkgbootstrap .PHONY create-kernel-packages-extra-flavor${flavor:C,^""$,${_default_flavor},}-${_kernel}: _pkgbootstrap .PHONY
@cd ${KSTAGEDIR}/kernel.${_kernel} ; \ @cd ${KSTAGEDIR}/kernel.${_kernel} ; \
env -i LC_COLLATE=C sort ${KSTAGEDIR}/kernel.${_kernel}.meta | \
awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \ awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
-v kernel=yes -v _kernconf=${_kernel} \ -v kernel=yes -v _kernconf=${_kernel} ; \
${KSTAGEDIR}/kernel.${_kernel}.meta ; \
cap_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VCAP_MKDB_ENDIAN` ; \ cap_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VCAP_MKDB_ENDIAN` ; \
pwd_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VPWD_MKDB_ENDIAN` ; \ pwd_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VPWD_MKDB_ENDIAN` ; \
sed -e "s/%VERSION%/${PKG_VERSION}/" \ sed -e "s/%VERSION%/${PKG_VERSION}/" \