Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 25 Jun 2012 23:30:17 -0700
From:      Simon Gerraty <sjg@juniper.net>
To:        <freebsd-arch@freebsd.org>
Cc:        sjg@juniper.net
Subject:   Allow user install
Message-ID:  <20120626063017.D05DA58081@chaos.jnpr.net>

next in thread | raw e-mail | index | archive | help
The patch below is a step towards supporting unprivileged buildworld
etc.  Eg.

$ cd bin/cat
$ make -n install DESTDIR=/tmp          
install -s -o root -g wheel -m 555   cat /tmp/bin
install -o root -g wheel -m 444 cat.1.gz  /tmp/usr/share/man/man1
$ make -n install -DWITHOUT_INSTALL_OWN DESTDIR=/tmp
install -s  -m 555   cat /tmp/bin
install  -m 444 cat.1.gz  /tmp/usr/share/man/man1
$

This is similar to the approach used in my generic mk-files, but
leveraging the -DWITHOUT_* stuff in bsd.own.mk

--sjg

Index: share/mk/bsd.files.mk
===================================================================
--- share/mk/bsd.files.mk	(revision 237026)
+++ share/mk/bsd.files.mk	(working copy)
@@ -23,6 +23,11 @@
 ${group}MODE?=	${SHAREMODE}
 ${group}DIR?=	${BINDIR}
 
+.if ${MK_INSTALL_OWN} != "no"
+${group}_INSTALL_OWN ?= -o ${${group}OWN} -g ${${group}GRP}
+${group}_INSTALL_OWN.ALLSRC ?= -o ${${group}OWN_${.ALLSRC:T}} -g ${${group}GRP_${.ALLSRC:T}}
+.endif
+
 _${group}FILES=
 .for file in ${${group}}
 .if defined(${group}OWN_${file:T}) || defined(${group}GRP_${file:T}) || \
@@ -39,8 +44,8 @@
 .endif
 installfiles: _${group}INS_${file:T}
 _${group}INS_${file:T}: ${file}
-	${INSTALL} -o ${${group}OWN_${.ALLSRC:T}} \
-	    -g ${${group}GRP_${.ALLSRC:T}} -m ${${group}MODE_${.ALLSRC:T}} \
+	${INSTALL} ${${group}_INSTALL_OWN.ALLSRC} \
+	    -m ${${group}MODE_${.ALLSRC:T}} \
 	    ${.ALLSRC} \
 	    ${DESTDIR}${${group}DIR_${.ALLSRC:T}}/${${group}NAME_${.ALLSRC:T}}
 .else
@@ -51,11 +56,11 @@
 installfiles: _${group}INS
 _${group}INS: ${_${group}FILES}
 .if defined(${group}NAME)
-	${INSTALL} -o ${${group}OWN} -g ${${group}GRP} \
+	${INSTALL} ${${group}_INSTALL_OWN} \
 	    -m ${${group}MODE} ${.ALLSRC} \
 	    ${DESTDIR}${${group}DIR}/${${group}NAME}
 .else
-	${INSTALL} -o ${${group}OWN} -g ${${group}GRP} \
+	${INSTALL} ${${group}_INSTALL_OWN} \
 	    -m ${${group}MODE} ${.ALLSRC} ${DESTDIR}${${group}DIR}
 .endif
 .endif
Index: share/mk/bsd.own.mk
===================================================================
--- share/mk/bsd.own.mk	(revision 237026)
+++ share/mk/bsd.own.mk	(working copy)
@@ -353,6 +353,7 @@
     INET6 \
     INFO \
     INSTALLLIB \
+    INSTALL_OWN \
     IPFILTER \
     IPFW \
     IPX \
@@ -645,6 +646,13 @@
 CTFCONVERT_CMD=	@:
 .endif 
 
+
+.if ${MK_INSTALL_OWN} != "no"
+.for x in BIN CONF DOC INFO KMOD LIB MAN NLS SHARE
+$x_INSTALL_OWN ?= -o ${$xOWN} -g ${$xGRP}
+.endfor
+.endif
+
 .endif # !_WITHOUT_SRCCONF
 
 .endif	# !target(__<bsd.own.mk>__)
Index: share/mk/bsd.lib.mk
===================================================================
--- share/mk/bsd.lib.mk	(revision 237026)
+++ share/mk/bsd.lib.mk	(working copy)
@@ -259,15 +259,15 @@
 .ORDER: beforeinstall _libinstall
 _libinstall:
 .if defined(LIB) && !empty(LIB) && ${MK_INSTALLLIB} != "no"
-	${INSTALL} -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
+	${INSTALL} -C ${LIB_INSTALL_OWN} -m ${LIBMODE} \
 	    ${_INSTALLFLAGS} lib${LIB}.a ${DESTDIR}${LIBDIR}
 .endif
 .if ${MK_PROFILE} != "no" && defined(LIB) && !empty(LIB)
