summaryrefslogtreecommitdiff
path: root/vendor/getinfo
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2016-08-10 16:19:00 +0200
committerJulian Andres Klode <jak@debian.org>2016-08-10 16:19:00 +0200
commite02c3a9ec2b2f7a8d4aecd70f2ecdae27c207aa9 (patch)
treeffa99f96949f3eab728a1b8caecdd014ea8d6f81 /vendor/getinfo
parentb2cfacf1180e4b3fcbb2ae2ea52cf270ef74e971 (diff)
parent61fef4ddbec8f70bb9e213ac0491d4e6cfefab30 (diff)
Merge branch 'cmake'
Diffstat (limited to 'vendor/getinfo')
-rwxr-xr-xvendor/getinfo49
1 files changed, 46 insertions, 3 deletions
diff --git a/vendor/getinfo b/vendor/getinfo
index 79da83620..37e0c1480 100755
--- a/vendor/getinfo
+++ b/vendor/getinfo
@@ -2,7 +2,47 @@
# 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
+}
+
+if [ "$1" = "--vendor" ]; then
+ CURRENT_VENDOR="$2"
+ shift 2
+else
+ CURRENT_VENDOR=$(getcurrent)
+fi
+INFO="$(readlink -f "${BASEDIR}/$CURRENT_VENDOR/apt-vendor.ent")"
VERBATIM="${BASEDIR}/../doc/apt-verbatim.ent"
if [ -z "$INFO" ] || [ ! -e "$INFO" ]; then
@@ -24,8 +64,8 @@ case "$1" in
debian-stable-codename|debian-oldstable-codename|debian-testing-codename|ubuntu-codename)
getrawfield "$1" "$VERBATIM"
;;
-keyring-package|keyring-filename|keyring-master-filename|keyring-removed-filename|keyring-uri|current-codename)
- exec $0 'vendor' "$@"
+sourceslist-list-format|keyring-package|keyring-filename|keyring-master-filename|keyring-removed-filename|keyring-uri|current-codename)
+ exec $0 --vendor $CURRENT_VENDOR 'vendor' "$@"
;;
vendor)
getfield "$2"
@@ -33,6 +73,9 @@ vendor)
verbatim)
getfield "$2" "$VERBATIM"
;;
+current)
+ echo $CURRENT_VENDOR
+ ;;
*)
echo >&2 "Unknown data field $1 requested"
exit 2