Merged from trunk 5565:5581
authorFabian Groffen <grobian@gentoo.org>
Fri, 12 Jan 2007 22:54:13 +0000 (22:54 -0000)
committerFabian Groffen <grobian@gentoo.org>
Fri, 12 Jan 2007 22:54:13 +0000 (22:54 -0000)
add some invalid ops to getcpv to make sure it returns the cpv still
(WarnerBro)

print the incorrect atom (WarnerBro)

Valid categories in catpkgsplit (WarnerBro)

catch and validate new ValueError Exception (WarnerBro)

Fix comments for catpkgsplit (WarnerBro)

Handle the exception in isvalidatom, change it to use a portage
exceptoin, thanks to Zac for pointing this out (WarnerBro)

learn to spell (WarnerBro)

SpanKY likes the latin categories (WarnerBro)

Use a global to ensure that the valid_category regex is cached.

dont compress files that are already compressed and dont do sanity
checking on the link dest as we cant properly verify things like
absolute symlinks (SpankMan)

use cached suffix value and if it is not valid, lets warn (SpankMan)

Allow catpkgsplit to be less strict for atoms that come from installed
packages (for backward compatibility).

Fix ebuild environment color.map support so that it works properly
through exec calls (since the color variables can not be directly
exported due to env pollution).

drop lazy bindings check once and for all ... the system ldso should
have the logic #71609 (SpankMan)

For bug #147512, don't print a cryptic error message when an
EnvironmentError occurs.  Also, allow the user to get a traceback via
--debug.

Change vercmp to use int() instead of string atoi, catch ValueError in
pkgcmp (WarnerBro)

svn path=/main/branches/prefix/; revision=5618

bin/ecompressdir
bin/emerge
bin/isolated-functions.sh
bin/misc-functions.sh
pym/portage.py
pym/portage_dep.py
pym/portage_versions.py
tests/portage_dep/test_dep_getcpv.py
tests/portage_dep/test_isvalidatom.py

index 405f8e2f542c9a093774412270fd5edb82d5a4c9..3f6fb251ec79a5861fe42b1b998a81fe349d1f98 100755 (executable)
@@ -10,7 +10,10 @@ fi
 
 # figure out the new suffix
 suffix=$(ecompress --suffix)
-[[ -z ${suffix} ]] && exit 0
+if [[ -z ${suffix} ]] ; then
+       vecho "${0##*/}: unable to figure out compressed suffix"
+       exit 1
+fi
 
 source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
 
@@ -25,19 +28,14 @@ for dir in "$@" ; do
                vecho "${0##*/}: $(ecompress --bin) ${dir#${D}}"
        fi
 
-       find "${dir}" -type f -print0 | xargs -0 ecompress
+       find "${dir}" -type f '!' -name '*'${suffix} -print0 | xargs -0 ecompress
        ((ret+=$?))
        find -L "${dir}" -type l | \
        while read brokenlink ; do
                olddest=$(readlink "${brokenlink}")
                newdest="${olddest}${suffix}"
-               if [[ -e ${newdest} ]] ; then
-                       ln -snf "${newdest}" "${brokenlink}"
-                       ((ret+=$?))
-               else
-                       vecho "ecompressdir: unknown broken symlink: ${brokenlink}"
-                       ((++ret))
-               fi
+               ln -snf "${newdest}" "${brokenlink}"
+               ((ret+=$?))
        done
 done
 
index 75d4cb7214c6e253884d4c65d24478fb45ff9bbe..5eec86e18d6a1ec5c427416cfffa728560c2d37d 100755 (executable)
@@ -4991,6 +4991,8 @@ def emerge_main():
        # together with EMERGE_DEFAULT_OPTS (which may vary depending on the
        # the value of --config-root).
        myaction, myopts, myfiles = parse_opts(sys.argv[1:], silent=True)
+       if "--debug" in myopts:
+               os.environ["PORTAGE_DEBUG"] = "1"
        if "--config-root" in myopts:
                os.environ["PORTAGE_CONFIGROOT"] = myopts["--config-root"]
 
