Gentoo Archives: gentoo-catalyst

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