forked from pool/rpmlint
Accepting request 44204 from Base:System
Copy from Base:System/rpmlint based on submit request 44204 from user dirkmueller OBS-URL: https://build.opensuse.org/request/show/44204 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/rpmlint?expand=0&rev=67
This commit is contained in:
parent
88b0c395f0
commit
f7d2015dce
44
BashismsCheck.py
Normal file
44
BashismsCheck.py
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
#############################################################################
|
||||||
|
# File : BashismsCheck.py
|
||||||
|
# Package : rpmlint
|
||||||
|
# Author : Guido Berhoerster
|
||||||
|
# Purpose : check /bin/sh shell scripts for bashisms
|
||||||
|
#############################################################################
|
||||||
|
|
||||||
|
import re
|
||||||
|
import AbstractCheck
|
||||||
|
import Config
|
||||||
|
import Pkg
|
||||||
|
from Filter import *
|
||||||
|
|
||||||
|
class BashismsCheck(AbstractCheck.AbstractFilesCheck):
|
||||||
|
RE_BIN_SH = re.compile('#!\s*(/usr)?/bin/sh(\s+|$)')
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
AbstractCheck.AbstractFilesCheck.__init__(self, "BashismsCheck", ".*")
|
||||||
|
|
||||||
|
def check_file(self, pkg, filename):
|
||||||
|
try:
|
||||||
|
f = open(filename)
|
||||||
|
except:
|
||||||
|
return
|
||||||
|
try:
|
||||||
|
first_line = f.read(256).split("\n")[0]
|
||||||
|
if self.RE_BIN_SH.match(first_line):
|
||||||
|
status, output = Pkg.getstatusoutput(["dash", "-n", filename])
|
||||||
|
if status == 2:
|
||||||
|
printWarning(pkg, "bin-sh-syntax-error", filename)
|
||||||
|
status, output = Pkg.getstatusoutput(["checkbashisms", filename])
|
||||||
|
if status == 1:
|
||||||
|
printInfo(pkg, "potential-bashisms", filename)
|
||||||
|
finally:
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
check = BashismsCheck()
|
||||||
|
|
||||||
|
if Config.info:
|
||||||
|
addDetails('bin-sh-syntax-error',
|
||||||
|
'''A /bin/sh shell script contains a syntax error.''',
|
||||||
|
'potential-bashisms',
|
||||||
|
'''checkbashisms reported potential bashisms in a /bin/sh shell
|
||||||
|
script, you might want to manually check this script for bashisms.''')
|
1
config
1
config
@ -34,6 +34,7 @@ addCheck("CheckFilelist")
|
|||||||
addCheck("CheckKDE4Deps")
|
addCheck("CheckKDE4Deps")
|
||||||
addCheck("KMPPolicyCheck")
|
addCheck("KMPPolicyCheck")
|
||||||
addCheck("CheckAlternativesGhostFiles")
|
addCheck("CheckAlternativesGhostFiles")
|
||||||
|
addCheck("BashismsCheck")
|
||||||
|
|
||||||
# stuff autobuild takes care about
|
# stuff autobuild takes care about
|
||||||
addFilter(".*invalid-version.*")
|
addFilter(".*invalid-version.*")
|
||||||
|
17
confusing-invalid-spec-name.patch
Normal file
17
confusing-invalid-spec-name.patch
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
# Confusing message. The problem is not that the file does not end
|
||||||
|
# with ".spec", but that there is a mismatch of specname and pkg name.
|
||||||
|
Index: rpmlint-0.95/SpecCheck.py
|
||||||
|
===================================================================
|
||||||
|
--- rpmlint-0.95.orig/SpecCheck.py 2010-07-29 09:29:28.000000000 +0200
|
||||||
|
+++ rpmlint-0.95/SpecCheck.py 2010-07-29 09:44:32.000000000 +0200
|
||||||
|
@@ -593,8 +593,8 @@ addDetails(
|
||||||
|
SPEC file to build a valid RPM package.''',
|
||||||
|
|
||||||
|
'invalid-spec-name',
|
||||||
|
-'''Your spec filename must end with '.spec'. If it's not the case, rename your
|
||||||
|
-file and rebuild your package.''',
|
||||||
|
+'''The spec file name (without the .spec suffix) must match the package name
|
||||||
|
+("Name:" tag). Either rename your package or the specfile.''',
|
||||||
|
|
||||||
|
'non-utf8-spec-file',
|
||||||
|
'''The character encoding of the spec file is not UTF-8. Convert it for
|
@ -29,6 +29,7 @@ setOption("ValidGroups", (
|
|||||||
"Amusements/Toys/Graphics" ,\
|
"Amusements/Toys/Graphics" ,\
|
||||||
"Amusements/Toys/Other" ,\
|
"Amusements/Toys/Other" ,\
|
||||||
"Amusements/Toys/Screensavers" ,\
|
"Amusements/Toys/Screensavers" ,\
|
||||||
|
"Development/Debug" ,\
|
||||||
"Development/Languages/C and C++" ,\
|
"Development/Languages/C and C++" ,\
|
||||||
"Development/Languages/Fortran" ,\
|
"Development/Languages/Fortran" ,\
|
||||||
"Development/Languages/Java" ,\
|
"Development/Languages/Java" ,\
|
||||||
|
@ -1,3 +1,23 @@
|
|||||||
|
-------------------------------------------------------------------
|
||||||
|
Thu Jul 29 18:25:47 CEST 2010 - dmueller@suse.de
|
||||||
|
|
||||||
|
- fix printWarning error in CheckBashisms
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Thu Jul 29 07:49:02 UTC 2010 - puzel@novell.com
|
||||||
|
|
||||||
|
- add confusing-invalid-spec-name.patch
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Tue Jul 20 09:12:08 UTC 2010 - guido+opensuse.org@berhoerster.name
|
||||||
|
|
||||||
|
- add BashismsCheck
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Mon Jul 12 11:05:58 CEST 2010 - dmueller@suse.de
|
||||||
|
|
||||||
|
- add Development/Debug group (bnc#612044)
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
Wed Jun 30 12:12:53 UTC 2010 - lnussel@suse.de
|
Wed Jun 30 12:12:53 UTC 2010 - lnussel@suse.de
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ Name: rpmlint
|
|||||||
BuildRequires: rpm-python
|
BuildRequires: rpm-python
|
||||||
Summary: Rpm correctness checker
|
Summary: Rpm correctness checker
|
||||||
Version: 0.95
|
Version: 0.95
|
||||||
Release: 10
|
Release: 14
|
||||||
Source0: %{name}-%{version}.tar.bz2
|
Source0: %{name}-%{version}.tar.bz2
|
||||||
Source1: config
|
Source1: config
|
||||||
Source1001: config.in
|
Source1001: config.in
|
||||||
@ -46,6 +46,7 @@ Source17: CheckFilelist.py
|
|||||||
Source18: CheckDBusPolicy.py
|
Source18: CheckDBusPolicy.py
|
||||||
Source19: CheckAlternativesGhostFiles.py
|
Source19: CheckAlternativesGhostFiles.py
|
||||||
Source20: rpmgroups.config
|
Source20: rpmgroups.config
|
||||||
|
Source21: BashismsCheck.py
|
||||||
Source100: syntax-validator.py
|
Source100: syntax-validator.py
|
||||||
Url: http://rpmlint.zarb.org/
|
Url: http://rpmlint.zarb.org/
|
||||||
License: GPLv2+
|
License: GPLv2+
|
||||||
@ -54,6 +55,7 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
|||||||
Requires: rpm-python, /usr/bin/readelf, file, findutils, cpio, bash
|
Requires: rpm-python, /usr/bin/readelf, file, findutils, cpio, bash
|
||||||
Requires: desktop-file-utils
|
Requires: desktop-file-utils
|
||||||
Requires: python-magic
|
Requires: python-magic
|
||||||
|
Requires: dash checkbashisms
|
||||||
BuildArch: noarch
|
BuildArch: noarch
|
||||||
Patch0: rpmlint-suse.diff
|
Patch0: rpmlint-suse.diff
|
||||||
Patch1: suse-checks.diff
|
Patch1: suse-checks.diff
|
||||||
@ -114,6 +116,7 @@ Patch72: version-control-internal-file.diff
|
|||||||
Patch73: avoid-mismatched-libregex.diff
|
Patch73: avoid-mismatched-libregex.diff
|
||||||
Patch74: filename-non-utf8-exception.diff
|
Patch74: filename-non-utf8-exception.diff
|
||||||
Patch75: stricter-interpreter-check.diff
|
Patch75: stricter-interpreter-check.diff
|
||||||
|
Patch76: confusing-invalid-spec-name.patch
|
||||||
%py_requires
|
%py_requires
|
||||||
|
|
||||||
%description
|
%description
|
||||||
@ -187,6 +190,7 @@ Authors:
|
|||||||
%patch73
|
%patch73
|
||||||
%patch74
|
%patch74
|
||||||
%patch75
|
%patch75
|
||||||
|
%patch76 -p1
|
||||||
cp -p %{SOURCE1} .
|
cp -p %{SOURCE1} .
|
||||||
cp -p %{SOURCE2} .
|
cp -p %{SOURCE2} .
|
||||||
cp -p %{SOURCE3} .
|
cp -p %{SOURCE3} .
|
||||||
@ -206,6 +210,7 @@ cp -p %{SOURCE16} .
|
|||||||
cp -p %{SOURCE17} .
|
cp -p %{SOURCE17} .
|
||||||
cp -p %{SOURCE18} .
|
cp -p %{SOURCE18} .
|
||||||
cp -p %{SOURCE19} .
|
cp -p %{SOURCE19} .
|
||||||
|
cp -p %{SOURCE21} .
|
||||||
|
|
||||||
%build
|
%build
|
||||||
make %{?_smp_mflags}
|
make %{?_smp_mflags}
|
||||||
|
Loading…
Reference in New Issue
Block a user