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