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 1Pt0sh-0002WZ-Pa for garchives@archives.gentoo.org; Fri, 25 Feb 2011 16:51:04 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 7A520E06F9; Fri, 25 Feb 2011 16:50:56 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 3AC3CE06F9 for ; Fri, 25 Feb 2011 16:50:56 +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 9966C1B4018 for ; Fri, 25 Feb 2011 16:50:55 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 036BA8006E for ; Fri, 25 Feb 2011 16:50:55 +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: <4dfe8e7e2fb3338d3473ddfd59f0f81d003e8cc1.fuzzyray@gentoo> 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: 4dfe8e7e2fb3338d3473ddfd59f0f81d003e8cc1 Date: Fri, 25 Feb 2011 16:50:55 +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: f6fadedf83511f40079c62ada63a94d9 commit: 4dfe8e7e2fb3338d3473ddfd59f0f81d003e8cc1 Author: Paul Varner gentoo org> AuthorDate: Fri Feb 25 16:21:04 2011 +0000 Commit: Paul Varner gentoo org> CommitDate: Fri Feb 25 16:21:04 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/gentoolkit.gi= t;a=3Dcommit;h=3D4dfe8e7e Apply latest changes from Jared Hancock Fixes described issues from: http://bugs.gentoo.org/show_bug.cgi?id=3D259318#c88 "It's now more vocal when handling global flags, and does not indicate make.conf was edited if it was not. Actually, more specifically, it does not modify make.conf unnecessarily. (As before, it modified make.conf every time regardless of whether or not it changed anything) Also fixed the issue with removing and disabling multiple flags for a package." --- bin/euse | 121 ++++++++++++++++++++++++--------------------------------= ----- 1 files changed, 48 insertions(+), 73 deletions(-) diff --git a/bin/euse b/bin/euse index 175febb..10e9044 100755 --- a/bin/euse +++ b/bin/euse @@ -936,11 +936,13 @@ add_flag() { return 1 else NEW_MAKE_CONF_USE=3D"${NEW_MAKE_CONF_USE} ${1}" + echo "Adding flag \"${1}\" to make.conf" >&2 fi } =20 remove_flag() { NEW_MAKE_CONF_USE=3D"${NEW_MAKE_CONF_USE// ${1} / }" + echo "Removing flag \"${1}\" from make.conf" >&2 } =20 # Function: clean_package_use {{{ @@ -1035,6 +1037,7 @@ modify_package() { while [[ -n ${2} ]]; do shift local flag=3D${1} + local method=3D"add" ACTIVE=3D"-" # # Fetch flag ACTIVE status (+,-,null) @@ -1045,8 +1048,15 @@ modify_package() { get_flagstatus_pkg "${flag}" "${pkg}" "${ACTIVE}" "${V}" > /dev/null # # --- Sanity checks - # (1) make sure ${pkg} exists in portdir - if [[ ! -d "$(get_portdir)/${pkg}" ]]; then + # (1) make sure ${pkg} exists in portdir or an overlay + local exists=3D1 + for portdir in ${ALL_PORTDIRS[@]}; do + if [[ -d "${portdir}/${pkg}" ]]; then + exists=3D0 + break + fi + done + if [[ $exists =3D=3D 1 ]]; then fatal "Package \"${pkg}\" does not exist" # # (2) make sure ${flag} is defined in get_useflaglist @@ -1067,66 +1077,24 @@ modify_package() { error "Invalid package atom. Did you forget the version?" continue fi - # If flag is enabled in portage USE flags (emerge --info),=20 - # then "remove"ing the flag should be replaced with adding - # the negative flag instead + # If removing a disabled flag, or addind an enabled one, emit a warning= , + # indicating a likely misunderstanding if [[ "${ACTION}" =3D=3D "remove" ]]; then - if [[ "${ACTIVE:-${GLOBAL_ACTIVE}}" =3D=3D "+" ]]; then - if [[ -n $(echo "${ACTIVE_FLAGS[4]}" | grep "^$PACKAGE" \ - | grep " $flag") ]]; then - iuse=3D$(echo "${ACTIVE_FLAGS[5]} " | grep -Ee "^${pkg_re}" \ - | cut -d ";" -f4 | egrep -o "[+-]?${flag}") - # Ensure the flag is enabled in the ebuild _and_ in package.use, - # if so, enable it in package.use - if [[ "${iuse}" =3D~ "+" ]]; then - # The flag is currently enabled in the ebuild, so add a - # disablement - flag=3D"-${flag}" - ACTION=3D"add" - fi - else - # Not enabled in package.use, so disable it there - flag=3D"-${flag}" - ACTION=3D"add" - fi - else - error "USE flag \"$flag\" is already disabled for $PACKAGE" - continue + if [[ "${ACTIVE:-${GLOBAL_ACTIVE}}" =3D=3D "-" ]]; then + warn "USE flag \"$flag\" is already disabled for $PACKAGE" fi + flag=3D"-${flag}" elif [[ "${ACTION}" =3D=3D "prune" ]]; then # Just remove the flag below [[ "${ACTIVE}" =3D=3D "-" ]] && flag=3D"-${flag}" - ACTION=3D"remove" - # If flag is currently disabled for the package requested=20 - # to be enabled in, then "remove" the negative + method=3D"remove" elif [[ "${ACTION}" =3D=3D "add" ]]; then - if [[ "${ACTIVE}" =3D=3D "-" ]]; then - # If flag is masked, it should be added to package.mask, instead - # of package.use. For now, yield a warning and quit - if [[ -n $(echo " ${ACTIVE_FLAGS[6]}" | grep " -${flag} ") ]]; then - error "USE flag \"$flag\" is masked. Enabling in package.use will" \ - "\nbe ineffective. You may have an incorrect profile selected." - continue - elif [[ -n $(echo "${ACTIVE_FLAGS[4]}" | grep "^$PACKAGE" \ - | grep " -$flag") ]]; then - iuse=3D$(echo "${ACTIVE_FLAGS[5]} " | grep -Ee "^${pkg_re}" \ - | cut -d ";" -f4 | egrep -o "[+-]?${flag}") - # Ensure the flag is disabled in the ebuild _and_ in package.use, - # if so, enable it in package.use - if [[ "${iuse}" =3D~ "+" ]]; then - # The flag is currently disabled by package.use only, so remove the - # disablement - flag=3D"-${flag}" - ACTION=3D"remove" - fi - fi - elif [[ "${ACTIVE:-${GLOBAL_ACTIVE:--}}" =3D=3D "+" ]]; then + if [[ "${ACTIVE:-${GLOBAL_ACTIVE:--}}" =3D=3D "+" ]]; then # XXX: Perhaps look at indicating where it is enabled - error "USE flag \"$flag\" is already enabled for $PACKAGE" - continue + warn "USE flag \"$flag\" is already enabled for $PACKAGE" fi fi - case "${ACTION}" in + case "${method}" in "add") local filename if [[ -d ${PACKAGE_USE_PATH} ]]; then @@ -1198,6 +1166,8 @@ modify() { return; fi; =20 + local make_conf_modified=3D0 + if [ -z "${*}" ]; then if [ "${ACTION}" !=3D "prune" ]; then echo "WARNING: no USE flags listed for modification, do you really" @@ -1212,41 +1182,45 @@ modify() { =20 NEW_MAKE_CONF_USE=3D" ${ACTIVE_FLAGS[1]} " =20 - while [ -n "${1}" ]; do - if [ "${ACTION}" =3D=3D "add" ]; then - if echo " ${NEW_MAKE_CONF_USE} " | grep " ${1} " > /dev/null; then + while [[ -n "${1}" ]]; do + if [[ "${ACTION}" =3D=3D "add" ]]; then + if [[ -n $(grep " ${1} " <<< " ${NEW_MAKE_CONF_USE} ") ]]; then + warn "Use flag \"${1}\" is already enabled globally" shift - elif echo " ${NEW_MAKE_CONF_USE} " | grep " -${1} " > /dev/null; then - remove_flag "-${1}" + elif [[ -n $(grep " -${1} " <<< " ${NEW_MAKE_CONF_USE} ") ]]; then + remove_flag "-${1}" || exit + make_conf_modified=3D1 else add_flag "${1}" || exit + make_conf_modified=3D1 shift fi - elif [ "${ACTION}" =3D=3D "remove" ]; then - if echo " ${NEW_MAKE_CONF_USE} " | grep " -${1} " > /dev/null; then + elif [[ "${ACTION}" =3D=3D "remove" ]]; then + if [[ -n $(grep " -${1} " <<< " ${NEW_MAKE_CONF_USE} ") ]]; then + warn "Use flag \"${1}\" is already disabled globally" shift - elif echo " ${NEW_MAKE_CONF_USE} " | grep " ${1} " > /dev/null; then - remove_flag "${1}" + elif [[ -n $(grep " ${1} " <<< " ${NEW_MAKE_CONF_USE} ") ]]; then + remove_flag "${1}" || exit + make_conf_modified=3D1 else add_flag "-${1}" || exit + make_conf_modified=3D1 shift fi - elif [ "${ACTION}" =3D=3D "prune" ]; then - if echo " ${NEW_MAKE_CONF_USE} " | grep " ${1} " > /dev/null; then - remove_flag "${1}" - elif echo " ${NEW_MAKE_CONF_USE} " | grep " -${1} " > /dev/null; then - remove_flag "-${1}" + elif [[ "${ACTION}" =3D=3D "prune" ]]; then + if [[ -n $(grep " ${1} " <<< " ${NEW_MAKE_CONF_USE} ") ]]; then + remove_flag "${1}" || exit + make_conf_modified=3D1 + elif [[ -n $(grep " -${1} " <<< " ${NEW_MAKE_CONF_USE} ") ]]; then + remove_flag "-${1}" || exit + make_conf_modified=3D1 + else + warn "Use flag \"${1}\" is not set globally" fi shift fi done =20 - #echo "old flags:" - #echo ${ACTIVE_FLAGS[1]} - #echo - #echo "new flags:" - #echo ${NEW_MAKE_CONF_USE} - # a little loop to add linebreaks so we don't end with one ultra-long l= ine NEW_MAKE_CONF_USE_2=3D"" for x in ${NEW_MAKE_CONF_USE}; do @@ -1257,6 +1231,7 @@ modify() { fi done =20 + [[ ${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}" =20