]> code.ossystems Code Review - openembedded-core.git/commitdiff
lib/oe: sync with OE.dev
authorJoshua Lock <josh@linux.intel.com>
Tue, 3 Aug 2010 17:18:03 +0000 (18:18 +0100)
committerRichard Purdie <rpurdie@linux.intel.com>
Wed, 4 Aug 2010 10:43:12 +0000 (11:43 +0100)
Most notable change is the move to creating symlinks to patches in the metadata
tree rather than copying them.

Signed-off-by: Joshua Lock <josh@linux.intel.com>
meta/lib/oe/patch.py
meta/lib/oe/path.py
meta/lib/oe/utils.py

index 94c56bc101f91fd480e215412573e2e6010f86e4..f203d683da22ff18d4cb0156fe1427f050a3a25e 100644 (file)
@@ -1,3 +1,5 @@
+import oe.path
+
 class NotFoundError(Exception):
     def __init__(self, path):
         self.path = path
@@ -234,15 +236,10 @@ class QuiltTree(PatchSet):
         if not self.initialized:
             self.InitFromDir()
         PatchSet.Import(self, patch, force)
-
-        args = ["import", "-p", patch["strippath"]]
-        if force:
-            args.append("-f")
-            args.append("-dn")
-        args.append(patch["file"])
-
-        self._runcmd(args)
-
+        oe.path.symlink(patch["file"], self._quiltpatchpath(patch["file"]))
+        f = open(os.path.join(self.dir, "patches","series"), "a");
+        f.write(os.path.basename(patch["file"]) + " -p" + patch["strippath"]+"\n")
+        f.close()
         patch["quiltfile"] = self._quiltpatchpath(patch["file"])
         patch["quiltfilemd5"] = bb.utils.md5_file(patch["quiltfile"])
 
index 89029515818e64761910bcc15334a901507aaeeb..f58c0138bb41d602c6511ffe848e6aa74f91d32c 100644 (file)
@@ -42,3 +42,25 @@ def format_display(path, metadata):
         return path
     else:
         return rel
+
+def remove(path):
+    """Equivalent to rm -f or rm -rf"""
+    import os, errno, shutil
+    try:
+        os.unlink(path)
+    except OSError, exc:
+        if exc.errno == errno.EISDIR:
+            shutil.rmtree(path)
+        elif exc.errno != errno.ENOENT:
+            raise
+
+def symlink(source, destination, force=False):
+    """Create a symbolic link"""
+    import os, errno
+    try:
+        if force:
+            remove(destination)
+        os.symlink(source, destination)
+    except OSError, e:
+        if e.errno != errno.EEXIST or os.readlink(destination) != source:
+            raise
index e61d663a5000967d677bb02f39d0cd793358dd11..3469700726bb63c67b5da59af32369558d43fe51 100644 (file)
@@ -67,3 +67,14 @@ def str_filter(f, str, d):
 def str_filter_out(f, str, d):
     from re import match
     return " ".join(filter(lambda x: not match(f, x, 0), str.split()))
+
+def param_bool(cfg, field, dflt = None):
+    """Lookup <field> in <cfg> map and convert it to a boolean; take
+    <dflt> when this <field> does not exist"""
+    value = cfg.get(field, dflt)
+    strvalue = str(value).lower()
+    if strvalue in ('yes', 'y', 'true', 't', '1'):
+        return True
+    elif strvalue in ('no', 'n', 'false', 'f', '0'):
+        return False
+    raise ValueError("invalid value for boolean parameter '%s': '%s'" % (field, value))