Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 94661 | Differences between
and this patch

Collapse All | Expand All

(-)portage-2.0.51.22/pym/portage.py (-44 / +71 lines)
Lines 52-65 Link Here
52
	sys.exit(127)
52
	sys.exit(127)
53
53
54
try:
54
try:
55
	# XXX: This should get renamed to bsd_chflags, I think.
55
	import freebsd
56
	import chflags
57
	bsd_chflags = chflags
58
except SystemExit, e:
56
except SystemExit, e:
59
	raise
57
	raise
60
except:
58
except:
61
	# XXX: This should get renamed to bsd_chflags, I think.
59
	freebsd = None
62
	bsd_chflags = None
63
60
64
try:
61
try:
65
	import cvstree
62
	import cvstree
Lines 2738-2749 Link Here
2738
	try:
2735
	try:
2739
		if not sstat:
2736
		if not sstat:
2740
			sstat=os.lstat(src)
2737
			sstat=os.lstat(src)
2741
		if bsd_chflags:
2742
			sflags=bsd_chflags.lgetflags(src)
2743
			if sflags < 0:
2744
				# Problem getting flags...
2745
				writemsg("!!! Couldn't get flags for "+dest+"\n")
2746
				return None
2747
2738
2748
	except SystemExit, e:
2739
	except SystemExit, e:
2749
		raise
2740
		raise
Lines 2761-2780 Link Here
2761
		dstat=os.lstat(os.path.dirname(dest))
2752
		dstat=os.lstat(os.path.dirname(dest))
2762
		destexists=0
2753
		destexists=0
2763
2754
2764
	if bsd_chflags:
2755
	if freebsd:
2765
		# Check that we can actually unset schg etc flags...
2766
		# Clear the flags on source and destination; we'll reinstate them after merging
2767
		if(destexists):
2768
			if bsd_chflags.lchflags(dest, 0) < 0:
2769
				writemsg("!!! Couldn't clear flags on file being merged: \n ")
2770
		# We might have an immutable flag on the parent dir; save and clear.
2756
		# We might have an immutable flag on the parent dir; save and clear.
2771
		pflags=bsd_chflags.lgetflags(os.path.dirname(dest))
2757
		pflags=os.lstat(os.path.dirname(dest)).st_flags
2772
		bsd_chflags.lchflags(os.path.dirname(dest), 0)
2758
		
2773
2759
		if destexists:
2774
		# Don't bother checking the return value here; if it fails then the next line will catch it.
2760
			try:
2775
		bsd_chflags.lchflags(src, 0)
2761
				freebsd.lchflags(os.path.dirname(dest), 0)
2762
				freebsd.lchflags(dest, 0)
2763
				
2764
				freebsd.lchflags(src, 0)
2765
			except OSError, e:
2766
				if e[0] == 45:
2767
					writemsg("Operation not supported on destination\n")
2768
				else:
2769
					writemsg("!!! Unable to reset flags.\n")
2770
					return None
2776
2771
2777
		if bsd_chflags.lhasproblems(src)>0 or (destexists and bsd_chflags.lhasproblems(dest)>0) or bsd_chflags.lhasproblems(os.path.dirname(dest))>0:
2772
		if os.lstat(src).st_flags & 0x0160016 != 0 or ( destexists and os.lstat(dest).st_flags & 0x0160016 != 0 or os.lstat(os.path.dirname(dest)).st_flags & 0x0160016 != 0 ):
2778
			# This is bad: we can't merge the file with these flags set.
2773
			# This is bad: we can't merge the file with these flags set.
2779
			writemsg("!!! Can't merge file "+dest+" because of flags set\n")
2774
			writemsg("!!! Can't merge file "+dest+" because of flags set\n")
2780
			return None
2775
			return None
Lines 2803-2814 Link Here
2803
			else:
2798
			else:
2804
				os.symlink(target,dest)
2799
				os.symlink(target,dest)
2805
			lchown(dest,sstat[stat.ST_UID],sstat[stat.ST_GID])
2800
			lchown(dest,sstat[stat.ST_UID],sstat[stat.ST_GID])
2806
			if bsd_chflags:
2801
			if freebsd:
2807
				# Restore the flags we saved before moving
2802
				try:
2808
				if bsd_chflags.lchflags(dest, sflags) < 0 or bsd_chflags.lchflags(os.path.dirname(dest), pflags) < 0:
2803
					# Restore the flags we saved before moving
2809
					writemsg("!!! Couldn't restore flags ("+str(flags)+") on " + dest+":\n")
2804
					freebsd.lchflags(dest, sstat.st_flags)
2810
					writemsg("!!! %s\n" % str(e))
2805
					freebsd.lchflags(os.path.dirname(dest), pflags)
2811
					return None
2806
				except OSError, e:
2807
					if e[0] == 45:
2808
						writemsg("Operation not supported on destination\n")
2809
					else:
2810
						writemsg("!!! Couldn't restore flags ("+str(sstat.st_flags)+") on " + dest+":\n")
2811
						writemsg("!!! %s\n" % str(e))
2812
						return None
2812
			return os.lstat(dest)[stat.ST_MTIME]
2813
			return os.lstat(dest)[stat.ST_MTIME]
2813
		except SystemExit, e:
2814
		except SystemExit, e:
2814
			raise
2815
			raise
Lines 2883-2893 Link Here
2883
		os.utime(dest, (sstat[stat.ST_ATIME], sstat[stat.ST_MTIME]))
2884
		os.utime(dest, (sstat[stat.ST_ATIME], sstat[stat.ST_MTIME]))
