Gentoo Archives: gentoo-catalyst

From: Brian Dolbec <dolsen@g.o>
To: Matt Turner <mattst88@g.o>
Cc: gentoo-catalyst@l.g.o
Subject: Re: [gentoo-catalyst] [PATCH 2/4] Remove self.mounts and self.mountmap's use of paths for keys and paths.
Date: Sat, 14 Dec 2013 11:15:57
Message-Id: 1387019742.3897.121.camel@big_daddy.dol-sen.ca
In Reply to: Re: [gentoo-catalyst] [PATCH 2/4] Remove self.mounts and self.mountmap's use of paths for keys and paths. by Matt Turner
1 On Fri, 2013-12-13 at 21:08 -0800, Matt Turner wrote:
2 > On Fri, Dec 13, 2013 at 7:07 PM, Brian Dolbec <dolsen@g.o> wrote:
3 > > Migrate more hardcoded paths to use settings variables instead.
4 >
5 > I can't really make any sense of the commit title,
6
7 This is the full commit message in git:
8
9 Remove self.mounts and self.mountmap's use of paths for keys and paths.
10
11 Migrate more hardcoded paths to use settings variables instead.
12 ---------------
13
14 git send-email broke it up, using the first line as the subject, the
15 other lines are included in the main text body.
16
17
18
19 > and it'd be
20 > preferable to do one path per patch.
21
22 Re-coding that mounts and mountmap mess was hard enough and required
23 lots of testing, fixing to get it correct and working. Splitting it up
24 even more is an exercise in futility.
25
26 >
27 > > ---
28 > > catalyst | 3 ++
29 > > modules/generic_stage_target.py | 80 ++++++++++++++++++++---------------------
30 > > 2 files changed, 43 insertions(+), 40 deletions(-)
31 > >
32 > > diff --git a/catalyst b/catalyst
33 > > index 19ec77e..60cea3e 100755
34 > > --- a/catalyst
35 > > +++ b/catalyst
36 > > @@ -62,8 +62,11 @@ def parse_config(myconfig):
37 > > config_file=""
38 > >
39 > > confdefaults={
40 > > + "distdir": "/usr/portage/distfiles",
41 > > "hash_function": "crc32",
42 > > + "packagedir": "/usr/portage/packages",
43 > > "portdir": "/usr/portage",
44 > > + "port_tmpdir": "/var/tmp/portage",
45 > > "repo_name": "portage",
46 > > "sharedir": "/usr/lib/catalyst",
47 > > "snapshot_name": "portage-",
48 > > diff --git a/modules/generic_stage_target.py b/modules/generic_stage_target.py
49 > > index c2888b6..342c65b 100644
50 > > --- a/modules/generic_stage_target.py
51 > > +++ b/modules/generic_stage_target.py
52 > > @@ -179,11 +179,11 @@ class generic_stage_target(generic_target):
53 > > "/usr/portage":self.settings["snapshot_cache_path"]+"/portage",\
54 > > "/usr/portage/distfiles":self.settings["distdir"],"/var/tmp/portage":"tmpfs"}
55 > > else:
56 > > - self.mounts=["/proc","/dev","/usr/portage/distfiles","/var/tmp/portage"]
57 > > - self.mountmap={"/proc":"/proc","/dev":"/dev","/dev/pts":"/dev/pts",\
58 > > - "/usr/portage/distfiles":self.settings["distdir"],"/var/tmp/portage":"tmpfs"}
59 > > + self.mounts=["proc","dev", "distdir", "port_tmpdir"]
60 > > + self.mountmap={"proc":"/proc", "dev":"/dev", "pts":"/dev/pts",
61 > > + "distdir":self.settings["distdir"], "port_tmpdir":"tmpfs"}
62 > > if os.uname()[0] == "Linux":
63 > > - self.mounts.append("/dev/pts")
64 > > + self.mounts.append("pts")
65 > >
66 > > self.set_mounts()
67 > >
68 > > @@ -195,16 +195,15 @@ class generic_stage_target(generic_target):
69 > > self.set_pkgcache_path()
70 > > print "Location of the package cache is "+\
71 > > self.settings["pkgcache_path"]
72 > > - self.mounts.append("/usr/portage/packages")
73 > > - self.mountmap["/usr/portage/packages"]=\
74 > > - self.settings["pkgcache_path"]
75 > > + self.mounts.append("packagedir")
76 > > + self.mountmap["packagedir"] = self.settings["pkgcache_path"]
77 > >
78 > > if "KERNCACHE" in self.settings:
79 > > self.set_kerncache_path()
80 > > print "Location of the kerncache is "+\
81 > > self.settings["kerncache_path"]
82 > > - self.mounts.append("/tmp/kerncache")
83 > > - self.mountmap["/tmp/kerncache"]=self.settings["kerncache_path"]
84 > > + self.mounts.append("kerncache")
85 > > + self.mountmap["kerncache"]=self.settings["kerncache_path"]
86 > >
87 > > if "CCACHE" in self.settings:
88 > > if "CCACHE_DIR" in os.environ:
89 > > @@ -216,8 +215,8 @@ class generic_stage_target(generic_target):
90 > > raise CatalystError,\
91 > > "Compiler cache support can't be enabled (can't find "+\
92 > > ccdir+")"
93 > > - self.mounts.append("/var/tmp/ccache")
94 > > - self.mountmap["/var/tmp/ccache"]=ccdir
95 > > + self.mounts.append("ccache")
96 > > + self.mountmap["ccache"]=ccdir
97 > > """ for the chroot: """
98 > > self.env["CCACHE_DIR"]="/var/tmp/ccache"
99 > >
100 > > @@ -406,7 +405,7 @@ class generic_stage_target(generic_target):
101 > >
102 > > def set_cleanables(self):
103 > > self.settings["cleanables"]=["/etc/resolv.conf","/var/tmp/*","/tmp/*",\
104 > > - "/root/*","/usr/portage"]
105 > > + "/root/*", self.settings["portdir"]]
106 > >
107 > > def set_snapshot_path(self):
108 > > self.settings["snapshot_path"]=normpath(self.settings["storedir"]+\
109 > > @@ -615,21 +614,21 @@ class generic_stage_target(generic_target):
110 > > return
111 > >
112 > > for x in self.mounts:
113 > > - if not os.path.exists(mypath+x):
114 > > + if not os.path.exists(mypath + self.mountmap[x]):
115 > > continue
116 > >
117 > > - if ismount(mypath+x):
118 > > + if ismount(mypath +self.mountmap[x]):
119 > > """ Something is still mounted "" """
120 > > try:
121 > > - print x+" is still mounted; performing auto-bind-umount...",
122 > > + print self.mountmap[x] + " is still mounted; performing auto-bind-umount...",
123 > > """ Try to umount stuff ourselves """
124 > > self.unbind()
125 > > - if ismount(mypath+x):
126 > > - raise CatalystError, "Auto-unbind failed for "+x
127 > > + if ismount(mypath + self.mountmap[x]):
128 > > + raise CatalystError, "Auto-unbind failed for " + self.mountmap[x]
129 > > else:
130 > > print "Auto-unbind successful..."
131 > > except CatalystError:
132 > > - raise CatalystError, "Unable to auto-unbind "+x
133 > > + raise CatalystError, "Unable to auto-unbind " + self.mountmap[x]
134 > >
135 > > def unpack(self):
136 > > unpack=True
137 > > @@ -787,7 +786,7 @@ class generic_stage_target(generic_target):
138 > > print "Valid snapshot cache, skipping unpack of portage tree..."
139 > > unpack=False
140 > > else:
141 > > - destdir=normpath(self.settings["chroot_path"]+"/usr/portage")
142 > > + destdir=normpath(self.settings["chroot_path"] + self.settings["portdir"])
143 > > cleanup_errmsg="Error removing existing snapshot directory."
144 > > cleanup_msg=\
145 > > "Cleaning up existing portage tree (This can take a long time)..."
146 > > @@ -801,7 +800,7 @@ class generic_stage_target(generic_target):
147 > >
148 > > if "AUTORESUME" in self.settings \
149 > > and os.path.exists(self.settings["chroot_path"]+\
150 > > - "/usr/portage/") \
151 > > + self.settings["portdir"]) \
152 > > and os.path.exists(self.settings["autoresume_path"]\
153 > > +"unpack_portage") \
154 > > and self.settings["snapshot_path_hash"] == snapshot_hash:
155 > > @@ -848,7 +847,7 @@ class generic_stage_target(generic_target):
156 > > cmd("rm -f "+self.settings["chroot_path"]+"/etc/portage/make.profile",\
157 > > "Error zapping profile link",env=self.env)
158 > > cmd("mkdir -p "+self.settings["chroot_path"]+"/etc/portage/")
159 > > - cmd("ln -sf ../../usr/portage/profiles/"+\
160 > > + cmd("ln -sf ../.." + self.settings["portdir"] + "/profiles/"+\
161 > > self.settings["target_profile"]+" "+\
162 > > self.settings["chroot_path"]+"/etc/portage/make.profile",\
163 > > "Error creating profile link",env=self.env)
164 > > @@ -874,10 +873,10 @@ class generic_stage_target(generic_target):
165 > > if os.path.exists(x):
166 > > print "Copying overlay dir " +x
167 > > cmd("mkdir -p "+self.settings["chroot_path"]+\
168 > > - "/usr/local/portage",\
169 > > + self.settings["local_overlay"],\
170 > > "Could not make portage_overlay dir",env=self.env)
171 > > cmd("cp -R "+x+"/* "+self.settings["chroot_path"]+\
172 > > - "/usr/local/portage",\
173 > > + self.settings["local_overlay"],\
174 > > "Could not copy portage_overlay",env=self.env)
175 > >
176 > > def root_overlay(self):
177 > > @@ -897,7 +896,7 @@ class generic_stage_target(generic_target):
178 > >
179 > > def bind(self):
180 > > for x in self.mounts:
181 > > - if not os.path.exists(self.settings["chroot_path"]+x):
182 > > + if not os.path.exists(self.settings["chroot_path"] + self.mountmap[x]):
183 > > os.makedirs(self.settings["chroot_path"]+x,0755)
184 > >
185 > > if not os.path.exists(self.mountmap[x]):
186 > > @@ -909,11 +908,11 @@ class generic_stage_target(generic_target):
187 > > self.snapshot_lock_object.read_lock()
188 > > if os.uname()[0] == "FreeBSD":
189 > > if src == "/dev":
190 > > - retval=os.system("mount -t devfs none "+\
191 > > - self.settings["chroot_path"]+x)
192 > > + retval=os.system("mount -t devfs none " +
193 > > + self.settings["chroot_path"] + src)
194 > > else:
195 > > - retval=os.system("mount_nullfs "+src+" "+\
196 > > - self.settings["chroot_path"]+x)
197 > > + retval=os.system("mount_nullfs " + src + " " +
198 > > + self.settings["chroot_path"] + src)
199 > > else:
200 > > if src == "tmpfs":
201 > > if "var_tmpfs_portage" in self.settings:
202 > > @@ -921,11 +920,11 @@ class generic_stage_target(generic_target):
203 > > self.settings["var_tmpfs_portage"]+"G "+src+" "+\
204 > > self.settings["chroot_path"]+x)
205 > > else:
206 > > - retval=os.system("mount --bind "+src+" "+\
207 > > - self.settings["chroot_path"]+x)
208 > > + retval=os.system("mount --bind " + src + " " +
209 > > + self.settings["chroot_path"] + src)
210 > > if retval!=0:
211 > > self.unbind()
212 > > - raise CatalystError,"Couldn't bind mount "+src
213 > > + raise CatalystError,"Couldn't bind mount " + src
214 > >
215 > > def unbind(self):
216 > > ouch=0
217 > > @@ -934,25 +933,26 @@ class generic_stage_target(generic_target):
218 > > myrevmounts.reverse()
219 > > """ Unmount in reverse order for nested bind-mounts """
220 > > for x in myrevmounts:
221 > > - if not os.path.exists(mypath+x):
222 > > + if not os.path.exists(mypath + self.mountmap[x]):
223 > > continue
224 > >
225 > > - if not ismount(mypath+x):
226 > > + if not ismount(mypath + self.mountmap[x]):
227 > > continue
228 > >
229 > > retval=os.system("umount "+\
230 > > - os.path.join(mypath,x.lstrip(os.path.sep)))
231 > > + os.path.join(mypath, self.mountmap[x].lstrip(os.path.sep)))
232 > >
233 > > if retval!=0:
234 > > - warn("First attempt to unmount: "+mypath+x+" failed.")
235 > > + warn("First attempt to unmount: " + mypath +
236 > > + self.mountmap[x] +" failed.")
237 > > warn("Killing any pids still running in the chroot")
238 > >
239 > > self.kill_chroot_pids()
240 > >
241 > > - retval2=os.system("umount "+mypath+x)
242 > > + retval2=os.system("umount " + mypath + self.mountmap[x])
243 > > if retval2!=0:
244 > > ouch=1
245 > > - warn("Couldn't umount bind mount: "+mypath+x)
246 > > + warn("Couldn't umount bind mount: " + mypath + self.mountmap[x])
247 > >
248 > > if "SNAPCACHE" in self.settings and x == "/usr/portage":
249 > > try:
250 > > @@ -1118,9 +1118,9 @@ class generic_stage_target(generic_target):
251 > > "Could not replace /etc/hosts",env=self.env)
252 > >
253 > > """ Remove our overlay """
254 > > - if os.path.exists(self.settings["chroot_path"]+"/usr/local/portage"):
255 > > - cmd("rm -rf "+self.settings["chroot_path"]+"/usr/local/portage",\
256 > > - "Could not remove /usr/local/portage",env=self.env)
257 > > + if os.path.exists(self.settings["chroot_path"] + self.settings["local_overlay"]):
258 > > + cmd("rm -rf " + self.settings["chroot_path"] + self.settings["local_overlay"],
259 > > + "Could not remove " + self.settings["local_overlay"], env=self.env)
260 > > cmd("sed -i '/^PORTDIR_OVERLAY/d' "+self.settings["chroot_path"]+\
261 > > "/etc/portage/make.conf",\
262 > > "Could not remove PORTDIR_OVERLAY from make.conf",env=self.env)
263 > > --
264 > > 1.8.3.2
265 > >
266 > >
267 >
268 > There are piles of unrelated changes. :(
269
270 Yes, there are 2 distinct commits in one, one is the mounts, mountmap
271 changes, the other is the migrate more hard coded paths. The latter
272 changes the "/usr/local/portage" hard coding to using a setting
273 variable. It was done before I found the feature in gitg that lets me
274 select individual lines to include in a commit.

Attachments

File name MIME type
signature.asc application/pgp-signature

Replies