diff options
author | jonas <jonas@8f53b18a-e215-0410-8885-9f593d34873e> | 2006-06-10 18:18:37 +0000 |
---|---|---|
committer | jonas <jonas@8f53b18a-e215-0410-8885-9f593d34873e> | 2006-06-10 18:18:37 +0000 |
commit | b6d85b04286d30498a11aaac36e75032b1e72801 (patch) | |
tree | 2fc597a2ae2cf69a5cc6b3e7162f02f89613b08d /addons/x11infoscreen/usr/local/bin/savelocaltweaks | |
parent | 369cb1e5a343ec9e7c6f05de64f0eb102488d77f (diff) |
Added all work so far...
git-svn-id: svn+ssh://xayide/home/jonas/private_svn/fleshybrid/trunk@2 8f53b18a-e215-0410-8885-9f593d34873e
Diffstat (limited to 'addons/x11infoscreen/usr/local/bin/savelocaltweaks')
-rwxr-xr-x | addons/x11infoscreen/usr/local/bin/savelocaltweaks | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/addons/x11infoscreen/usr/local/bin/savelocaltweaks b/addons/x11infoscreen/usr/local/bin/savelocaltweaks new file mode 100755 index 0000000..b303cda --- /dev/null +++ b/addons/x11infoscreen/usr/local/bin/savelocaltweaks @@ -0,0 +1,61 @@ +#!/bin/sh + +#set -e + +basedir="/etc" +targetdir="/tmp/localtweaks" +includefile="/etc/local/localtweaks.include" +excludefile="/etc/local/localtweaks.exclude" +extensions=".orig .old" + +for ext in $extensions; do + extfiles="`find $basedir -name \*$ext`" + for extfile in $extfiles; do + xextfile="${extfile%$ext}" + files="$files ${xextfile#$basedir}" + done +done + +includes="" +if [ -d "`dirname $includefile`" ] && [ -r $includefile ]; then + includes="`cat $includefile`" + for include in $includes; do + files="$files ${include#$basedir}" + done +fi + +excludes="" +if [ -d "`dirname $excludefile`" ] && [ -r $excludefile ]; then + xexcludes="`cat $excludefile`" + for exclude in $xexcludes; do + excludes="$excludes ${exclude#$basedir}" + done +fi + +# process all files once each +for file in `for x in $files; do echo $x; done | uniq | sort`; do + + for exclude in $excludes; do + [ "$file" = "$exclude" ] && continue 2 + done + + ext="" + for xext in $extensions; do + if [ -e $basedir/$file$xext ]; then + ext="$xext" + continue + fi + done + + newdir="$targetdir/$basedir/`dirname $file`" + mkdir -p $newdir + cp -af $basedir/$file $newdir + + # Only diff against existing and non-empty files. + if [ -n "$ext" ] && [ -s $basedir/$file$ext ]; then + diff -ruN $basedir/$file$ext $basedir/$file > $targetdir/$basedir/$file.diff + chown --reference=$basedir/$file $targetdir/$basedir/$file.diff + chmod --reference=$basedir/$file $targetdir/$basedir/$file.diff + chmod a-x $targetdir/$basedir/$file.diff + fi +done |