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