[oe-commits] org.oe.dev stage-manager: Updates to fix various bugs copy files instead of moving them and handle symbolic links correctly (from poky)

rpurdie commit openembedded-commits at lists.openembedded.org
Sat Dec 1 23:30:17 UTC 2007


stage-manager: Updates to fix various bugs copy files instead of moving them and handle symbolic links correctly (from poky)

Author: rpurdie at openembedded.org
Branch: org.openembedded.dev
Revision: 9c25f953f12c9d014f2c3bede48fba906bf82600
ViewMTN: http://monotone.openembedded.org/revision/info/9c25f953f12c9d014f2c3bede48fba906bf82600
Files:
1
packages/stage-manager/files/stage-manager
packages/stage-manager/stagemanager-native_0.0.1.bb
Diffs:

#
# mt diff -r7037815966b09ab2bfe1464aaecbd89ab12ffc44 -r9c25f953f12c9d014f2c3bede48fba906bf82600
#
# 
# 
# patch "packages/stage-manager/files/stage-manager"
#  from [1368a040e4fc6b8a70a83f348cacf1c31683f7cf]
#    to [fb9aad832b3e02894ec5c57f49b3de656987cd54]
# 
# patch "packages/stage-manager/stagemanager-native_0.0.1.bb"
#  from [2c67701cd33fc4fa2760a291fa2337c04e3420cd]
#    to [3c3bbddbeddf23d86eb06dd0518a8e7c5185345c]
# 
============================================================
--- packages/stage-manager/files/stage-manager	1368a040e4fc6b8a70a83f348cacf1c31683f7cf
+++ packages/stage-manager/files/stage-manager	fb9aad832b3e02894ec5c57f49b3de656987cd54
@@ -1,6 +1,6 @@
 #!/usr/bin/env python
 
-# Copyright (C) 2006 Richard Purdie
+# Copyright (C) 2006-2007 Richard Purdie
 #
 # This program is free software; you can redistribute it and/or modify it under
 # the terms of the GNU General Public License version 2 as published by the Free
@@ -79,33 +79,54 @@ if __name__ == "__main__":
 
     found = False
 
+    def updateCache(path, fstamp):
+        cache[path] = {}
+        cache[path]['ts'] = fstamp[stat.ST_MTIME]
+        cache[path]['size'] = fstamp[stat.ST_SIZE]
+        found = True
+
+    def copyfile(path):
+        if options.copydir:
+            copypath = os.path.join(options.copydir, path.replace(options.parentdir, '', 1))
+            mkdirhier(os.path.split(copypath)[0])
+            os.system("cp -dp " + path + " " + copypath)
+
+    def copydir(path, fstamp):
+        if options.copydir:
+            copypath = os.path.join(options.copydir, path.replace(options.parentdir, '', 1))
+            if os.path.islink(path):
+                os.symlink(os.readlink(path), copypath)
+            else:
+                mkdirhier(copypath)
+            os.utime(copypath, (fstamp[stat.ST_ATIME], fstamp[stat.ST_MTIME]))
+
     for root, dirs, files in os.walk(options.parentdir):
         for f in files:
             path = os.path.join(root, f)
             if not os.access(path, os.R_OK):
                 continue
-            fstamp = os.stat(path)
+            fstamp = os.lstat(path)
             if path not in cache:
                 print "new file %s" % path
-                cache[path] = {}
-                cache[path]['ts'] = fstamp[stat.ST_MTIME]
-                cache[path]['size'] = fstamp[stat.ST_SIZE]
-                if options.copydir:
-                    copypath = os.path.join(options.copydir, path.replace(options.parentdir, '', 1))
-                    mkdirhier(os.path.split(copypath)[0])
-                    os.system("mv " + path + " " + copypath)
-                    found = True
+		updateCache(path, fstamp)
+                copyfile(path)
             else:
                 if cache[path]['ts'] != fstamp[stat.ST_MTIME] or cache[path]['size'] != fstamp[stat.ST_SIZE]:
                     print "file %s changed" % path
-                    cache[path] = {}
-                    cache[path]['ts'] = fstamp[stat.ST_MTIME]
-                    cache[path]['size'] = fstamp[stat.ST_SIZE]
-		    if options.copydir:
-                        copypath = os.path.join(options.copydir, path.replace(options.parentdir, '', 1))
-                        mkdirhier(os.path.split(copypath)[0])
-                        os.system("mv " + path + " " + copypath)
-                        found = True
+                    updateCache(path, fstamp)
+                    copyfile(path)
+        for d in dirs:
+            path = os.path.join(root, d)
+            fstamp = os.lstat(path)
+            if path not in cache:
+                print "new dir %s" % path
+		updateCache(path, fstamp)
+                copydir(path, fstamp)
+            else:
+                if cache[path]['ts'] != fstamp[stat.ST_MTIME]:
+                    print "dir %s changed" % path
+                    updateCache(path, fstamp)
+                    copydir(path, fstamp)
 
     if options.update:
         print "Updating"
============================================================
--- packages/stage-manager/stagemanager-native_0.0.1.bb	2c67701cd33fc4fa2760a291fa2337c04e3420cd
+++ packages/stage-manager/stagemanager-native_0.0.1.bb	3c3bbddbeddf23d86eb06dd0518a8e7c5185345c
@@ -1,5 +1,5 @@ DESCRIPTION = "Helper script for package
 DESCRIPTION = "Helper script for packaged-staging.bbclass"
-PR = "r1"
+PR = "r7"
 
 SRC_URI = "file://stage-manager"
 LICENSE = "GPLv2"






More information about the Openembedded-commits mailing list