-	${INSTALL} -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
+	${INSTALL} -C ${LIB_INSTALL_OWN} -m ${LIBMODE} \
 	    ${_INSTALLFLAGS} lib${LIB}_p.a ${DESTDIR}${LIBDIR}
 .endif
 .if defined(SHLIB_NAME)
-	${INSTALL} ${STRIP} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
+	${INSTALL} ${STRIP} ${LIB_INSTALL_OWN} -m ${LIBMODE} \
 	    ${_INSTALLFLAGS} ${_SHLINSTALLFLAGS} \
 	    ${SHLIB_NAME} ${DESTDIR}${SHLIBDIR}
 .if defined(SHLIB_LINK)
@@ -287,7 +287,7 @@
 	sed -e 's,@@SHLIB@@,${_LDSCRIPTROOT}${SHLIBDIR}/${SHLIB_NAME},g' \
 	    -e 's,@@LIBDIR@@,${_LDSCRIPTROOT}${LIBDIR},g' \
 	    ${.CURDIR}/${SHLIB_LDSCRIPT} > lib${LIB}.ld
-	${INSTALL} -S -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
+	${INSTALL} -S -C ${LIB_INSTALL_OWN} -m ${LIBMODE} \
 	    ${_INSTALLFLAGS} lib${LIB}.ld ${DESTDIR}${LIBDIR}/${SHLIB_LINK}
 .else
 .if ${SHLIBDIR} == ${LIBDIR}
@@ -304,11 +304,11 @@
 .endif # SHLIB_LINK
 .endif # SHIB_NAME
 .if defined(INSTALL_PIC_ARCHIVE) && defined(LIB) && !empty(LIB) && ${MK_TOOLCHAIN} != "no"
-	${INSTALL} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
+	${INSTALL} ${LIB_INSTALL_OWN} -m ${LIBMODE} \
 	    ${_INSTALLFLAGS} lib${LIB}_pic.a ${DESTDIR}${LIBDIR}
 .endif
 .if defined(WANT_LINT) && !defined(NO_LINT) && defined(LIB) && !empty(LIB)
-	${INSTALL} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
+	${INSTALL} ${LIB_INSTALL_OWN} -m ${LIBMODE} \
 	    ${_INSTALLFLAGS} ${LINTLIB} ${DESTDIR}${LINTLIBDIR}
 .endif
 .endif # !defined(INTERNALLIB)
Index: share/mk/bsd.prog.mk
===================================================================
--- share/mk/bsd.prog.mk	(revision 237026)
+++ share/mk/bsd.prog.mk	(working copy)
@@ -157,10 +157,10 @@
 _proginstall:
 .if defined(PROG)
 .if defined(PROGNAME)
-	${INSTALL} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
+	${INSTALL} ${STRIP} ${BIN_INSTALL_OWN} -m ${BINMODE} \
 	    ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}/${PROGNAME}
 .else
-	${INSTALL} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
+	${INSTALL} ${STRIP} ${BIN_INSTALL_OWN} -m ${BINMODE} \
 	    ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}
 .endif
 .endif
@@ -185,10 +185,15 @@
 SCRIPTSOWN_${script:T}?=	${SCRIPTSOWN}
 SCRIPTSGRP_${script:T}?=	${SCRIPTSGRP}
 SCRIPTSMODE_${script:T}?=	${SCRIPTSMODE}
+
+.if ${MK_INSTALL_OWN} != "no"
+SCRIPTS_INSTALL_OWN.ALLSRC ?= -o ${SCRIPTSOWN_${.ALLSRC:T}} -g ${SCRIPTSGRP_${.ALLSRC:T}}
+.endif
+
 _scriptsinstall: _SCRIPTSINS_${script:T}
 _SCRIPTSINS_${script:T}: ${script}
-	${INSTALL} -o ${SCRIPTSOWN_${.ALLSRC:T}} \
-	    -g ${SCRIPTSGRP_${.ALLSRC:T}} -m ${SCRIPTSMODE_${.ALLSRC:T}} \
+	${INSTALL} ${SCRIPTS_INSTALL_OWN.ALLSRC} \
+	    -m ${SCRIPTSMODE_${.ALLSRC:T}} \
 	    ${.ALLSRC} \
 	    ${DESTDIR}${SCRIPTSDIR_${.ALLSRC:T}}/${SCRIPTSNAME_${.ALLSRC:T}}
 .endfor
Index: share/mk/bsd.doc.mk
===================================================================
--- share/mk/bsd.doc.mk	(revision 237026)
+++ share/mk/bsd.doc.mk	(working copy)
@@ -135,11 +135,11 @@
 realinstall:
 .for _dev in ${PRINTERDEVICE:Mhtml}
 	cd ${SRCDIR}; \
