Gentoo Archives: gentoo-commits

From: Zac Medico <zmedico@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/package/ebuild/, bin/
Date: Sun, 28 Aug 2011 23:33:00
Message-Id: ae9b6cb513c7b29376caecf3b4e52aac452e2b93.zmedico@gentoo
1 commit: ae9b6cb513c7b29376caecf3b4e52aac452e2b93
2 Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
3 AuthorDate: Sun Aug 28 23:29:49 2011 +0000
4 Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
5 CommitDate: Sun Aug 28 23:29:49 2011 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=ae9b6cb5
7
8 doebuild: avoid redundant distfiles checks
9
10 When the unpack phase is already marked as complete, it's wasteful to
11 check distfiles digests. In order to avoid this, we have to migrate the
12 distfiles/workdir timestamp comparisons from ebuild.sh to doebuild.py,
13 so that doebuild always knows when unpack will be triggered. This also
14 allows us to eliminate code in dyn_unpack that duplicated dyn_clean,
15 actually call dyn_clean instead.
16
17 ---
18 bin/ebuild.sh | 37 +---------------
19 pym/portage/package/ebuild/doebuild.py | 70 +++++++++++++++++++++++++++++++-
20 2 files changed, 71 insertions(+), 36 deletions(-)
21
22 diff --git a/bin/ebuild.sh b/bin/ebuild.sh
23 index d68e54b..23a1240 100755
24 --- a/bin/ebuild.sh
25 +++ b/bin/ebuild.sh
26 @@ -726,41 +726,10 @@ dyn_setup() {
27 }
28
29 dyn_unpack() {
30 - local newstuff="no"
31 - if [ -e "${WORKDIR}" ]; then
32 - local x
33 - local checkme
34 - for x in $A ; do
35 - vecho ">>> Checking ${x}'s mtime..."
36 - if [ "${PORTAGE_ACTUAL_DISTDIR:-${DISTDIR}}/${x}" -nt "${WORKDIR}" ]; then
37 - vecho ">>> ${x} has been updated; recreating WORKDIR..."
38 - newstuff="yes"
39 - break
40 - fi
41 - done
42 - if [ ! -f "${PORTAGE_BUILDDIR}/.unpacked" ] ; then
43 - vecho ">>> Not marked as unpacked; recreating WORKDIR..."
44 - newstuff="yes"
45 - fi
46 - fi
47 - if [ "${newstuff}" == "yes" ]; then
48 - # We don't necessarily have privileges to do a full dyn_clean here.
49 - rm -rf "${PORTAGE_BUILDDIR}"/{.setuped,.unpacked,.prepared,.configured,.compiled,.tested,.installed,.packaged,build-info}
50 - if ! has keepwork $FEATURES ; then
51 - rm -rf "${WORKDIR}"
52 - fi
53 - if [ -d "${T}" ] && \
54 - ! has keeptemp $FEATURES ; then
55 - rm -rf "${T}" && mkdir "${T}"
56 - fi
57 - fi
58 - if [ -e "${WORKDIR}" ]; then
59 - if [ "$newstuff" == "no" ]; then
60 - vecho ">>> WORKDIR is up-to-date, keeping..."
61 - return 0
62 - fi
63 + if [[ -f ${PORTAGE_BUILDDIR}/.unpacked ]] ; then
64 + vecho ">>> WORKDIR is up-to-date, keeping..."
65 + return 0
66 fi
67 -
68 if [ ! -d "${WORKDIR}" ]; then
69 install -m${PORTAGE_WORKDIR_MODE:-0700} -d "${WORKDIR}" || die "Failed to create dir '${WORKDIR}'"
70 fi
71
72 diff --git a/pym/portage/package/ebuild/doebuild.py b/pym/portage/package/ebuild/doebuild.py
73 index c252e86..a95a418 100644
74 --- a/pym/portage/package/ebuild/doebuild.py
75 +++ b/pym/portage/package/ebuild/doebuild.py
76 @@ -432,6 +432,7 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0,
77 "install":["test"],
78 "rpm": ["install"],
79 "package":["install"],
80 + "merge" :["install"],
81 }
82
83 if mydbapi is None:
84 @@ -666,6 +667,68 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0,
85 return unmerge(mysettings["CATEGORY"],
86 mysettings["PF"], myroot, mysettings, vartree=vartree)
87
88 + phases_to_run = set()
89 + if "noauto" in mysettings.features or \
90 + mydo not in actionmap_deps:
91 + phases_to_run.add(mydo)
92 + else:
93 + phase_stack = [mydo]
94 + while phase_stack:
95 + x = phase_stack.pop()
96 + if x in phases_to_run:
97 + continue
98 + phases_to_run.add(x)
99 + phase_stack.extend(actionmap_deps.get(x, []))
100 + del phase_stack
101 +
102 + alist = set(mysettings.configdict["pkg"].get("A", "").split())
103 +
104 + unpacked = False
105 + if "unpack" in phases_to_run:
106 + try:
107 + workdir_st = os.stat(mysettings["WORKDIR"])
108 + except OSError:
109 + pass
110 + else:
111 + newstuff = False
112 + if not os.path.exists(os.path.join(
113 + mysettings["PORTAGE_BUILDDIR"], ".unpacked")):
114 + writemsg_stdout(
115 + ">>> Not marked as unpacked; recreating WORKDIR...\n")
116 + newstuff = True
117 + else:
118 + for x in alist:
119 + writemsg_stdout(">>> Checking %s's mtime...\n" % x)
120 + try:
121 + x_st = os.stat(os.path.join(
122 + mysettings["DISTDIR"], x))
123 + except OSError:
124 + # file not fetched yet
125 + x_st = None
126 +
127 + if x_st is None or x_st.st_mtime > workdir_st.st_mtime:
128 + writemsg_stdout(">>> Timestamp of "
129 + "%s has changed; recreating WORKDIR...\n" % x)
130 + newstuff = True
131 + break
132 +
133 + if newstuff:
134 + if builddir_lock is None and \
135 + 'PORTAGE_BUILDIR_LOCKED' not in mysettings:
136 + builddir_lock = EbuildBuildDir(
137 + scheduler=PollScheduler().sched_iface,
138 + settings=mysettings)
139 + builddir_lock.lock()
140 + try:
141 + _spawn_phase("clean", mysettings)
142 + finally:
143 + if builddir_lock is not None:
144 + builddir_lock.unlock()
145 + builddir_lock = None
146 + else:
147 + writemsg_stdout(">>> WORKDIR is up-to-date, keeping...\n")
148 + unpacked = True
149 +
150 # Build directory creation isn't required for any of these.
151 # In the fetch phase, the directory is needed only for RESTRICT=fetch
152 # in order to satisfy the sane $PWD requirement (from bug #239560)
153 @@ -739,10 +802,9 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0,
154 # Only try and fetch the files if we are going to need them ...
155 # otherwise, if user has FEATURES=noauto and they run `ebuild clean
156 # unpack compile install`, we will try and fetch 4 times :/
157 - need_distfiles = tree == "porttree" and \
158 + need_distfiles = tree == "porttree" and not unpacked and \
159 (mydo in ("fetch", "unpack") or \
160 mydo not in ("digest", "manifest") and "noauto" not in features)
161 - alist = set(mysettings.configdict["pkg"].get("A", "").split())
162 if need_distfiles:
163
164 src_uri, = mydbapi.aux_get(mysettings.mycpv,
165 @@ -787,6 +849,10 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0,
166 # Files are already checked inside fetch(),
167 # so do not check them again.
168 checkme = []
169 + elif unpacked:
170 + # The unpack phase is marked as complete, so it
171 + # would be wasteful to check distfiles again.
172 + checkme = []
173 else:
174 checkme = alist