diff mbox

[01/20] Add ability to remove files from packages by prefixing by an exclamation mark

Message ID 1407352611-7652-1-git-send-email-diorcet.yann@gmail.com
State New
Delegated to: Esben Haabendal
Headers show

Commit Message

Yann Diorcet Aug. 6, 2014, 7:16 p.m. UTC
---
 classes/package.oeclass | 30 ++++++++++++++++++++++++++----
 1 file changed, 26 insertions(+), 4 deletions(-)
diff mbox

Patch

diff --git a/classes/package.oeclass b/classes/package.oeclass
index 9486479..c363e84 100644
--- a/classes/package.oeclass
+++ b/classes/package.oeclass
@@ -48,7 +48,13 @@  def do_split(d):
         oelite.util.makedirs(root)
 
         files = (d.get("FILES_" + pkg) or "").split()
-        for file in files:
+        resolved_files = []
+        removed_files = []
+        while len(files):
+            file = files.pop(0)
+            remove = file.startswith("!")
+            if remove:
+                file = file[1:]
             if os.path.isabs(file):
                 file = "." + file
             if not os.path.islink(file):
@@ -61,15 +67,31 @@  def do_split(d):
             if globbed:
                 if [ file ] != globbed:
                     if not file in globbed:
-                        files += globbed
+                        if remove:
+                            files += ["!"+ x for x in globbed]
+                        else:
+                            files += globbed
                         continue
                     else:
                         globbed.remove(file)
-                        files += globbed
+                        if remove:
+                            files += ["!"+ x for x in globbed]
+                        else:
+                            files += globbed
+                        continue
             if (not os.path.islink(file)) and (not os.path.exists(file)):
                 continue
-            if file in seen:
+            if remove:
+                removed_files.append(file)
                 continue
+            if not file in seen:
+                resolved_files.append(file)
+
+        for file in removed_files:
+            if file in resolved_files:
+                resolved_files.remove(file)
+
+        for file in resolved_files:
             seen.append(file)
             if os.path.isdir(file) and not os.path.islink(file):
                 oelite.util.makedirs(os.path.join(root,file))