getinfo 860 B

12345678910111213141516171819202122232425262728293031323334353637
  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. if [ -z "$INFO" ] || [ ! -e "$INFO" ]; then
  6. echo >&2 'The current vendor is not valid or not chosen by the buildsystem yet.'
  7. exit 1
  8. fi
  9. getrawfield() {
  10. grep --max-count=1 "^<!ENTITY $1 \"" "${2:-$INFO}" | cut -d'"' -f 2
  11. }
  12. getfield() {
  13. local FIELD="$(getrawfield "$@")"
  14. FIELD="${FIELD#*>}"
  15. echo "${FIELD%<*}"
  16. }
  17. case "$1" in
  18. debian-stable-codename)
  19. getrawfield 'stable-codename' "${BASEDIR}/../doc/apt-verbatim.ent"
  20. ;;
  21. ubuntu-codename)
  22. getrawfield 'stable-codename' "${BASEDIR}/../doc/apt-verbatim.ent"
  23. ;;
  24. keyring-package|keyring-filename|keyring-master-filename|keyring-removed-filename|keyring-uri)
  25. getfield "$1"
  26. ;;
  27. *)
  28. echo >&2 "Unknown data field $1 requested"
  29. exit 2
  30. ;;
  31. esac