Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 153109
Collapse All | Expand All

(-)portage-2.1.2_pre3/pym/portage.py (-36 / +21 lines)
Lines 23-28 try: Link Here
23
	except ImportError:
23
	except ImportError:
24
		import pickle as cPickle
24
		import pickle as cPickle
25
25
26
	# Move this at the start of the merge codepath to avoid useless imports
27
	bsdflags = os.uname()[0] in ["FreeBSD"]
28
29
	if bsdflags:
30
		import freebsd
31
26
	import stat
32
	import stat
27
	import commands
33
	import commands
28
	from time import sleep
34
	from time import sleep
Lines 42-54 except ImportError, e: Link Here
42
	raise
48
	raise
43
49
44
try:
50
try:
45
	# XXX: This should get renamed to bsd_chflags, I think.
46
	import chflags
47
	bsd_chflags = chflags
48
except ImportError:
49
	bsd_chflags = None
50
51
try:
52
	from cache.cache_errors import CacheError
51
	from cache.cache_errors import CacheError
53
	import cvstree
52
	import cvstree
54
	import xpak
53
	import xpak
Lines 3270-3292 def movefile(src,dest,newmtime=None,ssta Link Here
3270
		dstat=os.lstat(os.path.dirname(dest))
3269
		dstat=os.lstat(os.path.dirname(dest))
3271
		destexists=0
3270
		destexists=0
3272
3271
3273
	if bsd_chflags:
3272
	if bsdflags:
3274
		# Check that we can actually unset schg etc flags...
3275
		# Clear the flags on source and destination; we'll reinstate them after merging
3276
		if destexists and dstat.st_flags != 0:
3273
		if destexists and dstat.st_flags != 0:
3277
			if bsd_chflags.lchflags(dest, 0) < 0:
3274
			freebsd.lchflags(dest, 0)
3278
				writemsg("!!! Couldn't clear flags on file being merged: \n ",
3275
		pflags = os.stat(os.path.dirname(dest)).st_flags
3279
					noiselevel=-1)
3280
		# We might have an immutable flag on the parent dir; save and clear.
3281
		pflags=bsd_chflags.lgetflags(os.path.dirname(dest))
3282
		if pflags != 0:
3276
		if pflags != 0:
3283
			bsd_chflags.lchflags(os.path.dirname(dest), 0)
3277
			freebsd.lchflags(os.path.dirname(dest), 0)
3284
3285
		if (destexists and bsd_chflags.lhasproblems(dest)>0) or bsd_chflags.lhasproblems(os.path.dirname(dest))>0:
3286
			# This is bad: we can't merge the file with these flags set.
3287
			writemsg("!!! Can't merge file "+dest+" because of flags set\n",
3288
				noiselevel=-1)
3289
			return None
3290
3278
3291
	if destexists:
3279
	if destexists:
3292
		if stat.S_ISLNK(dstat[stat.ST_MODE]):
3280
		if stat.S_ISLNK(dstat[stat.ST_MODE]):
Lines 3388-3399 def movefile(src,dest,newmtime=None,ssta Link Here
3388
		os.utime(dest, (sstat[stat.ST_ATIME], sstat[stat.ST_MTIME]))
3376
		os.utime(dest, (sstat[stat.ST_ATIME], sstat[stat.ST_MTIME]))
3389
		newmtime=sstat[stat.ST_MTIME]
3377
		newmtime=sstat[stat.ST_MTIME]
3390
3378
3391
	if bsd_chflags:
3379
	if bsdflags:
3392
		# Restore the flags we saved before moving
3380
		# Restore the flags we saved before moving
3393
		if pflags and bsd_chflags.lchflags(os.path.dirname(dest), pflags) < 0:
3381
		if pflags:
3394
			writemsg("!!! Couldn't restore flags ("+str(sflags)+") on " + dest+":\n",
3382
			freebsd.lchflags(os.path.dirname(dest), pflags)
3395
				noiselevel=-1)
3396
			return None
3397
3383
3398
	return newmtime
3384
	return newmtime
3399
3385
Lines 6649-6660 class dblink: Link Here
6649
				if mydmode!=None:
6635
				if mydmode!=None:
6650
					# destination exists
6636
					# destination exists
6651
6637
6652
					if bsd_chflags:
6638
					if bsdflags:
6653
						# Save then clear flags on dest.
6639
						# Save then clear flags on dest.
6654
						dflags=bsd_chflags.lgetflags(mydest)
6640
						dflags = os.lstat(mydest).st_flags
6655
						if dflags != 0 and bsd_chflags.lchflags(mydest, 0) < 0:
6641
						if dflags != 0:
6656
							writemsg("!!! Couldn't clear flags on '"+mydest+"'.\n",
6642
							freebsd.lchflags(mydest, 0)
6657
								noiselevel=-1)
6658
6643
6659
					if not os.access(mydest, os.W_OK):
6644
					if not os.access(mydest, os.W_OK):
6660
						pkgstuff = pkgsplit(self.pkg)
6645
						pkgstuff = pkgsplit(self.pkg)
Lines 6668-6675 class dblink: Link Here
6668
					if stat.S_ISLNK(mydmode) or stat.S_ISDIR(mydmode):
6653
					if stat.S_ISLNK(mydmode) or stat.S_ISDIR(mydmode):
6669
						# a symlink to an existing directory will work for us; keep it:
6654
						# a symlink to an existing directory will work for us; keep it:
6670
						writemsg_stdout("--- %s/\n" % mydest)
6655
						writemsg_stdout("--- %s/\n" % mydest)
6671
						if bsd_chflags:
6656
						if bsdflags:
6672
							bsd_chflags.lchflags(mydest, dflags)
6657
							freebsd.lchflags(mydest, dflags)
6673
					else:
6658
					else:
6674
						# a non-directory and non-symlink-to-directory.  Won't work for us.  Move out of the way.
6659
						# a non-directory and non-symlink-to-directory.  Won't work for us.  Move out of the way.
6675
						if movefile(mydest,mydest+".backup", mysettings=self.settings) is None:
6660
						if movefile(mydest,mydest+".backup", mysettings=self.settings) is None:
Lines 6681-6688 class dblink: Link Here
6681
							selinux.secure_mkdir(mydest,sid)
6666
							selinux.secure_mkdir(mydest,sid)
6682
						else:
6667
						else:
6683
							os.mkdir(mydest)
6668
							os.mkdir(mydest)
6684
						if bsd_chflags:
6669
						if bsdflags:
6685
							bsd_chflags.lchflags(mydest, dflags)
6670
							freebsd.lchflags(mydest, dflags)
6686
						os.chmod(mydest,mystat[0])
6671
						os.chmod(mydest,mystat[0])
6687
						os.chown(mydest,mystat[4],mystat[5])
6672
						os.chown(mydest,mystat[4],mystat[5])
6688
						writemsg_stdout(">>> %s/\n" % mydest)
6673
						writemsg_stdout(">>> %s/\n" % mydest)

Return to bug 153109