From 0ac8aa55da1cb5e53a9102fd007dd01ee6d17894 Mon Sep 17 00:00:00 2001 From: Emmanuel Vadot Date: Mon, 2 Nov 2020 18:23:50 +0000 Subject: pkgbase: Add incremental packages This adds a new target update-packages which will create the new packages compared to the last run. This is how to use it: At this point we cut a release $ make buildworld ... $ make buildkernel $ make packages There is now a PKG_VERSION directory with latest link pointing to it Distribute the packages to server $ something something that update the source tree $ make buildworld ... $ make buildkernel $ make update-packages You know have a PKG_VERSION directory in the REPODIR and latest link pointing to it. In PKG_VERSION dir only the packages which differs from the latest run are named PKG_VERSION, otherwise the old packages are there. The process is : Build the new packages in the PKG_VERSION directory Compare the internal data with the PKG_VERSION_FROM version. The comparison is done by checking the internal hash of the packages. By default PKG_VERSION_FROM is set to what the latest link points to. If the old and new version matches, we rm the new package and cp the old one. Differential Revision: https://reviews.freebsd.org/D25984 --- Makefile | 4 ++-- Makefile.inc1 | 43 +++++++++++++++++++++++++++++++++++++------ 2 files changed, 39 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 9b55fe6f01f3..32d5977c3eac 100644 --- a/Makefile +++ b/Makefile @@ -162,8 +162,8 @@ TGTS= all all-man buildenv buildenvvars buildkernel buildworld \ xdev-links native-xtools native-xtools-install stageworld stagekernel \ stage-packages stage-packages-kernel stage-packages-world \ create-packages-world create-packages-kernel create-packages \ - packages installconfig real-packages sign-packages package-pkg \ - print-dir test-system-compiler test-system-linker + update-packages packages installconfig real-packages real-update-packages \ + sign-packages package-pkg print-dir test-system-compiler test-system-linker # These targets require a TARGET and TARGET_ARCH be defined. XTGTS= native-xtools native-xtools-install xdev xdev-build xdev-install \ diff --git a/Makefile.inc1 b/Makefile.inc1 index c52895259e3a..7c9f266eba6c 100644 --- a/Makefile.inc1 +++ b/Makefile.inc1 @@ -568,12 +568,12 @@ EXTRA_REVISION= _${_BRANCH:C/-PRERELEASE/.p/} .elif ${_BRANCH:M*-p*} EXTRA_REVISION= _${_BRANCH:C/.*-p([0-9]+$)/\1/} .endif -PKG_VERSION= ${_REVISION}${EXTRA_REVISION} +PKG_VERSION:= ${_REVISION}${EXTRA_REVISION} .endif .endif # !defined(PKG_VERSION) .if !defined(PKG_TIMESTAMP) -TIMEEPOCHNOW= %s +TIMEEPOCHNOW= %s SOURCE_DATE_EPOCH= ${TIMEEPOCHNOW:gmtime} .else SOURCE_DATE_EPOCH= ${PKG_TIMESTAMP} @@ -1855,9 +1855,22 @@ _pkgbootstrap: .PHONY @env ASSUME_ALWAYS_YES=YES pkg bootstrap .endif +.if make(create-world-packages-jobs) || make(create-kernel-packages*) || make(real-update-packages) +PKG_ABI!=${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/usr/bin/uname config ABI +.endif + +.if !defined(PKG_VERSION_FROM) +.if defined(PKG_ABI) +PKG_VERSION_FROM!=/usr/bin/readlink ${REPODIR}/${PKG_ABI}/latest +.endif +.endif + packages: .PHONY ${_+_}${MAKE} -C ${.CURDIR} PKG_VERSION=${PKG_VERSION} real-packages +update-packages: .PHONY + ${_+_}${MAKE} -C ${.CURDIR} PKG_VERSION=${PKG_VERSION} real-update-packages + package-pkg: .PHONY rm -rf /tmp/ports.${TARGET} || : env ${WMAKEENV:Q} SRCDIR=${.CURDIR} PORTSDIR=${PORTSDIR} REVISION=${_REVISION} \ @@ -1867,6 +1880,28 @@ package-pkg: .PHONY real-packages: stage-packages create-packages sign-packages .PHONY +real-update-packages: stage-packages .PHONY + ${_+_}${MAKE} -C ${.CURDIR} PKG_VERSION=${PKG_VERSION} create-packages + @echo "==> Checking for new packages (comparing ${PKG_VERSION} to ${PKG_VERSION_FROM})" + @for pkg in ${REPODIR}/${PKG_ABI}/${PKG_VERSION_FROM}/${PKG_NAME_PREFIX}-*; do \ + pkgname=$$(pkg query -F $${pkg} '%n' | sed 's/${PKG_NAME_PREFIX}-\(.*\)/\1/') ; \ + newpkgname=${PKG_NAME_PREFIX}-$${pkgname}-${PKG_VERSION}.${PKG_FORMAT} ; \ + oldsum=$$(pkg query -F $${pkg} '%X') ; \ + if [ ! -f ${REPODIR}/${PKG_ABI}/${PKG_VERSION}/$${newpkgname} ]; then \ + continue; \ + fi ; \ + newsum=$$(pkg query -F ${REPODIR}/${PKG_ABI}/${PKG_VERSION}/$${newpkgname} '%X') ; \ + if [ "$${oldsum}" == "$${newsum}" ]; then \ + echo "==> Keeping old ${PKG_NAME_PREFIX}-$${pkgname}-${PKG_VERSION_FROM}.${PKG_FORMAT}" ; \ + rm ${REPODIR}/${PKG_ABI}/${PKG_VERSION}/$${newpkgname} ; \ + cp $${pkg} ${REPODIR}/${PKG_ABI}/${PKG_VERSION} ; \ + else \ + echo "==> New package $${newpkgname}" ; \ + fi ; \ + done + ${_+_}@cd ${.CURDIR}; \ + ${MAKE} -f Makefile.inc1 PKG_VERSION=${PKG_VERSION} sign-packages + stage-packages-world: .PHONY @mkdir -p ${WSTAGEDIR} ${_+_}@cd ${.CURDIR}; \ @@ -1917,10 +1952,6 @@ create-world-packages: _pkgbootstrap .PHONY .include "${WSTAGEDIR}/packages.mk" .endif -.if make(create-world-packages-jobs) || make(create-kernel-packages*) -PKG_ABI!=${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/usr/bin/uname config ABI -.endif - create-world-packages-jobs: .PHONY .for pkgname in ${_PKGS} create-world-packages-jobs: create-world-package-${pkgname} -- cgit v1.2.3