Fix hand-rolled METALOG entries for installconfig during distributeworld

During distributeworld we call distribute on subdirectories, which in
turn calls installconfig. However, this recursive installconfig call
appends the distribution name (in these cases, "base") to DESTDIR. For
install(1) this works fine as its -D argument comes from the top-level
Makefile.inc1, which passes the original DESTDIR, thereby resulting in
the METALOG entry having the distribution name as a prefix representing
its true installed path relative to the root, but for the hand-rolled
entries they do not use install(1) and thus do not have access to what
the original DESTDIR was, resulting in the METALOG missing this prefix.

Thus, pass down the name of the distribution via a new variable DISTBASE
(chosen as Makefile.inc1 already uses that to convey this exact same
information to etc's distrib-dirs during distributeworld) and prepend
this to the handful of manually-generated METALOG entries. For the
installworld case this variable will be empty and so this behaves as
before.

Note that we need to be careful to avoid double slashes in the METALOG;
distributeworld uses find | awk to split the single METALOG up into
multiple dist.meta files, and this relies on the paths in the METALOG
having the exact prefix ./dist (or ./dist/usr/lib/debug).

Reviewed by:	brooks, emaste
Differential Revision:	https://reviews.freebsd.org/D33997
This commit is contained in:
Jessica Clarke 2022-02-28 22:36:39 +00:00
parent 1ae2c59bcf
commit b58ea3e1f7
4 changed files with 6 additions and 6 deletions

View File

@ -573,8 +573,8 @@ install-passwd: .PHONY
${PWD_MKDB_CMD} -i -p -d ${DESTDIR}/etc ${DESTDIR}/etc/master.passwd
.if defined(NO_ROOT) && defined(METALOG)
( \
echo "./etc/pwd.db type=file mode=0644 uname=root gname=wheel"; \
echo "./etc/spwd.db type=file mode=0600 uname=root gname=wheel"; \
echo "./etc/passwd type=file mode=0644 uname=root gname=wheel"; \
echo ".${DISTBASE}/etc/pwd.db type=file mode=0644 uname=root gname=wheel"; \
echo ".${DISTBASE}/etc/spwd.db type=file mode=0600 uname=root gname=wheel"; \
echo ".${DISTBASE}/etc/passwd type=file mode=0644 uname=root gname=wheel"; \
) | cat -l >> ${METALOG}
.endif

View File

@ -94,7 +94,7 @@ DISTRIBUTION?= base
distribute: .MAKE
.for dist in ${DISTRIBUTION}
${_+_}cd ${.CURDIR}; \
${MAKE} install installconfig -DNO_SUBDIR DESTDIR=${DISTDIR}/${dist} SHARED=copies
${MAKE} install installconfig -DNO_SUBDIR DISTBASE=/${dist} DESTDIR=${DISTDIR}/${dist} SHARED=copies
.endfor
.endif
# Convenience targets to run 'build${target}' and 'install${target}' when

View File

@ -30,7 +30,7 @@ PRECIOUSPROG=
afterinstallconfig:
${CAP_MKDB_CMD} ${CAP_MKDB_ENDIAN} ${DESTDIR}/etc/login.conf
.if defined(NO_ROOT) && defined(METALOG)
echo "./etc/login.conf.db type=file mode=0644 uname=root gname=wheel" | \
echo ".${DISTBASE}/etc/login.conf.db type=file mode=0644 uname=root gname=wheel" | \
cat -l >> ${METALOG}
.endif

View File

@ -17,7 +17,7 @@ afterinstallconfig:
${SERVICES_MKDB_CMD} ${CAP_MKDB_ENDIAN} -q -o ${DESTDIR}/var/db/services.db \
${DESTDIR}/etc/services
.if defined(NO_ROOT) && defined(METALOG)
echo "./var/db/services.db type=file mode=0644 uname=root gname=wheel" | \
echo ".${DISTBASE}/var/db/services.db type=file mode=0644 uname=root gname=wheel" | \
cat -l >> ${METALOG}
.endif
.endif