Lines 51-65
Link Here
|
51 |
sys.stderr.write("!!! gone wrong. The exception was non-standard and we were unable to catch it.\n\n") |
51 |
sys.stderr.write("!!! gone wrong. The exception was non-standard and we were unable to catch it.\n\n") |
52 |
sys.exit(127) |
52 |
sys.exit(127) |
53 |
|
53 |
|
|
|
54 |
flagsNotWritable = 0x0160016 |
54 |
try: |
55 |
try: |
55 |
# XXX: This should get renamed to bsd_chflags, I think. |
56 |
import freebsd as bsdutils |
56 |
import chflags |
|
|
57 |
bsd_chflags = chflags |
58 |
except SystemExit, e: |
57 |
except SystemExit, e: |
59 |
raise |
58 |
raise |
60 |
except: |
59 |
except: |
61 |
# XXX: This should get renamed to bsd_chflags, I think. |
60 |
bsdutils = None |
62 |
bsd_chflags = None |
|
|
63 |
|
61 |
|
64 |
try: |
62 |
try: |
65 |
import cvstree |
63 |
import cvstree |
Lines 2761-2780
Link Here
|
2761 |
dstat=os.lstat(os.path.dirname(dest)) |
2759 |
dstat=os.lstat(os.path.dirname(dest)) |
2762 |
destexists=0 |
2760 |
destexists=0 |
2763 |
|
2761 |
|
2764 |
if bsd_chflags: |
2762 |
if bsdutils: |
2765 |
# Check that we can actually unset schg etc flags... |
2763 |
if destexists: |
2766 |
# Clear the flags on source and destination; we'll reinstate them after merging |
2764 |
# We might have an immutable flag on the parent dir; |
2767 |
if(destexists): |
2765 |
# save and clear. |
2768 |
if bsd_chflags.lchflags(dest, 0) < 0: |
2766 |
pflags=os.lstat(os.path.dirname(dest)).st_flags |
2769 |
writemsg("!!! Couldn't clear flags on file being merged: \n ") |
2767 |
|
2770 |
# We might have an immutable flag on the parent dir; save and clear. |
2768 |
try: |
2771 |
pflags=bsd_chflags.lgetflags(os.path.dirname(dest)) |
2769 |
if destexists: |
2772 |
bsd_chflags.lchflags(os.path.dirname(dest), 0) |
2770 |
bsdutils.lchflags(os.path.dirname(dest), 0) |
2773 |
|
2771 |
bsdutils.lchflags(dest, 0) |
2774 |
# Don't bother checking the return value here; if it fails then the next line will catch it. |
2772 |
|
2775 |
bsd_chflags.lchflags(src, 0) |
2773 |
bsdutils.lchflags(src, 0) |
|
|
2774 |
except OSError, e: |
2775 |
import errno |
2776 |
if e[0] == errno.EOPNOTSUPP: |
2777 |
writemsg("Operation not supported on destination\n") |
2778 |
else: |
2779 |
writemsg("!!! Unable to reset flags.\n") |
2780 |
return None |
2776 |
|
2781 |
|
2777 |
if bsd_chflags.lhasproblems(src)>0 or (destexists and bsd_chflags.lhasproblems(dest)>0) or bsd_chflags.lhasproblems(os.path.dirname(dest))>0: |
2782 |
if os.lstat(src).st_flags & flagsNotWritable != 0 or ( destexists and os.lstat(dest).st_flags & flagsNotWritable != 0 or os.lstat(os.path.dirname(dest)).st_flags & flagsNotWritable != 0 ): |
2778 |
# This is bad: we can't merge the file with these flags set. |
2783 |
# 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") |
2784 |
writemsg("!!! Can't merge file "+dest+" because of flags set\n") |
2780 |
return None |
2785 |
return None |
Lines 2803-2814
Link Here
|
2803 |
else: |
2808 |
else: |
2804 |
os.symlink(target,dest) |
2809 |
os.symlink(target,dest) |
2805 |
lchown(dest,sstat[stat.ST_UID],sstat[stat.ST_GID]) |
2810 |
lchown(dest,sstat[stat.ST_UID],sstat[stat.ST_GID]) |
2806 |
if bsd_chflags: |
2811 |
if bsdutils: |
2807 |
# Restore the flags we saved before moving |
2812 |
try: |
2808 |
if bsd_chflags.lchflags(dest, sflags) < 0 or bsd_chflags.lchflags(os.path.dirname(dest), pflags) < 0: |
2813 |
# Restore the flags we saved before moving |
2809 |
writemsg("!!! Couldn't restore flags ("+str(flags)+") on " + dest+":\n") |
2814 |
bsdutils.lchflags(dest, sstat.st_flags) |
2810 |
writemsg("!!! %s\n" % str(e)) |
2815 |
if destexists: |
2811 |
return None |
2816 |
bsdutils.lchflags(os.path.dirname(dest), pflags) |
|
|
2817 |
except OSError, e: |
2818 |
import errno |
2819 |
if e[0] == errno.EOPNOTSUPP: |
2820 |
writemsg("Operation not supported on destination\n") |
2821 |
else: |
2822 |
writemsg("!!! Couldn't restore flags ("+str(sstat.st_flags)+") on " + dest+":\n") |
2823 |
writemsg("!!! %s\n" % str(e)) |
2824 |
return None |
2812 |
return os.lstat(dest)[stat.ST_MTIME] |
2825 |
return os.lstat(dest)[stat.ST_MTIME] |
2813 |
except SystemExit, e: |
2826 |
except SystemExit, e: |
2814 |
raise |
2827 |
raise |
Lines 2883-2893
Link Here
|
2883 |
os.utime(dest, (sstat[stat.ST_ATIME], sstat[stat.ST_MTIME])) |
2896 |
os.utime(dest, (sstat[stat.ST_ATIME], sstat[stat.ST_MTIME])) |
2884 |
newmtime=sstat[stat.ST_MTIME] |
2897 |
newmtime=sstat[stat.ST_MTIME] |
2885 |
|
2898 |
|
2886 |
if bsd_chflags: |
2899 |
if bsdutils: |
2887 |
# Restore the flags we saved before moving |
2900 |
try: |
2888 |
if bsd_chflags.lchflags(dest, sflags) < 0 or bsd_chflags.lchflags(os.path.dirname(dest), pflags) < 0: |
2901 |
# Restore the flags we saved before moving |
2889 |
writemsg("!!! Couldn't restore flags ("+str(sflags)+") on " + dest+":\n") |
2902 |
bsdutils.lchflags(dest, sstat.st_flags) |
2890 |
return None |
2903 |
if destexists: |
|
|
2904 |
bsdutils.lchflags(os.path.dirname(dest), pflags) |
2905 |
except OSError, e: |
2906 |
import errno |
2907 |
if e[0] == errno.EOPNOTSUPP: |
2908 |
writemsg("Operation not supported on destination\n") |
2909 |
else: |
2910 |
writemsg("!!! Couldn't restore flags ("+str(sstat.st_flags)+") on " + dest+":\n") |
2911 |
return None |
2891 |
|
2912 |
|
2892 |
return newmtime |
2913 |
return newmtime |
2893 |
|
2914 |
|
Lines 6705-6715
Link Here
|
6705 |
if mydmode!=None: |
6726 |
if mydmode!=None: |
6706 |
# destination exists |
6727 |
# destination exists |
6707 |
|
6728 |
|
6708 |
if bsd_chflags: |
6729 |
if bsdutils: |
6709 |
# Save then clear flags on dest. |
6730 |
# Save then clear flags on dest. |
6710 |
dflags=bsd_chflags.lgetflags(mydest) |
6731 |
dflags=os.lstat(mydest).st_flags |
6711 |
if(bsd_chflags.lchflags(mydest, 0)<0): |
6732 |
try: |
6712 |
writemsg("!!! Couldn't clear flags on '"+mydest+"'.\n") |
6733 |
bsdutils.lchflags(mydest, 0) |
|
|
6734 |
except OSError, e: |
6735 |
import errno |
6736 |
if e[0] == errno.EOPNOTSUPP: |
6737 |
writemsg("Operation not supported on destination\n") |
6738 |
else: |
6739 |
writemsg("!!! Unable to clear flags on " + mydest + ".\n") |
6740 |
return None |
6713 |
|
6741 |
|
6714 |
if not os.access(mydest, os.W_OK): |
6742 |
if not os.access(mydest, os.W_OK): |
6715 |
pkgstuff = pkgsplit(self.pkg) |
6743 |
pkgstuff = pkgsplit(self.pkg) |
Lines 6723-6730
Link Here
|
6723 |
if stat.S_ISLNK(mydmode) or stat.S_ISDIR(mydmode): |
6751 |
if stat.S_ISLNK(mydmode) or stat.S_ISDIR(mydmode): |
6724 |
# a symlink to an existing directory will work for us; keep it: |
6752 |
# a symlink to an existing directory will work for us; keep it: |
6725 |
print "---",mydest+"/" |
6753 |
print "---",mydest+"/" |
6726 |
if bsd_chflags: |
6754 |
if bsdutils: |
6727 |
bsd_chflags.lchflags(mydest, dflags) |
6755 |
try: |
|
|
6756 |
bsdutils.lchflags(mydest, dflags) |
6757 |
except OSError, e: |
6758 |
import errno |
6759 |
if e[0] == errno.EOPNOTSUPP: |
6760 |
writemsg("Operation not supported on destination\n") |
6761 |
else: |
6762 |
writemsg("!!! Unable to clear flags on " + mydest + ".\n") |
6763 |
return None |
6728 |
else: |
6764 |
else: |
6729 |
# a non-directory and non-symlink-to-directory. Won't work for us. Move out of the way. |
6765 |
# 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: |
6766 |
if movefile(mydest,mydest+".backup", mysettings=self.settings) == None: |
Lines 6736-6743
Link Here
|
6736 |
selinux.secure_mkdir(mydest,sid) |
6772 |
selinux.secure_mkdir(mydest,sid) |
6737 |
else: |
6773 |
else: |
6738 |
os.mkdir(mydest) |
6774 |
os.mkdir(mydest) |
6739 |
if bsd_chflags: |
6775 |
if bsdutils: |
6740 |
bsd_chflags.lchflags(mydest, dflags) |
6776 |
bsdutils.lchflags(mydest, dflags) |
6741 |
os.chmod(mydest,mystat[0]) |
6777 |
os.chmod(mydest,mystat[0]) |
6742 |
lchown(mydest,mystat[4],mystat[5]) |
6778 |
lchown(mydest,mystat[4],mystat[5]) |
6743 |
print ">>>",mydest+"/" |
6779 |
print ">>>",mydest+"/" |
Lines 6749-6756
Link Here
|
6749 |
else: |
6785 |
else: |
6750 |
os.mkdir(mydest) |
6786 |
os.mkdir(mydest) |
6751 |
os.chmod(mydest,mystat[0]) |
6787 |
os.chmod(mydest,mystat[0]) |
6752 |
if bsd_chflags: |
6788 |
if bsdutils: |
6753 |
bsd_chflags.lchflags(mydest, bsd_chflags.lgetflags(mysrc)) |
6789 |
try: |
|
|
6790 |
bsdutils.lchflags(mydest, os.lstat(mysrc).st_flags) |
6791 |
except OSError, e: |
6792 |
import errno |
6793 |
if e[0] == errno.EOPNOTSUPP: |
6794 |
writemsg("Operation not supported on destination\n") |
6795 |
else: |
6796 |
writemsg("!!! Unable to set flags on " + mydest + ".\n") |
6797 |
return None |
6754 |
lchown(mydest,mystat[4],mystat[5]) |
6798 |
lchown(mydest,mystat[4],mystat[5]) |
6755 |
print ">>>",mydest+"/" |
6799 |
print ">>>",mydest+"/" |
6756 |
outfile.write("dir "+myrealdest+"\n") |
6800 |
outfile.write("dir "+myrealdest+"\n") |