Gentoo Archives: gentoo-catalyst

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

Replies