[oe-commits] org.oe.dev packaged-staging: add a recipe for stage-manager and DEPENDS on it

koen commit openembedded-commits at lists.openembedded.org
Tue Oct 17 08:38:58 UTC 2006


packaged-staging: add a recipe for stage-manager and DEPENDS on it

Author: koen at openembedded.org
Branch: org.openembedded.dev
Revision: 3dae7e8b48fc4cd00b9157a823128dc1f38457c8
ViewMTN: http://monotone.openembedded.org/revision.psp?id=3dae7e8b48fc4cd00b9157a823128dc1f38457c8
Files:
1
packages/stage-manager
packages/stage-manager/files
packages/stage-manager/files/stage-manager
packages/stage-manager/stagemanager-native_0.0.bb
classes/packaged-staging.bbclass
mtn:execute
true
Diffs:

#
# mt diff -r46e19d94013b5ae2209ab70b990c946b2ebc5c19 -r3dae7e8b48fc4cd00b9157a823128dc1f38457c8
#
# 
# 
# add_dir "packages/stage-manager"
# 
# add_dir "packages/stage-manager/files"
# 
# add_file "packages/stage-manager/files/stage-manager"
#  content [4a92fee454a001ca8e637af475d73852401394fc]
# 
# add_file "packages/stage-manager/stagemanager-native_0.0.bb"
#  content [55a830ea446defbbace1ac574eec784a1a86858a]
# 
# patch "classes/packaged-staging.bbclass"
#  from [7d48ddb5c5b746fafe188e065c4741cf3b1bc9a9]
#    to [da5f51ca93cb51b5f63a30a3b1a219439e1b0cab]
# 
#   set "packages/stage-manager/files/stage-manager"
#  attr "mtn:execute"
# value "true"
# 
============================================================
--- packages/stage-manager/files/stage-manager	4a92fee454a001ca8e637af475d73852401394fc
+++ packages/stage-manager/files/stage-manager	4a92fee454a001ca8e637af475d73852401394fc
@@ -0,0 +1,110 @@
+#!/usr/bin/env python
+
+import optparse
+import os, sys, stat
+
+__version__ = "0.0.1"
+
+
+def write_cache(cachefile, cachedata):
+    fd = open(cachefile, 'w')
+    for f in cachedata:
+        s = f + '|' + str(cachedata[f]['ts']) + '|' + str(cachedata[f]['size'])
+        fd.write(s + '\n')
+    fd.close()
+
+def read_cache(cachefile):
+    cache = {}
+    f = open(cachefile, 'r')
+    lines = f.readlines()
+    f.close()
+    for l in lines:
+        data = l.split('|')
+        cache[data[0]] = {}
+        cache[data[0]]['ts'] = int(data[1])
+        cache[data[0]]['size'] = int(data[2])
+    return cache
+
+def mkdirhier(dir):
+    """Create a directory like 'mkdir -p', but does not complain if
+    directory already exists like os.makedirs
+    """
+    try:
+        os.makedirs(dir)
+    except OSError, e:
+        if e.errno != 17: raise e
+
+if __name__ == "__main__":
+    parser = optparse.OptionParser( version = "Metadata Stage Manager version %s" % ( __version__ ),
+    usage = """%prog [options]\n\nPerforms mamagement tasks on a metadata staging area.""" )
+
+    parser.add_option( "-p", "--parentdir", help = "the path to the metadata parent directory",
+               action = "store", dest = "parentdir", default = None)
+
+    parser.add_option( "-c", "--cachefile", help = "the cache file to use",
+               action = "store", dest = "cachefile", default = None)
+
+    parser.add_option( "-d", "--copydir", help = "copy changed files to this directory",
+               action = "store", dest = "copydir", default = None)
+
+    parser.add_option( "-u", "--update", help = "update the cache file",
+               action = "store_true", dest = "update", default = False)
+
+    (options, args) = parser.parse_args()
+
+    if options.parentdir is None:
+        print("Error, --parentdir option not supplied")
+        sys.exit(1)
+
+    if options.cachefile is None:
+        print("Error, --cachefile option not supplied")
+        sys.exit(1)
+
+    if not options.parentdir.endswith('/'):
+        options.parentdir = options.parentdir + '/'
+
+    cache = {}
+    if os.access(options.cachefile, os.F_OK):
+	cache = read_cache(options.cachefile)
+
+    found = False
+
+    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)
+            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
+            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
+
+    if options.update:
+        print "Updating"
+        mkdirhier(os.path.split(options.cachefile)[0])
+        write_cache(options.cachefile, cache)
+
+    if found:
+        sys.exit(5)
+    sys.exit(0)
+
+
+
============================================================
--- packages/stage-manager/stagemanager-native_0.0.bb	55a830ea446defbbace1ac574eec784a1a86858a
+++ packages/stage-manager/stagemanager-native_0.0.bb	55a830ea446defbbace1ac574eec784a1a86858a
@@ -0,0 +1,12 @@
+DESCRIPTION = "Helper script for packaged-staging.bbclass"
+
+SRC_URI = "file://stage-manager"
+
+INHIBIT_DEFAULT_DEPS = "1"
+
+do_install() {
+	install -d ${STAGING_BINDIR}
+	install -m 0755 ${WORKDIR}/stage-manager ${STAGING_BINDIR}
+}
+
+
============================================================
--- classes/packaged-staging.bbclass	7d48ddb5c5b746fafe188e065c4741cf3b1bc9a9
+++ classes/packaged-staging.bbclass	da5f51ca93cb51b5f63a30a3b1a219439e1b0cab
@@ -23,6 +23,8 @@ inherit package
 
 inherit package
 
+DEPENDS = "stagemanager-native"
+
 DEPLOY_DIR_PSTAGE 	= "${DEPLOY_DIR}/pstage" 
 
 PSTAGE_BUILD_CMD        = "${IPKGBUILDCMD}"






More information about the Openembedded-commits mailing list