summaryrefslogtreecommitdiff
path: root/rule_checker.py
diff options
context:
space:
mode:
Diffstat (limited to 'rule_checker.py')
-rwxr-xr-xrule_checker.py25
1 files changed, 24 insertions, 1 deletions
diff --git a/rule_checker.py b/rule_checker.py
index e17f6d0..539ee8a 100755
--- a/rule_checker.py
+++ b/rule_checker.py
@@ -16,10 +16,13 @@ import os
import os.path
import sys
+def report(file, lc, code):
+ print(file + ":Line " + str(lc) + " |"+code)
def ruleCheckInc(file):
error = 0
warning = 0
+ lc = 0
try:
f = open("packaging/"+file, 'r')
@@ -28,6 +31,7 @@ def ruleCheckInc(file):
print("WARNING: cannot find packaging/"+file)
return (0, 1)
for line in f:
+ lc += 1
# RULE 5.1
if re.search('^\s*BuildRequires', line, re.IGNORECASE):
error += 1
@@ -38,6 +42,7 @@ def ruleCheckInc(file):
if re.search('^#.*[^%]%[^%]', line) and not re.search('^#!', line):
error += 1
print("ERROR: unless it is shebang, you must not have rpm macro in a # comment. They are expanded and multiline macro will do unexpected effects.")
+ report(file, lc, line)
continue
# RULE 5.2
@@ -47,21 +52,39 @@ def ruleCheckInc(file):
re.search('^\s*Supplements', line, re.IGNORECASE):
error += 1
print("ERROR: RULE 5.2 .inc file cannot have unsupported relations")
+ report(file, lc, line)
+ continue
# RULE 1-1
if re.search('^\s*%package\s*-n', line, re.IGNORECASE):
error += 1
print("ERROR: RULE 1.1 to ensure 1.1, do not use -n option in package name")
+ report(file, lc, line)
+ continue
# Implicit / General Rule
if re.search('^\s*%package\s', line, re.IGNORECASE) and not re.search('^\s*%package\s', line):
error += 1
print('ERROR: (General) Please use %package, not '+re.search('^%package'))
+ report(file, lc, line)
+ continue
- # RULE 1-3
+ # RULE 1-3 / 1-4
if re.search('^\s*%package', line) and not re.search('^\s*%package\s*(root)|(sub1)|(sub2)', line):
error +=1
print("ERROR: RULE 1.3 the send prefix should be root, sub1, or sub2.")
+ report(file, lc, line)
+ continue
+
+ # RULE 1-5 + 1-9 / there is - in the name
+ if re.search('^\s*%package\s*root', line) and \
+ not re.search('^\s*%package\s*root-[a-zA-Z0-9_]*\s*$', line):
+ error += 1
+ print("ERROR: RULE 1.9 not met with root (RULE 1.5)")
+ report(file, lc, line)
+ continue
+
+