blob: 2ef257c906fc5a6bf89e66ebfbae9e9cd1c61fcb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
#!/bin/sh
# small helper to extract information form *.ent files
BASEDIR="$(readlink -f "$(dirname $0)")"
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 | LC_ALL=C sort)"
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 ubuntu
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
echo >&2 'The current vendor is not valid or not chosen by the buildsystem yet.'
exit 1
fi
getrawfield() {
awk "/<!ENTITY $1/ {f=NR} f && NR-1==f { print; exit 0 }" RS='"' "${2:-$INFO}"
}
getfield() {
local FIELD="$(getrawfield "$@")"
FIELD="${FIELD#*>}"
echo "${FIELD%<*}"
}
case "$1" in
debian-stable-codename|debian-oldstable-codename|debian-testing-codename|ubuntu-codename)
getrawfield "$1" "$VERBATIM"
;;
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"
;;
verbatim)
getfield "$2" "$VERBATIM"
;;
current)
echo $CURRENT_VENDOR
;;
*)
echo >&2 "Unknown data field $1 requested"
exit 2
;;
esac
|