Mercurial > vim
changeset 11370:e11d5966b822 v8.0.0570
patch 8.0.0570: can't run make with several jobs
commit https://github.com/vim/vim/commit/c03944151fec2d5469746642a949c8fcb5a744a8
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Apr 20 20:20:23 2017 +0200
patch 8.0.0570: can't run make with several jobs
Problem: Can't run make with several jobs, creating directories has a race
condition.
Solution: Use the MKDIR_P autoconf mechanism. (Eric N. Vander Weele,
closes #1639)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Thu, 20 Apr 2017 20:30:04 +0200 |
parents | a196f7b3d62b |
children | a945e33a8879 |
files | Filelist src/Makefile src/auto/configure src/config.mk.in src/configure.ac src/install-sh src/mkinstalldirs src/version.c |
diffstat | 8 files changed, 620 insertions(+), 74 deletions(-) [+] |
line wrap: on
line diff
--- a/Filelist +++ b/Filelist @@ -239,7 +239,7 @@ SRC_UNIX = \ src/link.sh \ src/installman.sh \ src/installml.sh \ - src/mkinstalldirs \ + src/install-sh \ src/os_unix.c \ src/os_unix.h \ src/os_unixx.h \
--- a/src/Makefile +++ b/src/Makefile @@ -207,7 +207,7 @@ #SunOS 4.1.x +X11 -GUI 5.1b (J) Bram Moolenaar #SunOS 4.1.3_U1 (sun4c) gcc +X11 +GUI Athena 5.0w (J) Darren Hiebert #SUPER-UX 6.2 (NEC SX-4) cc +X11R6 Motif,Athena4.6b (P) Lennart Schultz -#Tandem/NSK (c) Matthew Woehlke +#Tandem/NSK (c) Matthew Woehlke #Unisys 6035 cc +X11 Motif 5.3 (8) Glauber Ribeiro #ESIX V4.2 cc +X11 6.0 (a) Reinhard Wobst #Mac OS X 10.[23] gcc Carbon 6.2 (x) Bram Moolenaar @@ -403,6 +403,7 @@ CClink = $(CC) # First one is for static linking, second one for dynamic loading. # Use --with-luajit if you want to use LuaJIT instead of Lua. # Set PATH environment variable to find lua or luajit executable. +# This requires at least "normal" features, "tiny" and "small" don't work. #CONF_OPT_LUA = --enable-luainterp #CONF_OPT_LUA = --enable-luainterp=dynamic #CONF_OPT_LUA = --enable-luainterp --with-luajit @@ -429,16 +430,15 @@ CClink = $(CC) # the next line. # When you get an error for a missing "perl.exp" file, try creating an empty # one: "touch perl.exp". -# This requires at least "small" features, "tiny" doesn't work. +# This requires at least "normal" features, "tiny" and "small" don't work. #CONF_OPT_PERL = --enable-perlinterp #CONF_OPT_PERL = --enable-perlinterp=dynamic # PYTHON -# Uncomment this when you want to include the Python interface. -# Requires small features or better, fails with tiny features. +# Uncomment lines here when you want to include the Python interface. +# This requires at least "normal" features, "tiny" and "small" don't work. # NOTE: This may cause threading to be enabled, which has side effects (such # as using different libraries and debugging becomes more difficult). -# NOTE: Using this together with Perl may cause a crash in initialization. # For Python3 support make a symbolic link in /usr/local/bin: # ln -s python3 python3.1 # If both python2.x and python3.x are enabled then the linking will be via @@ -454,6 +454,7 @@ CClink = $(CC) # Uncomment this when you want to include the Ruby interface. # First one for static linking, second one for loading when used. # Note: you need the development package (e.g., ruby1.9.1-dev on Ubuntu). +# This requires at least "normal" features, "tiny" and "small" don't work. #CONF_OPT_RUBY = --enable-rubyinterp #CONF_OPT_RUBY = --enable-rubyinterp=dynamic #CONF_OPT_RUBY = --enable-rubyinterp --with-ruby-command=ruby1.9.1 @@ -617,7 +618,7 @@ AUTOCONF = autoconf #PURIFY = purify # VALGRIND - remove the # to use valgrind for memory leaks and access errors. -# Used for the unittest targets. +# Used for the unittest targets. # VALGRIND = valgrind --tool=memcheck --leak-check=yes --num-callers=25 --log-file=valgrind.$@ # NBDEBUG - debugging the netbeans interface. @@ -649,15 +650,15 @@ LINT_OPTIONS = -beprxzF # coverage information. (provided by Yegappan Lakshmanan) # 1. make clean, run configure and build Vim as usual. # 2. Generate the baseline code coverage information: -# $ lcov -c -i -b . -d objects -o objects/coverage_base.info +# $ lcov -c -i -b . -d objects -o objects/coverage_base.info # 3. Run "make test" to run the unit tests. The code coverage information will # be generated in the src/objects directory. # 4. Generate the code coverage information from the tests: -# $ lcov -c -b . -d objects/ -o objects/coverage_test.info +# $ lcov -c -b . -d objects/ -o objects/coverage_test.info # 5. Combine the baseline and test code coverage data: -# $ lcov -a objects/coverage_base.info -a objects/coverage_test.info -o objects/coverage_total.info +# $ lcov -a objects/coverage_base.info -a objects/coverage_test.info -o objects/coverage_total.info # 6. Process the test coverage data and generate a report in html: -# $ genhtml objects/coverage_total.info -o objects +# $ genhtml objects/coverage_total.info -o objects # 7. Open the objects/index.html file in a web browser to view the coverage # information. # @@ -2566,7 +2567,7 @@ DESKTOPPATH = $(DESTDIR)$(DATADIR)/appli KDEPATH = $(HOME)/.kde/share/icons install-icons: if test -n "$(DESTDIR)"; then \ - $(SHELL) ./mkinstalldirs $(ICON48PATH) $(ICON32PATH) \ + $(MKDIR_P) $(ICON48PATH) $(ICON32PATH) \ $(ICON16PATH) $(DESKTOPPATH); \ fi @@ -2607,7 +2608,7 @@ install-icons: $(DEST_LANG) $(DEST_KMAP) $(DEST_COMP) $(DEST_MACRO) \ $(DEST_PACK) $(DEST_TOOLS) $(DEST_TUTOR) $(DEST_SPELL) \ $(DEST_AUTO) $(DEST_AUTO)/xml $(DEST_PLUG): - -$(SHELL) ./mkinstalldirs $@ + $(MKDIR_P) $@ -chmod $(DIRMOD) $@ # create links from various names to vim. This is only done when the links @@ -2787,25 +2788,25 @@ clean celan: testclean SHADOWDIR = shadow shadow: runtime pixmaps - mkdir $(SHADOWDIR) - cd $(SHADOWDIR); ln -s ../*.[chm] ../*.in ../*.sh ../*.xs ../*.xbm ../gui_gtk_res.xml ../toolcheck ../proto ../vimtutor ../gvimtutor ../mkinstalldirs . + $(MKDIR_P) $(SHADOWDIR) + cd $(SHADOWDIR); ln -s ../*.[chm] ../*.in ../*.sh ../*.xs ../*.xbm ../gui_gtk_res.xml ../toolcheck ../proto ../vimtutor ../gvimtutor ../install-sh . mkdir $(SHADOWDIR)/auto cd $(SHADOWDIR)/auto; ln -s ../../auto/configure . - mkdir $(SHADOWDIR)/po + $(MKDIR_P) $(SHADOWDIR)/po cd $(SHADOWDIR)/po; ln -s ../../po/*.po ../../po/*.mak ../../po/*.vim ../../po/Makefile . cd $(SHADOWDIR); rm -f auto/link.sed cp Makefile configure $(SHADOWDIR) rm -f $(SHADOWDIR)/auto/config.mk $(SHADOWDIR)/config.mk.dist cp config.mk.dist $(SHADOWDIR)/auto/config.mk cp config.mk.dist $(SHADOWDIR) - mkdir $(SHADOWDIR)/xxd + $(MKDIR_P) $(SHADOWDIR)/xxd cd $(SHADOWDIR)/xxd; ln -s ../../xxd/*.[ch] ../../xxd/Make* . if test -d $(RSRC_DIR); then \ cd $(SHADOWDIR); \ ln -s ../infplist.xml .; \ ln -s ../$(RSRC_DIR) ../os_mac.rsr.hqx ../dehqx.py .; \ fi - mkdir $(SHADOWDIR)/testdir + $(MKDIR_P) $(SHADOWDIR)/testdir cd $(SHADOWDIR)/testdir; ln -s ../../testdir/Makefile \ ../../testdir/Make_all.mak \ ../../testdir/README.txt \ @@ -2942,7 +2943,7 @@ auto/gui_gtk_gresources.h: gui_gtk_res.x objects: objects/.dirstamp objects/.dirstamp: - mkdir -p objects + $(MKDIR_P) objects touch objects/.dirstamp # All object files depend on the objects directory, so that parallel make @@ -3273,8 +3274,7 @@ install_macosx: gui_bundle # Generate the help tags file now, it won't work with "make installruntime". -@srcdir=`pwd`; cd $(HELPSOURCE); $(MAKE) VIMEXE=$$srcdir/$(VIMTARGET) vimtags # Install the runtime files. Recursive! - -mkdir -p $(DESTDIR)$(prefix)/$(RESDIR)/vim/runtime -# -mkdir $(DESTDIR)$(prefix)/$(APPDIR)/bin + $(MKDIR_P) $(DESTDIR)$(prefix)/$(RESDIR)/vim/runtime srcdir=`pwd`; $(MAKE) -f Makefile installruntime \ VIMEXE=$$srcdir/$(VIMTARGET) \ prefix=$(DESTDIR)$(prefix)/$(RESDIR)$(VIMDIR) \ @@ -3292,16 +3292,16 @@ gui_bundle: $(RESDIR) bundle-dir bundle- bundle-language $(RESDIR): - mkdir -p $@ + $(MKDIR_P) $@ bundle-dir: $(APPDIR)/Contents $(VIMTARGET) # Make a link to the runtime directory, so that we can try out the executable # without installing it. - mkdir -p $(RESDIR)/vim + $(MKDIR_P) $(RESDIR)/vim -ln -s `pwd`/../runtime $(RESDIR)/vim bundle-executable: $(VIMTARGET) - mkdir -p $(APPDIR)/Contents/MacOS + $(MKDIR_P) $(APPDIR)/Contents/MacOS cp $(VIMTARGET) $(APPDIR)/Contents/MacOS/$(VIMTARGET) bundle-info: bundle-dir @@ -3332,8 +3332,8 @@ bundle-rsrc: os_mac.rsr.hqx bundle-language: bundle-dir $(APPDIR)/Contents: - -$(SHELL) ./mkinstalldirs $(APPDIR)/Contents/MacOS - -$(SHELL) ./mkinstalldirs $(RESDIR)/English.lproj + $(MKDIR_P) $(APPDIR)/Contents/MacOS + $(MKDIR_P) $(RESDIR)/English.lproj ###############################################################################
--- a/src/auto/configure +++ b/src/auto/configure @@ -725,6 +725,7 @@ XCODE_SELECT CPP_MM CROSS_COMPILING STRIP +MKDIR_P AWK FGREP EGREP @@ -3446,7 +3447,7 @@ ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu - ac_ext=c + ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' @@ -3723,7 +3724,7 @@ if (eval "$ac_cpp conftest.$ac_ext") 2>& fi rm -f conftest* - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for fgrep" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for fgrep" >&5 $as_echo_n "checking for fgrep... " >&6; } if ${ac_cv_path_FGREP+:} false; then : $as_echo_n "(cached) " >&6 @@ -3789,7 +3790,7 @@ fi $as_echo "$ac_cv_path_FGREP" >&6; } FGREP="$ac_cv_path_FGREP" - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing strerror" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing strerror" >&5 $as_echo_n "checking for library containing strerror... " >&6; } if ${ac_cv_search_strerror+:} false; then : $as_echo_n "(cached) " >&6 @@ -3844,7 +3845,7 @@ if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" fi - for ac_prog in gawk mawk nawk awk + for ac_prog in gawk mawk nawk awk do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 @@ -3885,6 +3886,76 @@ fi test -n "$AWK" && break done + ac_aux_dir= +for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do + if test -f "$ac_dir/install-sh"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install-sh -c" + break + elif test -f "$ac_dir/install.sh"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install.sh -c" + break + elif test -f "$ac_dir/shtool"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/shtool install -c" + break + fi +done +if test -z "$ac_aux_dir"; then + as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5 +fi + +# These three variables are undocumented and unsupported, +# and are intended to be withdrawn in a future Autoconf release. +# They can cause serious problems if a builder's source tree is in a directory +# whose full name contains unusual characters. +ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. +ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. +ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a thread-safe mkdir -p" >&5 +$as_echo_n "checking for a thread-safe mkdir -p... " >&6; } +if test -z "$MKDIR_P"; then + if ${ac_cv_path_mkdir+:} false; then : + $as_echo_n "(cached) " >&6 +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in mkdir gmkdir; do + for ac_exec_ext in '' $ac_executable_extensions; do + as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext" || continue + case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #( + 'mkdir (GNU coreutils) '* | \ + 'mkdir (coreutils) '* | \ + 'mkdir (fileutils) '4.1*) + ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext + break 3;; + esac + done + done + done +IFS=$as_save_IFS + +fi + + test -d ./--version && rmdir ./--version + if test "${ac_cv_path_mkdir+set}" = set; then + MKDIR_P="$ac_cv_path_mkdir -p" + else + # As a last resort, use the slow shell script. Don't cache a + # value for MKDIR_P within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the value is a relative name. + MKDIR_P="$ac_install_sh -d" + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5 +$as_echo "$MKDIR_P" >&6; } # Extract the first word of "strip", so it can be a program name with args. set dummy strip; ac_word=$2 @@ -14714,6 +14785,7 @@ gives unlimited permission to copy, dist ac_pwd='$ac_pwd' srcdir='$srcdir' +MKDIR_P='$MKDIR_P' AWK='$AWK' test -n "\$AWK" || AWK=awk _ACEOF @@ -15271,6 +15343,11 @@ ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_ # CONFIG_FILE # + ac_MKDIR_P=$MKDIR_P + case $MKDIR_P in + [\\/$]* | ?:[\\/]* ) ;; + */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;; + esac _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 @@ -15324,6 +15401,7 @@ s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t s&@builddir@&$ac_builddir&;t t s&@abs_builddir@&$ac_abs_builddir&;t t s&@abs_top_builddir@&$ac_abs_top_builddir&;t t +s&@MKDIR_P@&$ac_MKDIR_P&;t t $ac_datarootdir_hack " eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \
--- a/src/config.mk.in +++ b/src/config.mk.in @@ -103,6 +103,8 @@ AWK = @AWK@ STRIP = @STRIP@ +MKDIR_P = @MKDIR_P@ + EXEEXT = @EXEEXT@ CROSS_COMPILING = @CROSS_COMPILING@
--- a/src/configure.ac +++ b/src/configure.ac @@ -11,12 +11,13 @@ AC_DEFINE(UNIX) AC_PROG_MAKE_SET dnl Checks for programs. -AC_PROG_CC dnl required by almost everything -AC_PROG_CPP dnl required by header file checks -AC_PROGRAM_EGREP dnl required by AC_EGREP_CPP -AC_PROG_FGREP dnl finds working grep -F -AC_ISC_POSIX dnl required by AC_C_CROSS -AC_PROG_AWK dnl required for "make html" in ../doc +AC_PROG_CC dnl required by almost everything +AC_PROG_CPP dnl required by header file checks +AC_PROGRAM_EGREP dnl required by AC_EGREP_CPP +AC_PROG_FGREP dnl finds working grep -F +AC_ISC_POSIX dnl required by AC_C_CROSS +AC_PROG_AWK dnl required for "make html" in ../doc +AC_PROG_MKDIR_P dnl portable "mkdir -p", also works in parallel dnl Don't strip if we don't have it AC_CHECK_PROG(STRIP, strip, strip, :)
new file mode 100644 --- /dev/null +++ b/src/install-sh @@ -0,0 +1,501 @@ +#!/bin/sh +# install - install a program, script, or datafile + +scriptversion=2013-12-25.23; # UTC + +# This originates from X11R5 (mit/util/scripts/install.sh), which was +# later released in X11R6 (xc/config/util/install.sh) with the +# following copyright and license. +# +# Copyright (C) 1994 X Consortium +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- +# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# +# Except as contained in this notice, the name of the X Consortium shall not +# be used in advertising or otherwise to promote the sale, use or other deal- +# ings in this Software without prior written authorization from the X Consor- +# tium. +# +# +# FSF changes to this file are in the public domain. +# +# Calling this script install-sh is preferred over install.sh, to prevent +# 'make' implicit rules from creating a file called install from it +# when there is no Makefile. +# +# This script is compatible with the BSD install script, but was written +# from scratch. + +tab=' ' +nl=' +' +IFS=" $tab$nl" + +# Set DOITPROG to "echo" to test this script. + +doit=${DOITPROG-} +doit_exec=${doit:-exec} + +# Put in absolute file names if you don't have them in your path; +# or use environment vars. + +chgrpprog=${CHGRPPROG-chgrp} +chmodprog=${CHMODPROG-chmod} +chownprog=${CHOWNPROG-chown} +cmpprog=${CMPPROG-cmp} +cpprog=${CPPROG-cp} +mkdirprog=${MKDIRPROG-mkdir} +mvprog=${MVPROG-mv} +rmprog=${RMPROG-rm} +stripprog=${STRIPPROG-strip} + +posix_mkdir= + +# Desired mode of installed file. +mode=0755 + +chgrpcmd= +chmodcmd=$chmodprog +chowncmd= +mvcmd=$mvprog +rmcmd="$rmprog -f" +stripcmd= + +src= +dst= +dir_arg= +dst_arg= + +copy_on_change=false +is_target_a_directory=possibly + +usage="\ +Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE + or: $0 [OPTION]... SRCFILES... DIRECTORY + or: $0 [OPTION]... -t DIRECTORY SRCFILES... + or: $0 [OPTION]... -d DIRECTORIES... + +In the 1st form, copy SRCFILE to DSTFILE. +In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. +In the 4th, create DIRECTORIES. + +Options: + --help display this help and exit. + --version display version info and exit. + + -c (ignored) + -C install only if different (preserve the last data modification time) + -d create directories instead of installing files. + -g GROUP $chgrpprog installed files to GROUP. + -m MODE $chmodprog installed files to MODE. + -o USER $chownprog installed files to USER. + -s $stripprog installed files. + -t DIRECTORY install into DIRECTORY. + -T report an error if DSTFILE is a directory. + +Environment variables override the default commands: + CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG + RMPROG STRIPPROG +" + +while test $# -ne 0; do + case $1 in + -c) ;; + + -C) copy_on_change=true;; + + -d) dir_arg=true;; + + -g) chgrpcmd="$chgrpprog $2" + shift;; + + --help) echo "$usage"; exit $?;; + + -m) mode=$2 + case $mode in + *' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*) + echo "$0: invalid mode: $mode" >&2 + exit 1;; + esac + shift;; + + -o) chowncmd="$chownprog $2" + shift;; + + -s) stripcmd=$stripprog;; + + -t) + is_target_a_directory=always + dst_arg=$2 + # Protect names problematic for 'test' and other utilities. + case $dst_arg in + -* | [=\(\)!]) dst_arg=./$dst_arg;; + esac + shift;; + + -T) is_target_a_directory=never;; + + --version) echo "$0 $scriptversion"; exit $?;; + + --) shift + break;; + + -*) echo "$0: invalid option: $1" >&2 + exit 1;; + + *) break;; + esac + shift +done + +# We allow the use of options -d and -T together, by making -d +# take the precedence; this is for compatibility with GNU install. + +if test -n "$dir_arg"; then + if test -n "$dst_arg"; then + echo "$0: target directory not allowed when installing a directory." >&2 + exit 1 + fi +fi + +if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then + # When -d is used, all remaining arguments are directories to create. + # When -t is used, the destination is already specified. + # Otherwise, the last argument is the destination. Remove it from $@. + for arg + do + if test -n "$dst_arg"; then + # $@ is not empty: it contains at least $arg. + set fnord "$@" "$dst_arg" + shift # fnord + fi + shift # arg + dst_arg=$arg + # Protect names problematic for 'test' and other utilities. + case $dst_arg in + -* | [=\(\)!]) dst_arg=./$dst_arg;; + esac + done +fi + +if test $# -eq 0; then + if test -z "$dir_arg"; then + echo "$0: no input file specified." >&2 + exit 1 + fi + # It's OK to call 'install-sh -d' without argument. + # This can happen when creating conditional directories. + exit 0 +fi + +if test -z "$dir_arg"; then + if test $# -gt 1 || test "$is_target_a_directory" = always; then + if test ! -d "$dst_arg"; then + echo "$0: $dst_arg: Is not a directory." >&2 + exit 1 + fi + fi +fi + +if test -z "$dir_arg"; then + do_exit='(exit $ret); exit $ret' + trap "ret=129; $do_exit" 1 + trap "ret=130; $do_exit" 2 + trap "ret=141; $do_exit" 13 + trap "ret=143; $do_exit" 15 + + # Set umask so as not to create temps with too-generous modes. + # However, 'strip' requires both read and write access to temps. + case $mode in + # Optimize common cases. + *644) cp_umask=133;; + *755) cp_umask=22;; + + *[0-7]) + if test -z "$stripcmd"; then + u_plus_rw= + else + u_plus_rw='% 200' + fi + cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; + *) + if test -z "$stripcmd"; then + u_plus_rw= + else + u_plus_rw=,u+rw + fi + cp_umask=$mode$u_plus_rw;; + esac +fi + +for src +do + # Protect names problematic for 'test' and other utilities. + case $src in + -* | [=\(\)!]) src=./$src;; + esac + + if test -n "$dir_arg"; then + dst=$src + dstdir=$dst + test -d "$dstdir" + dstdir_status=$? + else + + # Waiting for this to be detected by the "$cpprog $src $dsttmp" command + # might cause directories to be created, which would be especially bad + # if $src (and thus $dsttmp) contains '*'. + if test ! -f "$src" && test ! -d "$src"; then + echo "$0: $src does not exist." >&2 + exit 1 + fi + + if test -z "$dst_arg"; then + echo "$0: no destination specified." >&2 + exit 1 + fi + dst=$dst_arg + + # If destination is a directory, append the input filename; won't work + # if double slashes aren't ignored. + if test -d "$dst"; then + if test "$is_target_a_directory" = never; then + echo "$0: $dst_arg: Is a directory" >&2 + exit 1 + fi + dstdir=$dst + dst=$dstdir/`basename "$src"` + dstdir_status=0 + else + dstdir=`dirname "$dst"` + test -d "$dstdir" + dstdir_status=$? + fi + fi + + obsolete_mkdir_used=false + + if test $dstdir_status != 0; then + case $posix_mkdir in + '') + # Create intermediate dirs using mode 755 as modified by the umask. + # This is like FreeBSD 'install' as of 1997-10-28. + umask=`umask` + case $stripcmd.$umask in + # Optimize common cases. + *[2367][2367]) mkdir_umask=$umask;; + .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; + + *[0-7]) + mkdir_umask=`expr $umask + 22 \ + - $umask % 100 % 40 + $umask % 20 \ + - $umask % 10 % 4 + $umask % 2 + `;; + *) mkdir_umask=$umask,go-w;; + esac + + # With -d, create the new directory with the user-specified mode. + # Otherwise, rely on $mkdir_umask. + if test -n "$dir_arg"; then + mkdir_mode=-m$mode + else + mkdir_mode= + fi + + posix_mkdir=false + case $umask in + *[123567][0-7][0-7]) + # POSIX mkdir -p sets u+wx bits regardless of umask, which + # is incompatible with FreeBSD 'install' when (umask & 300) != 0. + ;; + *) + tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ + trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 + + if (umask $mkdir_umask && + exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 + then + if test -z "$dir_arg" || { + # Check for POSIX incompatibilities with -m. + # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or + # other-writable bit of parent directory when it shouldn't. + # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. + ls_ld_tmpdir=`ls -ld "$tmpdir"` + case $ls_ld_tmpdir in + d????-?r-*) different_mode=700;; + d????-?--*) different_mode=755;; + *) false;; + esac && + $mkdirprog -m$different_mode -p -- "$tmpdir" && { + ls_ld_tmpdir_1=`ls -ld "$tmpdir"` + test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" + } + } + then posix_mkdir=: + fi + rmdir "$tmpdir/d" "$tmpdir" + else + # Remove any dirs left behind by ancient mkdir implementations. + rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null + fi + trap '' 0;; + esac;; + esac + + if + $posix_mkdir && ( + umask $mkdir_umask && + $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" + ) + then : + else + + # The umask is ridiculous, or mkdir does not conform to POSIX, + # or it failed possibly due to a race condition. Create the + # directory the slow way, step by step, checking for races as we go. + + case $dstdir in + /*) prefix='/';; + [-=\(\)!]*) prefix='./';; + *) prefix='';; + esac + + oIFS=$IFS + IFS=/ + set -f + set fnord $dstdir + shift + set +f + IFS=$oIFS + + prefixes= + + for d + do + test X"$d" = X && continue + + prefix=$prefix$d + if test -d "$prefix"; then + prefixes= + else + if $posix_mkdir; then + (umask=$mkdir_umask && + $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break + # Don't fail if two instances are running concurrently. + test -d "$prefix" || exit 1 + else + case $prefix in + *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; + *) qprefix=$prefix;; + esac + prefixes="$prefixes '$qprefix'" + fi + fi + prefix=$prefix/ + done + + if test -n "$prefixes"; then + # Don't fail if two instances are running concurrently. + (umask $mkdir_umask && + eval "\$doit_exec \$mkdirprog $prefixes") || + test -d "$dstdir" || exit 1 + obsolete_mkdir_used=true + fi + fi + fi + + if test -n "$dir_arg"; then + { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && + { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && + { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || + test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 + else + + # Make a couple of temp file names in the proper directory. + dsttmp=$dstdir/_inst.$$_ + rmtmp=$dstdir/_rm.$$_ + + # Trap to clean up those temp files at exit. + trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 + + # Copy the file name to the temp name. + (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && + + # and set any options; do chmod last to preserve setuid bits. + # + # If any of these fail, we abort the whole thing. If we want to + # ignore errors from any of these, just make sure not to ignore + # errors from the above "$doit $cpprog $src $dsttmp" command. + # + { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && + { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && + { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && + { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && + + # If -C, don't bother to copy if it wouldn't change the file. + if $copy_on_change && + old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && + new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && + set -f && + set X $old && old=:$2:$4:$5:$6 && + set X $new && new=:$2:$4:$5:$6 && + set +f && + test "$old" = "$new" && + $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 + then + rm -f "$dsttmp" + else + # Rename the file to the real destination. + $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || + + # The rename failed, perhaps because mv can't rename something else + # to itself, or perhaps because mv is so ancient that it does not + # support -f. + { + # Now remove or move aside any old file at destination location. + # We try this two ways since rm can't unlink itself on some + # systems and the destination file might be busy for other + # reasons. In this case, the final cleanup might fail but the new + # file should still install successfully. + { + test ! -f "$dst" || + $doit $rmcmd -f "$dst" 2>/dev/null || + { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && + { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } + } || + { echo "$0: cannot unlink or rename $dst" >&2 + (exit 1); exit 1 + } + } && + + # Now rename the file to the real destination. + $doit $mvcmd "$dsttmp" "$dst" + } + fi || exit 1 + + trap '' 0 + fi +done + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-time-zone: "UTC" +# time-stamp-end: "; # UTC" +# End:
deleted file mode 100755 --- a/src/mkinstalldirs +++ /dev/null @@ -1,38 +0,0 @@ -#! /bin/sh -# mkinstalldirs --- make directory hierarchy -# Author: Noah Friedman <friedman@prep.ai.mit.edu> -# Created: 1993-05-16 -# Public domain - -errstatus=0 - -for file -do - set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` - shift - - pathcomp= - for d - do - pathcomp="$pathcomp$d" - case "$pathcomp" in - -* ) pathcomp=./$pathcomp ;; - esac - - if test ! -d "$pathcomp"; then - echo "mkdir $pathcomp" 1>&2 - - mkdir "$pathcomp" || lasterr=$? - - if test ! -d "$pathcomp"; then - errstatus=$lasterr - fi - fi - - pathcomp="$pathcomp/" - done -done - -exit $errstatus - -# mkinstalldirs ends here