project-id 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #!/bin/sh
  2. # Prints a package's identification PACKAGE VERSION or PACKAGE.
  3. #
  4. # Copyright (C) 2001-2003, 2005, 2015-2016 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 3 of the License, or
  9. # (at your option) 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, see <http://www.gnu.org/licenses/>.
  18. want_version="$1"
  19. # NLS nuisances: Letter ranges are different in the Estonian locale.
  20. LC_ALL=C
  21. while true; do
  22. if test -f configure; then
  23. package=`(grep '^PACKAGE_NAME=' configure; grep '^ *PACKAGE=' configure) | grep -v '=[ ]*$' | sed -e '1q' | sed -e 's/^[^=]*=//' | sed -e "s/^'//" -e "s/'$//"`
  24. case "$package" in
  25. *[\"\$\`\{\}]*)
  26. # Some packages (gcal) retrieve the package name dynamically.
  27. package=
  28. ;;
  29. esac
  30. if test -n "$package"; then
  31. is_gnu=`LC_ALL=C grep "GNU $package" * 2>/dev/null | grep -v '^libtool:'`
  32. if test -n "$is_gnu"; then
  33. package="GNU $package"
  34. fi
  35. if test -n "$want_version"; then
  36. version=`(grep '^PACKAGE_VERSION=' configure; grep '^ *VERSION=' configure) | grep -v '=[ ]*$' | sed -e '1q' | sed -e 's/^[^=]*=//' | sed -e "s/^'//" -e "s/'$//"`
  37. case "$version" in
  38. *[\"\$\`\{\}]*)
  39. # Some packages (gcal, gcc, clisp) retrieve the version dynamically.
  40. version=
  41. ;;
  42. esac
  43. if test -n "$version"; then
  44. echo "$package $version"
  45. else
  46. echo "$package"
  47. fi
  48. else
  49. echo "$package"
  50. fi
  51. exit 0
  52. fi
  53. fi
  54. dir=`basename "\`pwd\`"`
  55. case "$dir" in
  56. i18n)
  57. # This directory name, used in GNU make, is not the top level directory.
  58. ;;
  59. *[A-Za-z]*[0-9]*)
  60. package=`echo "$dir" | sed -e 's/^\([^0-9]*\)[0-9].*$/\1/' -e 's/[-_]$//'`
  61. if test -n "$want_version"; then
  62. version=`echo "$dir" | sed -e 's/^[^0-9]*\([0-9].*\)$/\1/'`
  63. echo "$package $version"
  64. else
  65. echo "$package"
  66. fi
  67. exit 0
  68. ;;
  69. esac
  70. # Go to parent directory
  71. last=`/bin/pwd`
  72. cd ..
  73. curr=`/bin/pwd`
  74. if test "$last" = "$curr"; then
  75. # Oops, didn't find the package name.
  76. if test -n "$want_version"; then
  77. echo "PACKAGE VERSION"
  78. else
  79. echo "PACKAGE"
  80. fi
  81. exit 0
  82. fi
  83. done