svn commit: r250640 - in stable/9: . etc
Brooks Davis
brooks at FreeBSD.org
Tue May 14 21:15:37 UTC 2013
Author: brooks
Date: Tue May 14 21:15:36 2013
New Revision: 250640
URL: http://svnweb.freebsd.org/changeset/base/250640
Log:
MFC r245825,245890,246097,246127,246315:
Introduce a new option -DNO_ROOT that allows install and distribution
targets to be run without root privilege.
Information about ownership, group, flags, and suid bits are stored in
the file specified by METALOG which defaults to ${DESTDIR}/METALOG.
This file can be used in conjunction with bsdtar or makefs to generate
archives or file system images with correct permissions.
Sponsored by: DARPA, AFRL
Modified:
stable/9/Makefile.inc1 (contents, props changed)
stable/9/etc/Makefile
Directory Properties:
stable/9/etc/ (props changed)
Modified: stable/9/Makefile.inc1
==============================================================================
--- stable/9/Makefile.inc1 Tue May 14 20:25:07 2013 (r250639)
+++ stable/9/Makefile.inc1 Tue May 14 21:15:36 2013 (r250640)
@@ -4,6 +4,8 @@
# Make command line options:
# -DNO_CLEANDIR run ${MAKE} clean, instead of ${MAKE} cleandir
# -DNO_CLEAN do not clean at all
+# -DDB_FROM_SRC use the user/group databases in src/etc instead of
+# the system database when installing.
# -DNO_SHARE do not go into share subdir
# -DKERNFAST define NO_KERNEL{CONFIG,CLEAN,DEPEND,OBJ}
# -DNO_KERNELCONFIG do not run config in ${MAKE} buildkernel
@@ -11,13 +13,14 @@
# -DNO_KERNELDEPEND do not run ${MAKE} depend in ${MAKE} buildkernel
# -DNO_KERNELOBJ do not run ${MAKE} obj in ${MAKE} buildkernel
# -DNO_PORTSUPDATE do not update ports in ${MAKE} update
+# -DNO_ROOT install without using root privilege
# -DNO_DOCUPDATE do not update doc 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_MTREE="list of mtree files" to process to allow local directories
# to be created before files are installed
+# METALOG="path to metadata log" to write permission and ownership
+# when NO_ROOT is set. (default: ${DESTDIR}/METALOG)
# TARGET="machine" to crossbuild world for a different machine type
# TARGET_ARCH= may be required when a TARGET supports multiple endians
@@ -174,7 +177,7 @@ OBJTREE= ${MAKEOBJDIRPREFIX}/${TARGET}.$
.endif
WORLDTMP= ${OBJTREE}${.CURDIR}/tmp
# /usr/games added for fortune which depend on strfile
-BPATH= ${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/usr/games
+BPATH= ${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/usr/games:${WORLDTMP}/legacy/bin
XPATH= ${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin:${WORLDTMP}/usr/games
STRICTTMPPATH= ${BPATH}:${XPATH}
TMPPATH= ${STRICTTMPPATH}:${PATH}
@@ -353,8 +356,19 @@ IMAKE+= __MAKE_SHELL=${INSTALLTMP}/sh
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"
+INSTALLFLAGS+= -N ${.CURDIR}/etc
+MTREEFLAGS+= -N ${.CURDIR}/etc
+.endif
+.if defined(NO_ROOT)
+METALOG?= ${DESTDIR}/${DISTDIR}/METALOG
+IMAKE+= -DNO_ROOT METALOG=${METALOG}
+INSTALL_DDIR= ${DESTDIR}/${DISTDIR}
+INSTALLFLAGS+= -U -M ${METALOG} -D ${INSTALL_DDIR:S://:/:g:C:/$::}
+MTREEFLAGS+= -W
+.endif
+.if defined(DB_FROM_SRC) || defined(NO_ROOT)
+IMAKE_INSTALL= INSTALL="install ${INSTALLFLAGS}"
+IMAKE_MTREE= MTREE_CMD="nmtree ${MTREEFLAGS}"
.endif
# kernel stage
@@ -393,7 +407,7 @@ _worldtmp:
rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c
.endif
.for _dir in \
- lib usr legacy/usr
+ lib usr legacy/bin legacy/usr
mkdir -p ${WORLDTMP}/${_dir}
.endfor
mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
@@ -662,7 +676,7 @@ _nmtree_itools= nmtree
.endif
ITOOLS= [ awk cap_mkdb cat chflags chmod chown \
- date echo egrep find grep ${_install-info} \
+ date echo egrep find grep id install ${_install-info} \
ln lockf make mkdir mtree ${_nmtree_itools} mv pwd_mkdb \
rm sed sh sysctl test true uname wc ${_zoneinfo}
@@ -685,6 +699,8 @@ EXTRA_DISTRIBUTIONS+= games
EXTRA_DISTRIBUTIONS+= lib32
.endif
+MTREE_MAGIC?= mtree 2.0
+
distributeworld installworld: installcheck installcheck_UGID
mkdir -p ${INSTALLTMP}
progs=$$(for prog in ${ITOOLS}; do \
@@ -707,6 +723,9 @@ distributeworld installworld: installche
done); \
cp $$libs $$progs ${INSTALLTMP}
cp -R $${PATH_LOCALE:-"/usr/share/locale"} ${INSTALLTMP}/locale
+.if defined(NO_ROOT)
+ echo "#${MTREE_MAGIC}" > ${METALOG}
+.endif
.if make(distributeworld)
.for dist in ${EXTRA_DISTRIBUTIONS}
-mkdir ${DESTDIR}/${DISTDIR}/${dist}
@@ -716,10 +735,20 @@ distributeworld installworld: installche
-p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
-p ${DESTDIR}/${DISTDIR}/${dist}/usr/include >/dev/null
+.if defined(NO_ROOT)
+ ${IMAKEENV} nmtree -C -f ${.CURDIR}/etc/mtree/BSD.root.dist | \
+ sed -e 's#^\./#./${dist}/#' >> ${METALOG}
+ ${IMAKEENV} nmtree -C -f ${.CURDIR}/etc/mtree/BSD.usr.dist | \
+ sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
+ ${IMAKEENV} nmtree -C -f ${.CURDIR}/etc/mtree/BSD.include.dist | \
+ sed -e 's#^\./#./${dist}/usr/include/#' >> ${METALOG}
+.endif
.endfor
-mkdir ${DESTDIR}/${DISTDIR}/base
- ${_+_}cd ${.CURDIR}; ${IMAKE} distrib-dirs \
- LOCAL_MTREE=${LOCAL_MTREE} DESTDIR=${DESTDIR}/${DISTDIR}/base
+ cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
+ METALOG=${METALOG} ${IMAKE_INSTALL} ${IMAKE_MTREE} \
+ DISTBASE=/base DESTDIR=${DESTDIR}/${DISTDIR}/base \
+ LOCAL_MTREE=${LOCAL_MTREE} distrib-dirs
.endif
${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}; \
${IMAKEENV} rm -rf ${INSTALLTMP}
@@ -727,12 +756,30 @@ distributeworld installworld: installche
.for dist in ${EXTRA_DISTRIBUTIONS}
find ${DESTDIR}/${DISTDIR}/${dist} -empty -delete
.endfor
+.if defined(NO_ROOT)
+.for dist in base ${EXTRA_DISTRIBUTIONS}
+ @# For each file that exists in this dist, print the corresponding
+ @# line from the METALOG. This relies on the fact that
+ @# a line containing only the filename will sort immediatly before
+ @# the relevant mtree line.
+ cd ${DESTDIR}/${DISTDIR}; \
+ find ./${dist} | sort -u ${METALOG} - | \
+ awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
+ ${DESTDIR}/${DISTDIR}/${dist}.meta
+.endfor
+.endif
.endif
packageworld:
.for dist in base ${EXTRA_DISTRIBUTIONS}
+.if defined(NO_ROOT)
+ ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
+ tar cvJf ${DESTDIR}/${DISTDIR}/${dist}.txz \
+ @${DESTDIR}/${DISTDIR}/${dist}.meta
+.else
${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
tar cvJf ${DESTDIR}/${DISTDIR}/${dist}.txz .
+.endif
.endfor
#
@@ -769,7 +816,7 @@ redistribute:
distrib-dirs distribution:
cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
- ${IMAKE_INSTALL} ${IMAKE_MTREE} ${.TARGET}
+ ${IMAKE_INSTALL} ${IMAKE_MTREE} METALOG=${METALOG} ${.TARGET}
#
# buildkernel and installkernel
@@ -1092,6 +1139,10 @@ _nmtree= lib/libnetbsd \
usr.sbin/nmtree
.endif
+.if ${BOOTSTRAPPING} < 1000027
+_cat= bin/cat
+.endif
+
.if ${BOOTSTRAPPING} >= 900040 && ${BOOTSTRAPPING} < 900041
_awk= usr.bin/awk
.endif
@@ -1138,6 +1189,7 @@ bootstrap-tools:
${_ar} \
${_dtc} \
${_awk} \
+ ${_cat} \
usr.bin/lorder \
usr.bin/makewhatis \
${_mklocale} \
@@ -1263,7 +1315,12 @@ cross-tools:
# hierarchy - ensure that all the needed directories are present
#
hierarchy:
+.if defined(NO_ROOT)
+ cd ${.CURDIR}/etc; ${MAKE} LOCAL_MTREE=${LOCAL_MTREE} \
+ -DNO_ROOT METALOG=${METALOG} distrib-dirs
+.else
cd ${.CURDIR}/etc; ${MAKE} LOCAL_MTREE=${LOCAL_MTREE} distrib-dirs
+.endif
#
# libraries - build all libraries, and install them under ${DESTDIR}.
@@ -1651,7 +1708,8 @@ NOFUN=-DNO_FSCHG -DWITHOUT_HTML -DWITHOU
XDDIR=${XDEV_ARCH}-freebsd
XDTP=/usr/${XDDIR}
-CDBENV=MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX}/${XDDIR}
+CDBENV=MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX}/${XDDIR} \
+ INSTALL="sh ${.CURDIR}/tools/install.sh"
CDENV= ${CDBENV} \
_SHLIBDIRPREFIX=${XDTP} \
TOOLS_PREFIX=${XDTP}
Modified: stable/9/etc/Makefile
==============================================================================
--- stable/9/etc/Makefile Tue May 14 20:25:07 2013 (r250639)
+++ stable/9/etc/Makefile Tue May 14 21:15:36 2013 (r250640)
@@ -156,6 +156,9 @@ ETCMAIL=Makefile README mailer.conf acce
# Special top level files for FreeBSD
FREEBSD=COPYRIGHT
+# Sanitize DESTDIR
+DESTDIR:= ${DESTDIR:C://*:/:g}
+
afterinstall:
.if ${MK_MAN} != "no"
${_+_}cd ${.CURDIR}/../share/man; ${MAKE} makedb
@@ -177,6 +180,10 @@ CAP_MKDB_ENDIAN?=
PWD_MKDB_ENDIAN?=
.endif
+.if defined(NO_ROOT)
+METALOG.add?= cat -l >> ${METALOG}
+.endif
+
distribution:
.if !defined(DESTDIR)
@echo "set DESTDIR before running \"make ${.TARGET}\""
@@ -198,6 +205,14 @@ distribution:
.endif
pwd_mkdb ${PWD_MKDB_ENDIAN} -i -p -d ${DESTDIR}/etc \
${DESTDIR}/etc/master.passwd
+.if defined(NO_ROOT)
+ ( \
+ echo "./etc/login.conf.db type=file mode=0644 uname=root gname=wheel"; \
+ echo "./etc/passwd type=file mode=0644 uname=root gname=wheel"; \
+ echo "./etc/pwd.db type=file mode=0644 uname=root gname=wheel"; \
+ echo "./etc/spwd.db type=file mode=0600 uname=root gname=wheel"; \
+ ) | ${METALOG.add}
+.endif
.if ${MK_BLUETOOTH} != "no"
${_+_}cd ${.CURDIR}/bluetooth; ${MAKE} install
.endif
@@ -321,6 +336,21 @@ distrib-dirs: ${MTREES:N/*}
-f $$m -p $$d; \
${MTREE_CMD} -deU ${MTREE_FOLLOWS_SYMLINKS} -f $$m -p $$d; \
done; true
+.if defined(NO_ROOT)
+ @set ${MTREES}; \
+ while test $$# -ge 2; do \
+ m=${.CURDIR}/$$1; \
+ shift; \
+ d=$$1; \
+ test "$$d" == "/" && d=""; \
+ d=${DISTBASE}$$d; \
+ shift; \
+ ${ECHO} "${MTREE_CMD:N-W} -C -f $$m -K uname,gname | " \
+ "sed s#^\.#.$$d# | ${METALOG.add}" ; \
+ ${MTREE_CMD:N-W} -C -f $$m -K uname,gname | sed s#^\.#.$$d# | \
+ ${METALOG.add} ; \
+ done; true
+.endif
${INSTALL_SYMLINK} usr/src/sys ${DESTDIR}/sys
cd ${DESTDIR}/usr/share/man; \
for mandir in man*; do \
More information about the svn-src-stable-9
mailing list