chiark / gitweb /
Add support for patching source packages.
authorPaul Sokolovsky <pfalcon@users.sourceforge.net>
Thu, 16 Jun 2011 20:57:49 +0000 (23:57 +0300)
committerPaul Sokolovsky <pfalcon@users.sourceforge.net>
Sat, 2 Jul 2011 15:30:47 +0000 (18:30 +0300)
Sometimes there's a need to patch upstream source. While this can be
scripted using prebuild commands, it's very verbose and unstructured,
so add dedicated patching support.

Details:

To patch source, specific build's metadata line should include:

patch=patch1.patch;patch2.patch;...

Patches are separated with ';', at least one patch should be specified.
They are applied in the order given. Patches are looked up in
metadata/<package>/ directory. Different builds obviously may reference
the same patch(es).

build.py

index 107f511ed02106c52dd6ebbb901d9a2bc6b2b328..5d13d225e2eec5479386a1ef0ca659f63640a14f 100755 (executable)
--- a/build.py
+++ b/build.py
@@ -334,6 +334,16 @@ for app in apps:
                         print "Error running pre-build command"
                         sys.exit(1)
 
+                # Apply patches if any
+                if 'patch' in thisbuild:
+                    for patch in thisbuild['patch'].split(';'):
+                        print "Applying " + patch
+                        patch_path = os.path.join('metadata', app['id'], patch)
+                        if subprocess.call(['patch', '-p1',
+                                        '-i', os.path.abspath(patch_path)], cwd=root_dir) != 0:
+                            print "Failed to apply patch %s" % patch_path
+                            sys.exit(1)
+
                 # Special case init functions for funambol...
                 if thisbuild.get('initfun', 'no')  == "yes":