From 890f2daa3ce1482427514f0b29bc4fd66a66cde4 Mon Sep 17 00:00:00 2001 From: Jonas Smedegaard Date: Thu, 5 Aug 2004 17:38:14 +0000 Subject: Avoid tsort. Support exclude and include files. Fail on error. --- savelocaltweaks | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/savelocaltweaks b/savelocaltweaks index 41caaef..7471765 100755 --- a/savelocaltweaks +++ b/savelocaltweaks @@ -1,18 +1,33 @@ #!/bin/sh +set -e + targetdir=/tmp/localtweaks origfiles="`cd /etc && find . -name '*.orig'`" oldfiles="`cd /etc && find . -name '*.old'`" +includes="" +excludes="" +if [ -d /etc/local ]; then + if [ -r /etc/local/localtweaks.include ]; then + includes="`cat /etc/local/localtweaks.include`" + fi + if [ -r /etc/local/localtweaks.exclude ]; then + excludes="`cat /etc/local/localtweaks.exclude`" + fi +fi -# merge all to only process once when both .orig and .old exist -files="`echo $origfiles $oldfiles | tsort`" +files="$origfiles $oldfiles $includes" -for file in $files; do +# process all *.{orig,old} once each +for file in `for x in $files; do echo $x; done | uniq | sort`; do olddir="/etc/`dirname $file`" newdir="$targetdir/`dirname $file`" oldname="`basename $file`" newname="`basename $file .orig`" + for exclude in $excludes; do + [ "$newname" = "$exclude" ] && continue 2 + done if [ ! -e $olddir/$newname.orig ]; then newname="`basename $file .old`" fi -- cgit v1.2.3