aboutsummaryrefslogtreecommitdiff
path: root/pomu
diff options
context:
space:
mode:
Diffstat (limited to 'pomu')
-rw-r--r--pomu/cli.py2
-rw-r--r--pomu/data/zugaina.py2
-rw-r--r--pomu/patch/patch.py4
-rw-r--r--pomu/source/file.py3
-rw-r--r--pomu/source/portage.py18
-rw-r--r--pomu/util/pkg.py2
-rw-r--r--pomu/util/portage.py4
-rw-r--r--pomu/util/remote.py6
8 files changed, 15 insertions, 26 deletions
diff --git a/pomu/cli.py b/pomu/cli.py
index f9b40f0..bb3fe58 100644
--- a/pomu/cli.py
+++ b/pomu/cli.py
@@ -90,7 +90,7 @@ def import_cmd(package, patch):
@click.argument('patch', type=click.Path(exists=True), nargs=-1, required=True)
def patch(package):
"""Patch an existing package"""
- category, name, *_ = cpv_split(package)
+ category, name, _ = cpv_split(package)
pkg = pomu_active_repo().get_package(name=name, category=category).expect()
pkg.patch(patch).expect()
diff --git a/pomu/data/zugaina.py b/pomu/data/zugaina.py
index 88f2fbc..92accb8 100644
--- a/pomu/data/zugaina.py
+++ b/pomu/data/zugaina.py
@@ -40,7 +40,7 @@ class ZugainaDataSource(DataSource):
for div in doc.xpath('//div[@id="ebuild_list"]/ul/div'):
id_ = div.xpath('li/a')[0].get('href').split('/')[3]
pv = div.xpath('li/div/b')[0].text
- v = cpv_split(pv, True)[2]
+ v = cpv_split(pv)[2]
overlay = div.xpath('@id')[0]
res.append((id_, v, overlay))
return res
diff --git a/pomu/patch/patch.py b/pomu/patch/patch.py
index ddc205b..7bb9cb8 100644
--- a/pomu/patch/patch.py
+++ b/pomu/patch/patch.py
@@ -35,7 +35,7 @@ def process_changes(_repo, single):
res = {x: res[x] for x in res if res[x]}
paths = {x: paths[x] for x in paths if res[x]}
for _pkg, diffs in res.items(): # add each change as its own patch
- cat, name, *_ = cpv_split(_pkg)
+ cat, name, _ = cpv_split(_pkg)
patch_contents = '\n'.join(diffs)
pkg = _repo.get_package(name, cat).expect()
patch_name = '{}-user_changes.patch'.format(int(time()))
@@ -88,7 +88,7 @@ def process_changes(_repo, single):
if pkpref in res:
res[pkpref].append(f)
for _pkg, diffs in res.items(): # apply each newly added patch
- cat, name, *_ = cpv_split(_pkg)
+ cat, name, _ = cpv_split(_pkg)
pkg = _repo.get_package(name, cat).expect()
for d in diffs:
pkg.patch(d)
diff --git a/pomu/source/file.py b/pomu/source/file.py
index 7658435..67ecdb2 100644
--- a/pomu/source/file.py
+++ b/pomu/source/file.py
@@ -60,8 +60,7 @@ class LocalEbuildSource(BaseSource):
uri = path.abspath(uri)
dirn, basen = path.split(uri)
basen = basen[:-7]
- _, name, v1, v2, v3 = cpv_split(basen)
- ver = ver_str(v1, v2, v3)
+ _, name, ver = cpv_split(basen)
parent = dirn.split('/')[-1]
# we need to query the impure world
# TODO: write a global option which would set the impure values non-interactively
diff --git a/pomu/source/portage.py b/pomu/source/portage.py
index abd5851..9b5d57f 100644
--- a/pomu/source/portage.py
+++ b/pomu/source/portage.py
@@ -42,7 +42,7 @@ class PortagePackage(PackageBase):
with open(path.join(pkgdir, 'PORTAGE_DATA'), 'r') as f:
repo = f.readline().strip()
- if sanity_check(repo, pkg.category, pkg.name, None, None, None, pkg.slot, ver=pkg.version):
+ if sanity_check(repo, pkg.category, pkg.name, pkg.version, pkg.slot):
return Result.Ok(PortagePackage(repo, pkg.category, pkg.name, pkg.slot, pkg.version))
return Result.Err('Package {} not found'.format(pkg))
@@ -66,8 +66,8 @@ class PortageSource(BaseSource):
pkg, _, slot = uri.partition(':') # slot may be omitted
if not slot:
slot = None
- category, name, vernum, suff, rev = cpv_split(pkg)
- res = sanity_check(repo, category, name, vernum, suff, rev, slot)
+ category, name, ver = cpv_split(pkg)
+ res = sanity_check(repo, category, name, ver, slot)
if not res:
return Result.Err()
return Result.Ok(res)
@@ -103,8 +103,7 @@ class PortageSource(BaseSource):
if path.isfile(uri):
if not uri.endswith('.ebuild'):
return Result.Err()
- _, name, v1, v2, v3 = cpv_split(path.basename(uri))
- ver = ver_str(v1, v2, v3)
+ _, name, ver = cpv_split(path.basename(uri))
dircomps = path.dirname(uri)[len(repo_path):].split('/')
if len(dircomps) != 2:
return Result.Err()
@@ -126,7 +125,7 @@ class PortageSource(BaseSource):
return PortagePackage.from_data_dir(metadir)
-def sanity_check(repo, category, name, vernum, suff, rev, slot, ver=None):
+def sanity_check(repo, category, name, ver, slot):
"""
Checks whether a package descriptor is valid and corresponds
to a package in a configured portage repository
@@ -135,13 +134,6 @@ def sanity_check(repo, category, name, vernum, suff, rev, slot, ver=None):
return False
if repo and repo not in list(portage_repos()):
return False
- if not ver:
- if (rev or suff) and not vernum:
- return False
- if vernum:
- ver = ver_str(vernum, suff, rev)
- else:
- ver = None
pkgs = repo_pkgs(repo, category, name, ver, slot)
if not pkgs:
return False
diff --git a/pomu/util/pkg.py b/pomu/util/pkg.py
index a4ee991..b65ec88 100644
--- a/pomu/util/pkg.py
+++ b/pomu/util/pkg.py
@@ -14,7 +14,7 @@ def ver_str(vernum, suff, rev):
"""Gets the string representation of the version (specified by number, suffix and rev)"""
return vernum + (suff if suff else '') + ('-' + rev if rev else '')
-def cpv_split(pkg, unified_ver=False):
+def cpv_split(pkg, unified_ver=True):
"""
Extracts category, name, version number, suffix, revision from a package descriptor
e.g. dev-libs/openssl-0.9.8z_p8-r100 -> dev-libs, openssl, 0.9.8z, p8, r100
diff --git a/pomu/util/portage.py b/pomu/util/portage.py
index 98946d9..b505602 100644
--- a/pomu/util/portage.py
+++ b/pomu/util/portage.py
@@ -23,8 +23,8 @@ def best_ver(repo, category, name, ver=None):
if x.endswith('.ebuild')]
if not ebuilds:
return None
- cat, name, vernum, suff, rev = cpv_split(best(ebuilds))
- return ver_str(vernum, suff, rev)
+ cat, name, ver = cpv_split(best(ebuilds))
+ return ver
def repo_pkgs(repo, category, name, ver=None, slot=None):
"""List of package occurences in the repo"""
diff --git a/pomu/util/remote.py b/pomu/util/remote.py
index b1ce78a..f992c1d 100644
--- a/pomu/util/remote.py
+++ b/pomu/util/remote.py
@@ -20,10 +20,9 @@ def filelist_to_cpvs(tree):
not comps[2].endswith('.ebuild')):
continue
category, name, ebuild = comps[0], comps[1], comps[2][:-7]
- c, n, v, s, r = cpv_split(ebuild)
+ c, n, ver = cpv_split(ebuild)
if not category or n != name:
continue
- ver = ver_str(v, s, r)
res.append((category, name, ver))
return res
@@ -34,7 +33,6 @@ def get_full_cpv(cpvs, name, category=None, version=None):
cpvl = list(filter(lambda x: x[2] == version, cpvl))[:1]
b = best(list('{}/{}-{}'.format(c, n, v) for c, n, v in cpvl))
if b:
- cat, name, v, s, r = cpv_split(b)
- ver = ver_str(v, s, r)
+ cat, name, ver = cpv_split(b)
return Result.Ok((cat, name, ver))
return Result.Err()