fox-wrapper-3.sh 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #!/bin/bash
  2. # Copyright 1999-2005 Gentoo Foundation
  3. # Distributed under the terms of the GNU General Public License v2
  4. # Based on the am-wrapper.sh script (sys-devel/automake-wrapper-1-r1)
  5. #
  6. # Executes the correct fox-config version, based on the value of WANT_FOX.
  7. # All versions of fox after 1.0.x ship with a fox-config script
  8. #
  9. #
  10. # Stable branches first, in descending order, then unstable branches.
  11. # After a new stable branch, prepend the new version and bump (or remove)
  12. # the last unstable branch
  13. #
  14. vers="1.6 1.4 1.7"
  15. bindir=/usr/bin
  16. if [ "${0##*/}" = "fox-wrapper.sh" ] ; then
  17. echo "fox-wrapper: Don't call this script directly, use fox-config instead" >&2
  18. exit 1
  19. fi
  20. if [ -z "${WANT_FOX}" ] ; then
  21. echo "fox-wrapper: Set the WANT_FOX variable to the desired version of fox, e.g.:" >&2
  22. echo " WANT_FOX=\"1.6\" fox-config $@"
  23. exit 1
  24. fi
  25. for v in ${vers} ; do
  26. eval binary_${v/./_}="fox-${v}-config"
  27. done
  28. #
  29. # Check the WANT_FOX setting
  30. #
  31. for v in ${vers} x ; do
  32. if [ "${v}" = "x" ] ; then
  33. echo "fox-wrapper: WANT_FOX was set to an invalid version ${WANT_FOX}" >&2
  34. echo " Valid values of WANT_FOX are: ${vers// /, }"
  35. exit 1
  36. fi
  37. if [ "${WANT_FOX}" = "${v}" ] ; then
  38. binary="binary_${v/./_}"
  39. binary="${!binary}"
  40. break
  41. fi
  42. done
  43. if [ "${WANT_FOXWRAPPER_DEBUG}" ] ; then
  44. echo "fox-wrapper: DEBUG: WANT_FOX is set to ${WANT_FOX}" >&2
  45. echo "fox-wrapper: DEBUG: will execute <$binary>" >&2
  46. fi
  47. #
  48. # for further consistency
  49. #
  50. for v in ${vers} ; do
  51. mybin="binary_${v/./_}"
  52. if [ "${binary}" = "${!mybin}" ] ; then
  53. export WANT_FOX="${v}"
  54. fi
  55. done
  56. #
  57. # Now try to run the binary
  58. #
  59. if [ ! -x "${bindir}/${binary}" ] ; then
  60. echo "fox-wrapper: $binary is missing or not executable." >&2
  61. echo " Please try emerging the correct version of fox, i.e.:" >&2
  62. echo " emerge '=x11-libs/${binary/-config/}*'" >&2
  63. exit 1
  64. fi
  65. "$binary" "$@"