Normalize deployment tools usage and definitions by putting into one place

instead of sprinkling them out over many disjoint files. This is a follow-up
to achieve the same goal in an incomplete rev.348521.

Approved by:	imp
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D20520
This commit is contained in:
Maxim Sobolev 2020-04-07 02:46:22 +00:00
parent be4ed3d2cf
commit a8b8edb25e
9 changed files with 50 additions and 19 deletions

View File

@ -57,6 +57,8 @@ _MKSHOWCONFIG= t
SRCDIR?= ${.CURDIR} SRCDIR?= ${.CURDIR}
LOCALBASE?= /usr/local LOCALBASE?= /usr/local
.include "share/mk/src.tools.mk"
# Cross toolchain changes must be in effect before bsd.compiler.mk # Cross toolchain changes must be in effect before bsd.compiler.mk
# so that gets the right CC, and pass CROSS_TOOLCHAIN to submakes. # so that gets the right CC, and pass CROSS_TOOLCHAIN to submakes.
.if defined(CROSS_TOOLCHAIN) .if defined(CROSS_TOOLCHAIN)
@ -874,8 +876,8 @@ MTREEFLAGS+= -W
INSTALLFLAGS+= -h sha256 INSTALLFLAGS+= -h sha256
.endif .endif
.if defined(DB_FROM_SRC) || defined(NO_ROOT) .if defined(DB_FROM_SRC) || defined(NO_ROOT)
IMAKE_INSTALL= INSTALL="install ${INSTALLFLAGS}" IMAKE_INSTALL= INSTALL="${INSTALL_CMD} ${INSTALLFLAGS}"
IMAKE_MTREE= MTREE_CMD="mtree ${MTREEFLAGS}" IMAKE_MTREE= MTREE_CMD="${MTREE_CMD} ${MTREEFLAGS}"
.endif .endif
DESTDIR_MTREEFLAGS= -deU DESTDIR_MTREEFLAGS= -deU
@ -887,12 +889,12 @@ WORLDTMP_MTREEFLAGS= -deUW
# that are created by mtree to be owned by root/wheel. # that are created by mtree to be owned by root/wheel.
DESTDIR_MTREEFLAGS+= -W DESTDIR_MTREEFLAGS+= -W
.endif .endif
MTREE?= mtree DISTR_MTREE= ${MTREE_CMD}
.if ${BUILD_WITH_STRICT_TMPPATH} != 0 .if ${BUILD_WITH_STRICT_TMPPATH} != 0
MTREE= ${WORLDTMP}/legacy/usr/sbin/mtree DISTR_MTREE= ${WORLDTMP}/legacy/usr/sbin/mtree
.endif .endif
WORLDTMP_MTREE= ${MTREE} ${WORLDTMP_MTREEFLAGS} WORLDTMP_MTREE= ${DISTR_MTREE} ${WORLDTMP_MTREEFLAGS}
DESTDIR_MTREE= ${MTREE} ${DESTDIR_MTREEFLAGS} DESTDIR_MTREE= ${DISTR_MTREE} ${DESTDIR_MTREEFLAGS}
# kernel stage # kernel stage
KMAKEENV= ${WMAKEENV:NSYSROOT=*} KMAKEENV= ${WMAKEENV:NSYSROOT=*}
@ -1363,14 +1365,14 @@ distributeworld installworld stageworld: _installcheck_world .PHONY
.endif .endif
.endif .endif
.if defined(NO_ROOT) .if defined(NO_ROOT)
${IMAKEENV} ${MTREE} -C -f ${.CURDIR}/etc/mtree/BSD.root.dist | \ ${IMAKEENV} ${DISTR_MTREE} -C -f ${.CURDIR}/etc/mtree/BSD.root.dist | \
sed -e 's#^\./#./${dist}/#' >> ${METALOG} sed -e 's#^\./#./${dist}/#' >> ${METALOG}
${IMAKEENV} ${MTREE} -C -f ${.CURDIR}/etc/mtree/BSD.usr.dist | \ ${IMAKEENV} ${DISTR_MTREE} -C -f ${.CURDIR}/etc/mtree/BSD.usr.dist | \
sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG} sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
${IMAKEENV} ${MTREE} -C -f ${.CURDIR}/etc/mtree/BSD.include.dist | \ ${IMAKEENV} ${DISTR_MTREE} -C -f ${.CURDIR}/etc/mtree/BSD.include.dist | \
sed -e 's#^\./#./${dist}/usr/include/#' >> ${METALOG} sed -e 's#^\./#./${dist}/usr/include/#' >> ${METALOG}
.if defined(_LIBCOMPAT) .if defined(_LIBCOMPAT)
${IMAKEENV} ${MTREE} -C -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist | \ ${IMAKEENV} ${DISTR_MTREE} -C -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist | \
sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG} sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
.endif .endif
.endif .endif

View File

@ -2,11 +2,11 @@
# $FreeBSD$ # $FreeBSD$
.include <src.opts.mk> .include <src.opts.mk>
.include <src.tools.mk>
FILESGROUPS= FILES FILESGROUPS= FILES
NLS_ALIASES= POSIX C \ NLS_ALIASES= POSIX C \
en_US.US_ASCII C en_US.US_ASCII C
PWD_MKDB_CMD?= pwd_mkdb
# No need as it is empty and just causes rebuilds since this file does so much. # No need as it is empty and just causes rebuilds since this file does so much.
UPDATE_DEPENDFILE= no UPDATE_DEPENDFILE= no
@ -99,8 +99,6 @@ distribution:
.endif .endif
.endif .endif
MTREE_CMD?= mtree
MTREES= mtree/BSD.root.dist / \ MTREES= mtree/BSD.root.dist / \
mtree/BSD.var.dist /var \ mtree/BSD.var.dist /var \
mtree/BSD.usr.dist /usr \ mtree/BSD.usr.dist /usr \

