From fcf1208158973279c6410c1d24233ae8dfaedf91 Mon Sep 17 00:00:00 2001 From: Jessica Clarke Date: Fri, 15 Jul 2022 23:04:34 +0100 Subject: [PATCH] Makefile.inc1 release bsd.own.mk: Introduce and use TAR_CMD Our uses of tar rely on BSDisms, and so do not work in environments where GNU tar is the default tar. Providing a TAR_CMD variable like some other commands allows it to be overridden to use bsdtar in such cases. Reviewed by: brooks, delphij, gjb Obtained from: CheriBSD Differential Revision: https://reviews.freebsd.org/D35813 --- Makefile.inc1 | 24 ++++++++++++------------ release/Makefile | 4 ++-- share/mk/bsd.own.mk | 2 ++ 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/Makefile.inc1 b/Makefile.inc1 index b9691017a1ab..98cb357946f7 100644 --- a/Makefile.inc1 +++ b/Makefile.inc1 @@ -1491,12 +1491,12 @@ packageworld: .PHONY .for dist in base ${EXTRA_DISTRIBUTIONS} .if defined(NO_ROOT) ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \ - tar cvf - --exclude usr/lib/debug \ + ${TAR_CMD} cvf - --exclude usr/lib/debug \ @${DESTDIR}/${DISTDIR}/${dist}.meta | \ ${XZ_CMD} > ${PACKAGEDIR}/${dist}.txz .else ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \ - tar cvf - --exclude usr/lib/debug . | \ + ${TAR_CMD} cvf - --exclude usr/lib/debug . | \ ${XZ_CMD} > ${PACKAGEDIR}/${dist}.txz .endif .endfor @@ -1504,11 +1504,11 @@ packageworld: .PHONY .for dist in ${DEBUG_DISTRIBUTIONS} . if defined(NO_ROOT) ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \ - tar cvf - @${DESTDIR}/${DISTDIR}/${dist}.debug.meta | \ + ${TAR_CMD} cvf - @${DESTDIR}/${DISTDIR}/${dist}.debug.meta | \ ${XZ_CMD} > ${PACKAGEDIR}/${dist}-dbg.txz . else ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \ - tar cvLf - usr/lib/debug | \ + ${TAR_CMD} cvLf - usr/lib/debug | \ ${XZ_CMD} > ${PACKAGEDIR}/${dist}-dbg.txz . endif .endfor @@ -1827,25 +1827,25 @@ packagekernel: .PHONY .if defined(NO_ROOT) .if !defined(NO_INSTALLKERNEL) cd ${DESTDIR}/${DISTDIR}/kernel; \ - tar cvf - --exclude '*.debug' \ + ${TAR_CMD} cvf - --exclude '*.debug' \ @${DESTDIR}/${DISTDIR}/kernel.meta | \ ${XZ_CMD} > ${PACKAGEDIR}/kernel.txz .endif .if ${MK_DEBUG_FILES} != "no" cd ${DESTDIR}/${DISTDIR}/kernel; \ - tar cvf - --include '*/*/*.debug' \ + ${TAR_CMD} cvf - --include '*/*/*.debug' \ @${DESTDIR}/${DISTDIR}/kernel.meta | \ ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel-dbg.txz .endif .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes" .for _kernel in ${BUILDKERNELS:[2..-1]} cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \ - tar cvf - --exclude '*.debug' \ + ${TAR_CMD} cvf - --exclude '*.debug' \ @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \ ${XZ_CMD} > ${PACKAGEDIR}/kernel.${_kernel}.txz .if ${MK_DEBUG_FILES} != "no" cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \ - tar cvf - --include '*/*/*.debug' \ + ${TAR_CMD} cvf - --include '*/*/*.debug' \ @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \ ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}-dbg.txz .endif @@ -1854,22 +1854,22 @@ packagekernel: .PHONY .else .if !defined(NO_INSTALLKERNEL) cd ${DESTDIR}/${DISTDIR}/kernel; \ - tar cvf - --exclude '*.debug' . | \ + ${TAR_CMD} cvf - --exclude '*.debug' . | \ ${XZ_CMD} > ${PACKAGEDIR}/kernel.txz .endif .if ${MK_DEBUG_FILES} != "no" cd ${DESTDIR}/${DISTDIR}/kernel; \ - tar cvf - --include '*/*/*.debug' $$(eval find .) | \ + ${TAR_CMD} cvf - --include '*/*/*.debug' $$(eval find .) | \ ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel-dbg.txz .endif .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes" .for _kernel in ${BUILDKERNELS:[2..-1]} cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \ - tar cvf - --exclude '*.debug' . | \ + ${TAR_CMD} cvf - --exclude '*.debug' . | \ ${XZ_CMD} > ${PACKAGEDIR}/kernel.${_kernel}.txz .if ${MK_DEBUG_FILES} != "no" cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \ - tar cvf - --include '*/*/*.debug' $$(eval find .) | \ + ${TAR_CMD} cvf - --include '*/*/*.debug' $$(eval find .) | \ ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}-dbg.txz .endif .endfor diff --git a/release/Makefile b/release/Makefile index db9cc6b22cbe..6f250e0fc9ca 100644 --- a/release/Makefile +++ b/release/Makefile @@ -138,14 +138,14 @@ kernel.txz: src.txz: mkdir -p ${DISTDIR}/usr ln -fs ${WORLDDIR} ${DISTDIR}/usr/src - cd ${DISTDIR} && tar cLvf - --exclude .svn --exclude .zfs \ + cd ${DISTDIR} && ${TAR_CMD} cLvf - --exclude .svn --exclude .zfs \ --exclude .git --exclude @ --exclude usr/src/release/dist usr/src | \ ${XZ_CMD} > ${.OBJDIR}/src.txz ports.txz: mkdir -p ${DISTDIR}/usr ln -fs ${PORTSDIR} ${DISTDIR}/usr/ports - cd ${DISTDIR} && tar cLvf - \ + cd ${DISTDIR} && ${TAR_CMD} cLvf - \ --exclude .git --exclude .svn \ --exclude usr/ports/distfiles --exclude usr/ports/packages \ --exclude 'usr/ports/INDEX*' --exclude work usr/ports | \ diff --git a/share/mk/bsd.own.mk b/share/mk/bsd.own.mk index 09d7dfbd25c8..a4a407ac8b6a 100644 --- a/share/mk/bsd.own.mk +++ b/share/mk/bsd.own.mk @@ -265,6 +265,8 @@ INSTALL_RSYMLINK?= ${INSTALL} ${RSYMLINK} STRIP?= -s .endif +TAR_CMD?= tar + COMPRESS_CMD?= gzip -cn COMPRESS_EXT?= .gz