summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Purdie <richard@openedhand.com>2007-11-25 14:03:49 +0000
committerRichard Purdie <richard@openedhand.com>2007-11-25 14:03:49 +0000
commit84e1d7cc07bce1194b890c57664b453f36c0308c (patch)
treeec3ed211ae255f87464467ddd4868a5c05de37fe
parent2f2de3f3a109cfe9179ff5165dd47c9f32416f04 (diff)
downloadopenembedded-core-84e1d7cc07bce1194b890c57664b453f36c0308c.tar.gz
openembedded-core-84e1d7cc07bce1194b890c57664b453f36c0308c.tar.bz2
openembedded-core-84e1d7cc07bce1194b890c57664b453f36c0308c.zip
Add stage-manager-native
git-svn-id: https://svn.o-hand.com/repos/poky/trunk@3229 311d38ba-8fff-0310-9ca6-ca027cbcb966
-rwxr-xr-xmeta/packages/stage-manager/files/stage-manager120
-rw-r--r--meta/packages/stage-manager/stagemanager-native_0.0.1.bb23
2 files changed, 143 insertions, 0 deletions
diff --git a/meta/packages/stage-manager/files/stage-manager b/meta/packages/stage-manager/files/stage-manager
new file mode 100755
index 0000000000..733a0a4f72
--- /dev/null
+++ b/meta/packages/stage-manager/files/stage-manager
@@ -0,0 +1,120 @@
+#!/usr/bin/env python
+
+# 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
+# Software Foundation;
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+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)
+
+
+
diff --git a/meta/packages/stage-manager/stagemanager-native_0.0.1.bb b/meta/packages/stage-manager/stagemanager-native_0.0.1.bb
new file mode 100644
index 0000000000..7074d37307
--- /dev/null
+++ b/meta/packages/stage-manager/stagemanager-native_0.0.1.bb
@@ -0,0 +1,23 @@
+DESCRIPTION = "Helper script for packaged-staging.bbclass"
+PR = "r1"
+
+SRC_URI = "file://stage-manager"
+LICENSE = "GPLv2"
+
+PACKAGE_ARCH = "all"
+
+inherit native
+
+DEPENDS = " "
+PACKAGE_DEPENDS = " "
+PATCHTOOL = ""
+INHIBIT_DEFAULT_DEPS = "1"
+
+do_install() {
+ install -d ${STAGING_BINDIR}
+ install -m 0755 ${WORKDIR}/stage-manager ${STAGING_BINDIR}
+}
+
+do_stage() {
+:
+}