install-info-dir.sh 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. #! /bin/sh
  2. # Copyright (C) 2011-2017 Free Software Foundation, Inc.
  3. #
  4. # This program is free software; you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation; either version 2, or (at your option)
  7. # any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. # Checks on the 'install-info' target.
  17. # Details about the individual checks' purposes and motivations are
  18. # inlined, below.
  19. # FIXME: this test is a good candidate for a conversion to TAP,
  20. # FIXME: and could be merged with 'txinfo27.sh'.
  21. required=makeinfo
  22. . test-init.sh
  23. cwd=$(pwd) || fatal_ "cannot get current working directory"
  24. mkdir bin
  25. saved_PATH=$PATH; export saved_PATH
  26. PATH=$cwd/bin$PATH_SEPARATOR$PATH; export PATH
  27. cat >> configure.ac <<'END'
  28. AC_OUTPUT
  29. END
  30. cat > Makefile.am << 'END'
  31. info_TEXINFOS = foo.texi
  32. END
  33. cat > foo.texi << 'END'
  34. \input texinfo
  35. @setfilename foo.info
  36. @c All the following directives might be required to allow older
  37. @c versions of the 'install-info' program (e.g., version 4.8) to
  38. @c create the 'dir' index file in ${infodir}. Don't remove them.
  39. @settitle foo
  40. @dircategory Dummy utilities
  41. @direntry
  42. * Foo: (foo). Does nothing at all, but has a nice name.
  43. @end direntry
  44. @node Top
  45. Hello world!
  46. @bye
  47. END
  48. $ACLOCAL
  49. $AUTOMAKE -a
  50. $AUTOCONF
  51. instdir=_inst
  52. destdir=_dest
  53. ./configure --prefix="$cwd/$instdir" --infodir="$cwd/$instdir/info"
  54. $MAKE info
  55. test -f foo.info
  56. if install-info --version; then
  57. # Skip some checks even if 'install-info' is the one from dpkg, not
  58. # the one from GNU info, as the former might try to create files in
  59. # '/var/backups/', causing spurious failures like this for non-root
  60. # users.
  61. if install-info --version | $EGREP -i '(dpkg|debian) install-info'; then
  62. have_installinfo=no
  63. else
  64. have_installinfo=yes
  65. fi
  66. else
  67. have_installinfo=no
  68. fi
  69. # The 'install-info' target updates the '${infodir}/dir' file
  70. # by default (if the 'install-info' program is available).
  71. # This should happen in a normal as well as in a DESTDIR installation.
  72. if test $have_installinfo = yes; then
  73. $MAKE install-info
  74. test -f $instdir/info/foo.info
  75. cat $instdir/info/dir
  76. $FGREP 'Does nothing at all, but has a nice name' $instdir/info/dir
  77. $MAKE uninstall
  78. test ! -e $instdir/info/foo.info
  79. cat $instdir/info/dir
  80. $FGREP 'but has a nice name' $instdir/info/dir && exit 1
  81. dir="$destdir/$cwd/$instdir/info"
  82. $MAKE DESTDIR="$cwd/$destdir" install-info
  83. test -f "$dir"/foo.info
  84. cat "$dir"/dir
  85. $FGREP 'Does nothing at all, but has a nice name' "$dir"/dir
  86. $MAKE DESTDIR="$cwd/$destdir" uninstall
  87. test ! -e "$dir"/foo.info
  88. $FGREP 'but has a nice name' "$dir"/dir && exit 1
  89. unset dir
  90. fi
  91. rm -rf $instdir $destdir
  92. # The 'install-info' target doesn't fail if the 'install-info'
  93. # program is not available.
  94. cat > bin/install-info <<'END'
  95. #!/bin/sh
  96. echo error from install-info >&2
  97. exit 127
  98. END
  99. chmod a+x bin/install-info
  100. run_make -M install-info
  101. test -f $instdir/info/foo.info
  102. test ! -e $instdir/info/dir
  103. grep 'error from install-info' output && exit 1
  104. rm -rf $instdir output
  105. if test $have_installinfo = yes; then
  106. # The 'install-info' target doesn't try to guess whether the 'install-info'
  107. # is the GNU or debian version.
  108. unindent > bin/install-info <<'END'
  109. #!/bin/sh
  110. set -e; set -u;
  111. for fd in 1 2; do
  112. for str in dpkg debian Debian; do
  113. eval "echo This is $str install-info >&$fd"
  114. done
  115. done
  116. PATH=$saved_PATH; export PATH
  117. exec install-info ${1+"$@"}
  118. END
  119. $MAKE install-info
  120. test -f $instdir/info/foo.info
  121. cat $instdir/info/dir
  122. $MAKE uninstall
  123. test ! -e $instdir/info/foo.info
  124. cat $instdir/info/dir
  125. $FGREP 'but has a nice name' $instdir/info/dir && exit 1
  126. : For shells with busted 'set -e'.
  127. fi
  128. rm -rf $instdir bin/install-info
  129. # The 'AM_UPDATE_INFO_DIR' environment variable can be used to
  130. # prevent the creation or update of the '${infodir}/dir' file,
  131. # if set to a "no" value.
  132. for val in no NO n; do
  133. rm -rf $instdir
  134. env AM_UPDATE_INFO_DIR="$val" $MAKE install-info
  135. test -f $instdir/info/foo.info
  136. test ! -e $instdir/info/dir
  137. done
  138. $MAKE install-info
  139. if test $have_installinfo != yes; then
  140. echo 'Does nothing at all, but has a nice name' > $instdir/info/dir
  141. fi
  142. chmod a-w $instdir/info/dir
  143. for val in no NO n; do
  144. env AM_UPDATE_INFO_DIR="$val" $MAKE uninstall
  145. cat $instdir/info/dir
  146. $FGREP 'Does nothing at all, but has a nice name' $instdir/info/dir
  147. done
  148. if test $have_installinfo = yes; then
  149. for val in 'yes' 'who cares!'; do
  150. rm -rf $instdir
  151. env AM_UPDATE_INFO_DIR="$val" $MAKE install-info
  152. test -f $instdir/info/foo.info
  153. cat $instdir/info/dir
  154. env AM_UPDATE_INFO_DIR="$val" $MAKE uninstall
  155. test ! -e $instdir/info/foo.info
  156. $FGREP 'but has a nice name' $instdir/info/dir && exit 1
  157. : For shells with busted 'set -e'.
  158. done
  159. fi
  160. :