Merged from trunk 7903:7908
authorFabian Groffen <grobian@gentoo.org>
Fri, 5 Oct 2007 18:22:18 +0000 (18:22 -0000)
committerFabian Groffen <grobian@gentoo.org>
Fri, 5 Oct 2007 18:22:18 +0000 (18:22 -0000)
   | 7904     | In the EbuildQuote check, combine the var_assignment regex  |
   | zmedico  | together with the ignore_line regex. This also fixes an     |
   |          | issue with the var_assignment regex allowing violations     |
   |          | like `make DESTDIR=${D}` to slip through.                   |

   | 7905     | Eliminate confusing false positive error messages for       |
   | zmedico  | SRC_URI.syntax and digestentry.unused that are reported     |
   |          | when the SRC_URI for one or more ebuilds can't be parsed    |
   |          | for some reason. There's no point in producing a false      |
   |          | error here since the root cause will produce a valid error  |
   |          | elsewhere, such as "SRC_URI.syntax" or "ebuild.sytax".      |
   |          | Also, update the docs for the "ebuild.syntax" error to      |
   |          | indicate that a digest verification failure can trigger it. |

   | 7907     | this isnt part of gentoolkit anymore                        |
   | SpankMan |                                                             |

   | 7908     | no need to use "function" when defining a function          |
   | SpankMan |                                                             |

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

bin/etc-update
bin/repoman
man/repoman.1
pym/repoman/checks.py

index d39052d6b3fdd681f645cd8233a7f701e6367501..4ca47a510d46e684a8e7a8598bc3966b3d80f0d3 100755 (executable)
 cd /
 
 if type -P gsed >/dev/null ; then
-       function sed() { gsed "$@"; }
+       sed() { gsed "$@"; }
 fi
 
