instmany-mans.sh 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. #! /bin/sh
  2. # Copyright (C) 2008-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. # Installing many files should not exceed the command line length limit.
  17. # This is the mans sister test of 'instmany.sh', see there for details.
  18. . test-init.sh
  19. # In order to have a useful test on modern systems (which have a high
  20. # limit, if any), use a fake install program that errors out for more
  21. # than 2K characters in a command line. The POSIX limit is 4096, but
  22. # that may include space taken up by the environment.
  23. limit=2500
  24. subdir=long_subdir_name_with_many_characters
  25. nfiles=81
  26. list=$(seq_ 1 $nfiles)
  27. oPATH=$PATH; export oPATH
  28. nPATH=$(pwd)/x-bin$PATH_SEPARATOR$PATH; export nPATH
  29. mkdir x-bin
  30. sed "s|@limit@|$limit|g" >x-bin/my-install <<'END'
  31. #! /bin/sh
  32. limit=@limit@
  33. PATH=$oPATH; export PATH
  34. if test -z "$orig_INSTALL"; then
  35. echo "$0: \$orig_INSTALL variable not set" >&2
  36. exit 1
  37. fi
  38. len=`expr "$orig_INSTALL $*" : ".*" 2>/dev/null || echo $limit`
  39. if test $len -ge $limit; then
  40. echo "$0: safe command line limit of $limit characters exceeded" >&2
  41. exit 1
  42. fi
  43. exec $orig_INSTALL "$@"
  44. exit 1
  45. END
  46. # Creative quoting in the next line to please maintainer-check.
  47. sed "s|@limit@|$limit|g" >x-bin/'rm' <<'END'
  48. #! /bin/sh
  49. limit=@limit@
  50. PATH=$oPATH; export PATH
  51. RM='rm -f'
  52. len=`expr "$RM $*" : ".*" 2>/dev/null || echo $limit`
  53. if test $len -ge $limit; then
  54. echo "$0: safe command line limit of $limit characters exceeded" >&2
  55. exit 1
  56. fi
  57. exec $RM "$@"
  58. exit 1
  59. END
  60. # Creative quoting in the next line to please maintainer-check.
  61. chmod +x x-bin/'rm' x-bin/my-install
  62. cat >setenv.in <<'END'
  63. orig_INSTALL='@INSTALL@'
  64. # In case we've falled back on the install-sh script (seen e.g.,
  65. # on AIX 7.1), we need to make sure we use its absolute path,
  66. # as we don't know from which directory we'll be run.
  67. case "$orig_INSTALL" in
  68. /*) ;;
  69. */*) orig_INSTALL=$(pwd)/$orig_INSTALL;;
  70. esac
  71. export orig_INSTALL
  72. END
  73. cat >>configure.ac <<END
  74. AC_CONFIG_FILES([setenv.sh:setenv.in])
  75. AC_CONFIG_FILES([$subdir/Makefile])
  76. AC_OUTPUT
  77. END
  78. cat >Makefile.am <<END
  79. SUBDIRS = $subdir
  80. END
  81. mkdir $subdir
  82. cd $subdir
  83. cat >Makefile.am <<'END'
  84. man_MANS =
  85. man3_MANS =
  86. notrans_man_MANS =
  87. notrans_man3_MANS =
  88. END
  89. for n in $list; do
  90. unindent >>Makefile.am <<END
  91. man_MANS += page$n.1
  92. man3_MANS += page$n.man
  93. notrans_man_MANS += npage$n.1
  94. notrans_man3_MANS += npage$n.man
  95. END
  96. echo >page$n.1
  97. echo >page$n.man
  98. echo >npage$n.1
  99. echo >npage$n.man
  100. done
  101. cd ..
  102. $ACLOCAL
  103. $AUTOCONF
  104. $AUTOMAKE --add-missing
  105. instdir=$(pwd)/inst
  106. mkdir build
  107. cd build
  108. ../configure --prefix="$instdir"
  109. . ./setenv.sh
  110. test -n "$orig_INSTALL"
  111. $MAKE
  112. # Try whether native install (or install-sh) works.
  113. $MAKE install
  114. test -f "$instdir/share/man/man1/page1.1"
  115. # Multiple uninstall should work, too.
  116. $MAKE uninstall
  117. $MAKE uninstall
  118. test $(find "$instdir" -type f -print | wc -l) -eq 0
  119. # Try whether we don't exceed the low limit.
  120. PATH=$nPATH; export PATH
  121. run_make INSTALL=my-install install
  122. test -f "$instdir/share/man/man1/page1.1"
  123. run_make INSTALL=my-install uninstall
  124. test $(find "$instdir" -type f -print | wc -l) -eq 0
  125. PATH=$oPATH; export PATH
  126. cd $subdir
  127. srcdir=../../$subdir
  128. # Ensure 'make install' fails when 'install' fails.
  129. # We cheat here, for efficiency, knowing the internal rule names.
  130. # For correctness, one should '$MAKE install' here always, or at
  131. # least use install-exec or install-data.
  132. for file in page3.1 page$nfiles.1 npage3.1 npage$nfiles.1; do
  133. chmod a-r $srcdir/$file
  134. test ! -r $srcdir/$file || skip_ "cannot drop file read permissions"
  135. $MAKE install-man1 && exit 1
  136. chmod u+r $srcdir/$file
  137. done
  138. for file in page3.man page$nfiles.man npage3.man npage$nfiles.man; do
  139. chmod a-r $srcdir/$file
  140. $MAKE install-man3 && exit 1
  141. chmod u+r $srcdir/$file
  142. done
  143. :