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