]> git.saurik.com Git - apt.git/blame - vendor/getinfo
get pdiff files from the same mirror as the index
[apt.git] / vendor / getinfo
CommitLineData
0005fa07
DK
1#!/bin/sh
2# small helper to extract information form *.ent files
3
4BASEDIR="$(readlink -f "$(dirname $0)")"
9ee51546
JAK
5
6getcurrent() {
7 # search for an exact match to use the correct sources.list example
8 cd $BASEDIR
bd95e2b2 9 DISTROS="$(find . -mindepth 1 -maxdepth 1 -type d | cut -d'/' -f 2)"
9ee51546
JAK
10 for DISTRO in $DISTROS; do
11 if dpkg-vendor --is $DISTRO; then
12 echo $DISTRO
13 return 0
14 fi
15 done
16
17 # if we haven't found a specific, look for a deriving
18 # we do ubuntu and debian last as those are the biggest families
19 # and would therefore potentially 'shadow' smaller families
20 # (especially debian as it sorts quiet early)
21 for DISTRO in $DISTROS; do
22 if [ "$DISTRO" = 'debian' -o "$DISTRO" = 'ubuntu' ]; then continue; fi
23 if dpkg-vendor --derives-from $DISTRO; then
24 echo $DISTRO
25 return 0
26 fi
27 done
28
29 # Do the ubuntu/debian dance we talked about
30 if dpkg-vendor --derives-from ubuntu; then
31 echo $DISTRO
32 return 0
33 fi
34
35 echo debian
36 return 0
37}
38
79635b69
JAK
39if [ "$1" = "--vendor" ]; then
40 CURRENT_VENDOR="$2"
41 shift 2
42else
43 CURRENT_VENDOR=$(getcurrent)
44fi
45INFO="$(readlink -f "${BASEDIR}/$CURRENT_VENDOR/apt-vendor.ent")"
fa19cc95 46VERBATIM="${BASEDIR}/../doc/apt-verbatim.ent"
0005fa07
DK
47
48if [ -z "$INFO" ] || [ ! -e "$INFO" ]; then
49 echo >&2 'The current vendor is not valid or not chosen by the buildsystem yet.'
50 exit 1
51fi
52
53getrawfield() {
7fa4f5e1 54 awk "/<!ENTITY $1/ {f=NR} f && NR-1==f { print; exit 0 }" RS='"' "${2:-$INFO}"
0005fa07
DK
55}
56
57getfield() {
58 local FIELD="$(getrawfield "$@")"
59 FIELD="${FIELD#*>}"
60 echo "${FIELD%<*}"
61}
62
63case "$1" in
9feb98eb 64debian-stable-codename|debian-oldstable-codename|debian-testing-codename|ubuntu-codename)
fa19cc95
DK
65 getrawfield "$1" "$VERBATIM"
66 ;;
f7a46d97 67sourceslist-list-format|keyring-package|keyring-filename|keyring-master-filename|keyring-removed-filename|keyring-uri|current-codename)
79635b69 68 exec $0 --vendor $CURRENT_VENDOR 'vendor' "$@"
fa19cc95
DK
69 ;;
70vendor)
71 getfield "$2"
0005fa07 72 ;;
fa19cc95
DK
73verbatim)
74 getfield "$2" "$VERBATIM"
0005fa07 75 ;;
9ee51546 76current)
79635b69 77 echo $CURRENT_VENDOR
9ee51546 78 ;;
0005fa07
DK
79*)
80 echo >&2 "Unknown data field $1 requested"
81 exit 2
82 ;;
83esac