]>
Commit | Line | Data |
---|---|---|
0005fa07 DK |
1 | #!/bin/sh |
2 | # small helper to extract information form *.ent files | |
3 | ||
4 | BASEDIR="$(readlink -f "$(dirname $0)")" | |
9ee51546 JAK |
5 | |
6 | getcurrent() { | |
7 | # search for an exact match to use the correct sources.list example | |
8 | cd $BASEDIR | |
9 | DISTROS="$(find -mindepth 1 -maxdepth 1 -type d | cut -d'/' -f 2)" | |
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 | ||
39 | INFO="$(readlink -f "${BASEDIR}/$(getcurrent)/apt-vendor.ent")" | |
fa19cc95 | 40 | VERBATIM="${BASEDIR}/../doc/apt-verbatim.ent" |
0005fa07 DK |
41 | |
42 | if [ -z "$INFO" ] || [ ! -e "$INFO" ]; then | |
43 | echo >&2 'The current vendor is not valid or not chosen by the buildsystem yet.' | |
44 | exit 1 | |
45 | fi | |
46 | ||
47 | getrawfield() { | |
7fa4f5e1 | 48 | awk "/<!ENTITY $1/ {f=NR} f && NR-1==f { print; exit 0 }" RS='"' "${2:-$INFO}" |
0005fa07 DK |
49 | } |
50 | ||
51 | getfield() { | |
52 | local FIELD="$(getrawfield "$@")" | |
53 | FIELD="${FIELD#*>}" | |
54 | echo "${FIELD%<*}" | |
55 | } | |
56 | ||
57 | case "$1" in | |
9feb98eb | 58 | debian-stable-codename|debian-oldstable-codename|debian-testing-codename|ubuntu-codename) |
fa19cc95 DK |
59 | getrawfield "$1" "$VERBATIM" |
60 | ;; | |
f7a46d97 | 61 | sourceslist-list-format|keyring-package|keyring-filename|keyring-master-filename|keyring-removed-filename|keyring-uri|current-codename) |
fa19cc95 DK |
62 | exec $0 'vendor' "$@" |
63 | ;; | |
64 | vendor) | |
65 | getfield "$2" | |
0005fa07 | 66 | ;; |
fa19cc95 DK |
67 | verbatim) |
68 | getfield "$2" "$VERBATIM" | |
0005fa07 | 69 | ;; |
9ee51546 JAK |
70 | |
71 | current) | |
72 | getcurrent | |
73 | ;; | |
0005fa07 DK |
74 | *) |
75 | echo >&2 "Unknown data field $1 requested" | |
76 | exit 2 | |
77 | ;; | |
78 | esac |