Changeset View
Changeset View
Standalone View
Standalone View
head/share/mk/bsd.init.mk
# $FreeBSD$ | # $FreeBSD$ | ||||
# The include file <bsd.init.mk> includes <bsd.opts.mk>, | # The include file <bsd.init.mk> includes <bsd.opts.mk>, | ||||
# ../Makefile.inc and <bsd.own.mk>; this is used at the | # ../Makefile.inc and <bsd.own.mk>; this is used at the | ||||
# top of all <bsd.*.mk> files that actually "build something". | # top of all <bsd.*.mk> files that actually "build something". | ||||
# bsd.opts.mk is included early so Makefile.inc can use the | # bsd.opts.mk is included early so Makefile.inc can use the | ||||
# MK_FOO variables. | # MK_FOO variables. | ||||
.if !target(__<bsd.init.mk>__) | .if !target(__<bsd.init.mk>__) | ||||
__<bsd.init.mk>__: | __<bsd.init.mk>__: | ||||
.include <bsd.opts.mk> | .include <bsd.opts.mk> | ||||
.-include "local.init.mk" | .-include "local.init.mk" | ||||
.if exists(${.CURDIR}/../Makefile.inc) | .if exists(${.CURDIR}/../Makefile.inc) | ||||
.include "${.CURDIR}/../Makefile.inc" | .include "${.CURDIR}/../Makefile.inc" | ||||
.endif | .endif | ||||
.include <bsd.own.mk> | .include <bsd.own.mk> | ||||
.MAIN: all | .MAIN: all | ||||
# Handle INSTALL_AS_USER here to maximize the chance that | |||||
bdrewery: You moved the logic from bsd.own.mk (more coverage) to bsd.init.mk (less coverage) and it is… | |||||
bdreweryUnsubmitted Not Done Inline ActionsThis fixes it but I'm not sure I like it. Makefiles may have a valid need to know what user is being installed as without funky hacks. diff --git etc/Makefile etc/Makefile index 7eadb1bba99b..2f94d7806c42 100644 --- etc/Makefile +++ etc/Makefile @@ -342,19 +342,6 @@ distribution: MTREE_CMD?= mtree -.if ${MK_INSTALL_AS_USER} == "yes" && ${_uid} != 0 -MTREE_FILTER= sed -e 's,\([gu]\)name=,\1id=,g' \ - -e 's,\(uid=\)[^ ]* ,\1${_uid} ,' \ - -e 's,\(gid=\)[^ ]* ,\1${_gid} ,' \ - -e 's,\(uid=\)[^ ]*$$,\1${_uid},' \ - -e 's,\(gid=\)[^ ]*$$,\1${_gid},' -.else -MTREE_FILTER= cat -.if !defined(NO_FSCHG) -MTREE_FSCHG= -i -.endif -.endif - MTREES= mtree/BSD.root.dist / \ mtree/BSD.var.dist /var \ mtree/BSD.usr.dist /usr \ @@ -467,3 +454,16 @@ etc-examples: etc-examples-install DESTDIR=${DESTDIR}${SHAREDIR}/examples .include <bsd.prog.mk> + +.if ${MK_INSTALL_AS_USER} == "yes" && ${_uid} != 0 +MTREE_FILTER= sed -e 's,\([gu]\)name=,\1id=,g' \ + -e 's,\(uid=\)[^ ]* ,\1${_uid} ,' \ + -e 's,\(gid=\)[^ ]* ,\1${_gid} ,' \ + -e 's,\(uid=\)[^ ]*$$,\1${_uid},' \ + -e 's,\(gid=\)[^ ]*$$,\1${_gid},' +.else +MTREE_FILTER= cat +.if !defined(NO_FSCHG) +MTREE_FSCHG= -i +.endif +.endif bdrewery: This fixes it but I'm not sure I like it. Makefiles may have a valid need to know what user is… | |||||
vangyzenAuthorUnsubmitted Not Done Inline ActionsThe reason was to make sure it was included as late as possible and therefore had final say on OWN/GRP. The reduced coverage didn't seem to be relevant, since I didn't see any problems in my testing. However, I don't remember testing make distribution or anything that descended into etc. Your patch seems fine to me. Sorry for the trouble. vangyzen: The reason was to make sure it was included as late as possible and therefore had final say on… | |||||
vangyzenAuthorUnsubmitted Not Done Inline ActionsWe could move the logic to set _uid (and _gid) into a separate, possibly new file that could be included here and etc/Makefile. Do you think it's worth the effort, or should we wait until the next consumer pops up (if any)? vangyzen: We could move the logic to set _uid (and _gid) into a separate, possibly new file that could be… | |||||
bdreweryUnsubmitted Not Done Inline ActionsI'll just go with my patch for now. bdrewery: I'll just go with my patch for now. | |||||
# it has final authority over fooOWN and fooGRP. | |||||
.if ${MK_INSTALL_AS_USER} != "no" | |||||
.if !defined(_uid) | |||||
_uid!= id -u | |||||
.export _uid | |||||
.endif | |||||
.if ${_uid} != 0 | |||||
.if !defined(USER) | |||||
# Avoid exporting USER | |||||
.if !defined(_USER) | |||||
_USER!= id -un | |||||
.export _USER | |||||
.endif | |||||
USER= ${_USER} | |||||
.endif | |||||
.if !defined(_gid) | |||||
_gid!= id -g | |||||
.export _gid | |||||
.endif | |||||
.for x in BIN CONF DOC DTB INFO KMOD LIB MAN NLS SHARE | |||||
$xOWN= ${USER} | |||||
$xGRP= ${_gid} | |||||
.endfor | |||||
.endif | |||||
.endif | |||||
# Some targets need to know when something may build. This is used to | # Some targets need to know when something may build. This is used to | ||||
# optimize targets that are only needed when building something, such as | # optimize targets that are only needed when building something, such as | ||||
# (not) reading in depend files. For DIRDEPS_BUILD, it will only calculate | # (not) reading in depend files. For DIRDEPS_BUILD, it will only calculate | ||||
# the dependency graph at .MAKE.LEVEL==0, so nothing should be built there. | # the dependency graph at .MAKE.LEVEL==0, so nothing should be built there. | ||||
# Skip "build" logic if: | # Skip "build" logic if: | ||||
# - DIRDEPS_BUILD at MAKELEVEL 0 | # - DIRDEPS_BUILD at MAKELEVEL 0 | ||||
# - make -V is used without an override | # - make -V is used without an override | ||||
# - make install is used without other targets. This is to avoid breaking | # - make install is used without other targets. This is to avoid breaking | ||||
Show All 32 Lines |
You moved the logic from bsd.own.mk (more coverage) to bsd.init.mk (less coverage) and it is right after an include of bsd.own.mk. I don't quite understand why.
It breaks INSTALL_AS_USER in etc/Makefile since it (arguably incorrectly) uses _uid before including bsd.prog.mk/bsd.init.mk