X-Git-Url: https://git.ao2.it/etcdiff.git/blobdiff_plain/92d43d71368540ea7b7d72d309d69a9133943638..refs/heads/master:/etcdiff.include?ds=sidebyside diff --git a/etcdiff.include b/etcdiff.include index 44564d8..f25076b 100644 --- a/etcdiff.include +++ b/etcdiff.include @@ -7,7 +7,7 @@ _get_unpack_package() if [ "x$PACKAGE" = "x" ]; then echo "Argument missing." - exit 1 + return 1 fi FILEPATH=$(apt-cache show $PACKAGE | grep ^Filename | cut -d ' ' -f 2-) @@ -15,7 +15,7 @@ _get_unpack_package() if [ "x$FILEPATH" = "x" ]; then echo "Package '$PACKAGE' does not exist." - exit 1 + return 1 fi ARCHIVE=$(basename $FILEPATH) @@ -33,14 +33,14 @@ _do_etcdiff() if [ "x$ETCBASEDIR" = "x" ]; then echo "Argument missing." - exit 1 + return 1 fi REPORT_NAME=$(basename $ETCBASEDIR) # Report diff between debian conf and our local one rm -f $REPORTDIR/$REPORT_NAME.diff - find $PREFIX/etc -type f | \ + [ -d $PREFIX/etc ] && find $PREFIX/etc -type f | \ while read file; do diff -ruN $ETCBASEDIR/${file#$PREFIX/} ${file#$PREFIX} >> $REPORTDIR/$REPORT_NAME.diff @@ -48,14 +48,14 @@ _do_etcdiff() # Report symlinks in /etc rm -f $REPORTDIR/$REPORT_NAME.symlinks - find $PREFIX/etc -type l | \ + [ -d $PREFIX/etc ] && find $PREFIX/etc -type l | \ while read file; do stat -c '%N' $file >> $REPORTDIR/$REPORT_NAME.symlinks done } -etchdiff_system() +etcdiff_system() { PACKAGES=$(dpkg --get-selections | grep 'install$' | cut -f 1 -d ' ') @@ -71,10 +71,19 @@ etchdiff_system() fi echo "Getting package $p..." - _get_unpack_package $p + if ! _get_unpack_package $p; + then + continue + fi # save the original etc dir for later processing - cp -ir $TEMPDIR/$PACKAGE/etc $TEMPDIR/__debian_etc + if [ ! -d $TEMPDIR/$p/etc ]; + then + echo "Warning: package $p does not have any /etc, but 'dpkg -L' shows it" + continue + else + cp -ir $TEMPDIR/$p/etc $TEMPDIR/__debian_etc + fi done _do_etcdiff $TEMPDIR/__debian_etc @@ -89,7 +98,7 @@ etcdiff_by_package() if [ "x$PACKAGE" = "x" ]; then echo "Argument missing." - exit 1 + return 1 fi if dpkg --status $PACKAGE | grep -q 'not-installed'; @@ -105,9 +114,21 @@ etcdiff_by_package() return 1 fi - _get_unpack_package $PACKAGE + if ! _get_unpack_package $PACKAGE; + then + return 1 + fi - _do_etcdiff $TEMPDIR/$PACKAGE $TEMPDIR/$PACKAGE + if [ ! -d $TEMPDIR/$PACKAGE/etc ]; + then + echo "Warning: package $p does not have any /etc, but 'dpkg -L' shows it" + return 1 + fi + + if ! _do_etcdiff $TEMPDIR/$PACKAGE $TEMPDIR/$PACKAGE; + then + return 1 + fi return 0 } @@ -119,7 +140,7 @@ etcdiff_by_file() if [ "x$FILE" = "x" ]; then echo "Argument missing." - exit 1 + return 1 fi if [ ! -e $FILE ]; @@ -149,7 +170,10 @@ etcdiff_by_file() then diff -ruN /dev/null $FILE > $REPORTDIR/$REPORT_NAME.diff else - _get_unpack_package $PACKAGE + if ! _get_unpack_package $PACKAGE; + then + return 1 + fi diff -ruN $FILE $TEMPDIR/$PACKAGE/$FILE > $REPORTDIR/$REPORT_NAME.diff fi