release: use xz via pipe when compressing the tarballs.

libarchive(3) doesn't support the new liblzma API yet, but this change
allows us to enable multi-threaded xz compression.
``make release'' should now finish in half the time on a machine with
several cores and fast disks (our typical build server).

This behaviour only applies when building a release and it doesn't
affect buildworld/installworld.  To disable threaded xz compression,
set XZ_THREADS=1.

Reviewed by:	gjb
Tested by:	gjb
This commit is contained in:
Rui Paulo 2015-02-17 23:13:45 +00:00
parent 4ac6485cc6
commit bd9cab6fb4
4 changed files with 34 additions and 36 deletions

View File

@ -912,25 +912,25 @@ packageworld:
.for dist in base ${EXTRA_DISTRIBUTIONS} .for dist in base ${EXTRA_DISTRIBUTIONS}
.if defined(NO_ROOT) .if defined(NO_ROOT)
${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \ ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
tar cvJf ${DESTDIR}/${DISTDIR}/${dist}.txz \ tar cvf - --exclude usr/lib/debug \
--exclude usr/lib/debug \ @${DESTDIR}/${DISTDIR}/${dist}.meta | \
@${DESTDIR}/${DISTDIR}/${dist}.meta ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/${dist}.txz
.else .else
${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \ ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
tar cvJf ${DESTDIR}/${DISTDIR}/${dist}.txz \ tar cvf - --exclude usr/lib/debug . | \
--exclude usr/lib/debug . ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/${dist}.txz
.endif .endif
.endfor .endfor
.for dist in ${DEBUG_DISTRIBUTIONS} .for dist in ${DEBUG_DISTRIBUTIONS}
. if defined(NO_ROOT) . if defined(NO_ROOT)
${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \ ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
tar cvJf ${DESTDIR}/${DISTDIR}/${dist}-dbg.txz \ tar cvf - @${DESTDIR}/${DISTDIR}/${dist}.debug.meta | \
@${DESTDIR}/${DISTDIR}/${dist}.debug.meta ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/${dist}-dbg.txz
. else . else
${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \ ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
tar cvJLf ${DESTDIR}/${DISTDIR}/${dist}-dbg.txz \ tar cvLf - usr/lib/debug | \
usr/lib/debug ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/${dist}-dbg.txz
. endif . endif
.endfor .endfor
@ -1138,19 +1138,21 @@ distributekernel distributekernel.debug:
packagekernel: packagekernel:
.if defined(NO_ROOT) .if defined(NO_ROOT)
cd ${DESTDIR}/${DISTDIR}/kernel; \ cd ${DESTDIR}/${DISTDIR}/kernel; \
tar cvJf ${DESTDIR}/${DISTDIR}/kernel.txz \ tar cvf - @${DESTDIR}/${DISTDIR}/kernel.meta | \
@${DESTDIR}/${DISTDIR}/kernel.meta ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.txz
.for _kernel in ${BUILDKERNELS:S/${INSTALLKERNEL}//} .for _kernel in ${BUILDKERNELS:S/${INSTALLKERNEL}//}
cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \ cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
tar cvJf ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.txz \ tar cvf - @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \
@${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.txz
.endfor .endfor
.else .else
cd ${DESTDIR}/${DISTDIR}/kernel; \ cd ${DESTDIR}/${DISTDIR}/kernel; \
tar cvJf ${DESTDIR}/${DISTDIR}/kernel.txz . tar cvf - . | \
${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.txz
.for _kernel in ${BUILDKERNELS:S/${INSTALLKERNEL}//} .for _kernel in ${BUILDKERNELS:S/${INSTALLKERNEL}//}
cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \ cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
tar cvJf ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.txz . tar cvf - . | \
${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.txz
.endfor .endfor
.endif .endif

View File

@ -33,18 +33,12 @@
# with xz(1) (extremely time consuming) # with xz(1) (extremely time consuming)
# WITH_CLOUDWARE: if set, build cloud hosting disk images with the release # WITH_CLOUDWARE: if set, build cloud hosting disk images with the release
# TARGET/TARGET_ARCH: architecture of built release # TARGET/TARGET_ARCH: architecture of built release
# XZ_FLAGS: Additional arguments to pass to xz(1)
# XZ_THREADS: Number of xz(1) threads to use
# NO_XZTHREADS: Disable multi-threaded xz(1) compression
# #
WORLDDIR?= ${.CURDIR}/.. WORLDDIR?= ${.CURDIR}/..
PORTSDIR?= /usr/ports PORTSDIR?= /usr/ports
DOCDIR?= /usr/doc DOCDIR?= /usr/doc
RELNOTES_LANG?= en_US.ISO8859-1 RELNOTES_LANG?= en_US.ISO8859-1
XZCMD?= /usr/bin/xz
XZ_FLAGS?=
XZ_THREADS?=
.if !defined(TARGET) || empty(TARGET) .if !defined(TARGET) || empty(TARGET)
TARGET= ${MACHINE} TARGET= ${MACHINE}
@ -59,15 +53,6 @@ TARGET_ARCH= ${TARGET}
IMAKE= ${MAKE} TARGET_ARCH=${TARGET_ARCH} TARGET=${TARGET} IMAKE= ${MAKE} TARGET_ARCH=${TARGET_ARCH} TARGET=${TARGET}
DISTDIR= dist DISTDIR= dist
.if !defined(NO_XZTHREADS) && empty(XZ_THREADS)
XZ_THREADS= 0
.else
XZ_THREADS= ${XZ_THREADS}
.endif
.if !empty(XZ_THREADS)
XZ_FLAGS+= -T ${XZ_THREADS}
.endif
# Define OSRELEASE by using newvars.sh # Define OSRELEASE by using newvars.sh
.if !defined(OSRELEASE) || empty(OSRELEASE) .if !defined(OSRELEASE) || empty(OSRELEASE)
.for _V in TYPE BRANCH REVISION .for _V in TYPE BRANCH REVISION
@ -158,16 +143,18 @@ kernel.txz:
src.txz: src.txz:
mkdir -p ${DISTDIR}/usr mkdir -p ${DISTDIR}/usr
ln -fs ${WORLDDIR} ${DISTDIR}/usr/src ln -fs ${WORLDDIR} ${DISTDIR}/usr/src
cd ${DISTDIR} && tar cLvJf ${.OBJDIR}/src.txz --exclude .svn --exclude .zfs \ cd ${DISTDIR} && tar cLvf - --exclude .svn --exclude .zfs \
--exclude .git --exclude @ --exclude usr/src/release/dist usr/src --exclude .git --exclude @ --exclude usr/src/release/dist usr/src | \
${XZ_CMD} > ${.OBJDIR}/src.txz
ports.txz: ports.txz:
mkdir -p ${DISTDIR}/usr mkdir -p ${DISTDIR}/usr
ln -fs ${PORTSDIR} ${DISTDIR}/usr/ports ln -fs ${PORTSDIR} ${DISTDIR}/usr/ports
cd ${DISTDIR} && tar cLvJf ${.OBJDIR}/ports.txz \ cd ${DISTDIR} && tar cLvf - \
--exclude .git --exclude .svn \ --exclude .git --exclude .svn \
--exclude usr/ports/distfiles --exclude usr/ports/packages \ --exclude usr/ports/distfiles --exclude usr/ports/packages \
--exclude 'usr/ports/INDEX*' --exclude work usr/ports --exclude 'usr/ports/INDEX*' --exclude work usr/ports | \
${XZ_CMD} > ${.OBJDIR}/ports.txz
reldoc: reldoc:
cd ${.CURDIR}/doc && ${MAKE} all install clean 'FORMATS=html txt' \ cd ${.CURDIR}/doc && ${MAKE} all install clean 'FORMATS=html txt' \
@ -309,7 +296,7 @@ release-install:
.for I in ${IMAGES} .for I in ${IMAGES}
cp -p ${I} ${DESTDIR}/${OSRELEASE}-${I} cp -p ${I} ${DESTDIR}/${OSRELEASE}-${I}
. if defined(WITH_COMPRESSED_IMAGES) && !empty(WITH_COMPRESSED_IMAGES) . if defined(WITH_COMPRESSED_IMAGES) && !empty(WITH_COMPRESSED_IMAGES)
${XZCMD} ${XZ_FLAGS} -k ${DESTDIR}/${OSRELEASE}-${I} ${XZ_CMD} -k ${DESTDIR}/${OSRELEASE}-${I}
. endif . endif
.endfor .endfor
cd ${DESTDIR} && sha256 ${OSRELEASE}* > ${DESTDIR}/CHECKSUM.SHA256 cd ${DESTDIR} && sha256 ${OSRELEASE}* > ${DESTDIR}/CHECKSUM.SHA256

View File

@ -101,7 +101,7 @@ vm-install:
# the DESTDIR. # the DESTDIR.
. for FORMAT in ${VMFORMATS} . for FORMAT in ${VMFORMATS}
# Don't keep the originals. There is a copy in ${.OBJDIR} if needed. # Don't keep the originals. There is a copy in ${.OBJDIR} if needed.
${XZCMD} ${XZ_FLAGS} ${DESTDIR}/vmimages/${OSRELEASE}.${FORMAT} ${XZ_CMD} ${DESTDIR}/vmimages/${OSRELEASE}.${FORMAT}
. endfor . endfor
. endif . endif
cd ${DESTDIR}/vmimages && sha256 ${OSRELEASE}* > \ cd ${DESTDIR}/vmimages && sha256 ${OSRELEASE}* > \

View File

@ -234,6 +234,15 @@ STRIP?= -s
COMPRESS_CMD?= gzip -cn COMPRESS_CMD?= gzip -cn
COMPRESS_EXT?= .gz COMPRESS_EXT?= .gz
# Set XZ_THREADS to 1 to disable multi-threading.
XZ_THREADS?= 0
.if !empty(XZ_THREADS)
XZ_CMD?= xz -T ${XZ_THREADS}
.else
XZ_CMD?= xz
.endif
# Pointer to the top directory into which tests are installed. Should not be # Pointer to the top directory into which tests are installed. Should not be
# overriden by Makefiles, but the user may choose to set this in src.conf(5). # overriden by Makefiles, but the user may choose to set this in src.conf(5).
TESTSBASE?= /usr/tests TESTSBASE?= /usr/tests