From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 7CB19138334 for ; Sun, 23 Dec 2018 11:14:08 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 38DD3E09B8; Sun, 23 Dec 2018 11:14:07 +0000 (UTC) Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id E9450E09B8 for ; Sun, 23 Dec 2018 11:14:06 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 7A457335C31 for ; Sun, 23 Dec 2018 11:14:04 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id BA67845B for ; Sun, 23 Dec 2018 11:14:02 +0000 (UTC) From: "Fabian Groffen" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Fabian Groffen" Message-ID: <1545563578.6d68e3cef901f3322a80525b472fb04d1304de5a.grobian@gentoo> Subject: [gentoo-commits] proj/portage:prefix commit in: / X-VCS-Repository: proj/portage X-VCS-Committer: grobian X-VCS-Committer-Name: Fabian Groffen X-VCS-Revision: 6d68e3cef901f3322a80525b472fb04d1304de5a X-VCS-Branch: prefix Date: Sun, 23 Dec 2018 11:14:02 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 5ef1ccbc-d15f-4bb5-a005-fa8f8319fdf7 X-Archives-Hash: 2f6be856152c34e1436eb4130f38d1b6 commit: 6d68e3cef901f3322a80525b472fb04d1304de5a Author: Fabian Groffen gentoo org> AuthorDate: Sun Dec 23 11:12:58 2018 +0000 Commit: Fabian Groffen gentoo org> CommitDate: Sun Dec 23 11:12:58 2018 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=6d68e3ce Merge remote-tracking branch 'overlays-gentoo-org/master' into prefix This also removes DEFAULT_PATH as part of merging daeb75b. Bug: https://bugs.gentoo.org/585986 Signed-off-by: Fabian Groffen gentoo.org> .travis.yml | 1 - NEWS | 8 +++- bin/ebuild-helpers/portageq | 2 +- bin/save-ebuild-env.sh | 5 ++- cnf/make.conf.example | 12 +++--- cnf/make.globals | 15 +++---- configure.ac | 5 --- lib/_emerge/post_emerge.py | 2 +- lib/portage/dbapi/vartree.py | 2 +- lib/portage/elog/mod_echo.py | 2 +- lib/portage/elog/mod_save.py | 4 +- lib/portage/elog/mod_save_summary.py | 4 +- lib/portage/emaint/modules/logs/__init__.py | 2 +- lib/portage/emaint/modules/logs/logs.py | 22 +++++------ .../package/ebuild/_config/special_env_vars.py | 7 ++-- lib/portage/package/ebuild/config.py | 11 ++++++ lib/portage/package/ebuild/doebuild.py | 28 ++++++++----- lib/portage/package/ebuild/prepare_build_dirs.py | 26 ++++++------ lib/portage/tests/emerge/test_simple.py | 2 +- lib/portage/tests/resolver/ResolverPlayground.py | 34 ++++++++++++++++ lib/portage/util/ExtractKernelVersion.py | 17 ++++++-- man/ebuild.5 | 2 +- man/emaint.1 | 6 +-- man/emerge.1 | 8 ++-- man/make.conf.5 | 46 ++++++++++++---------- man/portage.5 | 2 +- subst-install.in | 1 - travis.sh | 1 - 28 files changed, 173 insertions(+), 104 deletions(-) diff --cc .travis.yml index 16eaafc43,ab0b8d304..4f94e36a3 --- a/.travis.yml +++ b/.travis.yml @@@ -19,21 -19,6 +19,20 @@@ install script: - printf "[build_ext]\nportage-ext-modules=true" >> setup.cfg + - find . -type f -exec + sed -e "s|@PORTAGE_EPREFIX@||" + -e "s|@PORTAGE_BASE@|${PWD}|" + -e "s|@PORTAGE_MV@|$(type -P mv)|" + -e "s|@PORTAGE_BASH@|$(type -P bash)|" + -e "s|@PREFIX_PORTAGE_PYTHON@|$(type -P python)|" - -e "s|@DEFAULT_PATH@|/usr/bin:/bin|" + -e "s|@EXTRA_PATH@|/usr/sbin:/sbin|" + -e "s|@portagegroup@|$(id -gn)|" + -e "s|@portageuser@|$(id -un)|" + -e "s|@rootuser@|$(id -un)|" + -e "s|@rootuid@|$(id -u)|" + -e "s|@rootgid@|$(id -g)|" + -e "s|@sysconfdir@|/etc|" + -i '{}' + - ./setup.py test - ./setup.py install --root=/tmp/install-root - if [[ ${TRAVIS_PYTHON_VERSION} == ?.? ]]; then diff --cc bin/save-ebuild-env.sh index bb17382d4,947ac79d5..1cfd79f23 mode 100755,100644..100755 --- a/bin/save-ebuild-env.sh +++ b/bin/save-ebuild-env.sh @@@ -122,9 -118,6 +122,10 @@@ __save_ebuild_env() # user config variables unset DOC_SYMLINKS_DIR INSTALL_MASK PKG_INSTALL_MASK - # Prefix additions - unset DEFAULT_PATH EXTRA_PATH PORTAGE_GROUP PORTAGE_USER ++ # PREFIX LOCAL: Prefix additions ++ unset EXTRA_PATH PORTAGE_GROUP PORTAGE_USER ++ # END PREFIX LOCAL + declare -p declare -fp if [[ ${BASH_VERSINFO[0]} == 3 ]]; then diff --cc cnf/make.conf.example index ad290c7e6,ffebd24d4..81b9c0328 --- a/cnf/make.conf.example +++ b/cnf/make.conf.example @@@ -128,9 -128,9 +128,9 @@@ # up to several hundred megs, or even a few gigs. Note that # locations under /usr/portage are not necessarily safe for data # storage. See the PORTDIR documentation for more information. -#PKGDIR=/usr/portage/packages +#PKGDIR=@PORTAGE_EPREFIX@/usr/portage/packages # - # PORT_LOGDIR is the location where portage will store all the logs it + # PORTAGE_LOGDIR is the location where portage will store all the logs it # creates from each individual merge. They are stored as # ${CATEGORY}:${PF}:YYYYMMDD-HHMMSS.log in the directory specified. # If the directory does not exist, it will be created automatically and diff --cc cnf/make.globals index 24a42cba6,5a3015ae2..5013957ea --- a/cnf/make.globals +++ b/cnf/make.globals @@@ -103,35 -101,15 +104,35 @@@ PORTAGE_RSYNC_OPTS="--recursive --link PORTAGE_SYNC_STALE="30" # Executed before emerge exit if FEATURES=clean-logs is enabled. - PORT_LOGDIR_CLEAN="find \"\${PORT_LOGDIR}\" -type f ! -name \"summary.log*\" -mtime +7 -delete" + PORTAGE_LOGDIR_CLEAN="find \"\${PORTAGE_LOGDIR}\" -type f ! -name \"summary.log*\" -mtime +7 -delete" # Minimal CONFIG_PROTECT +# NOTE: in Prefix, these are NOT prefixed on purpose, because the +# profiles define them too CONFIG_PROTECT="/etc" CONFIG_PROTECT_MASK="/etc/env.d" # Disable auto-use USE_ORDER="env:pkg:conf:defaults:pkginternal:features:repo:env.d" ++# PREFIX LOCAL: additional vars set during install +# Default portage user/group +PORTAGE_USER='@portageuser@' +PORTAGE_GROUP='@portagegroup@' +PORTAGE_ROOT_USER='@rootuser@' + +# Default ownership of installed files. +PORTAGE_INST_UID="@rootuid@" +PORTAGE_INST_GID="@rootgid@" + - # Default PATH for ebuild env - DEFAULT_PATH="@DEFAULT_PATH@" +# Any extra PATHs to add to the ebuild environment's PATH (if any) +EXTRA_PATH="@EXTRA_PATH@" + +# The offset prefix this Portage was configured with (not used by +# Portage itself) +CONFIGURE_EPREFIX="@PORTAGE_EPREFIX@" ++# END PREFIX LOCAL + # Mode bits for ${WORKDIR} (see ebuild.5). PORTAGE_WORKDIR_MODE="0700" diff --cc configure.ac index 6b8021ec6,000000000..9083824eb mode 100644,000000..100644 --- a/configure.ac +++ b/configure.ac @@@ -1,140 -1,0 +1,135 @@@ +dnl Process this file with autoconf to produce a configure script. +AC_INIT(portage-prefix, @version@, prefix@gentoo.org) + +AC_PREREQ([2.61]) + +case "${prefix}" in + '') AC_MSG_ERROR([bad value ${prefix} for --prefix, must not be empty]) ;; + */) AC_MSG_ERROR([bad value ${prefix} for --prefix, must not end with '/']) ;; + /*|NONE) ;; + *) AC_MSG_ERROR([bad value ${prefix} for --prefix, must start with /]) ;; +esac + +AC_CANONICAL_BUILD +AC_CANONICAL_HOST +AC_CANONICAL_TARGET + +AM_INIT_AUTOMAKE + +dnl Checks for programs. +dnl store cflags prior, otherwise it's not propagated. +if test "x$CFLAGS" != "x" +then + CFLAGS=$CFLAGS +fi + +AC_PREFIX_DEFAULT([/usr]) + +AC_PROG_CC +AC_PROG_INSTALL +AC_PROG_LN_S +AC_PROG_EGREP + +GENTOO_PATH_XCU_ID() +GENTOO_PATH_PYTHON([2.7]) + +AC_PATH_PROG(PORTAGE_RM, [rm], no) +AC_PATH_PROG(PORTAGE_MV, [mv], no) +AC_PATH_PROG(PORTAGE_BASENAME, [basename], no) +AC_PATH_PROG(PORTAGE_DIRNAME, [dirname], no) +dnl avoid bash internal variable messing up things here +GENTOO_PATH_GNUPROG(PORTAGE_BASH, [bash]) +GENTOO_PATH_GNUPROG(PORTAGE_SED, [sed]) +GENTOO_PATH_GNUPROG(PORTAGE_WGET, [wget]) +GENTOO_PATH_GNUPROG(PORTAGE_FIND, [find]) +GENTOO_PATH_GNUPROG(PORTAGE_XARGS, [xargs]) +GENTOO_PATH_GNUPROG(PORTAGE_GREP, [grep]) + +AC_ARG_WITH(portage-user, +AC_HELP_STRING([--with-portage-user=myuser],[use user 'myuser' as portage owner (default portage)]), +[case "${withval}" in + ""|yes) AC_MSG_ERROR(bad value ${withval} for --with-portage-user);; + *) portageuser="${withval}";; +esac], +[portageuser="portage"]) + +AC_ARG_WITH(portage-group, +AC_HELP_STRING([--with-portage-group=mygroup],[use group 'mygroup' as portage users group (default portage)]), +[case "${withval}" in + ""|yes) AC_MSG_ERROR(bad value ${withval} for --with-portage-group);; + *) portagegroup="${withval}";; +esac], +[portagegroup="portage"]) + +AC_ARG_WITH(root-user, +AC_HELP_STRING([--with-root-user=myuser],[uses 'myuser' as owner of installed files (default is portage-user)]), +[case "${withval}" in + ""|yes) AC_MSG_ERROR(bad value ${withval} for --with-root-user);; + *) rootuser="${withval}";; +esac], +[rootuser="${portageuser}"]) + +AC_MSG_CHECKING([for user id of ${rootuser}]) +dnl grab uid of rootuser +rootuid=`${XCU_ID} -u "${rootuser}"` +if test "x`echo ${rootuid} | ${EGREP} '^[[0-9]]+$'`" != "x" +then + AC_MSG_RESULT([${rootuid}]) +else + AC_MSG_ERROR([error finding the user id of ${rootuser}]) +fi +AC_MSG_CHECKING([for group id of ${rootuser}]) +rootgid=`${XCU_ID} -g "${rootuser}"` +if test "x`echo ${rootgid} | ${EGREP} '^[[0-9]]+$'`" != "x" +then + AC_MSG_RESULT([${rootgid}]) +else + AC_MSG_ERROR([error finding the group id of ${rootuser}]) +fi + +AC_ARG_WITH(offset-prefix, +AC_HELP_STRING([--with-offset-prefix], + [specify the installation prefix for all packages, defaults to an empty string]), + [PORTAGE_EPREFIX=$withval], + [PORTAGE_EPREFIX='']) + +if test "x$PORTAGE_EPREFIX" != "x" +then + PORTAGE_EPREFIX=`${PREFIX_PORTAGE_PYTHON} -c "import os; print(os.path.normpath('$PORTAGE_EPREFIX'))"` - DEFAULT_PATH="${PORTAGE_EPREFIX}/usr/sbin:${PORTAGE_EPREFIX}/usr/bin:${PORTAGE_EPREFIX}/sbin:${PORTAGE_EPREFIX}/bin" - else - # this is what trunk uses in ebuild.sh - DEFAULT_PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" +fi + +AC_ARG_WITH(extra-path, +AC_HELP_STRING([--with-extra-path], [specify additional PATHs available to the portage build environment (use with care)]), +[EXTRA_PATH="$withval"], +[EXTRA_PATH=""]) + +AC_SUBST(portageuser) +AC_SUBST(portagegroup) +AC_SUBST(rootuser) +AC_SUBST(rootuid) +AC_SUBST(rootgid) +AC_SUBST(PORTAGE_EPREFIX) - AC_SUBST(DEFAULT_PATH) +AC_SUBST(EXTRA_PATH) +AC_SUBST(PORTAGE_BASE,['${exec_prefix}/lib/portage']) + +AC_SUBST(PORTAGE_RM) +AC_SUBST(PORTAGE_MV) +AC_SUBST(PORTAGE_BASENAME) +AC_SUBST(PORTAGE_DIRNAME) +AC_SUBST(PORTAGE_BASH) +AC_SUBST(PORTAGE_SED) +AC_SUBST(PORTAGE_WGET) +AC_SUBST(PORTAGE_FIND) +AC_SUBST(PORTAGE_XARGS) +AC_SUBST(PORTAGE_GREP) + +AC_CONFIG_FILES([subst-install], [chmod +x subst-install]) +AC_CONFIG_FILES([ + Makefile + man/Makefile + bin/Makefile + lib/Makefile + cnf/Makefile +]) + +AC_OUTPUT diff --cc lib/portage/package/ebuild/_config/special_env_vars.py index e2ea8c393,f4f2bec2c..70a9c83c1 --- a/lib/portage/package/ebuild/_config/special_env_vars.py +++ b/lib/portage/package/ebuild/_config/special_env_vars.py @@@ -80,8 -80,6 +80,9 @@@ environ_whitelist += "ROOT", "ROOTPATH", "SYSROOT", "T", "TMP", "TMPDIR", "USE_EXPAND", "USE_ORDER", "WORKDIR", "XARGS", "__PORTAGE_TEST_HARDLINK_LOCKS", - "DEFAULT_PATH", "EXTRA_PATH", - "PORTAGE_GROUP", "PORTAGE_USER", ++ # PREFIX LOCAL ++ "EXTRA_PATH", "PORTAGE_GROUP", "PORTAGE_USER", ++ # END PREFIX LOCAL ] # user config variables diff --cc lib/portage/package/ebuild/doebuild.py index 83b1f66a9,47c69967c..77c9c713a --- a/lib/portage/package/ebuild/doebuild.py +++ b/lib/portage/package/ebuild/doebuild.py @@@ -247,11 -243,16 +244,22 @@@ def _doebuild_path(settings, eapi=None) for x in portage_bin_path: path.append(os.path.join(x, "ebuild-helpers")) path.extend(prerootpath) - path.extend(defaultpath) + + for prefix in prefixes: + prefix = prefix if prefix else "/" + for x in ("usr/local/sbin", "usr/local/bin", "usr/sbin", "usr/bin", "sbin", "bin"): + # Respect order defined in ROOTPATH + x_abs = os.path.join(prefix, x) + if x_abs not in rootpath_set: + path.append(x_abs) + path.extend(rootpath) ++ ++ # PREFIX LOCAL: append EXTRA_PATH from make.globals ++ extrapath = [x for x in settings.get("EXTRA_PATH", "").split(":") if x] + path.extend(extrapath) + # END PREFIX LOCAL + settings["PATH"] = ":".join(path) def doebuild_environment(myebuild, mydo, myroot=None, settings=None, diff --cc subst-install.in index 033fa981b,000000000..e9f375d76 mode 100644,000000..100644 --- a/subst-install.in +++ b/subst-install.in @@@ -1,75 -1,0 +1,74 @@@ +#!@PORTAGE_BASH@ + +# for expansion below we need some things to be defined +prefix="@prefix@" +exec_prefix="@exec_prefix@" + +# For bug #279550 we have to do some nasty trick to make sure that sed +# doesn't strip the backslash in the replacement value (because it can +# be a backreference) and hence escape those. Eventually in strings we +# need to escape the backslash too, such that the single backslash +# doesn't get lost when considered an invalid escape +rootuser='@rootuser@' +portagegroup='@portagegroup@' +portageuser='@portageuser@' +rootuser=${rootuser//\\/\\\\} +portagegroup=${portagegroup//\\/\\\\\\\\} +portageuser=${portageuser//\\/\\\\\\\\} + +# there are many ways to do this all dynamic, but we only care for raw +# speed here, so let configure fill in this list and be done with it +at='@' +sedexp=( - -e "s,${at}DEFAULT_PATH${at},@DEFAULT_PATH@,g" + -e "s,${at}EXTRA_PATH${at},@EXTRA_PATH@,g" + -e "s,${at}PORTAGE_BASE${at},@PORTAGE_BASE@,g" + -e "s,${at}PORTAGE_BASH${at},@PORTAGE_BASH@,g" + -e "s,${at}PORTAGE_EPREFIX${at},@PORTAGE_EPREFIX@,g" + -e "s,${at}PORTAGE_MV${at},@PORTAGE_MV@,g" + -e "s,${at}PREFIX_PORTAGE_PYTHON${at},@PREFIX_PORTAGE_PYTHON@,g" + -e "s,${at}datadir${at},@datadir@,g" + -e "s,${at}portagegroup${at},${portagegroup},g" + -e "s,${at}portageuser${at},${portageuser},g" + -e "s,${at}rootgid${at},@rootgid@,g" + -e "s,${at}rootuid${at},@rootuid@,g" + -e "s,${at}rootuser${at},${rootuser},g" + -e "s,${at}sysconfdir${at},@sysconfdir@,g" +) + +sources=( ) +target= +args=( "$@" ) + +while [[ ${#@} != 0 ]] ; do + case "$1" in + -t) + [[ -n ${target} ]] && sources=( "${sources[@]}" "${target##*/}" ) + shift + target=":${1}" + ;; + -*) + shift + ;; + *) + if [[ -z ${target} ]] ; then + target="${1}" + elif [[ ${target} != ":"* ]] ; then + sources=( "${sources[@]}" "${target##*/}" ) + target="${1}" + else + sources=( "${sources[@]}" "${1##*/}" ) + fi + ;; + esac + shift +done + +target=${target#:} +INSTALL="@INSTALL@" +echo @INSTALL_DATA@ "${args[@]}" +if [[ ! -d ${target} ]] ; then + # either install will die, or it was just a single file copy + @INSTALL_DATA@ "${args[@]}" && sed -i "${sedexp[@]}" "${target}" +else + @INSTALL_DATA@ "${args[@]}" && sed -i "${sedexp[@]}" "${sources[@]/#/${target}/}" +fi diff --cc travis.sh index 3c03149e6,000000000..bcb95a9cb mode 100755,000000..100755 --- a/travis.sh +++ b/travis.sh @@@ -1,32 -1,0 +1,31 @@@ +#!/usr/bin/env bash + +# this script runs the tests as Travis would do (.travis.yml) and can be +# used to test the Prefix branch of portage on a non-Prefix system + +: ${TMPDIR=/var/tmp} + +HERE=$(dirname $(realpath ${BASH_SOURCE[0]})) +REPO=${HERE##*/}.$$ + +cd ${TMPDIR} +git clone ${HERE} ${REPO} + +cd ${REPO} +printf "[build_ext]\nportage-ext-modules=true" >> setup.cfg +find . -type f -exec \ + sed -e "s|@PORTAGE_EPREFIX@||" \ + -e "s|@PORTAGE_BASE@|${PWD}|" \ + -e "s|@PORTAGE_MV@|$(type -P mv)|" \ + -e "s|@PORTAGE_BASH@|$(type -P bash)|" \ + -e "s|@PREFIX_PORTAGE_PYTHON@|$(type -P python)|" \ - -e "s|@DEFAULT_PATH@|${EPREFIX}/usr/bin:${EPREFIX}/bin|" \ + -e "s|@EXTRA_PATH@|${EPREFIX}/usr/sbin:${EPREFIX}/sbin|" \ + -e "s|@portagegroup@|$(id -gn)|" \ + -e "s|@portageuser@|$(id -un)|" \ + -e "s|@rootuser@|$(id -un)|" \ + -e "s|@rootuid@|$(id -u)|" \ + -e "s|@rootgid@|$(id -g)|" \ + -e "s|@sysconfdir@|${EPREFIX}/etc|" \ + -i '{}' + +unset EPREFIX +./setup.py test