]> git.saurik.com Git - apt.git/blame_incremental - vendor/getinfo
doc: Fix fuzzy string regression
[apt.git] / vendor / getinfo
... / ...
CommitLineData
1#!/bin/sh
2# small helper to extract information form *.ent files
3
4BASEDIR="$(readlink -f "$(dirname $0)")"
5INFO="$(readlink -f "${BASEDIR}/current/apt-vendor.ent")"
6VERBATIM="${BASEDIR}/../doc/apt-verbatim.ent"
7
8if [ -z "$INFO" ] || [ ! -e "$INFO" ]; then
9 echo >&2 'The current vendor is not valid or not chosen by the buildsystem yet.'
10 exit 1
11fi
12
13getrawfield() {
14 awk "/<!ENTITY $1/ {f=NR} f && NR-1==f { print; exit 0 }" RS='"' "${2:-$INFO}"
15}
16
17getfield() {
18 local FIELD="$(getrawfield "$@")"
19 FIELD="${FIELD#*>}"
20 echo "${FIELD%<*}"
21}
22
23case "$1" in
24debian-stable-codename|debian-oldstable-codename|debian-testing-codename|ubuntu-codename)
25 getrawfield "$1" "$VERBATIM"
26 ;;
27keyring-package|keyring-filename|keyring-master-filename|keyring-removed-filename|keyring-uri|current-codename)
28 exec $0 'vendor' "$@"
29 ;;
30vendor)
31 getfield "$2"
32 ;;
33verbatim)
34 getfield "$2" "$VERBATIM"
35 ;;
36*)
37 echo >&2 "Unknown data field $1 requested"
38 exit 2
39 ;;
40esac