From 1c7929604b84d982296f082c060fcc305fd9146e Mon Sep 17 00:00:00 2001 From: Mykyta Holubakha Date: Fri, 7 Jul 2017 10:40:11 +0300 Subject: 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 --- pomu/package.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'pomu/package.py') 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): """ -- cgit v1.2.3-65-gdbad