Lines 3824-3881
Link Here
|
3824 |
join(offset, x), cfgfiledict, thismtime): |
3824 |
join(offset, x), cfgfiledict, thismtime): |
3825 |
return 1 |
3825 |
return 1 |
3826 |
elif stat.S_ISREG(mymode): |
3826 |
elif stat.S_ISREG(mymode): |
3827 |
# we are merging a regular file |
3827 |
# We are merging a regular file. |
3828 |
mymd5 = perform_md5(mysrc, calc_prelink=1) |
3828 |
mymd5 = perform_md5(mysrc, calc_prelink=1) |
3829 |
# calculate config file protection stuff |
|
|
3830 |
mydestdir = os.path.dirname(mydest) |
3831 |
moveme = 1 |
3832 |
zing = "!!!" |
3833 |
mymtime = None |
3829 |
mymtime = None |
|
|
3830 |
moveme = 1 |
3831 |
zing = ">>>" |
3832 |
# Now, config file management may come into play. |
3834 |
protected = self.isprotected(mydest) |
3833 |
protected = self.isprotected(mydest) |
3835 |
if mydmode != None: |
3834 |
if mydmode == None or not protected: |
3836 |
# destination file exists |
3835 |
# Destination doesn't exist yet or isn't protected. |
3837 |
if stat.S_ISDIR(mydmode): |
3836 |
pass |
3838 |
# install of destination is blocked by an existing directory with the same name |
3837 |
elif stat.S_ISDIR(mydmode): |
3839 |
cfgprot = 1 |
3838 |
# Destination is blocked by an existing directory. |
3840 |
showMessage("!!! %s\n" % mydest, |
3839 |
zing = "!!!" |
3841 |
level=logging.ERROR, noiselevel=-1) |
3840 |
mydest = new_protect_filename(mydest, newmd5=mymd5) |
3842 |
elif stat.S_ISREG(mydmode) or (stat.S_ISLNK(mydmode) and os.path.exists(mydest) and stat.S_ISREG(os.stat(mydest)[stat.ST_MODE])): |
3841 |
elif stat.S_ISREG(mydmode) or (stat.S_ISLNK(mydmode) and os.path.exists(mydest) and stat.S_ISREG(os.stat(mydest)[stat.ST_MODE])): |
3843 |
cfgprot = 0 |
3842 |
# Destination is blocked by an existing regular file, or |
3844 |
# install of destination is blocked by an existing regular file, |
3843 |
# by a symlink to an existing regular file. |
3845 |
# or by a symlink to an existing regular file; |
3844 |
if mymd5 == cfgfiledict.get(myrealdest, [None])[0] and not cfgfiledict["IGNORE"] |
3846 |
# now, config file management may come into play. |
3845 |
# Skip file since an identical update has previously |
3847 |
# we only need to tweak mydest if cfg file management is in play. |
3846 |
# been merged and the user has not chosen --noconfmem. |
3848 |
if protected: |
3847 |
moveme = 0 |
3849 |
# we have a protection path; enable config file management. |
3848 |
zing = "---" |
3850 |
destmd5 = perform_md5(mydest, calc_prelink=1) |
3849 |
mymtime = long(mystat.st_mtime) |
3851 |
if mymd5 == destmd5: |
3850 |
# A previously remembered update has been accepted, |
3852 |
#file already in place; simply update mtimes of destination |
3851 |
# so it is removed from confmem. |
3853 |
moveme = 1 |
3852 |
# ??? Why would we do that? |
3854 |
else: |
3853 |
del cfgfiledict[myrealdest] |
3855 |
if mymd5 == cfgfiledict.get(myrealdest, [None])[0]: |
3854 |
elif mymd5 == perform_md5(mydest, calc_prelink=1): |
3856 |
""" An identical update has previously been |
3855 |
# Destination file is identical but this doesn't mean |
3857 |
merged. Skip it unless the user has chosen |
3856 |
# that it was previously merged that way. (Otherwise |
3858 |
--noconfmem.""" |
3857 |
# above if would have succeeded). |
3859 |
moveme = cfgfiledict["IGNORE"] |
3858 |
pass |
3860 |
cfgprot = cfgfiledict["IGNORE"] |
3859 |
else: |
3861 |
if not moveme: |
3860 |
# Conflict with destination. |
3862 |
zing = "---" |
|
|
3863 |
mymtime = long(mystat.st_mtime) |
3864 |
else: |
3865 |
moveme = 1 |
3866 |
cfgprot = 1 |
3867 |
if moveme: |
3868 |
# Merging a new file, so update confmem. |
3869 |
cfgfiledict[myrealdest] = [mymd5] |
3870 |
elif destmd5 == cfgfiledict.get(myrealdest, [None])[0]: |
3871 |
"""A previously remembered update has been |
3872 |
accepted, so it is removed from confmem.""" |
3873 |
del cfgfiledict[myrealdest] |
3874 |
if cfgprot: |
3875 |
mydest = new_protect_filename(mydest, newmd5=mymd5) |
3861 |
mydest = new_protect_filename(mydest, newmd5=mymd5) |
3876 |
|
3862 |
cfgfiledict[myrealdest] = [mymd5] |
3877 |
# whether config protection or not, we merge the new file the |
3863 |
|
3878 |
# same way. Unless moveme=0 (blocking directory) |
|
|
3879 |
if moveme: |
3864 |
if moveme: |
3880 |
# Do not hardlink files unless they are in the same |
3865 |
# Do not hardlink files unless they are in the same |
3881 |
# directory, since otherwise tar may not be able to |
3866 |
# directory, since otherwise tar may not be able to |
Lines 3886-3913
Link Here
|
3886 |
# CONFIG_PROTECTed files since config files shouldn't be |
3871 |
# CONFIG_PROTECTed files since config files shouldn't be |
3887 |
# hardlinked to eachother (for example, shadow installs |
3872 |
# hardlinked to eachother (for example, shadow installs |
3888 |
# several identical config files inside /etc/pam.d/). |
3873 |
# several identical config files inside /etc/pam.d/). |
3889 |
parent_dir = os.path.dirname(myrealdest) |
|
|
3890 |
hardlink_key = (parent_dir, mymd5, mystat.st_size, |
3891 |
mystat.st_mode, mystat.st_uid, mystat.st_gid) |
3892 |
|
3893 |
hardlink_candidates = None |
3894 |
if not protected and mystat.st_size != 0: |
3874 |
if not protected and mystat.st_size != 0: |
3895 |
hardlink_candidates = self._md5_merge_map.get(hardlink_key) |
3875 |
hardlink_candidates = self._md5_merge_map.get( |
3896 |
if hardlink_candidates is None: |
3876 |
os.path.dirname(myrealdest), mymd5, |
3897 |
hardlink_candidates = [] |
3877 |
mystat.st_size, mystat.st_mode, |
3898 |
self._md5_merge_map[hardlink_key] = hardlink_candidates |
3878 |
mystat.st_uid, mystat.st_gid) |
3899 |
|
3879 |
if hardlink_candidates: |
3900 |
mymtime = movefile(mysrc, mydest, newmtime=thismtime, |
3880 |
hardlink_candidates.append(mydest) |
|
|
3881 |
else: |
3882 |
# ??? This seams strange, shouldn't we add the current |
3883 |
# file? self._md5_merge_map[hardlink_key] = [mydest] |
3884 |
self._md5_merge_map[hardlink_key] = [] |
3885 |
else: |
3886 |
hardlink_candidates = None |
3887 |
mymtime = movefile( |
3888 |
mysrc, mydest, newmtime=thismtime, |
3901 |
sstat=mystat, mysettings=self.settings, |
3889 |
sstat=mystat, mysettings=self.settings, |
3902 |
hardlink_candidates=hardlink_candidates) |
3890 |
hardlink_candidates=hardlink_candidates) |
3903 |
if mymtime is None: |
3891 |
if mymtime is None: |
3904 |
return 1 |
3892 |
return 1 |
3905 |
if hardlink_candidates is not None: |
|
|
3906 |
hardlink_candidates.append(mydest) |
3907 |
zing = ">>>" |
3908 |
|
3893 |
|
3909 |
if mymtime != None: |
3894 |
outfile.write("obj "+myrealdest+" "+mymd5+" "+str(mymtime)+"\n") |
3910 |
outfile.write("obj "+myrealdest+" "+mymd5+" "+str(mymtime)+"\n") |
|
|
3911 |
showMessage("%s %s\n" % (zing,mydest)) |
3895 |
showMessage("%s %s\n" % (zing,mydest)) |
3912 |
else: |
3896 |
else: |
3913 |
# we are merging a fifo or device node |
3897 |
# we are merging a fifo or device node |