-	    ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
+	    ${INSTALL} ${BIN_INSTALL_OWN} -m ${BINMODE} \
 	    ${DOC}*.html ${DESTDIR}${BINDIR}/${VOLUME}
 .endfor
 .for _dev in ${PRINTERDEVICE:Nhtml}
-	${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
+	${INSTALL} ${BIN_INSTALL_OWN} -m ${BINMODE} \
 	    ${DFILE.${_dev}} ${DESTDIR}${BINDIR}/${VOLUME}
 .endfor
 
Index: share/mk/bsd.man.mk
===================================================================
--- share/mk/bsd.man.mk	(revision 237026)
+++ share/mk/bsd.man.mk	(working copy)
@@ -53,7 +53,7 @@
 .error bsd.man.mk cannot be included directly.
 .endif
 
-MINSTALL?=	${INSTALL} -o ${MANOWN} -g ${MANGRP} -m ${MANMODE}
+MINSTALL?=	${INSTALL} ${MAN_INSTALL_OWN} -m ${MANMODE}
 
 CATDIR=		${MANDIR:H:S/$/\/cat/}
 CATEXT=		.cat
Index: share/mk/bsd.info.mk
===================================================================
--- share/mk/bsd.info.mk	(revision 237026)
+++ share/mk/bsd.info.mk	(working copy)
@@ -180,11 +180,11 @@
 .if ${MK_INFO} != "no" && defined(INFO)
 install: ${INSTALLINFODIRS}
 .if !empty(IFILES:N*.html)
-	${INSTALL} -o ${INFOOWN} -g ${INFOGRP} -m ${INFOMODE} \
+	${INSTALL} ${INFO_INSTALL_OWN} -m ${INFOMODE} \
 		${IFILES:N*.html} ${DESTDIR}${INFODIR}
 .endif
 .if !empty(FORMATS:Mhtml)
-	${INSTALL} -o ${INFOOWN} -g ${INFOGRP} -m ${INFOMODE} \
+	${INSTALL} ${INFO_INSTALL_OWN} -m ${INFOMODE} \
 		${INFO:S/$/.info.*.html/} ${DESTDIR}${INFODIR}
 .endif
 .else
Index: share/mk/bsd.incs.mk
===================================================================
--- share/mk/bsd.incs.mk	(revision 237026)
+++ share/mk/bsd.incs.mk	(working copy)
@@ -25,6 +25,11 @@
 ${group}MODE?=	${NOBINMODE}
 ${group}DIR?=	${INCLUDEDIR}
 
+.if ${MK_INSTALL_OWN} != "no"
+${group}_INSTALL_OWN ?= -o ${${group}OWN} -g ${${group}GRP}
+${group}_INSTALL_OWN.ALLSRC ?= -o ${${group}OWN_${.ALLSRC:T}} -g ${${group}GRP_${.ALLSRC:T}}
+.endif
+
 _${group}INCS=
 .for header in ${${group}}
 .if defined(${group}OWN_${header:T}) || defined(${group}GRP_${header:T}) || \
@@ -41,8 +46,8 @@
 .endif
 installincludes: _${group}INS_${header:T}
 _${group}INS_${header:T}: ${header}
-	${INSTALL} -C -o ${${group}OWN_${.ALLSRC:T}} \
-	    -g ${${group}GRP_${.ALLSRC:T}} -m ${${group}MODE_${.ALLSRC:T}} \
+	${INSTALL} -C ${${group}_INSTALL_OWN.ALLSRC} \
+	    -m ${${group}MODE_${.ALLSRC:T}} \
 	    ${.ALLSRC} \
 	    ${DESTDIR}${${group}DIR_${.ALLSRC:T}}/${${group}NAME_${.ALLSRC:T}}
 .else
@@ -53,10 +58,10 @@
 installincludes: _${group}INS
 _${group}INS: ${_${group}INCS}
 .if defined(${group}NAME)
-	${INSTALL} -C -o ${${group}OWN} -g ${${group}GRP} -m ${${group}MODE} \
+	${INSTALL} -C ${${group}_INSTALL_OWN} -m ${${group}MODE} \
 	    ${.ALLSRC} ${DESTDIR}${${group}DIR}/${${group}NAME}
 .else
-	${INSTALL} -C -o ${${group}OWN} -g ${${group}GRP} -m ${${group}MODE} \
+	${INSTALL} -C ${${group}_INSTALL_OWN} -m ${${group}MODE} \
 	    ${.ALLSRC} ${DESTDIR}${${group}DIR}
 .endif
 .endif



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120626063017.D05DA58081>