diff -ruN -I '\$FreeBSD:' --exclude=.svn --exclude=ctsrd --exclude=ctsrd-lib ./Makefile.inc1 ../src-mtree/Makefile.inc1 --- ./Makefile.inc1 2013-01-18 22:18:05.000000000 +0000 +++ ../src-mtree/Makefile.inc1 2013-01-18 23:59:23.000000000 +0000 @@ -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,10 +13,9 @@ # -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 # -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 @@ -22,6 +23,8 @@ # to be created before files are installed # LOCAL_TOOL_DIRS="list of dirs" to add additional dirs to the build-tools # list +# METALOG="path to metadata log" to write permission and ownership +# when NO_ROOT is set # TARGET="machine" to crossbuild world for a different machine type # TARGET_ARCH= may be required when a TARGET supports multiple endians # BUILDENV_SHELL= shell to launch for the buildenv target (def:/bin/sh) @@ -359,8 +362,19 @@ 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} +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 @@ -659,7 +673,7 @@ .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 mv pwd_mkdb rm sed sh sysctl \ test true uname wc ${_zoneinfo} @@ -704,6 +718,9 @@ done); \ cp $$libs $$progs ${INSTALLTMP} cp -R $${PATH_LOCALE:-"/usr/share/locale"} ${INSTALLTMP}/locale +.if defined(NO_ROOT) + echo "#mtree v2.0" > ${METALOG} +.endif .if make(distributeworld) .for dist in ${EXTRA_DISTRIBUTIONS} -mkdir ${DESTDIR}/${DISTDIR}/${dist} @@ -713,10 +730,20 @@ -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} @@ -724,12 +751,30 @@ .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 relevent mtree line. + cd ${DESTDIR}/${DISTDIR}; \ + find ./${dist} | sort -u ${METALOG} - | \ + awk 'BEGIN { print "#mtree 2.0" } !/ 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 # @@ -766,7 +811,7 @@ 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 @@ -1247,7 +1292,12 @@ # hierarchy - ensure that all the needed directories are present # hierarchy hier: +.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}. diff -ruN -I '\$FreeBSD:' --exclude=.svn --exclude=ctsrd --exclude=ctsrd-lib ./etc/Makefile ../src-mtree/etc/Makefile --- ./etc/Makefile 2013-01-18 16:40:01.000000000 +0000 +++ ../src-mtree/etc/Makefile 2013-01-18 23:59:23.000000000 +0000 @@ -156,6 +156,9 @@ # 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 @@ -324,6 +327,20 @@ -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} -C -f $$m | sed s#^\.#.$$d# >>" \ + "${METALOG}" ; \ + ${MTREE_CMD} -C -f $$m | sed s#^\.#.$$d# >> ${METALOG} ; \ + done; true +.endif ${INSTALL_SYMLINK} usr/src/sys ${DESTDIR}/sys cd ${DESTDIR}/usr/share/man; \ for mandir in man*; do \