From e890d0458258f6ddd0f2c6fcd322dbec8233bf00 Mon Sep 17 00:00:00 2001 From: Fabian Groffen Date: Fri, 5 Oct 2007 18:22:18 +0000 Subject: [PATCH] Merged from trunk 7903:7908 | 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 | 22 +++++++++++----------- bin/repoman | 31 +++++++++++++++++++++++-------- man/repoman.1 | 1 + pym/repoman/checks.py | 5 +---- 4 files changed, 36 insertions(+), 23 deletions(-) diff --git a/bin/etc-update b/bin/etc-update index d39052d6b..4ca47a510 100755 --- a/bin/etc-update +++ b/bin/etc-update @@ -13,10 +13,10 @@ 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 diff --git a/bin/repoman b/bin/repoman index 001e3289d..94699f1bd 100755 --- a/bin/repoman +++ b/bin/repoman @@ -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"): diff --git a/man/repoman.1 b/man/repoman.1 index 7b97a0abc..edbc7afd0 100644 --- a/man/repoman.1 +++ b/man/repoman.1 @@ -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 diff --git a/pym/repoman/checks.py b/pym/repoman/checks.py index de7ceee23..d30785aed 100644 --- a/pym/repoman/checks.py +++ b/pym/repoman/checks.py @@ -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 -- 2.26.2