diff options
author | 2017-07-22 05:03:41 +0300 | |
---|---|---|
committer | 2017-07-22 05:08:28 +0300 | |
commit | 12a4d649118f1f64c951cf66f72fdd910e9e6b73 (patch) | |
tree | b427daffc7d069ffd6a12f6c0bd173b44adf0f79 | |
parent | Fixed an off-by-one error (diff) | |
download | pomu-12a4d649118f1f64c951cf66f72fdd910e9e6b73.tar.gz pomu-12a4d649118f1f64c951cf66f72fdd910e9e6b73.tar.bz2 pomu-12a4d649118f1f64c951cf66f72fdd910e9e6b73.zip |
Generify the repo code to allow merging patches
Rename command: install -> import
-rw-r--r-- | pomu/cli.py | 4 | ||||
-rw-r--r-- | pomu/package.py | 9 | ||||
-rw-r--r-- | pomu/repo/repo.py | 14 |
3 files changed, 23 insertions, 4 deletions
diff --git a/pomu/cli.py b/pomu/cli.py index 9477ff9..14e0b95 100644 --- a/pomu/cli.py +++ b/pomu/cli.py @@ -75,8 +75,8 @@ def status(): @click.option('--patch', nargs=-1) #help='Patches for the package') @needs_repo -def install(package, patch): - """Install a package""" +def import(package, patch): + """Imports a package""" pkg = dispatcher.get_package(package).expect() pkg.patch(patch) res = pomu_active_repo().merge(pkg).expect() diff --git a/pomu/package.py b/pomu/package.py index 2651774..e145b88 100644 --- a/pomu/package.py +++ b/pomu/package.py @@ -151,3 +151,12 @@ class Package(): if self.slot != '0': s += self.slot return s + +class PatchList(): + """A class to represent a sequence of patches (can be merged in the repo)""" + def __init__(self, category, name, version, patches, slot='0'): + self.category = category + self.name = name + self.version = version + self.slot = slot + self.patches = patches diff --git a/pomu/repo/repo.py b/pomu/repo/repo.py index 4ca7a76..a60e5b2 100644 --- a/pomu/repo/repo.py +++ b/pomu/repo/repo.py @@ -7,7 +7,7 @@ from git import Repo from patch import PatchSet import portage -from pomu.package import Package +from pomu.package import Package, PatchList from pomu.util.cache import cached from pomu.util.fs import remove_file, strip_prefix from pomu.util.result import Result @@ -32,7 +32,17 @@ class Repository(): def pomu_dir(self): return path.join(self.root, 'metadata/pomu') - def merge(self, package): + def merge(self, mergeable): + """Merges a package or a patchset into the repository""" + if isinstance(mergeable, Package): + return merge_pkg(mergeable) + elif isinstance(mergeable, PatchList): + pkg = self.get_package(mergeable.name, mergeable.category, + mergeable.slot).unwrap() + return pkg.patch(mergeable.patches) + return Result.Err() #unreachable yet + + def merge_pkg(self, package): """Merge a package (a pomu.package.Package package) into the repository""" r = self.repo pkgdir = path.join(self.pomu_dir, package.category, package.name) |