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