Index: usr.sbin/mergemaster/mergemaster.8 =================================================================== --- usr.sbin/mergemaster/mergemaster.8 +++ usr.sbin/mergemaster/mergemaster.8 @@ -389,6 +389,14 @@ # Files to always avoid comparing #IGNORE_FILES='/etc/motd /etc/printcap foo bar' # +# Files to completely ignore file type mismatches for. This can lead to problems +# for certain mismatch combinations +#IGNORE_TYPE_FILES='/etc/aliases' +# +# Files that are allowed to be of the wrong type only if they are symbolic +# links to the correct type +#ALLOW_SYMLINK='/boot /var' +# # Additional options for diff. This will get unset when using -s. #DIFF_OPTIONS='-Bb' # Ignore changes in whitespace # Index: usr.sbin/mergemaster/mergemaster.sh =================================================================== --- usr.sbin/mergemaster/mergemaster.sh +++ usr.sbin/mergemaster/mergemaster.sh @@ -1034,6 +1034,29 @@ TEMPROOT_TYPE=`echo $TEMPROOT_TYPE | tr [:upper:] [:lower:]` INSTALLED_TYPE=`echo $INSTALLED_TYPE | tr [:upper:] [:lower:]` + # Ignore the type mismatch for user specified files if the installed + # file is of type symlink and the following conditions are met: + # - installed type is symlink + # - symlink target has the correct type + # - if DESTDIR is set, symlink does not point outside of it + # - file is listed in ALLOW_SYMLINK + if [ "${INSTALLED_TYPE}" = 'symbolic link' ]; then + SYMLINK_TARGET=`realpath ${DESTDIR}${COMPFILE#.}` + SYMLINK_TARGET_TYPE=`stat -f '%HT' ${SYMLINK_TARGET} | tr [:upper:] [:lower:]` + + if [ "$TEMPROOT_TYPE" = "$SYMLINK_TARGET_TYPE" ] && + test "-z $DESTDIR -o ${SYMLINK_TARGET} != ${SYMLINK_TARGET##${DESTDIR}}"; then + for _f in ${ALLOW_SYMLINK}; do + [ "${COMPFILE#.}" = "${_f}" ] && continue 2 + done + fi + fi + + # Completely ignore the type mismatch for user specified files + for _f in ${IGNORE_TYPE_FILES}; do + [ "${COMPFILE#.}" = "${_f}" ] && continue 2 + done + echo "*** The installed file ${DESTDIR}${COMPFILE#.} has the type \"$INSTALLED_TYPE\"" echo " but the new version has the type \"$TEMPROOT_TYPE\"" echo '' @@ -1061,7 +1084,8 @@ 'symbolic link') ln -sf $TARGET ${DESTDIR}${COMPFILE#.} ;; esac ;; *) echo '' - echo "*** See the man page about adding ${COMPFILE#.} to the list of IGNORE_FILES" + echo "*** See the man page about adding ${COMPFILE#.} to the list of IGNORE_FILES," + echo "*** IGNORE_TYPE_FILES or ALLOW_SYMLINK" press_to_continue ;; esac echo ''