diff options
author | Mykyta Holubakha <hilobakho@gmail.com> | 2017-07-07 10:40:11 +0300 |
---|---|---|
committer | Mykyta Holubakha <hilobakho@gmail.com> | 2017-07-18 23:26:27 +0300 |
commit | 1c7929604b84d982296f082c060fcc305fd9146e (patch) | |
tree | 7bba82a909ec6596d6c9572587241a8ea9b51a89 /pomu/package.py | |
parent | Fixed a logic error in Dispatcher (diff) | |
download | pomu-1c7929604b84d982296f082c060fcc305fd9146e.tar.gz pomu-1c7929604b84d982296f082c060fcc305fd9146e.tar.bz2 pomu-1c7929604b84d982296f082c060fcc305fd9146e.zip |
Overhauled patching support
dropped patch package source module
added --patch option to the install command
added a patch command to patch an existing package
integrated patch support into the Package class
created a MergedPackage module for operations on packages already in the
pomu repo
added ways to patch an existing package
added a base package source module (template), with base classes for
package-specific metadata and the source module per se
added a list_add utility function
implemented and_, and_then, and or in util.result
Diffstat (limited to 'pomu/package.py')
-rw-r--r-- | pomu/package.py | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/pomu/package.py b/pomu/package.py index 5027569..4a39cd3 100644 --- a/pomu/package.py +++ b/pomu/package.py @@ -13,10 +13,11 @@ import subprocess from patch import PatchSet from pomu.util.fs import strip_prefix +from pomu.util.misc import list_add from pomu.util.result import Result class Package(): - def __init__(self, name, root, backend=None, category=None, version=None, slot='0', d_path=None, files=None, filemap=None): + def __init__(self, name, root, backend=None, category=None, version=None, slot='0', d_path=None, files=None, filemap=None, patches=[]): """ Parameters: backend - specific source module object/class @@ -35,6 +36,7 @@ class Package(): self.version = version self.slot = slot self.filemap = {} + self.patches = patches if d_path is None and files is None and filemap is None: self.d_path = None self.read_path(self.root) @@ -82,14 +84,18 @@ class Package(): copy2(src, dest) except PermissionError: return Result.Err('You do not have enough permissions') - return Result.Ok() + return Result.Ok().and_(self.apply_patches()) + + def patch(self, patch): + list_add(self.patches, patch) - def apply_patches(self, location, patches): - """Applies a sequence of patches at the location""" + def apply_patches(self): + """Applies a sequence of patches at the root (after merging)""" ps = PatchSet() - for p in patches: + for p in self.patches: ps.parse(open(p, 'r')) - ps.apply(root=location) + ps.apply(root=self.root) + return Result.Ok() def gen_manifests(self, dst): """ |