aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStanislav Ochotnicky <sochotnicky@gmail.com>2009-07-07 00:22:28 +0200
committerStanislav Ochotnicky <sochotnicky@gmail.com>2009-07-07 23:38:23 +0200
commitae8b72973d91ce0662472c705f7994008cf8fae2 (patch)
treea91cad28f72e5f24687f8792889c650cb95bc4b1 /src/tinderbox/__init__.py
parentMoved tinderbox specific config (diff)
downloadcollagen-ae8b72973d91ce0662472c705f7994008cf8fae2.tar.gz
collagen-ae8b72973d91ce0662472c705f7994008cf8fae2.tar.bz2
collagen-ae8b72973d91ce0662472c705f7994008cf8fae2.zip
Fixed regression when we started installing deps
We are sending list of package infos now, instead of single package info to Matchbox. More changes to Matchbox pending
Diffstat (limited to 'src/tinderbox/__init__.py')
-rw-r--r--src/tinderbox/__init__.py78
1 files changed, 58 insertions, 20 deletions
diff --git a/src/tinderbox/__init__.py b/src/tinderbox/__init__.py
index 6aea7c1..75c789f 100644
--- a/src/tinderbox/__init__.py
+++ b/src/tinderbox/__init__.py
@@ -53,11 +53,6 @@ class Tinderbox(object):
package = Package(gnp.package_name, gnp.version, gnp.use_flags)
sleep(5)
self.emerge_package(package)
- pi = package.get_info()
- pi.emerge_info = self.get_emerge_info()
-
- msg = protocol.AddPackageInfo(pi)
- self.sock.sendall(pickle.dumps(msg))
else:
print "Unknown reply: %s" % reply_unpickled
@@ -128,10 +123,10 @@ class Tinderbox(object):
print "Something went really bad and we need logging, stat!"
log.error("Emerge of package %s failed with error code: %d" % (pkg, status))
-
-
-
- #TODO get contents && make binpkg && report back to matchbox && uninstall deps && uninstall pkg
+ package_infos = self._load_info('package_infos')
+ msg = protocol.AddPackageInfo(package_infos)
+ self.sock.sendall(pickle.dumps(msg))
+ #TODO make binpkg
def _emerge_package_subprocess(self, pkg, ebuild, dep_groups, package):
@@ -148,7 +143,6 @@ class Tinderbox(object):
deps_processed = []
for dep in group:
- orig_args = sys.argv
try:
# this will need to change since it's only a quick hack so that
# we don't have to do dep resolution ourselves
@@ -157,10 +151,17 @@ class Tinderbox(object):
# we need to run emerge_main() in child process since a lot of stuff in there
# likes to call sys.exit() and we don't want that do we?
if 0 == dep_emergepid:
- extra_use = dep[0]
- os.environ["USE"]=" ".join(extra_use)
- sys.argv = ["emerge","--verbose","=%s" % dep[1]]
- sys.exit(emerge.emerge_main())
+ try:
+ extra_use = dep[0]
+ if extra_use:
+ os.environ["USE"]=" ".join(extra_use)
+ sys.argv = ["emerge","--verbose","=%s" % dep[1]]
+ exit_code = emerge.emerge_main()
+ sys.exit(exit_code)
+ except Exception, e:
+ print_exc()
+ log.error(format_exc())
+ sys.exit(1)
ret = os.waitpid(dep_emergepid, 0)
if 0 != ret[1]:
raise Exception("emerge_main() failed with error code %d" % ret)
@@ -171,12 +172,20 @@ class Tinderbox(object):
break
deps_processed.append(dep)
- settings.setcpv(dep, mydb=portdb)
+ settings.setcpv(dep[1], mydb=portdb)
dep_use_enabled = set(settings["PORTAGE_USE"].split())
dep_iuse = set(settings["IUSE"].split())
- dep_name, dep_ver, dep_rev = portage.pkgsplit(dep)
+ dep_name, dep_ver, dep_rev = portage.pkgsplit(dep[1])
- dep_pkg = Package(dep_name,"%s-%s" % (dep_ver, dep_rev), list(dep_use_enabled & dep_iuse))
+ real_use_enabled = list(dep_use_enabled & dep_iuse)
+ if dep[0]:
+ for useflag in dep[0]:
+ if useflag.startswith('-'):
+ real_use_enabled.remove(useflag[1:])
+ elif 0 == real_use_enabled.count(useflag):
+ real_use_enabled.append(useflag)
+
+ dep_pkg = Package(dep_name,"%s-%s" % (dep_ver, dep_rev), real_use_enabled)
package_infos.append(dep_pkg.get_info())
@@ -184,6 +193,7 @@ class Tinderbox(object):
log.error("Unable to emerge package %s with deps %s" % (pkg, group))
# TODO unmerge succeeded deps
continue
+ settings.setcpv(pkg, mydb=portdb)
ret = portage.doebuild(ebuild, "merge", portage.root, settings, debug = False, tree="porttree")
if 0 != ret:
@@ -210,7 +220,7 @@ class Tinderbox(object):
package_infos.append(package.get_info())
for dep in group:
- dep_cat, dep_pv = portage.catsplit(dep)
+ dep_cat, dep_pv = portage.catsplit(dep[1])
ret = portage.unmerge(dep_cat, dep_pv, portage.root, settings, True, vartree=vartree)
if 0 != ret:
@@ -218,12 +228,40 @@ class Tinderbox(object):
pkg_cat, pkg_pv = portage.catsplit(pkg)
ret = portage.unmerge(pkg_cat, pkg_pv, portage.root, settings, True, vartree=vartree)
- if 0 != ret:
- log.error("Unable to unmerge dep %s" % dep)
+ if ret != 0:
+ log.error("Unable to unmerge package %s" % dep)
+ self._save_info('package_infos', package_infos)
+
+ def _save_info(self, key, data):
+ """
+ Save data inside CHROOT_LOGS directory, under name 'key'. This
+ function is called from within _emerge_package_subprocess to
+ save data for parent process
+ @param key: key used to identify data inside CHROOT_LOGS directory
+ @type key: string
+ @param data: data to be saved
+ @rtype: None
+ """
+ outfile = open("%s/%s" % (config.CHROOT_LOGS, key), "w")
+ pickle.dump(data, outfile)
+ outfile.close()
+ def _load_info(self, key):
+ """
+ Load data from CHROOT_LOGS directory (under WORK_CHROOT) with filename 'key'
+
+
+ @param key: key used to identify data inside directory
+ @type key: string
+ @rtype: depends on key
+ @returns: data loaded from filename, usually blob
+ """
+ infile = open("%s/%s/%s" % (config.WORK_CHROOT, config.CHROOT_LOGS,
+ key),"r")
+ return pickle.load(infile)