From 6db6a3e0ae009d272bf64f57a58e0d494cdff0da Mon Sep 17 00:00:00 2001 From: ajacoutot Date: Mon, 11 Aug 2014 09:03:27 +0000 Subject: [PATCH] Steal stripcom() from /etc/rc to parse sysmerge.ignore. --- usr.sbin/sysmerge/sysmerge.8 | 8 +++----- usr.sbin/sysmerge/sysmerge.sh | 24 ++++++++++++++++++------ 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/usr.sbin/sysmerge/sysmerge.8 b/usr.sbin/sysmerge/sysmerge.8 index ce10b07d524..15df0dcae99 100644 --- a/usr.sbin/sysmerge/sysmerge.8 +++ b/usr.sbin/sysmerge/sysmerge.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: sysmerge.8,v 1.56 2014/08/11 06:30:39 ajacoutot Exp $ +.\" $OpenBSD: sysmerge.8,v 1.57 2014/08/11 09:03:27 ajacoutot Exp $ .\" .\" Copyright (c) 2008 Antoine Jacoutot .\" @@ -161,10 +161,8 @@ to .Xr ftp 1 . .El .Pp -Files and directories can be excluded from comparison -by listing them in the file -.Pa /etc/sysmerge.ignore , -each entry separated by white space or a new line. +Files can be excluded from comparison by listing them in +.Pa /etc/sysmerge.ignore . The following files will always be skipped from comparison: .Pa /etc/*.db , .Pa /etc/localtime , diff --git a/usr.sbin/sysmerge/sysmerge.sh b/usr.sbin/sysmerge/sysmerge.sh index ddf1949b6e2..269dcc90320 100644 --- a/usr.sbin/sysmerge/sysmerge.sh +++ b/usr.sbin/sysmerge/sysmerge.sh @@ -1,6 +1,6 @@ #!/bin/ksh - # -# $OpenBSD: sysmerge.sh,v 1.149 2014/08/10 17:15:18 jmc Exp $ +# $OpenBSD: sysmerge.sh,v 1.150 2014/08/11 09:03:27 ajacoutot Exp $ # # Copyright (c) 2008-2014 Antoine Jacoutot # Copyright (c) 1998-2003 Douglas Barton @@ -75,6 +75,20 @@ report() { echo "$@" >> ${REPORT} } +# from OpenBSD's /etc/rc,v 1.438 +stripcom() { + local _file="$1" + local _line + + { + while read _line ; do + _line=${_line%%#*} # strip comments + test -z "$_line" && continue + echo $_line + done + } < $_file +} + # remove newly created work directory and exit with status 1 error_rm_wrkdir() { (($#)) && echo "!!!! ERROR: $@" @@ -323,13 +337,11 @@ sm_populate() { CF_DIFF=$(diff -q -I "##### " ${TEMPROOT}/${cf} ${DESTDIR}/${cf} 2>/dev/null) [[ -z ${CF_DIFF} ]] && IGNORE_FILES="${IGNORE_FILES} ${cf}" done - if [ -r /etc/sysmerge.ignore ]; then - while read i; do \ - IGNORE_FILES="${IGNORE_FILES} $(echo ${i} | sed -e 's,\.\.,,g' -e 's,#.*,,g')" - done < /etc/sysmerge.ignore + if [ -f /etc/sysmerge.ignore ]; then + IGNORE_FILES="${IGNORE_FILES} $(stripcom /etc/sysmerge.ignore)" fi for i in ${IGNORE_FILES}; do - rm -rf ${TEMPROOT}/${i}; + rm -f ${TEMPROOT}/${i} done } -- 2.20.1