pkgsrc/mk/unprivileged.mk
joerg 5b374e445d Main infrastructure for DESTDIR support.
Packages may set PKG_DESTDIR_SUPPORT to either "destdir" or
"user-destdir" to flag support for this, following the same
rules as PKG_INSTALLATION_TYPES (e.g. define before first include
of bsd.prefs.mk).

The user activates it via USE_DESTDIR. When set to "yes",
packages with "user-destdir" are handled as "destdir".
The installation of the package will not go to ${LOCALBASE},
but a subdirectory of ${WRKDIR} instead. pre/post install scripts are
not run and the package is not registered either. A binary package
can be created instead to be installed normally with pkg_add.

For "user-destdir" packages, everything is run as normal user and
ownership is supposed to be correctled by pkg_create later. Since
the current pkg_install code uses pax and it doesn't allow overwriting
owners, this does not work yet.

For "destdir" packages, installation, packaging and cleaning is run as
root.

This commit does not change the handling of DEPENDS_TARGET or
bin-install to allow recursive usage.
2006-10-09 12:25:44 +00:00

71 lines
2.2 KiB
Makefile

# $NetBSD: unprivileged.mk,v 1.6 2006/10/09 12:25:44 joerg Exp $
#
# This file collects definitions that are useful when using pkgsrc as an
# unprivileged (non-root) user. It is included automatically by the
# pkgsrc infrastructure.
#
# The following variables may be set by the pkgsrc user in mk.conf:
#
# UNPRIVILEGED : YesNo (default: undefined)
# If set to 'yes', enable unprivileged builds.
#
# UNPRIVILEGED_GROUP : Groupname (default: the current group)
# Specifies the group name (or gid) that will be used to install
# files.
#
# UNPRIVILEGED_USER : Username (default: the current user)
# Specifies the user name (or uid) that will be used to install
# files.
.if (defined(UNPRIVILEGED) && !empty(UNPRIVILEGED:M[Yy][Ee][Ss])) || ${_USE_DESTDIR} == "user-destdir"
# Guess which user/group has to be used.
. if !defined(UNPRIVILEGED_USER) || empty(UNPRIVILEGED_USER)
UNPRIVILEGED_USER!= ${ID} -n -u
. endif
. if !defined(UNPRIVILEGED_GROUP) || empty(UNPRIVILEGED_GROUP)
UNPRIVILEGED_GROUP!= ${ID} -n -g
. endif
.if ${_USE_DESTDIR} == "user-destdir" && (!defined(UNPRIVILEGED) || empty(UNPRIVILEGED:M[Yy][Ee][Ss]))
_SU_ROOT_USER:= ${ROOT_USER}
.endif
# Override super-user account.
ROOT_GROUP= ${UNPRIVILEGED_GROUP}
ROOT_USER= ${UNPRIVILEGED_USER}
# Override user/group pairs used to install files.
BINGRP= ${UNPRIVILEGED_GROUP}
BINOWN= ${UNPRIVILEGED_USER}
GAMEGRP= ${UNPRIVILEGED_GROUP}
GAMEOWN= ${UNPRIVILEGED_USER}
MANGRP= ${UNPRIVILEGED_GROUP}
MANOWN= ${UNPRIVILEGED_USER}
SHAREGRP= ${UNPRIVILEGED_GROUP}
SHAREOWN= ${UNPRIVILEGED_USER}
# Override installation modes. As a regular user, we may have problems
# when overwriting files if they are not writable.
BINMODE= 755
NONBINMODE= 644
# mtree is useless as a regular user because it won't set directory
# ownerships correctly.
NO_MTREE= yes
.endif
.if (defined(UNPRIVILEGED) && !empty(UNPRIVILEGED:M[Yy][Ee][Ss]))
# As a regular user, creation of other users and groups won't work, so
# disable this step by default.
PKG_CREATE_USERGROUP= NO
# Override commands that won't work as a regular user.
TOOLS_PLATFORM.chgrp= ${TRUE} chgrp
TOOLS_PLATFORM.chown= ${TRUE} chown
SU_CMD= ${SH} -c
# Do not attempt to modify /etc/shells as a regular user.
PKG_REGISTER_SHELLS= NO
.endif