index 25ef146a137fa0523402117c538f335d1216f550..1862d87b0ccbe966ca0f75fa348baa6b6ebae597 100644 (file)
@@ -211,16 +211,18 @@ set_colors() {
 
        ENDCOL=$'\e[A\e['${COLS}'C'    # Now, ${ENDCOL} will move us to the end of the
                                       # column;  irregardless of character width
-
-       [ -z "${GOOD}"    ] && GOOD=$'\e[32;01m'
-       [ -z "${WARN}"    ] && WARN=$'\e[33;01m'
-       [ -z "${BAD}"     ] && BAD=$'\e[31;01m'
-       [ -z "${HILITE}"  ] && HILITE=$'\e[36;01m'
-       [ -z "${BRACKET}" ] && BRACKET=$'\e[34;01m'
+       if [ -n "${PORTAGE_COLORMAP}" ] ; then
+               eval ${PORTAGE_COLORMAP}
+       else
+               GOOD=$'\e[32;01m'
+               WARN=$'\e[33;01m'
+               BAD=$'\e[31;01m'
+               HILITE=$'\e[36;01m'
+               BRACKET=$'\e[34;01m'
+       fi
        NORMAL=$'\e[0m'
 }
 
-export -n GOOD WARN BAD HILITE BRACKET
 RC_ENDCOL="yes"
 RC_INDENTATION=''
 RC_DEFAULT_INDENT=2
