commit 3a22417a258d9817a8cb370c9f7d478f6b27e586
parent b2db648eb28be650bfe548c3228c7cbb0a721d9f
Author: Antoine Amarilli <a3nm@a3nm.net>
Date: Sun, 3 Aug 2014 14:13:21 +0200
mv debdiffconf
Diffstat:
debdiffconf | | | 52 | ++++++++++++++++++++++++++++++++++++++++++++++++++++ |
debdiffconf.sh | | | 52 | ---------------------------------------------------- |
2 files changed, 52 insertions(+), 52 deletions(-)
diff --git a/debdiffconf b/debdiffconf
@@ -0,0 +1,52 @@
+#!/bin/bash
+
+# Usage: debdiffconf.sh FILE
+# Produce on stdout diff of FILE against the first installed Debian package
+# found that provides it.
+# Returns the exit code of diff if everything worked, 3 or 4 otherwise.
+
+# http://stackoverflow.com/a/4785518
+command -v apt-get >/dev/null 2>&1 || {
+ echo "apt-get not found, this is probably not a Debian system. Aborting." >&2;
+ exit 4; }
+command -v apt-file >/dev/null 2>&1 || {
+ echo "Please install apt-file: sudo apt-get install apt-file. Aborting." >&2;
+ exit 4; }
+
+FILE=$(readlink -f "$1")
+while read PACKAGE
+do
+ # verify from first installed package
+ if dpkg-query -W --showformat='${Status}\n' | grep installed > /dev/null
+ then
+ DIR=$(mktemp -d)
+ cd "$DIR"
+ echo "Trying $PACKAGE..." >&2
+ apt-get download "$PACKAGE" >&2
+ # downloaded archive is the only file present...
+ ARCHIVE=$(ls)
+ mkdir contents
+ # extract entire archive
+ dpkg-deb -x "$ARCHIVE" contents/ >&2
+ if [ -f "contents$FILE" ]
+ then
+ # package contained required file
+ diff "contents$FILE" "$FILE"
+ RET=$?
+ # cleanup
+ cd
+ rm -Rf "$DIR"
+ # exit entire script as this is the main shell
+ # with the return code from diff
+ exit $RET
+ else
+ # cleanup
+ cd
+ rm -Rf "$DIR"
+ fi
+ fi
+done < <(apt-file -l search "$FILE")
+# if we are here, it means we have found no suitable package
+echo "Could not find original package for $FILE" >&2
+exit 3
+
diff --git a/debdiffconf.sh b/debdiffconf.sh
@@ -1,52 +0,0 @@
-#!/bin/bash
-
-# Usage: debdiffconf.sh FILE
-# Produce on stdout diff of FILE against the first installed Debian package
-# found that provides it.
-# Returns the exit code of diff if everything worked, 3 or 4 otherwise.
-
-# http://stackoverflow.com/a/4785518
-command -v apt-get >/dev/null 2>&1 || {
- echo "apt-get not found, this is probably not a Debian system. Aborting." >&2;
- exit 4; }
-command -v apt-file >/dev/null 2>&1 || {
- echo "Please install apt-file: sudo apt-get install apt-file. Aborting." >&2;
- exit 4; }
-
-FILE=$(readlink -f "$1")
-while read PACKAGE
-do
- # verify from first installed package
- if dpkg-query -W --showformat='${Status}\n' | grep installed > /dev/null
- then
- DIR=$(mktemp -d)
- cd "$DIR"
- echo "Trying $PACKAGE..." >&2
- apt-get download "$PACKAGE" >&2
- # downloaded archive is the only file present...
- ARCHIVE=$(ls)
- mkdir contents
- # extract entire archive
- dpkg-deb -x "$ARCHIVE" contents/ >&2
- if [ -f "contents$FILE" ]
- then
- # package contained required file
- diff "contents$FILE" "$FILE"
- RET=$?
- # cleanup
- cd
- rm -Rf "$DIR"
- # exit entire script as this is the main shell
- # with the return code from diff
- exit $RET
- else
- # cleanup
- cd
- rm -Rf "$DIR"
- fi
- fi
-done < <(apt-file -l search "$FILE")
-# if we are here, it means we have found no suitable package
-echo "Could not find original package for $FILE" >&2
-exit 3
-