7 if [ "x$PACKAGE" = "x" ];
9 echo "Argument missing."
13 FILEPATH=$(apt-cache show $PACKAGE | grep ^Filename | cut -d ' ' -f 2-)
15 if [ "x$FILEPATH" = "x" ];
17 echo "Package '$PACKAGE' does not exist."
21 ARCHIVE=$(basename $FILEPATH)
23 wget -q -nc -c $DEBIANMIRROR/$FILEPATH -P $CACHEDIR && \
24 ([ -d $TEMPDIR/$PACKAGE ] || mkdir $TEMPDIR/$PACKAGE) && \
25 dpkg -x $CACHEDIR/$ARCHIVE $TEMPDIR/$PACKAGE
33 if [ "x$ETCBASEDIR" = "x" ];
35 echo "Argument missing."
39 REPORT_NAME=$(basename $ETCBASEDIR)
41 # Report diff between debian conf and our local one
42 rm -f $REPORTDIR/$REPORT_NAME.diff
43 [ -d $PREFIX/etc ] && find $PREFIX/etc -type f | \
46 diff -ruN $ETCBASEDIR/${file#$PREFIX/} ${file#$PREFIX} >> $REPORTDIR/$REPORT_NAME.diff
49 # Report symlinks in /etc
50 rm -f $REPORTDIR/$REPORT_NAME.symlinks
51 [ -d $PREFIX/etc ] && find $PREFIX/etc -type l | \
54 stat -c '%N' $file >> $REPORTDIR/$REPORT_NAME.symlinks
60 PACKAGES=$(dpkg --get-selections | grep 'install$' | cut -f 1 -d ' ')
62 rm $PROMPT_RM -rf $TEMPDIR/__debian_etc && mkdir $TEMPDIR/__debian_etc
67 # Skip packages which don't put anything in /etc
68 if ! dpkg -L $p | grep -q '/etc/';
73 echo "Getting package $p..."
74 if ! _get_unpack_package $p;
79 # save the original etc dir for later processing
80 if [ ! -d $TEMPDIR/$p/etc ];
82 echo "Warning: package $p does not have any /etc, but 'dpkg -L' shows it"
85 cp -ir $TEMPDIR/$p/etc $TEMPDIR/__debian_etc
89 _do_etcdiff $TEMPDIR/__debian_etc
91 rm -rf $TEMPDIR/__debian_etc
98 if [ "x$PACKAGE" = "x" ];
100 echo "Argument missing."
104 if dpkg --status $PACKAGE | grep -q 'not-installed';
106 echo "Package '$PACKAGE' not installed"
110 # Skip packages which don't put anything in /etc
111 if ! dpkg -L $PACKAGE | grep -q '/etc/';
113 echo "$PACKAGE does not put any file in /etc"
117 if ! _get_unpack_package $PACKAGE;
122 if [ ! -d $TEMPDIR/$PACKAGE/etc ];
124 echo "Warning: package $p does not have any /etc, but 'dpkg -L' shows it"
128 if ! _do_etcdiff $TEMPDIR/$PACKAGE $TEMPDIR/$PACKAGE;
140 if [ "x$FILE" = "x" ];
142 echo "Argument missing."
148 echo "ERROR, file $FILE does not exist."
154 echo "ERROR, file $FILE is not a regular file."
158 if [ $FILE = ${FILE#/etc/} ];
160 echo "ERROR, file path must begin with /etc/."
164 # Find out which installed package provides the config file
165 PACKAGE=$(dpkg-query -S "$FILE" | cut -d ':' -f 1 | uniq 2> /dev/null)
167 REPORT_NAME=$(basename $FILE)
169 if [ "x$PACKAGE" = "x" ];
171 diff -ruN /dev/null $FILE > $REPORTDIR/$REPORT_NAME.diff
173 if ! _get_unpack_package $PACKAGE;
177 diff -ruN $FILE $TEMPDIR/$PACKAGE/$FILE > $REPORTDIR/$REPORT_NAME.diff
180 if [ $(stat -c '%s' $REPORTDIR/$REPORT_NAME.diff) -eq 0 ];
182 rm -f $REPORTDIR/$REPORT_NAME.diff