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