index cdc2eb7a391c6aa531a2ec9cd0f058bb2d8eb16d..3a4931787e209b9a3e67d6d134e2d4b21fc7d057 100644 (file)
@@ -95,20 +95,6 @@ install_qa_check() {
                        fi
                fi
 
-               # Check for setid binaries but are not built with BIND_NOW
-               f=$(scanelf -qyRF '%b %p' "${ED}")
-               if [[ -n ${f} ]] ; then
-                       vecho -ne '\a\n'
-                       eqawarn "QA Notice: The following files are setXid, dyn linked, and using lazy bindings"
-                       eqawarn " This combination is generally discouraged.  Try re-emerging the package:"
-                       eqawarn " LDFLAGS='-Wl,-z,now' emerge ${PN}"
-                       eqawarn "${f}"
-                       vecho -ne '\a\n'
-                       # Do not fail here until we have sorted out the lazy issues with security team
-                       #die_msg="${die_msg} setXid lazy bindings,"
-                       sleep 1
-               fi
-
                # TEXTREL's are baaaaaaaad
                # Allow devs to mark things as ignorable ... e.g. things that are
                # binary-only and upstream isn't cooperating (nvidia-glx) ... we
index 5416f924f1805f5bbd8f765cc303eabf79c71031..ea43e5d648ffd3884fbeb751d1971375654797a3 100644 (file)
@@ -895,6 +895,8 @@ class config:
                @type local_config: Boolean
                """
 
+               debug = os.environ.get("PORTAGE_DEBUG") == "1"
+
                self.already_in_regenerate = 0
 
                self.locked   = 0
@@ -1134,9 +1136,12 @@ class config:
                        except SystemExit, e:
                                raise
                        except Exception, e:
+                               if debug:
+                                       raise
                                writemsg("!!! %s\n" % (e), noiselevel=-1)
-                               writemsg("!!! Incorrect multiline literals can cause this. Do not use them.\n", noiselevel=-1)
-                               writemsg("!!! Errors in this file should be reported on bugs.gentoo.org.\n")
+                               if not isinstance(e, EnvironmentError):
+                                       writemsg("!!! Incorrect multiline literals can cause " + \
+                                               "this. Do not use them.\n", noiselevel=-1)
                                sys.exit(1)
                        self.configlist.append(self.mygcfg)
                        self.configdict["globals"]=self.configlist[-1]
@@ -1158,13 +1163,18 @@ class config:
                                except SystemExit, e:
                                        raise
                                except Exception, e:
+                                       if debug:
+                                               raise
                                        writemsg("!!! %s\n" % (e), noiselevel=-1)
-                                       writemsg("!!! 'rm -Rf %s/usr/portage/profiles; emerge sync' may fix this. If it does\n" % EPREFIX,
-                                               noiselevel=-1)
-                                       writemsg("!!! not then please report this to bugs.gentoo.org and, if possible, a dev\n",
-                                               noiselevel=-1)
-                                       writemsg("!!! on #gentoo (irc.freenode.org)\n",
-                                               noiselevel=-1)
+                                       if not isinstance(e, EnvironmentError):
+                                               writemsg("!!! 'rm -Rf %s/usr/portage/profiles; " + \
+                                                       "emerge sync' may fix this. If it does\n" % EPREFIX,
+                                                       noiselevel=-1)
+                                               writemsg("!!! not then please report this to " + \
+                                                       "bugs.gentoo.org and, if possible, a dev\n",
+                                                               noiselevel=-1)
+                                               writemsg("!!! on #gentoo (irc.freenode.org)\n",
+                                                       noiselevel=-1)
                                        sys.exit(1)
                        self.configlist.append(self.mygcfg)
                        self.configdict["defaults"]=self.configlist[-1]
@@ -1178,9 +1188,12 @@ class config:
                        except SystemExit, e:
                                raise
                        except Exception, e:
+                               if debug:
+                                       raise
                                writemsg("!!! %s\n" % (e), noiselevel=-1)
-                               writemsg("!!! Incorrect multiline literals can cause this. Do not use them.\n",
-                                       noiselevel=-1)
+                               if not isinstance(e, EnvironmentError):
+                                       writemsg("!!! Incorrect multiline literals can cause " + \
+                                               "this. Do not use them.\n", noiselevel=-1)
                                sys.exit(1)
 
                        # Allow ROOT setting to come from make.conf if it's not overridden
@@ -2983,8 +2996,10 @@ def doebuild_environment(myebuild, mydo, myroot, mysettings, debug, use_cache, m
                mysettings["KVERS"]=myso[1]
 
        # Allow color.map to control colors associated with einfo, ewarn, etc...
+       mycolors = []
        for c in ("GOOD", "WARN", "BAD", "HILITE", "BRACKET"):
-               mysettings[c] = output.codes[c]
+               mycolors.append("%s=$'%s'" % (c, output.codes[c]))
+       mysettings["PORTAGE_COLORMAP"] = "\n".join(mycolors)
 
 def prepare_build_dirs(myroot, mysettings, cleanup):
 
index 545884409f46fea2e982a160768d5d7953a83093..f6131cc470c97d7bc2dbb01e65e1ac0c14c1ed36 100644 (file)
@@ -20,6 +20,7 @@
 
 import re, string, sys, types
 import portage_exception
+from portage_exception import InvalidData
 from portage_versions import catpkgsplit, catsplit, pkgcmp, pkgsplit, ververify
 
 def cpvequal(cpv1, cpv2):
@@ -359,7 +360,10 @@ def isvalidatom(atom, allow_blockers=False):
                return 0
        if allow_blockers and atom.startswith("!"):
                atom = atom[1:]
-       mycpv_cps = catpkgsplit(dep_getcpv(atom))
+       try:
+               mycpv_cps = catpkgsplit(dep_getcpv(atom))
+       except InvalidData:
+               return 0
        operator = get_operator(atom)
        if operator:
                if operator[0] in "<>" and atom[-1] == "*":
@@ -614,9 +618,7 @@ def match_from_list(mydep, candidate_list):
                for x in candidate_list:
                        try:
                                result = pkgcmp(pkgsplit(x), mysplit)
-                       except SystemExit:
-                               raise
-                       except:
+                       except ValueError:
                                writemsg("\nInvalid package name: %s\n" % x, noiselevel=-1)
                                raise
                        if result is None:
index ba46dd6ec98a88b4d3429044d7f9b72ab30646d9..16073ba7aeb2dc768403f7762722ffd453dc7d2d 100644 (file)
@@ -11,6 +11,7 @@ suffix_regexp = re.compile("^(alpha|beta|rc|pre|p)(\\d*)$")
 suffix_value = {"pre": -2, "p": 0, "alpha": -4, "beta": -3, "rc": -1}
 endversion_keys = ["pre", "p", "alpha", "beta", "rc"]
 
+from portage_exception import InvalidData
 
 def ververify(myver, silent=1):
        if ver_regexp.match(myver):
@@ -75,9 +76,9 @@ def vercmp(ver1, ver2, silent=1):
        
        # building lists of the version parts before the suffix
        # first part is simple
-       list1 = [string.atoi(match1.group(2))]
-       list2 = [string.atoi(match2.group(2))]
-       
+       list1 = [int(match1.group(2))]
+       list2 = [int(match2.group(2))]
+
        # this part would greatly benefit from a fixed-length version pattern
        if len(match1.group(3)) or len(match2.group(3)):
                vlist1 = match1.group(3)[1:].split(".")
@@ -262,9 +263,29 @@ def pkgsplit(mypkg,silent=1):
                pkgcache[mypkg]=None
                return None
 
+_valid_category = re.compile("^\w[\w-]*")
+
 catcache={}
 def catpkgsplit(mydata,silent=1):
-       "returns [cat, pkgname, version, rev ]"
+       """
+       Takes a Category/Package-Version-Rev and returns a list of each.
+       
+       @param mydata: Data to split
+       @type mydata: string 
+       @param silent: suppress error messages
+       @type silent: Boolean (integer)
+       @rype: list
+       @return:
+       1.  If each exists, it returns [cat, pkgname, version, rev]
+       2.  If cat is not specificed in mydata, cat will be "null"
+       3.  if rev does not exist it will be '-r0'
+       4.  If cat is invalid (specified but has incorrect syntax)
+               an InvalidData Exception will be thrown
+       """
+       
+       # Categories may contain a-zA-z0-9+_- but cannot start with -
+       global _valid_category
+       import portage_dep
        try:
                if not catcache[mydata]:
                        return None
@@ -277,6 +298,9 @@ def catpkgsplit(mydata,silent=1):
                retval=["null"]
                p_split=pkgsplit(mydata,silent=silent)
        elif len(mysplit)==2:
+               if portage_dep._dep_check_strict and \
+                       not _valid_category.match(mysplit[0]):
+                       raise InvalidData("Invalid category in %s" %mydata )
                retval=[mysplit[0]]
                p_split=pkgsplit(mysplit[1],silent=silent)
        if not p_split:
index 6928794a4728cad7c248b342f48ea1f311b6f61e..90e1b6e56bc30524b68f320e4a84e18233ad8210 100644 (file)
@@ -14,6 +14,8 @@ class DepGetCPV(TestCase):
                
                prefix_ops = ["<", ">", "=", "~", "!", "<=", 
                              ">=", "!=", "!<", "!>", "!~",""]
+
+               bad_prefix_ops = [ ">~", "<~", "~>", "~<" ]
                postfix_ops = [ "*", "" ]
 
                cpvs = ["sys-apps/portage"]
@@ -23,3 +25,7 @@ class DepGetCPV(TestCase):
                                for postfix in postfix_ops:
                                        self.assertEqual( dep_getcpv( 
                                                prefix + cpv + postfix ), cpv )
+                       for prefix in bad_prefix_ops:
+                               for postfix in postfix_ops:
+                                       self.assertNotEqual( dep_getcpv(
+                                               prefix + cpv + postfix ), cpv )
index 84225fa78357a32d576fa028737466bd3f424ef3..7835fbd0c984a3be8ddd4b32a017827f9e250013 100644 (file)
@@ -32,5 +32,5 @@ class IsValidAtom(TestCase):
                                atom_type = "valid"
                        else:
                                atom_type = "invalid"
-
-                       self.assertEqual( bool(isvalidatom( test[0] )), test[1] )
+                       self.assertEqual( bool(isvalidatom( test[0] )), test[1],
+                               msg="isvalidatom(%s) != %s" % ( test[0], test[1] ) )