Add an option DB_FROM_SRC to use src/etc's user/group databases when

installing.  This allows things like running installworld for 10-CURRENT
on a 9.0-RELEASE system without adding extra users and groups to the
passwd and group files.

To prevent potentially risky uid/gid mismatches on systems with
non-standard local values, require that DESTDIR be set if DB_FROM_SRC is
set.

Sponsored by:	DARPA, AFRL
Reviewed by:	peter
This commit is contained in:
Brooks Davis 2013-01-15 00:12:34 +00:00
parent db7b0ba78f
commit 41a8e2231d
2 changed files with 36 additions and 15 deletions

View File

@ -13,6 +13,8 @@
# -DNO_PORTSUPDATE do not update ports in ${MAKE} update
# -DNO_DOCUPDATE do not update doc in ${MAKE} update
# -DNO_WWWUPDATE do not update www in ${MAKE} update
# -DDB_FROM_SRC use the user/group databases in src/etc instead of
# the system database when installing.
# -DNO_CTF do not run the DTrace CTF conversion tools on built objects
# LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
# LOCAL_LIB_DIRS="list of dirs" to add additional dirs to libraries target
@ -340,12 +342,13 @@ LIB32WMAKEFLAGS+= \
LIB32WMAKE= ${LIB32WMAKEENV} ${MAKE} ${LIB32WMAKEFLAGS} \
-DWITHOUT_BIND -DWITHOUT_MAN -DWITHOUT_INFO -DWITHOUT_HTML
LIB32IMAKE= ${LIB32WMAKE:NINSTALL=*:NDESTDIR=*:N_LDSCRIPTROOT=*} -DNO_INCS
LIB32IMAKE= ${LIB32WMAKE:NINSTALL=*:NDESTDIR=*:N_LDSCRIPTROOT=*} -DNO_INCS \
${IMAKE_INSTALL}
.endif
# install stage
IMAKEENV= ${CROSSENV:N_LDSCRIPTROOT=*}
IMAKE= ${IMAKEENV} ${MAKE} -f Makefile.inc1
IMAKE= ${IMAKEENV} ${MAKE} -f Makefile.inc1 \
${IMAKE_INSTALL} ${IMAKE_MTREE}
.if empty(.MAKEFLAGS:M-n)
IMAKEENV+= PATH=${STRICTTMPPATH}:${INSTALLTMP} \
LD_LIBRARY_PATH=${INSTALLTMP} \
@ -354,6 +357,10 @@ IMAKE+= __MAKE_SHELL=${INSTALLTMP}/sh
.else
IMAKEENV+= PATH=${TMPPATH}:${INSTALLTMP}
.endif
.if defined(DB_FROM_SRC)
IMAKE_INSTALL= INSTALL="install -N ${.CURDIR}/etc"
IMAKE_MTREE= MTREE_CMD="nmtree -N ${.CURDIR}/etc"
.endif
# kernel stage
KMAKEENV= ${WMAKEENV}
@ -595,9 +602,11 @@ kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries}
installcheck:
#
# Require DESTDIR to be set if installing for a different architecture.
# Require DESTDIR to be set if installing for a different architecture or
# using the user/group database in the source tree.
#
.if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE}
.if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE} || \
defined(DB_FROM_SRC)
.if !make(distributeworld)
installcheck: installcheck_DESTDIR
installcheck_DESTDIR:
@ -608,6 +617,7 @@ installcheck_DESTDIR:
.endif
.endif
.if !defined(DB_FROM_SRC)
#
# Check for missing UIDs/GIDs.
#
@ -635,6 +645,7 @@ installcheck_UGID:
false; \
fi
.endfor
.endif
#
# Required install tools to be saved in a scratch dir for safety.
@ -692,6 +703,7 @@ distributeworld installworld: installcheck
done); \
cp $$libs $$progs ${INSTALLTMP}
cp -R $${PATH_LOCALE:-"/usr/share/locale"} ${INSTALLTMP}/locale
rm -f ${METALOG}
.if make(distributeworld)
.for dist in ${EXTRA_DISTRIBUTIONS}
-mkdir ${DESTDIR}/${DISTDIR}/${dist}
@ -753,7 +765,8 @@ redistribute:
.endif
distrib-dirs distribution:
cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} ${.TARGET}
cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
${IMAKE_INSTALL} ${.TARGET}
#
# buildkernel and installkernel
@ -1059,6 +1072,11 @@ _lex= usr.bin/lex
_yacc= usr.bin/yacc
.endif
.if defined(DB_FROM_SRC) && ${BOOTSTRAPPING} < 1000026
_nmtree= lib/libnetbsd \
usr.sbin/nmtree
.endif
.if ${BOOTSTRAPPING} >= 900040 && ${BOOTSTRAPPING} < 900041
_awk= usr.bin/awk
.endif
@ -1120,7 +1138,8 @@ bootstrap-tools:
${_lex} \
usr.bin/xinstall \
${_gensnmptree} \
usr.sbin/config
usr.sbin/config \
${_nmtree}
${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
cd ${.CURDIR}/${_tool}; \
${MAKE} DIRPRFX=${_tool}/ obj; \

View File

@ -291,25 +291,27 @@ distribution:
${DESTDIR}/etc/nsswitch.conf
.endif
MTREE_CMD?= mtree
distrib-dirs:
mtree -eU ${MTREE_FOLLOWS_SYMLINKS} -f ${.CURDIR}/mtree/BSD.root.dist -p ${DESTDIR}/
mtree -eU ${MTREE_FOLLOWS_SYMLINKS} -f ${.CURDIR}/mtree/BSD.var.dist -p ${DESTDIR}/var
mtree -eU ${MTREE_FOLLOWS_SYMLINKS} -f ${.CURDIR}/mtree/BSD.usr.dist -p ${DESTDIR}/usr
mtree -eU ${MTREE_FOLLOWS_SYMLINKS} -f ${.CURDIR}/mtree/BSD.include.dist \
${MTREE_CMD} -eU ${MTREE_FOLLOWS_SYMLINKS} -f ${.CURDIR}/mtree/BSD.root.dist -p ${DESTDIR}/
${MTREE_CMD} -eU ${MTREE_FOLLOWS_SYMLINKS} -f ${.CURDIR}/mtree/BSD.var.dist -p ${DESTDIR}/var
${MTREE_CMD} -eU ${MTREE_FOLLOWS_SYMLINKS} -f ${.CURDIR}/mtree/BSD.usr.dist -p ${DESTDIR}/usr
${MTREE_CMD} -eU ${MTREE_FOLLOWS_SYMLINKS} -f ${.CURDIR}/mtree/BSD.include.dist \
-p ${DESTDIR}/usr/include
.if ${MK_BIND_LIBS} != "no"
mtree -deU ${MTREE_FOLLOWS_SYMLINKS} -f ${.CURDIR}/mtree/BIND.include.dist \
${MTREE_CMD} -deU ${MTREE_FOLLOWS_SYMLINKS} -f ${.CURDIR}/mtree/BIND.include.dist \
-p ${DESTDIR}/usr/include
.endif
.if ${MK_BIND_MTREE} != "no"
mtree -deU ${MTREE_FOLLOWS_SYMLINKS} -f ${.CURDIR}/mtree/BIND.chroot.dist \
${MTREE_CMD} -deU ${MTREE_FOLLOWS_SYMLINKS} -f ${.CURDIR}/mtree/BIND.chroot.dist \
-p ${DESTDIR}/var/named
.endif
.if ${MK_GROFF} != "no"
mtree -deU ${MTREE_FOLLOWS_SYMLINKS} -f ${.CURDIR}/mtree/BSD.groff.dist -p ${DESTDIR}/usr
${MTREE_CMD} -deU ${MTREE_FOLLOWS_SYMLINKS} -f ${.CURDIR}/mtree/BSD.groff.dist -p ${DESTDIR}/usr
.endif
.if ${MK_SENDMAIL} != "no"
mtree -deU ${MTREE_FOLLOWS_SYMLINKS} -f ${.CURDIR}/mtree/BSD.sendmail.dist -p ${DESTDIR}/
${MTREE_CMD} -deU ${MTREE_FOLLOWS_SYMLINKS} -f ${.CURDIR}/mtree/BSD.sendmail.dist -p ${DESTDIR}/
.endif
cd ${DESTDIR}/; rm -f ${DESTDIR}/sys; ln -s usr/src/sys sys
cd ${DESTDIR}/usr/share/man/en.ISO8859-1; ln -sf ../man* .