diff options
Diffstat (limited to 'meta/classes/package.bbclass')
| -rw-r--r-- | meta/classes/package.bbclass | 72 |
1 files changed, 1 insertions, 71 deletions
diff --git a/meta/classes/package.bbclass b/meta/classes/package.bbclass index e17627eaac..c2741d0222 100644 --- a/meta/classes/package.bbclass +++ b/meta/classes/package.bbclass | |||
| @@ -318,76 +318,6 @@ python package_do_split_locales() { | |||
| 318 | #bb.data.setVar('RDEPENDS_%s' % mainpkg, ' '.join(rdep), d) | 318 | #bb.data.setVar('RDEPENDS_%s' % mainpkg, ' '.join(rdep), d) |
| 319 | } | 319 | } |
| 320 | 320 | ||
| 321 | def copyfile(src,dest,newmtime=None,sstat=None): | ||
| 322 | """ | ||
| 323 | Copies a file from src to dest, preserving all permissions and | ||
| 324 | attributes; mtime will be preserved even when moving across | ||
| 325 | filesystems. Returns true on success and false on failure. | ||
| 326 | """ | ||
| 327 | import os, stat, shutil, commands | ||
| 328 | |||
| 329 | #print "copyfile("+src+","+dest+","+str(newmtime)+","+str(sstat)+")" | ||
| 330 | try: | ||
| 331 | if not sstat: | ||
| 332 | sstat=os.lstat(src) | ||
| 333 | except Exception, e: | ||
| 334 | print "copyfile: Stating source file failed...", e | ||
| 335 | return False | ||
| 336 | |||
| 337 | destexists=1 | ||
| 338 | try: | ||
| 339 | dstat=os.lstat(dest) | ||
| 340 | except: | ||
| 341 | dstat=os.lstat(os.path.dirname(dest)) | ||
| 342 | destexists=0 | ||
| 343 | |||
| 344 | if destexists: | ||
| 345 | if stat.S_ISLNK(dstat[stat.ST_MODE]): | ||
| 346 | try: | ||
| 347 | os.unlink(dest) | ||
| 348 | destexists=0 | ||
| 349 | except Exception, e: | ||
| 350 | pass | ||
| 351 | |||
| 352 | if stat.S_ISLNK(sstat[stat.ST_MODE]): | ||
| 353 | try: | ||
| 354 | target=os.readlink(src) | ||
| 355 | if destexists and not stat.S_ISDIR(dstat[stat.ST_MODE]): | ||
| 356 | os.unlink(dest) | ||
| 357 | os.symlink(target,dest) | ||
| 358 | #os.lchown(dest,sstat[stat.ST_UID],sstat[stat.ST_GID]) | ||
| 359 | return os.lstat(dest) | ||
| 360 | except Exception, e: | ||
| 361 | print "copyfile: failed to properly create symlink:", dest, "->", target, e | ||
| 362 | return False | ||
| 363 | |||
| 364 | if stat.S_ISREG(sstat[stat.ST_MODE]): | ||
| 365 | try: # For safety copy then move it over. | ||
| 366 | shutil.copyfile(src,dest+"#new") | ||
| 367 | os.rename(dest+"#new",dest) | ||
| 368 | except Exception, e: | ||
| 369 | print 'copyfile: copy', src, '->', dest, 'failed.', e | ||
| 370 | return False | ||
| 371 | else: | ||
| 372 | #we don't yet handle special, so we need to fall back to /bin/mv | ||
| 373 | a=commands.getstatusoutput("/bin/cp -f "+"'"+src+"' '"+dest+"'") | ||
| 374 | if a[0]!=0: | ||
| 375 | print "copyfile: Failed to copy special file:" + src + "' to '" + dest + "'", a | ||
| 376 | return False # failure | ||
| 377 | try: | ||
| 378 | os.lchown(dest,sstat[stat.ST_UID],sstat[stat.ST_GID]) | ||
| 379 | os.chmod(dest, stat.S_IMODE(sstat[stat.ST_MODE])) # Sticky is reset on chown | ||
| 380 | except Exception, e: | ||
| 381 | print "copyfile: Failed to chown/chmod/unlink", dest, e | ||
| 382 | return False | ||
| 383 | |||
| 384 | if newmtime: | ||
| 385 | os.utime(dest,(newmtime,newmtime)) | ||
| 386 | else: | ||
| 387 | os.utime(dest, (sstat[stat.ST_ATIME], sstat[stat.ST_MTIME])) | ||
| 388 | newmtime=sstat[stat.ST_MTIME] | ||
| 389 | return newmtime | ||
| 390 | |||
| 391 | python populate_packages () { | 321 | python populate_packages () { |
| 392 | import glob, stat, errno, re | 322 | import glob, stat, errno, re |
| 393 | 323 | ||
| @@ -491,7 +421,7 @@ python populate_packages () { | |||
| 491 | fpath = os.path.join(root,file) | 421 | fpath = os.path.join(root,file) |
| 492 | dpath = os.path.dirname(fpath) | 422 | dpath = os.path.dirname(fpath) |
| 493 | bb.mkdirhier(dpath) | 423 | bb.mkdirhier(dpath) |
| 494 | ret = copyfile(file, fpath) | 424 | ret = bb.copyfile(file, fpath) |
| 495 | if ret is False or ret == 0: | 425 | if ret is False or ret == 0: |
| 496 | raise bb.build.FuncFailed("File population failed") | 426 | raise bb.build.FuncFailed("File population failed") |
| 497 | del localdata | 427 | del localdata |
