summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Grapentin <andreas@grapentin.org>2019-02-03 21:37:27 +0100
committerAndreas Grapentin <andreas@grapentin.org>2019-02-03 21:37:27 +0100
commit0ae6c79c6cfc8a17f6661a4329698982a83305d2 (patch)
tree99b6c1b70f42c69c193a1678ac4d0479079fc99d
parentdbc215617c106c8fd6133a6ab4e31c486e79c876 (diff)
linking packages to pkgbuilds
-rw-r--r--parabola_repolint/linter_checks/missing_pkgbuild.py2
-rw-r--r--parabola_repolint/linter_checks/multiple_pkgbuilds.py25
-rw-r--r--parabola_repolint/linter_checks/package_not_in_repo.py24
-rw-r--r--parabola_repolint/repocache.py35
4 files changed, 72 insertions, 14 deletions
diff --git a/parabola_repolint/linter_checks/missing_pkgbuild.py b/parabola_repolint/linter_checks/missing_pkgbuild.py
index 8af8766..7fa972c 100644
--- a/parabola_repolint/linter_checks/missing_pkgbuild.py
+++ b/parabola_repolint/linter_checks/missing_pkgbuild.py
@@ -14,7 +14,7 @@ class MissingPkgbuild(LinterCheckBase):
def check(self, package):
''' check for packages with nonexistant pkgbuild '''
- if package.pkgbuild is None:
+ if not package.pkgbuilds:
raise LinterIssue(package)
def format(self, issues):
diff --git a/parabola_repolint/linter_checks/multiple_pkgbuilds.py b/parabola_repolint/linter_checks/multiple_pkgbuilds.py
new file mode 100644
index 0000000..a5c3bb3
--- /dev/null
+++ b/parabola_repolint/linter_checks/multiple_pkgbuilds.py
@@ -0,0 +1,25 @@
+'''
+this is a linter check for packages with too many PKGBUILDs
+'''
+
+from parabola_repolint.linter import LinterIssue, LinterCheckBase, LinterCheckType
+from parabola_repolint.config import CONFIG
+
+
+class MultiplePkgbuilds(LinterCheckBase):
+ ''' check for a package without more than one PKGBUILD '''
+
+ name = 'multiple_pkgbuilds'
+ check_type = LinterCheckType.PACKAGE
+
+ def check(self, package):
+ ''' check for packages with too many PKGBUILDs '''
+ if len(package.pkgbuilds) > 1:
+ raise LinterIssue(package, package.pkgbuilds)
+
+ def format(self, issues):
+ ''' format the list of found issues '''
+ result = 'packages with multiple associated PKGBUILDs:'
+ for issue in issues:
+ result += '\n %s: %s' % (issue[0], issue[1])
+ return result
diff --git a/parabola_repolint/linter_checks/package_not_in_repo.py b/parabola_repolint/linter_checks/package_not_in_repo.py
new file mode 100644
index 0000000..835f145
--- /dev/null
+++ b/parabola_repolint/linter_checks/package_not_in_repo.py
@@ -0,0 +1,24 @@
+'''
+this is a linter check for package files that are not in the repository
+'''
+
+from parabola_repolint.linter import LinterIssue, LinterCheckBase, LinterCheckType
+from parabola_repolint.config import CONFIG
+
+
+class PackageNotInRepo(LinterCheckBase):
+ ''' check for a package that is not in the repo.db '''
+
+ name = 'package_not_in_repo'
+ check_type = LinterCheckType.PACKAGE
+
+ def check(self, package):
+ ''' check if the package is part of the repo '''
+ pass
+
+ def format(self, issues):
+ ''' format the list of found issues '''
+ result = 'packages not listed in repo.db:'
+ for issue in issues:
+ result += '\n %s' % issue[0]
+ return result
diff --git a/parabola_repolint/repocache.py b/parabola_repolint/repocache.py
index 372546a..e9076e2 100644
--- a/parabola_repolint/repocache.py
+++ b/parabola_repolint/repocache.py
@@ -41,9 +41,9 @@ class Package():
else:
self._data[cur] = line
- self._pkgbuild = repo.find_pkgbuild(self.pkgname)
- if self._pkgbuild is None and self.pkgname.endswith('-debug'):
- self._pkgbuild = repo.find_pkgbuild(self.pkgname[:-6])
+ self._pkgbuilds = repo.pkgbuild_cache.get(self.pkgname, [])
+ if not self._pkgbuilds and self.pkgname.endswith('-debug'):
+ self._pkgbuilds = repo.pkgbuild_cache.get(self.pkgname[:-6], [])
def _cached_pacinfo(self, cachefile, mtime):
''' get information from a package '''
@@ -68,9 +68,14 @@ class Package():
return self._path
@property
- def pkgbuild(self):
- ''' produce the pkgbuild to the package '''
- return self._pkgbuild
+ def pkgbuilds(self):
+ ''' produce the pkgbuilds to the package '''
+ return self._pkgbuilds
+
+ @property
+ def repo(self):
+ ''' produce the repo of the package '''
+ return self._repo
@property
def pkgname(self):
@@ -266,10 +271,15 @@ class Repo():
self._package_dir = package_dir
self._pkgbuilds = []
+ self._pkgbuild_cache = {}
for root, _, files in os.walk(self._pkgbuild_dir):
if 'PKGBUILD' in files:
- pkgbuild_path = os.path.join(root, 'PKGBUILD')
- self._pkgbuilds.append(Pkgbuild(self, pkgbuild_path))
+ pkgbuild = Pkgbuild(self, os.path.join(root, 'PKGBUILD'))
+ self._pkgbuilds.append(pkgbuild)
+ for pkgname in pkgbuild.srcinfo.pkginfo:
+ if pkgname not in self._pkgbuild_cache:
+ self._pkgbuild_cache[pkgname] = []
+ self._pkgbuild_cache[pkgname].append(pkgbuild)
self._packages = []
for root, _, files in os.walk(self._package_dir):
@@ -287,11 +297,10 @@ class Repo():
''' produce the list of packages in the repo '''
return self._packages
- def find_pkgbuild(self, pkgname):
- ''' find a pkgbuild by pkgname '''
- for pkgbuild in self.pkgbuilds:
- if pkgname in pkgbuild.srcinfo.pkginfo:
- return pkgbuild
+ @property
+ def pkgbuild_cache(self):
+ ''' produce the list of pkgbuilds by pkgname '''
+ return self._pkgbuild_cache
def __repr__(self):
''' produce a string representation of the repo '''