Skip to content

Commit

Permalink
build: Sort distributekernel METALOG when using -DNO_ROOT
Browse files Browse the repository at this point in the history
The metalog is produced by install -M, which is not inherently sorted.
This results in non-deterministic file ordering in kernel.txz. Order the
files in kernel.txz to support reproducible builds.

PR:		283214
Reviewed by:	emaste

Signed-off-by: Pat Maddox <[email protected]>
  • Loading branch information
patmaddox authored and emaste committed Jan 6, 2025
1 parent c2153a5 commit 58610d1
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions Makefile.inc1
Original file line number Diff line number Diff line change
Expand Up @@ -1903,25 +1903,22 @@ distributekernel distributekernel.debug: .PHONY
false
.endif
mkdir -p ${DESTDIR}/${DISTDIR}
.if defined(NO_ROOT)
@echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.premeta
.endif
rm -f ${DESTDIR}/${DISTDIR}/kernel.premeta
${_+_}cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.premeta/} \
${IMAKE_MTREE} PATH=${TMPPATH:Q} ${MAKE} KERNEL=${INSTKERNNAME} \
DISTBASE=/kernel DESTDIR=${INSTALL_DDIR}/kernel \
METALOG=${METALOG:S/METALOG/kernel.premeta/} \
${.TARGET:S/distributekernel/install/}
.if defined(NO_ROOT)
@sed -e 's|^./kernel|.|' ${DESTDIR}/${DISTDIR}/kernel.premeta > \
${DESTDIR}/${DISTDIR}/kernel.meta
echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.meta
sed -e 's|^./kernel|.|' ${DESTDIR}/${DISTDIR}/kernel.premeta | \
${METALOG_SORT_CMD} >> ${DESTDIR}/${DISTDIR}/kernel.meta
.endif
.endif
.if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
.for _kernel in ${BUILDKERNELS:[2..-1]}
.if defined(NO_ROOT)
@echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta
.endif
rm -f ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta
${_+_}cd ${KRNLOBJDIR}/${_kernel}; \
${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.${_kernel}.premeta/} \
${IMAKE_MTREE} PATH=${TMPPATH:Q} ${MAKE} \
Expand All @@ -1930,9 +1927,10 @@ distributekernel distributekernel.debug: .PHONY
METALOG=${METALOG:S/METALOG/kernel.${_kernel}.premeta/} \
${.TARGET:S/distributekernel/install/}
.if defined(NO_ROOT)
@sed -e "s|^./kernel.${_kernel}|.|" \
${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta > \
${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta
echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta
sed -e "s|^./kernel.${_kernel}|.|" \
${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta | \
${METALOG_SORT_CMD} >> ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta
.endif
.endfor
.endif
Expand Down

0 comments on commit 58610d1

Please sign in to comment.