diff options
author | bapt <bapt@FreeBSD.org> | 2016-10-22 20:39:18 +0000 |
---|---|---|
committer | bapt <bapt@FreeBSD.org> | 2016-10-22 20:39:18 +0000 |
commit | 017345e23d3ffe848743c367c8f2e0ed44564a9c (patch) | |
tree | 4085987fc506d0ef1ce9b3fb514bc469175fae29 /usr.sbin | |
parent | 0a95e47ecdc8c6e7eab1647caac3110f380e1f9f (diff) | |
download | FreeBSD-src-017345e23d3ffe848743c367c8f2e0ed44564a9c.zip FreeBSD-src-017345e23d3ffe848743c367c8f2e0ed44564a9c.tar.gz |
MFC r303784, r303785, r305620:
r303784:
etcupdate: directly use diff3(1) instead of merge(1)
During the last attempt to rmeove GNU rcs, 2 blockers were spotted:
We need an ident(1) and etcupdate(8) uses merge(1).
Now nothing should prevent to remove rcs from base
Reviewed by: jhb
Differential Revision: https://reviews.freebsd.org/D7401
r303785:
always install etcupdate
Now that etcupdate does not depend on rcs anymore there is no need to
conditionnally install it
r305620: (by vangyzen )
etcupdate: preserve the metadata of the destination file
When using diff3 to perform a three-way merge, etcupdate lost the destination
file's metadata. The metadata from the temporary file were used instead.
This was unpleasant for rc.d scripts, which require execute permission.
Use "cat >" to overwrite the destination file's contents while preserving its
metadata.
Reviewed by: bapt
Sponsored by: Dell Technologies
Differential Revision: https://reviews.freebsd.org/D7817
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/Makefile | 2 | ||||
-rwxr-xr-x | usr.sbin/etcupdate/etcupdate.sh | 18 |
2 files changed, 12 insertions, 8 deletions
diff --git a/usr.sbin/Makefile b/usr.sbin/Makefile index c2b0b7c..67499a1 100644 --- a/usr.sbin/Makefile +++ b/usr.sbin/Makefile @@ -25,6 +25,7 @@ SUBDIR= adduser \ digictl \ diskinfo \ dumpcis \ + etcupdate \ extattr \ extattrctl \ fifolog \ @@ -188,7 +189,6 @@ SUBDIR.${MK_QUOTAS}+= edquota SUBDIR.${MK_QUOTAS}+= quotaon SUBDIR.${MK_QUOTAS}+= repquota SUBDIR.${MK_RCMDS}+= rwhod -SUBDIR.${MK_RCS}+= etcupdate SUBDIR.${MK_SENDMAIL}+= editmap SUBDIR.${MK_SENDMAIL}+= mailstats SUBDIR.${MK_SENDMAIL}+= makemap diff --git a/usr.sbin/etcupdate/etcupdate.sh b/usr.sbin/etcupdate/etcupdate.sh index bb12d36..2b4c145 100755 --- a/usr.sbin/etcupdate/etcupdate.sh +++ b/usr.sbin/etcupdate/etcupdate.sh @@ -814,15 +814,19 @@ merge_file() local res # Try the merge to see if there is a conflict. - merge -q -p ${DESTDIR}$1 ${OLDTREE}$1 ${NEWTREE}$1 >/dev/null 2>&3 + diff3 -E -m ${DESTDIR}$1 ${OLDTREE}$1 ${NEWTREE}$1 > /dev/null 2>&3 res=$? case $res in 0) # No conflicts, so just redo the merge to the # real file. - log "merge ${DESTDIR}$1 ${OLDTREE}$1 ${NEWTREE}$1" + log "diff3 -E -m ${DESTDIR}$1 ${OLDTREE}$1 ${NEWTREE}$1" if [ -z "$dryrun" ]; then - merge ${DESTDIR}$1 ${OLDTREE}$1 ${NEWTREE}$1 + temp=$(mktemp -t etcupdate) + diff3 -E -m ${DESTDIR}$1 ${OLDTREE}$1 ${NEWTREE}$1 > ${temp} + # Use "cat >" to preserve metadata. + cat ${temp} > ${DESTDIR}$1 + rm -f ${temp} fi post_install_file $1 echo " M $1" @@ -832,10 +836,10 @@ merge_file() # the conflicts directory. if [ -z "$dryrun" ]; then install_dirs $NEWTREE $CONFLICTS $1 - log "cp -Rp ${DESTDIR}$1 ${CONFLICTS}$1" - cp -Rp ${DESTDIR}$1 ${CONFLICTS}$1 >&3 2>&1 - merge -A -q -L "yours" -L "original" -L "new" \ - ${CONFLICTS}$1 ${OLDTREE}$1 ${NEWTREE}$1 + log "diff3 -m -A ${DESTDIR}$1 ${CONFLICTS}$1" + diff3 -m -A -L "yours" -L "original" -L "new" \ + ${DESTDIR}$1 ${OLDTREE}$1 ${NEWTREE}$1 > \ + ${CONFLICTS}$1 fi echo " C $1" ;; |