View File

@ -550,11 +550,13 @@ MLINKS+=vis.3 nvis.3 \
MLINKS+=wordexp.3 wordfree.3 MLINKS+=wordexp.3 wordfree.3
.include <src.tools.mk>
afterinstallconfig: afterinstallconfig:
.if ${MK_TCSH} == "no" .if ${MK_TCSH} == "no"
sed -i "" -e 's;/bin/csh;/bin/sh;' ${DESTDIR}/etc/master.passwd sed -i "" -e 's;/bin/csh;/bin/sh;' ${DESTDIR}/etc/master.passwd
.endif .endif
pwd_mkdb -i -p -d ${DESTDIR}/etc ${DESTDIR}/etc/master.passwd ${PWD_MKDB_CMD} -i -p -d ${DESTDIR}/etc ${DESTDIR}/etc/master.passwd
.if defined(NO_ROOT) && defined(METALOG) .if defined(NO_ROOT) && defined(METALOG)
( \ ( \
echo "./etc/pwd.db type=file mode=0644 uname=root gname=wheel"; \ echo "./etc/pwd.db type=file mode=0644 uname=root gname=wheel"; \

25
share/mk/src.tools.mk Normal file
View File

@ -0,0 +1,25 @@
# Various tools used by the FreeBSD make installworld / distrib-dirs /
# distribution / installkernel targets. Also called "bootstrap tools"
# historically, however that name seemed to be ambiguous, as those tools
# merely help distributing the OS build artefacts into staging / production
# area.
#
# Very tiny subset of "itools", if you are old enough to know what it is.
#
# Please keep the list short, this file may and will be included from
# many places within the source tree. Rule of thumb: if the above mentioned
# targets survive with MYTOOL_CMD=false, then MYTOOL_CMD probably
# does not belong here. Stick it somewhere else, thank you very much!
#
# $FreeBSD$
.if !target(__<src.tools.mk>__)
INSTALL_CMD?= install
MTREE_CMD?= mtree
PWD_MKDB_CMD?= pwd_mkdb
SERVICES_MKDB_CMD?= services_mkdb
CAP_MKDB_CMD?= cap_mkdb
__<src.tools.mk>__:
.endif # !target(__<tools>__)

View File

@ -234,7 +234,7 @@ FFLAGS ?= -O
.endif .endif
EFLAGS ?= EFLAGS ?=
INSTALL ?= install INSTALL ?= ${INSTALL_CMD:Uinstall}
LEX ?= lex LEX ?= lex
LFLAGS ?= LFLAGS ?=

View File

@ -14,9 +14,10 @@ CLEANFILES+= termcap.db
CONFS= termcap.small CONFS= termcap.small
.include <bsd.endian.mk> .include <bsd.endian.mk>
.include <src.tools.mk>
termcap.db: termcap termcap.db: termcap
cap_mkdb ${CAP_MKDB_ENDIAN} -f ${.TARGET:R} ${.ALLSRC} ${CAP_MKDB_CMD} ${CAP_MKDB_ENDIAN} -f ${.TARGET:R} ${.ALLSRC}
etc-termcap: etc-termcap:
${INSTALL_SYMLINK} -T "package=runtime" \ ${INSTALL_SYMLINK} -T "package=runtime" \

View File

@ -2,13 +2,13 @@
# $FreeBSD$ # $FreeBSD$
.include <src.opts.mk> .include <src.opts.mk>
.include <src.tools.mk>
CONFS= fbtab login.conf motd.template login.access CONFS= fbtab login.conf motd.template login.access
PROG= login PROG= login
SRCS= login.c login_fbtab.c SRCS= login.c login_fbtab.c
CFLAGS+=-DLOGALL CFLAGS+=-DLOGALL
LIBADD= util pam LIBADD= util pam
CAP_MKDB_CMD?= cap_mkdb
WARNS?= 5 WARNS?= 5

View File

@ -19,8 +19,9 @@ SCRIPTSDIR=/usr/bin
CLEANFILES= vgrindefs.src.db CLEANFILES= vgrindefs.src.db
.include <bsd.endian.mk> .include <bsd.endian.mk>
.include <src.tools.mk>
vgrindefs.src.db: vgrindefs.src vgrindefs.src.db: vgrindefs.src
cap_mkdb ${CAP_MKDB_ENDIAN} -f vgrindefs.src ${.ALLSRC} ${CAP_MKDB_CMD} ${CAP_MKDB_ENDIAN} -f vgrindefs.src ${.ALLSRC}
.include <bsd.prog.mk> .include <bsd.prog.mk>

View File

@ -6,11 +6,13 @@ CONFS= services
PROG= services_mkdb PROG= services_mkdb
MAN= services_mkdb.8 MAN= services_mkdb.8
SRCS= services_mkdb.c uniq.c extern.h SRCS= services_mkdb.c uniq.c extern.h
SERVICES_MKDB_CMD?= ${PROG}
.include <bsd.endian.mk> .include <bsd.endian.mk>
.include <src.opts.mk> .include <src.opts.mk>
.if ${MK_SERVICESDB} != "no" .if ${MK_SERVICESDB} != "no"
# SERVICES_MKDB_CMD defined here
.include <src.tools.mk>
afterinstallconfig: afterinstallconfig:
${SERVICES_MKDB_CMD} ${CAP_MKDB_ENDIAN} -q -o ${DESTDIR}/var/db/services.db \ ${SERVICES_MKDB_CMD} ${CAP_MKDB_ENDIAN} -q -o ${DESTDIR}/var/db/services.db \
${DESTDIR}/etc/services ${DESTDIR}/etc/services