2884
		newmtime=sstat[stat.ST_MTIME]
2885
		newmtime=sstat[stat.ST_MTIME]
2885
2886
2886
	if bsd_chflags:
2887
	if freebsd:
2887
		# Restore the flags we saved before moving
2888
		try:
2888
		if bsd_chflags.lchflags(dest, sflags) < 0 or bsd_chflags.lchflags(os.path.dirname(dest), pflags) < 0:
2889
			# Restore the flags we saved before moving
2889
			writemsg("!!! Couldn't restore flags ("+str(sflags)+") on " + dest+":\n")
2890
			freebsd.lchflags(dest, sstat.st_flags)
2890
			return None
2891
			freebsd.lchflags(os.path.dirname(dest), pflags)
2892
		except OSError, e:
2893
			if e[0] == 45:
2894
				writemsg("Operation not supported on destination\n")
2895
			else:
2896
				writemsg("!!! Couldn't restore flags ("+str(sstat.st_flags)+") on " + dest+":\n")
2897
				return None
2891
2898
2892
	return newmtime
2899
	return newmtime
2893
2900
Lines 6705-6715 Link Here
6705
				if mydmode!=None:
6712
				if mydmode!=None:
6706
					# destination exists
6713
					# destination exists
6707
6714
6708
					if bsd_chflags:
6715
					if freebsd:
6709
						# Save then clear flags on dest.
6716
						# Save then clear flags on dest.
6710
						dflags=bsd_chflags.lgetflags(mydest)
6717
						dflags=os.lstat(mydest).st_flags
6711
						if(bsd_chflags.lchflags(mydest, 0)<0):
6718
						try:
6712
							writemsg("!!! Couldn't clear flags on '"+mydest+"'.\n")
6719
							freebsd.lchflags(mydest, 0)
6720
						except OSError, e:
6721
							if e[0] == 45:
6722
								writemsg("Operation not supported on destination\n")
6723
							else:
6724
								writemsg("!!! Unable to clear flags on " + mydest + ".\n")
6725
								return None
6713
6726
6714
					if not os.access(mydest, os.W_OK):
6727
					if not os.access(mydest, os.W_OK):
6715
						pkgstuff = pkgsplit(self.pkg)
6728
						pkgstuff = pkgsplit(self.pkg)
Lines 6723-6730 Link Here
6723
					if stat.S_ISLNK(mydmode) or stat.S_ISDIR(mydmode):
6736
					if stat.S_ISLNK(mydmode) or stat.S_ISDIR(mydmode):
6724
						# a symlink to an existing directory will work for us; keep it:
6737
						# a symlink to an existing directory will work for us; keep it:
6725
						print "---",mydest+"/"
6738
						print "---",mydest+"/"
6726
						if bsd_chflags:
6739
						if freebsd:
6727
							bsd_chflags.lchflags(mydest, dflags)
6740
							try:
6741
								freebsd.lchflags(mydest, dflags)
6742
							except OSError, e:
6743
								if e[0] == 45:
6744
									writemsg("Operation not supported on destination\n")
6745
								else:
6746
									writemsg("!!! Unable to clear flags on " + mydest + ".\n")
6747
									return None
6728
					else:
6748
					else:
6729
						# a non-directory and non-symlink-to-directory.  Won't work for us.  Move out of the way.
6749
						# a non-directory and non-symlink-to-directory.  Won't work for us.  Move out of the way.
6730
						if movefile(mydest,mydest+".backup", mysettings=self.settings) == None:
6750
						if movefile(mydest,mydest+".backup", mysettings=self.settings) == None:
Lines 6736-6743 Link Here
6736
							selinux.secure_mkdir(mydest,sid)
6756
							selinux.secure_mkdir(mydest,sid)
6737
						else:
6757
						else:
6738
							os.mkdir(mydest)
6758
							os.mkdir(mydest)
6739
						if bsd_chflags:
6759
						if freebsd:
6740
							bsd_chflags.lchflags(mydest, dflags)
6760
							freebsd.lchflags(mydest, dflags)
6741
						os.chmod(mydest,mystat[0])
6761
						os.chmod(mydest,mystat[0])
6742
						lchown(mydest,mystat[4],mystat[5])
6762
						lchown(mydest,mystat[4],mystat[5])
6743
						print ">>>",mydest+"/"
6763
						print ">>>",mydest+"/"
Lines 6749-6756 Link Here
6749
					else:
6769
					else:
6750
						os.mkdir(mydest)
6770
						os.mkdir(mydest)
6751
					os.chmod(mydest,mystat[0])
6771
					os.chmod(mydest,mystat[0])
6752
					if bsd_chflags:
6772
					if freebsd:
6753
						bsd_chflags.lchflags(mydest, bsd_chflags.lgetflags(mysrc))
6773
						try:
6774
							freebsd.lchflags(mydest, os.lstat(mysrc).st_flags)
6775
						except OSError, e:
6776
							if e[0] == 45:
6777
								writemsg("Operation not supported on destination\n")
6778
							else:
6779
								writemsg("!!! Unable to set flags on " + mydest + ".\n")
6780
								return None
6754
					lchown(mydest,mystat[4],mystat[5])
6781
					lchown(mydest,mystat[4],mystat[5])
6755
					print ">>>",mydest+"/"
6782
					print ">>>",mydest+"/"
6756
				outfile.write("dir "+myrealdest+"\n")
6783
				outfile.write("dir "+myrealdest+"\n")

Return to bug 94661