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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
|
# Copyright 1999-2009 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
from portage import os
from portage.output import colorize
from _emerge.Binpkg import Binpkg
from _emerge.CompositeTask import CompositeTask
from _emerge.EbuildBuild import EbuildBuild
from _emerge.PackageUninstall import PackageUninstall
class MergeListItem(CompositeTask):
"""
TODO: For parallel scheduling, everything here needs asynchronous
execution support (start, poll, and wait methods).
"""
__slots__ = ("args_set",
"binpkg_opts", "build_opts", "config_pool", "emerge_opts",
"find_blockers", "logger", "mtimedb", "pkg",
"pkg_count", "pkg_to_replace", "prefetcher",
"settings", "statusMessage", "world_atom") + \
("_install_task",)
def _start(self):
pkg = self.pkg
build_opts = self.build_opts
if pkg.installed:
# uninstall, executed by self.merge()
self.returncode = os.EX_OK
self.wait()
return
args_set = self.args_set
find_blockers = self.find_blockers
logger = self.logger
mtimedb = self.mtimedb
pkg_count = self.pkg_count
scheduler = self.scheduler
settings = self.settings
world_atom = self.world_atom
ldpath_mtimes = mtimedb["ldpath"]
action_desc = "Emerging"
preposition = "for"
if pkg.type_name == "binary":
action_desc += " binary"
if build_opts.fetchonly:
action_desc = "Fetching"
msg = "%s (%s of %s) %s" % \
(action_desc,
colorize("MERGE_LIST_PROGRESS", str(pkg_count.curval)),
colorize("MERGE_LIST_PROGRESS", str(pkg_count.maxval)),
colorize("GOOD", pkg.cpv))
portdb = pkg.root_config.trees["porttree"].dbapi
portdir_repo_name = portdb._repository_map.get(portdb.porttree_root)
if portdir_repo_name:
pkg_repo_name = pkg.metadata.get("repository")
if pkg_repo_name != portdir_repo_name:
if not pkg_repo_name:
pkg_repo_name = "unknown repo"
msg += " from %s" % pkg_repo_name
if pkg.root != "/":
msg += " %s %s" % (preposition, pkg.root)
if not build_opts.pretend:
self.statusMessage(msg)
logger.log(" >>> emerge (%s of %s) %s to %s" % \
(pkg_count.curval, pkg_count.maxval, pkg.cpv, pkg.root))
if pkg.type_name == "ebuild":
build = EbuildBuild(args_set=args_set,
background=self.background,
config_pool=self.config_pool,
find_blockers=find_blockers,
ldpath_mtimes=ldpath_mtimes, logger=logger,
opts=build_opts, pkg=pkg, pkg_count=pkg_count,
prefetcher=self.prefetcher, scheduler=scheduler,
settings=settings, world_atom=world_atom)
self._install_task = build
self._start_task(build, self._default_final_exit)
return
elif pkg.type_name == "binary":
binpkg = Binpkg(background=self.background,
find_blockers=find_blockers,
ldpath_mtimes=ldpath_mtimes, logger=logger,
opts=self.binpkg_opts, pkg=pkg, pkg_count=pkg_count,
prefetcher=self.prefetcher, settings=settings,
scheduler=scheduler, world_atom=world_atom)
self._install_task = binpkg
self._start_task(binpkg, self._default_final_exit)
return
def merge(self):
pkg = self.pkg
build_opts = self.build_opts
find_blockers = self.find_blockers
logger = self.logger
mtimedb = self.mtimedb
pkg_count = self.pkg_count
prefetcher = self.prefetcher
scheduler = self.scheduler
settings = self.settings
world_atom = self.world_atom
ldpath_mtimes = mtimedb["ldpath"]
if pkg.installed:
if not (build_opts.buildpkgonly or \
build_opts.fetchonly or build_opts.pretend):
uninstall = PackageUninstall(background=self.background,
ldpath_mtimes=ldpath_mtimes, opts=self.emerge_opts,
pkg=pkg, scheduler=scheduler, settings=settings,
world_atom=world_atom)
uninstall.start()
retval = uninstall.wait()
if retval != os.EX_OK:
return retval
return os.EX_OK
if build_opts.fetchonly or \
build_opts.buildpkgonly:
return self.returncode
retval = self._install_task.install()
return retval
|