summaryrefslogtreecommitdiff
path: root/vendor/getinfo
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2016-08-06 03:50:54 +0200
committerJulian Andres Klode <jak@debian.org>2016-08-06 22:35:54 +0200
commit9ee5154685e24bd588ae792af1e285e06a1f9dfc (patch)
tree7cd90af19e5eb4eba66c8b4e08054fa80d8cf01d /vendor/getinfo
parent4adc750a2a8d0c6b2c03353b5538bc7446020f68 (diff)
vendor/getinfo: Provide command to determine vendor to use
Introduce the 'current' command to eventually replace the current symbolic link. The current command does roughly the same as the makefile, the code has just been cleaned up a bit to work better as a shell function. Gbp-Dch: ignore
Diffstat (limited to 'vendor/getinfo')
-rwxr-xr-xvendor/getinfo40
1 files changed, 39 insertions, 1 deletions
diff --git a/vendor/getinfo b/vendor/getinfo
index 79da83620..4f94d7c42 100755
--- a/vendor/getinfo
+++ b/vendor/getinfo
@@ -2,7 +2,41 @@
# small helper to extract information form *.ent files
BASEDIR="$(readlink -f "$(dirname $0)")"
-INFO="$(readlink -f "${BASEDIR}/current/apt-vendor.ent")"
+
+getcurrent() {
+ # search for an exact match to use the correct sources.list example
+ cd $BASEDIR
+ DISTROS="$(find -mindepth 1 -maxdepth 1 -type d | cut -d'/' -f 2)"
+ for DISTRO in $DISTROS; do
+ if dpkg-vendor --is $DISTRO; then
+ echo $DISTRO
+ return 0
+ fi
+ done
+
+ # if we haven't found a specific, look for a deriving
+ # we do ubuntu and debian last as those are the biggest families
+ # and would therefore potentially 'shadow' smaller families
+ # (especially debian as it sorts quiet early)
+ for DISTRO in $DISTROS; do
+ if [ "$DISTRO" = 'debian' -o "$DISTRO" = 'ubuntu' ]; then continue; fi
+ if dpkg-vendor --derives-from $DISTRO; then
+ echo $DISTRO
+ return 0
+ fi
+ done
+
+ # Do the ubuntu/debian dance we talked about
+ if dpkg-vendor --derives-from ubuntu; then
+ echo $DISTRO
+ return 0
+ fi
+
+ echo debian
+ return 0
+}
+
+INFO="$(readlink -f "${BASEDIR}/$(getcurrent)/apt-vendor.ent")"
VERBATIM="${BASEDIR}/../doc/apt-verbatim.ent"
if [ -z "$INFO" ] || [ ! -e "$INFO" ]; then
@@ -33,6 +67,10 @@ vendor)
verbatim)
getfield "$2" "$VERBATIM"
;;
+
+current)
+ getcurrent
+ ;;
*)
echo >&2 "Unknown data field $1 requested"
exit 2