From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1Q4OVt-0003qn-NT for garchives@archives.gentoo.org; Tue, 29 Mar 2011 02:18:33 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 0A2EE1C089; Tue, 29 Mar 2011 02:18:15 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id BF01E1C089 for ; Tue, 29 Mar 2011 02:18:15 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 0B0731B4081 for ; Tue, 29 Mar 2011 02:18:15 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 622CA8006A for ; Tue, 29 Mar 2011 02:18:14 +0000 (UTC) From: "Paul Varner" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Paul Varner" Message-ID: Subject: [gentoo-commits] proj/gentoolkit:gentoolkit commit in: bin/ X-VCS-Repository: proj/gentoolkit X-VCS-Files: bin/euse X-VCS-Directories: bin/ X-VCS-Committer: fuzzyray X-VCS-Committer-Name: Paul Varner X-VCS-Revision: d48d1c9525f6632e9ba58202e028bb517b0a118c Date: Tue, 29 Mar 2011 02:18:14 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: 55a0af3415e82abd5409c12e2016c047 commit: d48d1c9525f6632e9ba58202e028bb517b0a118c Author: Paul Varner gentoo org> AuthorDate: Tue Mar 29 02:12:44 2011 +0000 Commit: Paul Varner gentoo org> CommitDate: Tue Mar 29 02:12:44 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/gentoolkit.gi= t;a=3Dcommit;h=3Dd48d1c95 Latest euse changes from Jared Hancock Prefers /etc/portage/make.conf when modifing global flags only if it defines the USE variable Also fixes a bug where euse would refuse to add hyphenated use flags. So you can: euse -E bash-completion --- bin/euse | 79 ++++++++++++++++++++++++++++++++++++--------------------= ------ 1 files changed, 46 insertions(+), 33 deletions(-) diff --git a/bin/euse b/bin/euse index dbbb129..8262271 100755 --- a/bin/euse +++ b/bin/euse @@ -29,10 +29,13 @@ warn() { echo -e "WARNING: ${*}" } =20 -# /etc/make.conf can now exist in /etc/portage/make.conf, prefer it over= /etc/make.conf for changes -if [ -e "${ETC}/portage/make.conf" ]; then +# /etc/make.conf can now exist in /etc/portage/make.conf, prefer it over +# /etc/make.conf for changes. Since this will only be used for modifying +# the USE variable, we need to make sure the one we pick is the one with +# the USE variable defined. +if [[ -n $(grep '^USE=3D"' "${ETC}/portage/make.conf" 2>/dev/null) ]]; t= hen MAKE_CONF_PATH=3D"${ETC}/portage/make.conf" -elif [ -e "${ETC}/make.conf" ]; then +elif [[ -e "${ETC}/make.conf" ]]; then MAKE_CONF_PATH=3D"${ETC}/make.conf" else fatal "make.conf does not exist" @@ -56,7 +59,7 @@ else fi PACKAGE_USE_PATH=3D${ETC}/portage/package.use =20 -[ -z "${MODE}" ] && MODE=3D"showhelp" # available operation modes: show= help, showversion, showdesc, showflags, modify +[ -z "${MODE:-}" ] && MODE=3D"showhelp" # available operation modes: sh= owhelp, showversion, showdesc, showflags, modify =20 parse_arguments() { if [ -z "${1}" ]; then @@ -74,8 +77,8 @@ parse_arguments() { -E | --enable) MODE=3D"modify"; ACTION=3D"add";; -D | --disable) MODE=3D"modify"; ACTION=3D"remove";; -P | --prune | -R | --remove) - MODE=3D"modify"; ACTION=3D= "prune";; - -p | --package) MODE=3D"modify"; shift; PACKAGE=3D${1}; SCOPE=3D= "local";; + MODE=3D"modify"; ACTION=3D"prune";; + -p | --package) MODE=3D"modify"; shift; PACKAGE=3D${1}; SCOPE=3D= "local";; -*) echo "ERROR: unknown option ${1} specified." echo @@ -83,10 +86,10 @@ parse_arguments() { ;; "%active") get_portageuseflags - ARGUMENTS=3D"${ARGUMENTS} ${ACTIVE_FLAGS[9]}" + ARGUMENTS=3D"${ARGUMENTS:-} ${ACTIVE_FLAGS[9]}" ;; *) - ARGUMENTS=3D"${ARGUMENTS} ${1}" + ARGUMENTS=3D"${ARGUMENTS:-} ${1}" ;; esac shift @@ -128,6 +131,7 @@ check_sanity() { done [ "${MODE}" =3D=3D "modify" -a ! -w "${MAKE_CONF_PATH}" ] && fatal ""${= MAKE_CONF_PATH}" is not writable" [ "${MODE}" =3D=3D "modify" -a -s "${PACKAGE_USE_PATH}" -a ! -w "${PACK= AGE_USE_PATH}" ] && fatal ""${PACKAGE_USE_PATH}" is not writable" + return 0 } # }}} =20 showhelp() { @@ -435,7 +439,7 @@ get_all_make_conf() { traverse_profile() { local curdir local parent - local rvalue + local rvalue=3D"" =09 curdir=3D"${2:-$(get_real_path ${MAKE_PROFILE_PATH})}" =09 @@ -458,7 +462,7 @@ traverse_profile() { # Function: get_all_make_defaults {{{ # Det all make.defaults by traversing the cascaded profile directories get_all_make_defaults() { - if [[ -z $MAKE_DEFAULTS ]]; then + if [[ -z ${MAKE_DEFAULTS:-} ]]; then MAKE_DEFAULTS=3D$(traverse_profile "make.defaults") fi echo $MAKE_DEFAULTS @@ -606,7 +610,7 @@ get_flagstatus() { # Flag status for package.use and ebuild, slot and version, and overlay # the version lives is if not PORTDIR # -# Full positive would be "[+PB]", full negative would be "[-pb], and ful= l=20 +# Full positive would be "[+PB]", full negative would be "[-pb]", and fu= ll=20 # missing would be "[? ]", question because the sign will default to th= e=20 # sign of the global status of the flag get_flagstatus_pkg() { @@ -671,8 +675,10 @@ get_flagstatus_pkg() { # Outputs: # Location of portage tree root get_portdir() { - if [ -z "${PORTDIR}" ]; then - use_backup=3D"${USE}" + # Use a subshell so we don't have to protect the variables in + # the current scope + ( + if [ -z "${PORTDIR:-}" ]; then source "${MAKE_GLOBALS_PATH}" for x in $(get_all_make_defaults); do source "${x}" @@ -680,9 +686,9 @@ get_portdir() { for x in $(get_all_make_conf); do source "${x}" done - USE=3D"${use_backup}" fi echo "${PORTDIR}" + ) } # }}} # This won't change while the script is running, so cache it PORTDIR=3D"$(get_portdir)" @@ -691,10 +697,14 @@ PORTDIR=3D"$(get_portdir)" # Outputs list of portage overlays as defined in the PORTDIR_OVERLAY # variable defined in make.conf=20 get_all_overlays() { - use_backup=3D"${USE}" - source "${MAKE_CONF_PATH}" - USE=3D"${use_backup}" - echo ${PORTDIR_OVERLAY} + # Use a subshell so we don't have to protect the variables in + # the current scope + (=20 + for x in $(get_all_make_conf); do + [[ -r "${x}" ]] && source "${x}" + done + echo ${PORTDIR_OVERLAY} + ) } # }}} ALL_PORTDIRS=3D( "$PORTDIR" $(get_all_overlays) ) =20 @@ -761,8 +771,7 @@ showdesc() { if array_contains "${useflags[*]}" "$1"; then get_flagstatus "${1}" # XXX: Handle overlay - grep "^${1} *-" ${ALL_PORTDIRS[@]/%//profiles/use.desc} 2> /dev/nul= l \ - | sed -re "s/^([^:]+)://" + grep -h "^${1} *-" ${ALL_PORTDIRS[@]/%//profiles/use.desc} 2> /dev/= null foundone=3D1 fi fi @@ -773,14 +782,14 @@ showdesc() { foundone=3D1 fi # Fetch all the packages data using this flag - infos=3D$( grep ":${1} *-" ${ALL_PORTDIRS[@]/%//profiles/use.local.d= esc} 2> /dev/null \ - | sed -re "s/^([^:]+):([^:]+):(${1}) *- *(.+)/\1|\2|\3|\4/g") + infos=3D$( grep -h ":${1} *-" ${ALL_PORTDIRS[@]/%//profiles/use.loca= l.desc} 2> /dev/null \ + | sed -re "s/^([^:]+):(${1}) *- *(.+)/\1|\2|\3/g") OIFS=3D$IFS; IFS=3D$'\n'; infos=3D($infos); IFS=3D$OIFS; for line in "${infos[@]}"; do OIFS=3D$IFS; IFS=3D"|"; line=3D($line); IFS=3D$OIFS - pkg=3D${line[1]}=20 - flag=3D${line[2]} - desc=3D${line[3]} + pkg=3D${line[0]}=20 + flag=3D${line[1]} + desc=3D${line[2]} if get_flagstatus "${flag}"; then ACTIVE=3D"+" else @@ -925,18 +934,22 @@ showflags() { =20 # two small helpers to add or remove a flag from a USE string add_flag() { - if [[ -n $(grep " -${1//-/} " <<< " ${ACTIVE_FLAGS[6]} ") ]]; then - error "Use flag \"${1//-/}\" is masked and should not be added" \ + # Remove leading '-' from flag if found + local flag=3D$1 + [[ ${flag:0:1} =3D=3D "-" ]] && flag=3D${1:1} + + if [[ -n $(grep " -${flag} " <<< " ${ACTIVE_FLAGS[6]} ") ]]; then + error "Use flag \"${flag}\" is masked and should not be added" \ "to make.conf." return 1 # Bug #104396 -- Only add use flags defined in use.desc and use.local.d= esc - elif [[ -z $(grep "^${1//-/}$" <<< "$(get_useflaglist)") ]]; then - error "Use flag \"${1//-/}\" is not defined in use.desc and should" \ + elif [[ -z $(grep "^${flag}$" <<< "$(get_useflaglist)") ]]; then + error "Use flag \"${flag}\" is not defined in use.desc and should" \ "not be added\nto make.conf." return 1 else NEW_MAKE_CONF_USE=3D"${NEW_MAKE_CONF_USE} ${1}" - echo "Adding flag \"${1}\" to make.conf" >&2 + echo "Adding flag \"${1}\" to make.conf" >&2 fi } =20 @@ -981,9 +994,8 @@ scrub_use_flag() { elif [[ -n "${PACKAGE}" ]]; then if [[ -n $(echo "${line}" | grep -Ee "${pkg_re}") ]]; then=09 # If this is the only (remaining) use flag defined - # for this package, then remove the whole line - if [[ -z $(echo "${line}" | \ - grep -Ee "${pkg_re} *-?${flag} *$") ]]; then + # for this package, then remove the whole line + if [[ -z $(echo "${line}" | grep -Ee "${pkg_re} *-?${flag} *$") ]]; th= en # Remove flag from this line echo "${line}" | sed -re "s/ *-?\b${flag}\b//" fi @@ -1231,6 +1243,7 @@ modify() { fi done =20 + # Bail if there is no need to modify make.conf [[ ${make_conf_modified} =3D=3D 1 ]] || return # make a backup just in case the user doesn't like the new make.conf cp -p "${MAKE_CONF_PATH}" "${MAKE_CONF_BACKUP_PATH}"