instmany-python.sh 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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 python sister test of 'instmany.sh', see there for details.
  18. required='python'
  19. . test-init.sh
  20. limit=2500
  21. subdir=long_subdir_name_with_many_characters
  22. nfiles=81
  23. list=$(seq_ 1 $nfiles)
  24. oPATH=$PATH; export oPATH
  25. nPATH=$(pwd)/x-bin$PATH_SEPARATOR$PATH; export nPATH
  26. mkdir x-bin
  27. sed "s|@limit@|$limit|g" >x-bin/my-install <<'END'
  28. #! /bin/sh
  29. limit=@limit@
  30. PATH=$oPATH; export PATH
  31. if test -z "$orig_INSTALL"; then
  32. echo "$0: \$orig_INSTALL variable not set" >&2
  33. exit 1
  34. fi
  35. len=`expr "$orig_INSTALL $*" : ".*" 2>/dev/null || echo $limit`
  36. if test $len -ge $limit; then
  37. echo "$0: safe command line limit of $limit characters exceeded" >&2
  38. exit 1
  39. fi
  40. exec $orig_INSTALL "$@"
  41. exit 1
  42. END
  43. # Creative quoting in the next line to please maintainer-check.
  44. sed "s|@limit@|$limit|g" >x-bin/'rm' <<'END'
  45. #! /bin/sh
  46. limit=@limit@
  47. PATH=$oPATH; export PATH
  48. RM='rm -f'
  49. len=`expr "$RM $*" : ".*" 2>/dev/null || echo $limit`
  50. if test $len -ge $limit; then
  51. echo "$0: safe command line limit of $limit characters exceeded" >&2
  52. exit 1
  53. fi
  54. exec $RM "$@"
  55. exit 1
  56. END
  57. # Creative quoting in the next line to please maintainer-check.
  58. chmod +x x-bin/'rm' x-bin/my-install
  59. cat >setenv.in <<'END'
  60. orig_INSTALL='@INSTALL@'
  61. # In case we've falled back on the install-sh script (seen e.g.,
  62. # on AIX 7.1), we need to make sure we use its absolute path,
  63. # as we don't know from which directory we'll be run.
  64. case "$orig_INSTALL" in
  65. /*) ;;
  66. */*) orig_INSTALL=$(pwd)/$orig_INSTALL;;
  67. esac
  68. export orig_INSTALL
  69. END
  70. cat >>configure.ac <<END
  71. AM_PATH_PYTHON
  72. AC_CONFIG_FILES([setenv.sh:setenv.in])
  73. AC_CONFIG_FILES([$subdir/Makefile])
  74. AC_OUTPUT
  75. END
  76. cat >Makefile.am <<END
  77. SUBDIRS = $subdir
  78. END
  79. mkdir $subdir
  80. cd $subdir
  81. cat >Makefile.am <<'END'
  82. python_PYTHON =
  83. nobase_python_PYTHON =
  84. END
  85. for n in $list; do
  86. unindent >>Makefile.am <<END
  87. python_PYTHON += python$n.py
  88. nobase_python_PYTHON += npython$n.py
  89. END
  90. echo >python$n.py
  91. echo >npython$n.py
  92. done
  93. cd ..
  94. $ACLOCAL
  95. $AUTOCONF
  96. $AUTOMAKE --add-missing
  97. instdir=$(pwd)/inst
  98. mkdir build
  99. cd build
  100. ../configure --prefix="$instdir"
  101. . ./setenv.sh
  102. test -n "$orig_INSTALL"
  103. $MAKE
  104. # Try whether native install (or install-sh) works.
  105. $MAKE install
  106. test -n "$(find "$instdir" -name python1.py)"
  107. # Multiple uninstall should work, too.
  108. $MAKE uninstall
  109. $MAKE uninstall
  110. test $(find "$instdir" -type f -print | wc -l) -eq 0
  111. # Try whether we don't exceed the low limit.
  112. PATH=$nPATH; export PATH
  113. run_make INSTALL=my-install install
  114. test -n "$(find "$instdir" -name python1.py)"
  115. run_make INSTALL=my-install uninstall
  116. test $(find "$instdir" -type f -print | wc -l) -eq 0
  117. PATH=$oPATH; export PATH
  118. cd $subdir
  119. srcdir=../../$subdir
  120. # Ensure 'make install' fails when 'install' fails.
  121. for file in python3.py python$nfiles.py
  122. do
  123. chmod a-r $srcdir/$file
  124. test ! -r $srcdir/$file || skip_ "cannot drop file read permissions"
  125. $MAKE install && exit 1
  126. chmod u+r $srcdir/$file
  127. done
  128. for file in npython3.py npython$nfiles.py
  129. do
  130. chmod a-r $srcdir/$file
  131. $MAKE install && exit 1
  132. chmod u+r $srcdir/$file
  133. done
  134. :