-function get_config() {
+get_config() {
        # the sed here does:
        #  - strip off comments
        #  - match lines that set item in question
@@ -34,7 +34,7 @@ function get_config() {
                "${PORTAGE_CONFIGROOT}"etc/etc-update.conf)
 }
 
-function scan() {
+scan() {
 
        echo "Scanning Configuration files..."
        rm -rf ${TMP}/files > /dev/null 2>&1
@@ -120,7 +120,7 @@ function scan() {
 
 }
 
-function sel_file() {
+sel_file() {
        local -i isfirst=0
        until [[ -f ${TMP}/files/${input} ]] || \
              [[ ${input} == -1 ]] || \
@@ -198,7 +198,7 @@ configuration file is followed by a list of possible replacement files."
        done
 }
 
-function user_special() {
+user_special() {
        if [ -r ${PORTAGE_CONFIGROOT}etc/etc-update.special ]; then
                if [ -z "$1" ]; then
                        echo "ERROR: user_special() called without arguments"
@@ -211,7 +211,7 @@ function user_special() {
        return 1
 }
 
-function read_int() {
+read_int() {
        # Read an integer from stdin.  Continously loops until a valid integer is
        # read.  This is a workaround for odd behavior of bash when an attempt is
        # made to store a value such as "1y" into an integer-only variable.
@@ -225,7 +225,7 @@ function read_int() {
        echo ${my_input}
 }
 
-function do_file() {
+do_file() {
        echo
        local -i my_input
        local -i fcount=0
@@ -300,7 +300,7 @@ function do_file() {
        count=${count}-1
 }
 
-function do_cfg() {
+do_cfg() {
 
        local file="${1}"
        local ofile="${2}"
@@ -366,7 +366,7 @@ Please select from the menu above (-1 to ignore this update): "
        done
 }
 
-function do_merge() {
+do_merge() {
        # make sure we keep the merged file in the secure tempdir
        # so we dont leak any information contained in said file
        # (think of case where the file has 0600 perms; during the
@@ -437,7 +437,7 @@ Please select from the menu above (-1 to exit, losing this merge): "
        return 255
 }
 
-function die() {
+die() {
        trap "" TERM
        trap "" KILL
        echo "Exiting: ${1}"
@@ -507,7 +507,7 @@ fi
 
 declare -i count=0
 declare input=0
-declare title="Gentoolkit's etc-update tool!"
+declare title="Gentoo's etc-update tool!"
 
 scan
 
index 001e3289d0401ed07c6b6f90f8d03cc1f6c1055a..94699f1bdab4d679c28ae491c84c3aefef8dee27 100755 (executable)
@@ -190,7 +190,7 @@ qahelp={
        "PROVIDE.syntax":"Syntax error in PROVIDE (usually an extra/missing space/parenthesis)",
        "RESTRICT.syntax":"Syntax error in RESTRICT (usually an extra/missing space/parenthesis)",
        "SRC_URI.syntax":"Syntax error in SRC_URI (usually an extra/missing space/parenthesis)",
-       "ebuild.syntax":"Error generating cache entry for ebuild; typically caused by ebuild syntax error",
+       "ebuild.syntax":"Error generating cache entry for ebuild; typically caused by ebuild syntax error or digest verification failure",
        "ebuild.output":"A simple sourcing of the ebuild produces output; this breaks ebuild policy.",
        "ebuild.nesteddie":"Placing 'die' inside ( ) prints an error, but doesn't stop the ebuild.",
        "variable.readonly":"Assigning a readonly variable",
@@ -973,18 +973,33 @@ for x in scanlist:
 
        fetchlist_dict = portage.FetchlistDict(checkdir, repoman_settings, portdb)
        myfiles_all = []
+       src_uri_error = False
        for mykey in fetchlist_dict:
                try:
                        myfiles_all.extend(fetchlist_dict[mykey])
                except portage.exception.InvalidDependString, e:
-                       stats["SRC_URI.syntax"] = stats["SRC_URI.syntax"] + 1
-                       fails["SRC_URI.syntax"].append(mykey+".ebuild SRC_URI: "+str(e))
+                       src_uri_error = True
+                       try:
+                               portdb.aux_get(mykey, ["SRC_URI"])
+                       except KeyError:
+                               # This will be reported as an "ebuild.syntax" error.
+                               pass
+                       else:
+                               stats["SRC_URI.syntax"] = stats["SRC_URI.syntax"] + 1
+                               fails["SRC_URI.syntax"].append(
+                                       "%s.ebuild SRC_URI: %s" % (mykey, e))
        del fetchlist_dict
-       myfiles_all = set(myfiles_all)
-       for entry in mydigests:
-               if entry not in myfiles_all:
-                       stats["digestentry.unused"] += 1
-                       fails["digestentry.unused"].append(checkdir+"::"+entry)
+       if not src_uri_error:
+               # This test can produce false positives if SRC_URI could not
+               # be parsed for one or more ebuilds. There's no point in
+               # producing a false error here since the root cause will
+               # produce a valid error elsewhere, such as "SRC_URI.syntax"
+               # or "ebuild.sytax".
+               myfiles_all = set(myfiles_all)
+               for entry in mydigests:
+                       if entry not in myfiles_all:
+                               stats["digestentry.unused"] += 1
+                               fails["digestentry.unused"].append(checkdir+"::"+entry)
        del myfiles_all
 
        if os.path.exists(checkdir+"/files"):
index 7b97a0abcb7fcc35a53f0abd1363af552ebdb76c..edbc7afd038b859536c6c5c0a8d97057144a491c 100644 (file)
@@ -221,6 +221,7 @@ A simple sourcing of the ebuild produces output; this breaks ebuild policy.
 .TP
 .B ebuild.syntax
 Error generating cache entry for ebuild; typically caused by ebuild syntax error
+or digest verification failure.
 .TP
 .B file.UTF8
 File is not UTF8 compliant
index de7ceee23f94af52f0aa35d954b3a7c4d090a359..d30785aed3e48a1f2d7033170c0b34b2d1714734 100644 (file)
@@ -118,13 +118,12 @@ class EbuildQuote(ContentCheck):
        """Ensure ebuilds have valid quoting around things like D,FILESDIR, etc..."""
 
        repoman_check_name = 'ebuild.minorsyn'
-       ignore_line = re.compile(r'(^$)|(^\s*#.*)')
+       ignore_line = re.compile(r'(^$)|(^\s*#.*)|(^\s*\w+=.*)')
        var_names = r'(D|S|T|ROOT|FILESDIR|WORKDIR)'
        var_reference = re.compile(r'\$({'+var_names+'}|' + \
                r'\$' + var_names + '\W)')
        missing_quotes = re.compile(r'(\s|^)[^"\s]*\${?' + var_names + \
                r'}?[^"\s]*(\s|$)')
-       var_assignment = re.compile(r'^\s*\w*=.*')
        cond_begin =  re.compile(r'(^|\s+)\[\[($|\\$|\s+)')
        cond_end =  re.compile(r'(^|\s+)\]\]($|\\$|\s+)')
        
@@ -161,8 +160,6 @@ class EbuildQuote(ContentCheck):
                                # get through the missing_quotes regex.
                                if self.var_reference.search(group) is None:
                                        continue
-                               if self.var_assignment.search(group) is not None:
-                                       continue
 
                                # This is an attempt to avoid false positives without getting
                                # too complex, while possibly allowing some (hopefully