getinfo 938 B

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