pld-builder.new: PLD_Builder/chroot.py Get content found between r...

arekm arekm at pld-linux.org
Sun Feb 25 15:48:17 CET 2007


Author: arekm                        Date: Sun Feb 25 14:48:17 2007 GMT
Module: pld-builder.new               Tag: HEAD
---- Log message:
Get content found between rpm markers.

---- Files affected:
pld-builder.new/PLD_Builder:
   chroot.py (1.24 -> 1.25) 

---- Diffs:

================================================================
Index: pld-builder.new/PLD_Builder/chroot.py
diff -u pld-builder.new/PLD_Builder/chroot.py:1.24 pld-builder.new/PLD_Builder/chroot.py:1.25
--- pld-builder.new/PLD_Builder/chroot.py:1.24	Sun Feb 25 15:09:19 2007
+++ pld-builder.new/PLD_Builder/chroot.py	Sun Feb 25 15:48:12 2007
@@ -2,7 +2,9 @@
 
 import os
 import re
-import subprocess
+import md5
+import random
+
 from config import config
 
 def quote(cmd):
@@ -40,13 +42,33 @@
         return r
 
 def cp(file, outfile, user="builder", rm=False):
+    m = md5.new()
+    m.update(str(random.getrandbits(4096)))
+    digest = m.hexdigest()
+
+    marker_start = "--- RPM BEGIN DIGEST %s ---" % digest
+    marker_end = "--- RPM END DIGEST %s ---" % digest
+
     f = open(outfile, 'w')
-    fileno = f.fileno()
-    cmd = "cat %s" % file
+    cmd = "echo \"%s\"; cat %s; echo \"%s\"" % (marker_start, file, marker_end)
     if rm:
         cmd += "; rm %s" % file
     c = command(cmd, user)
-    subprocess.call(c, shell = True, stdout = f)
+    f = os.popen(c)
+    # get file contents
+    marker = False
+    for l in p:
+        if not marker and l.strip() == marker_start:
+            marker = True
+            continue
+        p = l.strip().find(marker_end)
+        if p != -1:
+            l = l[:p]
+            f.write(l)
+            marker = False
+            break
+        if marker:
+            f.write(l)
     r = f.close()
     if r == None:
         return 0
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/pld-builder.new/PLD_Builder/chroot.py?r1=1.24&r2=1.25&f=u



More information about the pld-cvs-commit mailing list