blob: b303cda5ca3ab6296154091406e30693ed04f4dc (
plain)
- #!/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
|