project-id 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #!/bin/sh
  2. # Prints a package's identification PACKAGE VERSION or PACKAGE.
  3. #
  4. # Copyright (C) 2001-2003, 2005 Free Software Foundation, Inc.
  5. #
  6. # This program is free software; you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation; either version 2, or (at your option)
  9. # any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with this program; if not, write to the Free Software Foundation,
  18. # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  19. want_version="$1"
  20. # NLS nuisances: Letter ranges are different in the Estonian locale.
  21. LC_ALL=C
  22. while true; do
  23. if test -f configure; then
  24. package=`(grep '^PACKAGE_NAME=' configure; grep '^ *PACKAGE=' configure) | grep -v '=[ ]*$' | sed -e '1q' | sed -e 's/^[^=]*=//' | sed -e "s/^'//" -e "s/'$//"`
  25. case "$package" in
  26. *[\"\$\`\{\}]*)
  27. # Some packages (gcal) retrieve the package name dynamically.
  28. package=
  29. ;;
  30. esac
  31. if test -n "$package"; then
  32. is_gnu=`LC_ALL=C grep "GNU $package" * 2>/dev/null | grep -v '^libtool:'`
  33. if test -n "$is_gnu"; then
  34. package="GNU $package"
  35. fi
  36. if test -n "$want_version"; then
  37. version=`(grep '^PACKAGE_VERSION=' configure; grep '^ *VERSION=' configure) | grep -v '=[ ]*$' | sed -e '1q' | sed -e 's/^[^=]*=//' | sed -e "s/^'//" -e "s/'$//"`
  38. case "$version" in
  39. *[\"\$\`\{\}]*)
  40. # Some packages (gcal, gcc, clisp) retrieve the version dynamically.
  41. version=
  42. ;;
  43. esac
  44. if test -n "$version"; then
  45. echo "$package $version"
  46. else
  47. echo "$package"
  48. fi
  49. else
  50. echo "$package"
  51. fi
  52. exit 0
  53. fi
  54. fi
  55. dir=`basename \`pwd\``
  56. case "$dir" in
  57. i18n)
  58. # This directory name, used in GNU make, is not the top level directory.
  59. ;;
  60. *[A-Za-z]*[0-9]*)
  61. package=`echo "$dir" | sed -e 's/^\([^0-9]*\)[0-9].*$/\1/' -e 's/[-_]$//'`
  62. if test -n "$want_version"; then
  63. version=`echo "$dir" | sed -e 's/^[^0-9]*\([0-9].*\)$/\1/'`
  64. echo "$package $version"
  65. else
  66. echo "$package"
  67. fi
  68. exit 0
  69. ;;
  70. esac
  71. # Go to parent directory
  72. last=`/bin/pwd`
  73. cd ..
  74. curr=`/bin/pwd`
  75. if test "$last" = "$curr"; then
  76. # Oops, didn't find the package name.
  77. if test -n "$want_version"; then
  78. echo "PACKAGE VERSION"
  79. else
  80. echo "PACKAGE"
  81. fi
  82. exit 0
  83. fi
  84. done