blob: 601838c16c330dd3a9702c9cb9e9337632a1b6f3 (
plain)
- #!/bin/sh
- targetdir=/tmp/localtweaks
- origfiles="`cd /etc && find . -name '*.orig'`"
- oldfiles="`cd /etc && find . -name '*.old'`"
- # merge all to only process once when both .orig and .old exist
- files="`echo $origfiles $oldfiles | tsort`"
- for file in $files; do
- olddir="/etc/`dirname $file`"
- newdir="$targetdir/`dirname $file`"
- oldname="`basename $file`"
- newname="`basename $file .orig`"
- if [ ! -e $olddir/$newname.orig ]; then
- newname="`basename $file .old`"
- fi
- if [ "$oldname" = "$newname" ]; then
- echo "FATAL: file is neither .orig nor .old: \"$file\"!"
- exit 1
- fi
- if [ ! -e $olddir/$oldname ]; then
- echo "FATAL: file found disappeared again: \"$file\"!"
- exit 1
- fi
- mkdir -p $newdir
- cp -af $olddir/$newname $newdir
- # Only diff against non-empty files.
- if [ -s $olddir/$oldname ]; then
- diff -ruN $olddir/$oldname $olddir/$newname > $newdir/$newname.diff
- chmod --reference=$olddir/$newname $newdir/$newname.diff
- chown --reference=$olddir/$newname $newdir/$newname.diff
- fi
- done
|