salimma / rpms / rpmlint

Forked from rpms/rpmlint 4 years ago
Clone
15b5b3a
--- TagsCheck.py~	2007-08-29 23:46:39.000000000 +0300
15b5b3a
+++ TagsCheck.py	2007-09-03 19:54:09.000000000 +0300
15b5b3a
@@ -403,6 +403,7 @@
15b5b3a
 invalid_url_regex=re.compile(Config.getOption('InvalidURL'), re.IGNORECASE)
15b5b3a
 lib_regex=re.compile('^lib.*?(\.so.*)?$')
15b5b3a
 leading_space_regex=re.compile('^\s+')
15b5b3a
+license_regex=re.compile('\(([^)]+)\)|\s(?:and|or)\s')
15b5b3a
 invalid_version_regex=re.compile('([0-9](?:rc|alpha|beta|pre).*)', re.IGNORECASE)
15b5b3a
 # () are here for grouping purpose in the regexp
15b5b3a
 forbidden_words_regex=re.compile('(' + Config.getOption('ForbiddenWords') + ')', re.IGNORECASE)
15b5b3a
@@ -628,16 +629,20 @@
15b5b3a
 #                 printWarning(pkg, 'package-provides-itself')
15b5b3a
 #                 break
15b5b3a
 
15b5b3a
+        def split_license(license):
15b5b3a
+            return map(string.strip, [l for l in license_regex.split(license) if l])
15b5b3a
+
15b5b3a
         rpm_license = pkg[rpm.RPMTAG_LICENSE]
15b5b3a
         if not rpm_license:
15b5b3a
             printError(pkg, 'no-license')
15b5b3a
         else:
15b5b3a
             if rpm_license not in VALID_LICENSES:
15b5b3a
-                licenses = re.split('(?:[- ]like|/|ish|[- ]style|[- ]Style|and|or|&|\s|-)+', rpm_license)
15b5b3a
-                for l in licenses:
15b5b3a
-                    if l != '' and not l in VALID_LICENSES:
15b5b3a
-                        printWarning(pkg, 'invalid-license', rpm_license)
15b5b3a
-                        break
15b5b3a
+                for l1 in split_license(rpm_license):
15b5b3a
+                    if l1 in VALID_LICENSES:
15b5b3a
+                        continue
15b5b3a
+                    for l2 in split_license(l1):
15b5b3a
+                        if l2 not in VALID_LICENSES:
15b5b3a
+                            printWarning(pkg, 'invalid-license', l2)
15b5b3a
 
15b5b3a
         url=pkg[rpm.RPMTAG_URL]
15b5b3a
         if url and url != 'none':
15b5b3a
@@ -808,9 +813,7 @@
15b5b3a
 
15b5b3a
 'invalid-license',
15b5b3a
 '''The value of the License tag was not recognized.  Known values are:
15b5b3a
-%s
15b5b3a
-If the license is close to an existing one, you can use '<license> style'.''' \
15b5b3a
-% fill('"' + '", "'.join(VALID_LICENSES) + '".', 78),
15b5b3a
+%s''' % fill('"' + '", "'.join(VALID_LICENSES) + '".', 78),
15b5b3a
 
15b5b3a
 'invalid-url',
15b5b3a
 '''Your URL is not valid. It must begin with http, https or ftp and must no