aboutsummaryrefslogtreecommitdiff
blob: 6e098eb8a07640c14d498a08897a022e3892f082 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

from _emerge.CompositeTask import CompositeTask
from _emerge.EbuildPhase import EbuildPhase
from portage import os

class EbuildBinpkg(CompositeTask):
	"""
	This assumes that src_install() has successfully completed.
	"""
	__slots__ = ('pkg', 'settings') + \
		('_binpkg_tmpfile', '_binpkg_info')

	def _start(self):
		pkg = self.pkg
		root_config = pkg.root_config
		bintree = root_config.trees["bintree"]
		binpkg_tmpfile = os.path.join(bintree.pkgdir,
			pkg.cpv + ".tbz2." + str(os.getpid()))
		bintree._ensure_dir(os.path.dirname(binpkg_tmpfile))

		self._binpkg_tmpfile = binpkg_tmpfile
		self.settings["PORTAGE_BINPKG_TMPFILE"] = self._binpkg_tmpfile

		package_phase = EbuildPhase(background=self.background,
			phase='package', scheduler=self.scheduler,
			settings=self.settings)

		self._start_task(package_phase, self._package_phase_exit)

	def _package_phase_exit(self, package_phase):

		self.settings.pop("PORTAGE_BINPKG_TMPFILE", None)
		if self._default_exit(package_phase) != os.EX_OK:
			try:
				os.unlink(self._binpkg_tmpfile)
			except OSError:
				pass
			self.wait()
			return

		pkg = self.pkg
		bintree = pkg.root_config.trees["bintree"]
		self._binpkg_info = bintree.inject(pkg.cpv,
			filename=self._binpkg_tmpfile)

		self._current_task = None
		self.returncode = os.EX_OK
		self.wait()

	def get_binpkg_info(self):
		return self._binpkg_info