summaryrefslogtreecommitdiffstats
path: root/bitbake/lib
diff options
context:
space:
mode:
authorRichard Purdie <richard@openedhand.com>2007-10-30 11:46:19 +0000
committerRichard Purdie <richard@openedhand.com>2007-10-30 11:46:19 +0000
commitc9be325eb9b3140dad277bfda03a34e7b2cf7fdb (patch)
treecd02f283bf72bbc2cb075c4cb3734efe654596d2 /bitbake/lib
parent03446930ef7a5e87f4bfa14cf46146e359dec59a (diff)
downloadpoky-c9be325eb9b3140dad277bfda03a34e7b2cf7fdb.tar.gz
bitbake: Sync with upstream
git-svn-id: https://svn.o-hand.com/repos/poky/trunk@3040 311d38ba-8fff-0310-9ca6-ca027cbcb966
Diffstat (limited to 'bitbake/lib')
-rw-r--r--bitbake/lib/bb/__init__.py91
-rw-r--r--bitbake/lib/bb/taskdata.py6
2 files changed, 80 insertions, 17 deletions
diff --git a/bitbake/lib/bb/__init__.py b/bitbake/lib/bb/__init__.py
index 0460c96ff4..6179ef9a1c 100644
--- a/bitbake/lib/bb/__init__.py
+++ b/bitbake/lib/bb/__init__.py
@@ -155,8 +155,7 @@ def movefile(src,dest,newmtime=None,sstat=None):
155 if not sstat: 155 if not sstat:
156 sstat=os.lstat(src) 156 sstat=os.lstat(src)
157 except Exception, e: 157 except Exception, e:
158 print "!!! Stating source file failed... movefile()" 158 print "movefile: Stating source file failed...", e
159 print "!!!",e
160 return None 159 return None
161 160
162 destexists=1 161 destexists=1
@@ -180,13 +179,11 @@ def movefile(src,dest,newmtime=None,sstat=None):
180 if destexists and not stat.S_ISDIR(dstat[stat.ST_MODE]): 179 if destexists and not stat.S_ISDIR(dstat[stat.ST_MODE]):
181 os.unlink(dest) 180 os.unlink(dest)
182 os.symlink(target,dest) 181 os.symlink(target,dest)
183# os.lchown(dest,sstat[stat.ST_UID],sstat[stat.ST_GID]) 182 #os.lchown(dest,sstat[stat.ST_UID],sstat[stat.ST_GID])
184 os.unlink(src) 183 os.unlink(src)
185 return os.lstat(dest) 184 return os.lstat(dest)
186 except Exception, e: 185 except Exception, e:
187 print "!!! failed to properly create symlink:" 186 print "movefile: failed to properly create symlink:", dest, "->", target, e
188 print "!!!",dest,"->",target
189 print "!!!",e
190 return None 187 return None
191 188
192 renamefailed=1 189 renamefailed=1
@@ -198,8 +195,7 @@ def movefile(src,dest,newmtime=None,sstat=None):
198 import errno 195 import errno
199 if e[0]!=errno.EXDEV: 196 if e[0]!=errno.EXDEV:
200 # Some random error. 197 # Some random error.
201 print "!!! Failed to move",src,"to",dest 198 print "movefile: Failed to move", src, "to", dest, e
202 print "!!!",e
203 return None 199 return None
204 # Invalid cross-device-link 'bind' mounted or actually Cross-Device 200 # Invalid cross-device-link 'bind' mounted or actually Cross-Device
205 201
@@ -211,16 +207,13 @@ def movefile(src,dest,newmtime=None,sstat=None):
211 os.rename(dest+"#new",dest) 207 os.rename(dest+"#new",dest)
212 didcopy=1 208 didcopy=1
213 except Exception, e: 209 except Exception, e:
214 print '!!! copy',src,'->',dest,'failed.' 210 print 'movefile: copy', src, '->', dest, 'failed.', e
215 print "!!!",e
216 return None 211 return None
217 else: 212 else:
218 #we don't yet handle special, so we need to fall back to /bin/mv 213 #we don't yet handle special, so we need to fall back to /bin/mv
219 a=getstatusoutput("/bin/mv -f "+"'"+src+"' '"+dest+"'") 214 a=getstatusoutput("/bin/mv -f "+"'"+src+"' '"+dest+"'")
220 if a[0]!=0: 215 if a[0]!=0:
221 print "!!! Failed to move special file:" 216 print "movefile: Failed to move special file:" + src + "' to '" + dest + "'", a
222 print "!!! '"+src+"' to '"+dest+"'"
223 print "!!!",a
224 return None # failure 217 return None # failure
225 try: 218 try:
226 if didcopy: 219 if didcopy:
@@ -228,9 +221,7 @@ def movefile(src,dest,newmtime=None,sstat=None):
228 os.chmod(dest, stat.S_IMODE(sstat[stat.ST_MODE])) # Sticky is reset on chown 221 os.chmod(dest, stat.S_IMODE(sstat[stat.ST_MODE])) # Sticky is reset on chown
229 os.unlink(src) 222 os.unlink(src)
230 except Exception, e: 223 except Exception, e:
231 print "!!! Failed to chown/chmod/unlink in movefile()" 224 print "movefile: Failed to chown/chmod/unlink", dest, e
232 print "!!!",dest
233 print "!!!",e
234 return None 225 return None
235 226
236 if newmtime: 227 if newmtime:
@@ -240,7 +231,75 @@ def movefile(src,dest,newmtime=None,sstat=None):
240 newmtime=sstat[stat.ST_MTIME] 231 newmtime=sstat[stat.ST_MTIME]
241 return newmtime 232 return newmtime
242 233
234def copyfile(src,dest,newmtime=None,sstat=None):
235 """
236 Copies a file from src to dest, preserving all permissions and
237 attributes; mtime will be preserved even when moving across
238 filesystems. Returns true on success and false on failure.
239 """
240 import os, stat, shutil
241
242 #print "copyfile("+src+","+dest+","+str(newmtime)+","+str(sstat)+")"
243 try:
244 if not sstat:
245 sstat=os.lstat(src)
246 except Exception, e:
247 print "copyfile: Stating source file failed...", e
248 return False
249
250 destexists=1
251 try:
252 dstat=os.lstat(dest)
253 except:
254 dstat=os.lstat(os.path.dirname(dest))
255 destexists=0
256
257 if destexists:
258 if stat.S_ISLNK(dstat[stat.ST_MODE]):
259 try:
260 os.unlink(dest)
261 destexists=0
262 except Exception, e:
263 pass
264
265 if stat.S_ISLNK(sstat[stat.ST_MODE]):
266 try:
267 target=os.readlink(src)
268 if destexists and not stat.S_ISDIR(dstat[stat.ST_MODE]):
269 os.unlink(dest)
270 os.symlink(target,dest)
271 #os.lchown(dest,sstat[stat.ST_UID],sstat[stat.ST_GID])
272 return os.lstat(dest)
273 except Exception, e:
274 print "copyfile: failed to properly create symlink:", dest, "->", target, e
275 return False
276
277 if stat.S_ISREG(sstat[stat.ST_MODE]):
278 try: # For safety copy then move it over.
279 shutil.copyfile(src,dest+"#new")
280 os.rename(dest+"#new",dest)
281 except Exception, e:
282 print 'copyfile: copy', src, '->', dest, 'failed.', e
283 return False
284 else:
285 #we don't yet handle special, so we need to fall back to /bin/mv
286 a=getstatusoutput("/bin/cp -f "+"'"+src+"' '"+dest+"'")
287 if a[0]!=0:
288 print "copyfile: Failed to copy special file:" + src + "' to '" + dest + "'", a
289 return False # failure
290 try:
291 os.lchown(dest,sstat[stat.ST_UID],sstat[stat.ST_GID])
292 os.chmod(dest, stat.S_IMODE(sstat[stat.ST_MODE])) # Sticky is reset on chown
293 except Exception, e:
294 print "copyfile: Failed to chown/chmod/unlink", dest, e
295 return False
243 296
297 if newmtime:
298 os.utime(dest,(newmtime,newmtime))
299 else:
300 os.utime(dest, (sstat[stat.ST_ATIME], sstat[stat.ST_MTIME]))
301 newmtime=sstat[stat.ST_MTIME]
302 return newmtime
244 303
245####################################################################### 304#######################################################################
246####################################################################### 305#######################################################################
diff --git a/bitbake/lib/bb/taskdata.py b/bitbake/lib/bb/taskdata.py
index 5b2418f665..74a8b84bd5 100644
--- a/bitbake/lib/bb/taskdata.py
+++ b/bitbake/lib/bb/taskdata.py
@@ -559,7 +559,11 @@ class TaskData:
559 self.tasks_name[task], 559 self.tasks_name[task],
560 self.tasks_tdepends[task])) 560 self.tasks_tdepends[task]))
561 561
562 bb.msg.debug(3, bb.msg.domain.TaskData, "runtime ids (per fn):") 562 bb.msg.debug(3, bb.msg.domain.TaskData, "dependency ids (per fn):")
563 for fnid in self.depids:
564 bb.msg.debug(3, bb.msg.domain.TaskData, " %s %s: %s" % (fnid, self.fn_index[fnid], self.depids[fnid]))
565
566 bb.msg.debug(3, bb.msg.domain.TaskData, "runtime dependency ids (per fn):")
563 for fnid in self.rdepids: 567 for fnid in self.rdepids:
564 bb.msg.debug(3, bb.msg.domain.TaskData, " %s %s: %s" % (fnid, self.fn_index[fnid], self.rdepids[fnid])) 568 bb.msg.debug(3, bb.msg.domain.TaskData, " %s %s: %s" % (fnid, self.fn_index[fnid], self.rdepids[fnid]))
565 569