summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArfrever Frehtes Taifersar Arahesis <arfrever@gentoo.org>2011-05-11 21:29:16 +0000
committerArfrever Frehtes Taifersar Arahesis <arfrever@gentoo.org>2011-05-11 21:29:16 +0000
commite2297ccf7e1636a100f8a69924dcabe0016df953 (patch)
tree3400bb31249b7e2b75496884209992e7b8eb9204
parentUse cave instead of paludis (bug #347897). (diff)
downloadpython-updater-e2297ccf7e1636a100f8a69924dcabe0016df953.tar.gz
python-updater-e2297ccf7e1636a100f8a69924dcabe0016df953.tar.bz2
python-updater-e2297ccf7e1636a100f8a69924dcabe0016df953.zip
Support /etc/portage/env.
-rwxr-xr-xpython-updater52
1 files changed, 47 insertions, 5 deletions
diff --git a/python-updater b/python-updater
index 5ff04f4..706bdb9 100755
--- a/python-updater
+++ b/python-updater
@@ -20,7 +20,7 @@
# PKGS_MISSING = List of packages that are installed, but cannot be merged,
# because they have been pruned from portage.
-VERSION="0.8"
+VERSION="0.9"
OLD_PYTHON_VERSIONS=""
OLD_PYTHON2_VERSIONS=""
OLD_PYTHON3_VERSIONS=""
@@ -37,7 +37,7 @@ VERBOSE=0
PKGS_TO_REMERGE=""
PKGS_COUNT_REMERGE=0
PYTHON2_VERSIONS="2.1 2.2 2.3 2.4 2.5 2.6 2.7"
-PYTHON3_VERSIONS="3.0 3.1 3.2 3.3"
+PYTHON3_VERSIONS="3.0 3.1 3.2 3.3 3.4"
PYTHON_VERSIONS="${PYTHON2_VERSIONS} ${PYTHON3_VERSIONS}"
SUPPORTED_PMS="portage pkgcore paludis"
@@ -162,13 +162,55 @@ get_vdb_variable() {
fi
}
-USE_PYTHON=""
+# set_unless_changed(variable=value)
+# This function can be used in /etc/portage/env.
+set_unless_changed() {
+ if [[ $# -lt 1 ]]; then
+ die "${FUNCNAME}() requires at least 1 argument: VARIABLE=VALUE"
+ fi
+
+ local argument value variable
+ for argument in "$@"; do
+ if [[ ${argument} != *=* ]]; then
+ die "${FUNCNAME}(): Argument '${argument}' has incorrect syntax"
+ fi
+ variable="${argument%%=*}"
+ value="${argument#*=}"
+ if eval "[[ \${${variable}} == \$(env -u ${variable} /usr/bin/portageq envvar ${variable}) ]]"; then
+ eval "${variable}=\"\${value}\""
+ fi
+ done
+}
+
+# unset_unless_changed(variable)
+# This function can be used in /etc/portage/env.
+unset_unless_changed() {
+ if [[ $# -lt 1 ]]; then
+ die "${FUNCNAME}() requires at least 1 argument: VARIABLE"
+ fi
+
+ local variable
+ for variable in "$@"; do
+ if eval "[[ \${${variable}} == \$(env -u ${variable} /usr/bin/portageq envvar ${variable}) ]]"; then
+ unset ${variable}
+ fi
+ done
+}
+
+global_USE_PYTHON=""
# get_USE_PYTHON(CATEGORY, PN, SLOT)
get_USE_PYTHON() {
if [[ "${PMS_COMMAND[${PMS_INDEX}]}" =~ ^(emerge|pmerge)$ ]]; then
- if [[ -z "${USE_PYTHON}" ]]; then
- USE_PYTHON="$(/usr/bin/portageq envvar USE_PYTHON)"
+ if [[ -z "${global_USE_PYTHON}" ]]; then
+ global_USE_PYTHON="$(/usr/bin/portageq envvar USE_PYTHON)"
+ fi
+ USE_PYTHON="${global_USE_PYTHON}"
+ if [[ -f "/etc/portage/env/${1}/${2}" ]]; then
+ USE_PYTHON="$(. "/etc/portage/env/${1}/${2}"; echo "${USE_PYTHON}")"
+ fi
+ if [[ -f "/etc/portage/env/${1}/${2}:${3}" ]]; then
+ USE_PYTHON="$(. "/etc/portage/env/${1}/${2}:${3}"; echo "${USE_PYTHON}")"
fi
else
USE_PYTHON="$(cave print-id-environment-variable "${1}/${2}${3:+:}${3}::/?" --best --format %v --variable-name USE_PYTHON)"