[arch-dev-public] [namcap] version 3.0.2 in testing repo
On 2011/3/13 Rémy Oudompheng <remyoudompheng@gmail.com> wrote:
Hello people,
namcap version 3.0.1 is now in testing. This is a quick bugfix followup release that corrects bugs FS#23258, FS#23259, FS#23260.
Sources are at the usual places ftp://ftp.archlinux.org/other/namcap/namcap-3.0.1.tar.gz http://projects.archlinux.org/namcap.git/tree/?id=3.0.1
Have fun with it and don't hesitate to report any other bugs or wrong behaviour.
Version 3.0.2 is released. It features two bug fixes : * crashes in non-English locales (reported by Pierre) * large amount of false positives in the extravars rules for multiline arrays (reported by Allan). I have not bothered having an exact parser for getting names of shell variables used in PKGBUILDs. I am not sure it is a priority, but any patches are welcome. If you find (non-forged) PKGBUILDs giving lots of false positives, put your hands up. -- Rémy.
On 15/03/11 08:50, Rémy Oudompheng wrote:
On 2011/3/13 Rémy Oudompheng<remyoudompheng@gmail.com> wrote:
Hello people,
namcap version 3.0.1 is now in testing. This is a quick bugfix followup release that corrects bugs FS#23258, FS#23259, FS#23260.
Sources are at the usual places ftp://ftp.archlinux.org/other/namcap/namcap-3.0.1.tar.gz http://projects.archlinux.org/namcap.git/tree/?id=3.0.1
Have fun with it and don't hesitate to report any other bugs or wrong behaviour.
Version 3.0.2 is released. It features two bug fixes : * crashes in non-English locales (reported by Pierre) * large amount of false positives in the extravars rules for multiline arrays (reported by Allan).
This appears to have gotten worse: namcap-3.0.1:
find /var/abs/core -name PKGBUILD | xargs namcap | grep "Non standard variable" | wc -l 129
namcap-3.0.2:
find /var/abs/core -name PKGBUILD | xargs namcap | grep "Non standard variable" | wc -l 710
It turns out every PKGBUILD is giving the following warnings:
namcap /var/abs/core/tar/PKGBUILD PKGBUILD (tar) W: Non standard variable 'rootdelay' doesn't start with an underscore PKGBUILD (tar) W: Non standard variable 'init' doesn't start with an underscore PKGBUILD (tar) W: Non standard variable 'udevd_running' doesn't start with an underscore PKGBUILD (tar) W: Non standard variable 'root' doesn't start with an underscore
On Mon, Mar 14, 2011 at 8:48 PM, Allan McRae <allan@archlinux.org> wrote:
On 15/03/11 08:50, Rémy Oudompheng wrote:
On 2011/3/13 Rémy Oudompheng<remyoudompheng@gmail.com> wrote:
Hello people,
namcap version 3.0.1 is now in testing. This is a quick bugfix followup release that corrects bugs FS#23258, FS#23259, FS#23260.
Sources are at the usual places ftp://ftp.archlinux.org/other/namcap/namcap-3.0.1.tar.gz http://projects.archlinux.org/namcap.git/tree/?id=3.0.1
Have fun with it and don't hesitate to report any other bugs or wrong behaviour.
Version 3.0.2 is released. It features two bug fixes : * crashes in non-English locales (reported by Pierre) * large amount of false positives in the extravars rules for multiline arrays (reported by Allan).
This appears to have gotten worse:
namcap-3.0.1:
find /var/abs/core -name PKGBUILD | xargs namcap | grep "Non standard variable" | wc -l 129
namcap-3.0.2:
find /var/abs/core -name PKGBUILD | xargs namcap | grep "Non standard variable" | wc -l 710
It turns out every PKGBUILD is giving the following warnings:
namcap /var/abs/core/tar/PKGBUILD PKGBUILD (tar) W: Non standard variable 'rootdelay' doesn't start with an underscore PKGBUILD (tar) W: Non standard variable 'init' doesn't start with an underscore PKGBUILD (tar) W: Non standard variable 'udevd_running' doesn't start with an underscore PKGBUILD (tar) W: Non standard variable 'root' doesn't start with an underscore
Hmm: dmcgee@galway ~ $ namcap ~/projects/arch-repos/tar/trunk/PKGBUILD (no output here) I'm seeing some serious oddness...it matters what directory you are in as to how many errors get spewed out, and I don't see the ones you see at all above. dmcgee@galway ~ $ namcap projects/arch-repos/perl/trunk/PKGBUILD PKGBUILD (perl) W: Non standard variable 'arch_opts' doesn't start with an underscore dmcgee@galway ~ $ cd projects/pacman dmcgee@galway ~/projects/pacman (master) $ namcap ~/projects/arch-repos/perl/trunk/PKGBUILD PKGBUILD (perl) W: Non standard variable 'arch_opts' doesn't start with an underscore dmcgee@galway ~/projects/pacman (master) $ cd ../namcap/ dmcgee@galway ~/projects/namcap (master) $ namcap ~/projects/arch-repos/perl/trunk/PKGBUILD PKGBUILD (perl) W: Non standard variable 'perl-archive-extract' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-archive-tar' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-attribute-handlers' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-autodie' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-autoloader' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-base' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-b-debug' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-bignum' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-b-lint' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-cgi' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-class-isa' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-compress-raw-bzip2' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-compress-raw-zlib' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-constant' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-cpan' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-cpanplus' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-cpanplus-dist-build' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-data-dumper' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-db_file' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-devel-dprof' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-devel-peek' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-devel-ppport' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-digest' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-digest-md5' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-digest-sha' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-encode' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-encoding-warnings' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-exporter' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-extutils-cbuilder' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-extutils-command' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-extutils-constant' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-extutils-embed' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-extutils-install' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-extutils-makemaker' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-extutils-manifest' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-extutils-parsexs' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-file-fetch' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-file-path' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-file-temp' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-filter' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-filter-simple' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-getopt-long' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-if' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-io' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-io-compress' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perlio-via-quotedprint' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-io-zlib' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-ipc-cmd' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-ipc-sysv' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-libnet' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-locale-codes' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-locale-maketext' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-locale-maketext-simple' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-log-message' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-log-message-simple' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-math-bigint' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-math-bigint-fastcalc' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-math-bigrat' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-math-complex' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-memoize' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-mime-base64' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-module-build' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-module-corelist' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-module-load' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-module-load-conditional' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-module-loaded' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-module-pluggable' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-net-ping' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-next' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-object-accessor' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-package-constants' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-params-check' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-parent' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-parse-cpan-meta' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-pathtools' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-pod-escapes' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-pod-latex' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-podlators' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-pod-parser' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-pod-perldoc' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-pod-plainer' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-pod-simple' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-safe' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-scalar-list-utils' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-selfloader' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-shell' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-storable' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-switch' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-sys-syslog' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-term-ansicolor' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-term-cap' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-term-ui' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-test' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-test-harness' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-test-simple' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-text-balanced' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-text-parsewords' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-text-soundex' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-text-tabs+wraps' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-thread-queue' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-threads' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-thread-semaphore' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-threads-shared' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-tie-file' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-tie-refhash' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-time-hires' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-time-local' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-time-piece' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-unicode-collate' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-unicode-normalize' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-version' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-win32' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-win32api-file' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'perl-xsloader' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'arch_opts' doesn't start with an underscore PKGBUILD (perl) W: Non standard variable 'arch_opts' doesn't start with an underscore
On Mon, Mar 14, 2011 at 8:48 PM, Allan McRae <allan@archlinux.org> wrote:
On 15/03/11 08:50, Rémy Oudompheng wrote:
On 2011/3/13 Rémy Oudompheng<remyoudompheng@gmail.com> wrote:
Hello people,
namcap version 3.0.1 is now in testing. This is a quick bugfix followup release that corrects bugs FS#23258, FS#23259, FS#23260.
Sources are at the usual places ftp://ftp.archlinux.org/other/namcap/namcap-3.0.1.tar.gz http://projects.archlinux.org/namcap.git/tree/?id=3.0.1
Have fun with it and don't hesitate to report any other bugs or wrong behaviour.
Version 3.0.2 is released. It features two bug fixes : * crashes in non-English locales (reported by Pierre) * large amount of false positives in the extravars rules for multiline arrays (reported by Allan).
This appears to have gotten worse:
namcap-3.0.1:
find /var/abs/core -name PKGBUILD | xargs namcap | grep "Non standard variable" | wc -l 129
namcap-3.0.2:
find /var/abs/core -name PKGBUILD | xargs namcap | grep "Non standard variable" | wc -l 710
It turns out every PKGBUILD is giving the following warnings:
namcap /var/abs/core/tar/PKGBUILD PKGBUILD (tar) W: Non standard variable 'rootdelay' doesn't start with an underscore PKGBUILD (tar) W: Non standard variable 'init' doesn't start with an underscore PKGBUILD (tar) W: Non standard variable 'udevd_running' doesn't start with an underscore PKGBUILD (tar) W: Non standard variable 'root' doesn't start with an underscore
Note the original commit message on this rule, very telling...anyway, I have a hopefully real fix for this mess on the way. I didn't even realize I wasn't running the latest rule from my devel branch, but what I've coded up is hopefully a lot more correct fix for the problem. commit c35379b4e1ba2721c20ae1735f5e8028baa9a942 Author: Jesse Young <jesse.young@gmail.com> Date: Tue Jul 24 13:38:04 2007 -0700 Add extravars rule but don't enable it by default. It still needs tweaking to get it to work properly. Things inside the build function can trigger it, for example. Signed-off-by: Jason Chu <jason@archlinux.org>
This reverts the non-test portions of commit e2044d4583f80cd6283a2f8d0ffa1d6f5d834123. This is not the proper way to fix this, and we most definitely should not have to parse, subprocess, or do anything with bash more than once, especially in a rule. We also shouldn't assume everyone has a perfectly clean environment with no extra variables exported and defined. Revert the entire thing, minus the added test, with a better fix on the way. Signed-off-by: Dan McGee <dan@archlinux.org> --- Namcap/rules/extravars.py | 52 ++++++-------------------------------------- 1 files changed, 7 insertions(+), 45 deletions(-) diff --git a/Namcap/rules/extravars.py b/Namcap/rules/extravars.py index 0288335..01031f5 100644 --- a/Namcap/rules/extravars.py +++ b/Namcap/rules/extravars.py @@ -18,47 +18,8 @@ # import re -import os -import subprocess -import tempfile from Namcap.ruleclass import * -BASH_BUILTINS = set([ - "BASH", "BASHOPTS", "BASH_ALIASES", "BASH_ARGC", "BASH_ARGV", "BASH_CMDS", "BASH_LINENO", - "BASH_SOURCE", "BASH_VERSINFO", "BASH_VERSION", "DIRSTACK", "EUID", "GROUPS", "HOSTNAME", - "HOSTTYPE", "IFS", "MACHTYPE", "OPTERR", "OPTIND", "OSTYPE", "PATH", "PIPESTATUS", "PPID", - "PS1", "PS2", "PS3", "PS4", - "PWD", "SHELL", "SHELLOPTS", "SHLVL", "TERM", "UID", - ]) - -def find_lowercase_global_vars(pkgbuild): - # list the variable names beginning with a lowercase letter - varnames = [] - - # write an annotated PKGBUILD to a temporary file - f = tempfile.NamedTemporaryFile(delete = False) - annotated_pkgbuild = pkgbuild + "\ndeclare +x" - f.write(annotated_pkgbuild.encode('utf-8')) - f.close() - # run bash -r on it to list variables - cwd = os.getcwd() - os.chdir(os.path.dirname(f.name)) - p = subprocess.Popen(["bash", "-r", os.path.basename(f.name)], - stdout = subprocess.PIPE, stderr = subprocess.PIPE) - out, err = p.communicate() - - if p.returncode != 0: - raise ValueError("parsing PKGBUILD failed") - else: - for l in out.decode("utf-8", "ignore").splitlines(): - m = re.match('[\s]*([a-z][a-zA-Z_0-9]*)\+?=', l) - if not m: - continue - varnames.append(m.group(1)) - - os.unlink(f.name) - return set(varnames) - class package(PkgbuildRule): name = "extravars" description = "Verifies that extra variables start with an underscore" @@ -70,11 +31,12 @@ class package(PkgbuildRule): 'pkgbase', 'pkgver', 'pkgrel', 'pkgdesc', 'groups', 'url', 'install', 'changelog', 'options', 'optdepends'] - pkgbuild_vars = find_lowercase_global_vars("\n".join(pkginfo.pkgbuild)) - nonstdvars = pkgbuild_vars - set(stdvars) - self.warnings.extend( - [("extra-var-begins-without-underscore %s", varname) for - varname in nonstdvars] - ) + for i in pkginfo.pkgbuild: + m = re.match('[\s]*([a-z][^\s=]*[^+])=', i) + if m: + varname = m.group(1) + if varname not in stdvars: + if not varname.startswith('_'): + self.warnings.append(("extra-var-begins-without-underscore %s", varname)) # vim: set ts=4 sw=4 noet: -- 1.7.4.1
Add an additional fake package variable '%SETVARS%' that shows the currently defined variables when processing a PKGBUILD. Use this list in the extravars rule instead of broke-ass regex parsing that will never catch every possible corner case. Signed-off-by: Dan McGee <dan@archlinux.org> --- Namcap/rules/extravars.py | 11 ++++------- parsepkgbuild.sh | 8 ++++---- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/Namcap/rules/extravars.py b/Namcap/rules/extravars.py index 01031f5..0fcdb53 100644 --- a/Namcap/rules/extravars.py +++ b/Namcap/rules/extravars.py @@ -31,12 +31,9 @@ class package(PkgbuildRule): 'pkgbase', 'pkgver', 'pkgrel', 'pkgdesc', 'groups', 'url', 'install', 'changelog', 'options', 'optdepends'] - for i in pkginfo.pkgbuild: - m = re.match('[\s]*([a-z][^\s=]*[^+])=', i) - if m: - varname = m.group(1) - if varname not in stdvars: - if not varname.startswith('_'): - self.warnings.append(("extra-var-begins-without-underscore %s", varname)) + for varname in pkginfo["setvars"]: + if varname.islower() and varname not in stdvars \ + and not varname.startswith('_'): + self.warnings.append(("extra-var-begins-without-underscore %s", varname)) # vim: set ts=4 sw=4 noet: diff --git a/parsepkgbuild.sh b/parsepkgbuild.sh index d601579..5ffa566 100644 --- a/parsepkgbuild.sh +++ b/parsepkgbuild.sh @@ -124,6 +124,9 @@ if [ -n "$install" ]; then echo -e "%INSTALL%\n$install\n" fi +unset i +echo "%SETVARS%" +compgen -A variable } # is it a split pkgbuild ? @@ -136,10 +139,7 @@ if [ -n "${pkgbase}" ]; then for i in ${pkgnames[@]}; do echo $i; done echo "" pkginfo -fi - -# print per package information -if [ -n "${pkgbase}" ]; then + # print per package information for subpkg in ${pkgnames[@]} do echo -e '\0' -- 1.7.4.1
Add an additional fake package variable '%SETVARS%' that shows the currently defined variables when processing a PKGBUILD. Use this list in the extravars rule instead of broke-ass regex parsing that will never catch every possible corner case. Also update the tests accordingly. Variables defined inside a function are nothing we are going to worry about at the moment, so safely ignore them. Add a legal variable to ensure we don't have any false positives, and fix our own misgivings in the PKGBUILD parser so we aren't polluting the namespace. Signed-off-by: Dan McGee <dan@archlinux.org> --- Slightly touched-up resend; trying to get the unit tests passing would be a good idea. Namcap/rules/extravars.py | 11 ++++------- Namcap/tests/pkgbuild/test_extravars.py | 7 ++----- parsepkgbuild | 1 - parsepkgbuild.sh | 21 ++++++++++----------- 4 files changed, 16 insertions(+), 24 deletions(-) diff --git a/Namcap/rules/extravars.py b/Namcap/rules/extravars.py index 01031f5..0fcdb53 100644 --- a/Namcap/rules/extravars.py +++ b/Namcap/rules/extravars.py @@ -31,12 +31,9 @@ class package(PkgbuildRule): 'pkgbase', 'pkgver', 'pkgrel', 'pkgdesc', 'groups', 'url', 'install', 'changelog', 'options', 'optdepends'] - for i in pkginfo.pkgbuild: - m = re.match('[\s]*([a-z][^\s=]*[^+])=', i) - if m: - varname = m.group(1) - if varname not in stdvars: - if not varname.startswith('_'): - self.warnings.append(("extra-var-begins-without-underscore %s", varname)) + for varname in pkginfo["setvars"]: + if varname.islower() and varname not in stdvars \ + and not varname.startswith('_'): + self.warnings.append(("extra-var-begins-without-underscore %s", varname)) # vim: set ts=4 sw=4 noet: diff --git a/Namcap/tests/pkgbuild/test_extravars.py b/Namcap/tests/pkgbuild/test_extravars.py index 8913d87..651ec5a 100644 --- a/Namcap/tests/pkgbuild/test_extravars.py +++ b/Namcap/tests/pkgbuild/test_extravars.py @@ -42,6 +42,7 @@ source=(ftp://ftp.example.com/pub/mypackage-0.1.tar.gz) md5sums=('abcdefabcdef12345678901234567890') mycustomvar="something" +_legalvar="something else" build() { cd "${srcdir}"/${pkgname}-${pkgver} @@ -106,7 +107,6 @@ package() { self.assertEqual(r.errors, []) self.assertEqual(set(r.warnings), set([ ("extra-var-begins-without-underscore %s", "mycustomvar"), - ("extra-var-begins-without-underscore %s", "hello") ])) self.assertEqual(r.infos, []) @@ -114,10 +114,7 @@ package() { "a tricky PKGBUILD with custom variables without underscore" r = self.run_on_pkg(self.pkgbuild2) self.assertEqual(r.errors, []) - self.assertEqual(set(r.warnings), set([ - ("extra-var-begins-without-underscore %s", "mycustomvar"), - ("extra-var-begins-without-underscore %s", "hello") - ])) + self.assertEqual(r.warnings, []) self.assertEqual(r.infos, []) diff --git a/parsepkgbuild b/parsepkgbuild index 8f0f67d..04e71fd 100755 --- a/parsepkgbuild +++ b/parsepkgbuild @@ -9,4 +9,3 @@ export PATH=/tmp/parsepkgbuild PARSE_PKGBUILD_PATH=${PARSE_PKGBUILD_PATH:-/usr/share/namcap} exec /bin/bash --noprofile --norc -r "$PARSE_PKGBUILD_PATH"/parsepkgbuild.sh $1 - diff --git a/parsepkgbuild.sh b/parsepkgbuild.sh index d601579..4df298b 100644 --- a/parsepkgbuild.sh +++ b/parsepkgbuild.sh @@ -124,31 +124,31 @@ if [ -n "$install" ]; then echo -e "%INSTALL%\n$install\n" fi +unset i +echo "%SETVARS%" +compgen -A variable } # is it a split pkgbuild ? if [ -n "${pkgbase}" ]; then - pkgnames=(${pkgname[@]}) + _namcap_pkgnames=(${pkgname[@]}) unset pkgname echo -e "%SPLIT%\n1\n" echo -e "%BASE%\n${pkgbase}\n" echo "%NAMES%" - for i in ${pkgnames[@]}; do echo $i; done + for i in ${_namcap_pkgnames[@]}; do echo $i; done echo "" pkginfo -fi - -# print per package information -if [ -n "${pkgbase}" ]; then - for subpkg in ${pkgnames[@]} + # print per package information + for _namcap_subpkg in ${_namcap_pkgnames[@]} do echo -e '\0' - pkgname=$subpkg - package_$subpkg + pkgname=$_namcap_subpkg + package_$_namcap_subpkg pkginfo # did the function actually exist? echo "%PKGFUNCTION%" - type -t package_$subpkg || echo undefined + type -t package_$_namcap_subpkg || echo undefined echo "" done else @@ -156,4 +156,3 @@ else fi # vim: set noet ts=4 sw=4: - -- 1.7.4.1
participants (4)
-
Allan McRae
-
Dan McGee
-
Dan McGee
-
Rémy Oudompheng