{"thread":{"id":"5512","subject":"[PATCH] autoconf: Add checking for BSD-compatibile 'install' program","startedAt":"2006-09-07T12:31:18Z","lastAt":"2006-09-07T21:39:28Z","messageCount":3,"participants":["Jakub Narebski","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"26515","messageId":"200609071431.18343.jnareb@gmail.com","threadId":"5512","inReplyTo":null,"subject":"[PATCH] autoconf: Add checking for BSD-compatibile 'install' program","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-09-07T12:31:18Z","receivedAt":"2006-09-07T12:31:18Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Uncomment `AC_PROG_INSTALL' macro in configure.ac, and setting\n`INSTALL' variable in config.mak.in\n\nAdd `install-sh' shell script (required when using `AC_PROG_INSTALL'\nmacro) scriptversion=2005-11-07.23, taken from KDE SDK 3.5.3.\n\nSigned-off-by: Jakub Narebski <jnareb@gmail.com>\n---\nPerhaps `install-sh' script should be replaced by something simplier,\nfor example by script which was sent to git mailing list, but AFAIK\nnot accepted.\n\n config.mak.in |    2 \n configure.ac  |    3 \n install-sh    |  401 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n 3 files changed, 404 insertions(+), 2 deletions(-)\n\ndiff --git a/config.mak.in b/config.mak.in\nindex fccde61..d5b6451 100644\n--- a/config.mak.in\n+++ b/config.mak.in\n@@ -4,7 +4,7 @@ # @configure_input@\n CC = @CC@\n AR = @AR@\n TAR = @TAR@\n-#INSTALL = @INSTALL@\t\t# needs install-sh or install.sh in sources\n+INSTALL = @INSTALL@\n \n prefix = @prefix@\n exec_prefix = @exec_prefix@\ndiff --git a/configure.ac b/configure.ac\nindex 6a980a5..1a501f5 100644\n--- a/configure.ac\n+++ b/configure.ac\n@@ -92,11 +92,12 @@ AC_SUBST(NO_PYTHON)\n AC_SUBST(PYTHON_PATH)\n \n \n+## ----------------------------------------------------------------------\n ## Checks for programs.\n AC_MSG_NOTICE([CHECKS for programs])\n #\n AC_PROG_CC\n-#AC_PROG_INSTALL\t\t# needs install-sh or install.sh in sources\n+AC_PROG_INSTALL\n AC_CHECK_TOOL(AR, ar, :)\n AC_CHECK_PROGS(TAR, [gtar tar])\n #\ndiff --git a/install-sh b/install-sh\nnew file mode 100644\nindex 0000000..0ae12c0\n--- /dev/null\n+++ b/install-sh\n@@ -0,0 +1,401 @@\n+#!/bin/sh\n+# install - install a program, script, or datafile\n+\n+scriptversion=2005-11-07.23\n+\n+# This originates from X11R5 (mit/util/scripts/install.sh), which was\n+# later released in X11R6 (xc/config/util/install.sh) with the\n+# following copyright and license.\n+#\n+# Copyright (C) 1994 X Consortium\n+#\n+# Permission is hereby granted, free of charge, to any person obtaining a copy\n+# of this software and associated documentation files (the \"Software\"), to\n+# deal in the Software without restriction, including without limitation the\n+# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n+# sell copies of the Software, and to permit persons to whom the Software is\n+# furnished to do so, subject to the following conditions:\n+#\n+# The above copyright notice and this permission notice shall be included in\n+# all copies or substantial portions of the Software.\n+#\n+# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE\n+# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN\n+# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-\n+# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n+#\n+# Except as contained in this notice, the name of the X Consortium shall not\n+# be used in advertising or otherwise to promote the sale, use or other deal-\n+# ings in this Software without prior written authorization from the X Consor-\n+# tium.\n+#\n+#\n+# FSF changes to this file are in the public domain.\n+#\n+# Calling this script install-sh is preferred over install.sh, to prevent\n+# `make' implicit rules from creating a file called install from it\n+# when there is no Makefile.\n+#\n+# This script is compatible with the BSD install script, but was written\n+# from scratch.  It can only install one file at a time, a restriction\n+# shared with many OS's install programs.\n+\n+# set DOITPROG to echo to test this script\n+\n+# Don't use :- since 4.3BSD and earlier shells don't like it.\n+doit=\"${DOITPROG-}\"\n+\n+# put in absolute paths if you don't have them in your path; or use env. vars.\n+\n+mvprog=\"${MVPROG-mv}\"\n+cpprog=\"${CPPROG-cp}\"\n+chmodprog=\"${CHMODPROG-chmod}\"\n+chownprog=\"${CHOWNPROG-chown}\"\n+chgrpprog=\"${CHGRPPROG-chgrp}\"\n+stripprog=\"${STRIPPROG-strip}\"\n+rmprog=\"${RMPROG-rm}\"\n+mkdirprog=\"${MKDIRPROG-mkdir}\"\n+\n+posix_glob=\n+posix_mkdir=\n+\n+# Symbolic mode for testing mkdir with directories.\n+# It is the same as 755, but also tests that \"u+\" works.\n+test_mode=u=rwx,g=rx,o=rx,u+wx\n+\n+# Desired mode of installed file.\n+mode=0755\n+\n+# Desired mode of newly created intermediate directories.\n+# It is empty if not known yet.\n+intermediate_mode=\n+\n+chmodcmd=$chmodprog\n+chowncmd=\n+chgrpcmd=\n+stripcmd=\n+rmcmd=\"$rmprog -f\"\n+mvcmd=\"$mvprog\"\n+src=\n+dst=\n+dir_arg=\n+dstarg=\n+no_target_directory=\n+\n+usage=\"Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE\n+   or: $0 [OPTION]... SRCFILES... DIRECTORY\n+   or: $0 [OPTION]... -t DIRECTORY SRCFILES...\n+   or: $0 [OPTION]... -d DIRECTORIES...\n+\n+In the 1st form, copy SRCFILE to DSTFILE.\n+In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.\n+In the 4th, create DIRECTORIES.\n+\n+Options:\n+-c         (ignored)\n+-d         create directories instead of installing files.\n+-g GROUP   $chgrpprog installed files to GROUP.\n+-m MODE    $chmodprog installed files to MODE.\n+-o USER    $chownprog installed files to USER.\n+-s         $stripprog installed files.\n+-t DIRECTORY  install into DIRECTORY.\n+-T         report an error if DSTFILE is a directory.\n+--help     display this help and exit.\n+--version  display version info and exit.\n+\n+Environment variables override the default commands:\n+  CHGRPPROG CHMODPROG CHOWNPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG\n+\"\n+\n+while test -n \"$1\"; do\n+  case $1 in\n+    -c) shift\n+        continue;;\n+\n+    -d) dir_arg=true\n+        shift\n+        continue;;\n+\n+    -g) chgrpcmd=\"$chgrpprog $2\"\n+        shift\n+        shift\n+        continue;;\n+\n+    --help) echo \"$usage\"; exit $?;;\n+\n+    -m) mode=$2\n+        shift\n+        shift\n+        continue;;\n+\n+    -o) chowncmd=\"$chownprog $2\"\n+        shift\n+        shift\n+        continue;;\n+\n+    -s) stripcmd=$stripprog\n+        shift\n+        continue;;\n+\n+    -t) dstarg=$2\n+\tshift\n+\tshift\n+\tcontinue;;\n+\n+    -T) no_target_directory=true\n+\tshift\n+\tcontinue;;\n+\n+    --version) echo \"$0 $scriptversion\"; exit $?;;\n+\n+    *)  # When -d is used, all remaining arguments are directories to create.\n+\t# When -t is used, the destination is already specified.\n+\ttest -n \"$dir_arg$dstarg\" && break\n+        # Otherwise, the last argument is the destination.  Remove it from $@.\n+\tfor arg\n+\tdo\n+          if test -n \"$dstarg\"; then\n+\t    # $@ is not empty: it contains at least $arg.\n+\t    set fnord \"$@\" \"$dstarg\"\n+\t    shift # fnord\n+\t  fi\n+\t  shift # arg\n+\t  dstarg=$arg\n+\tdone\n+\tbreak;;\n+  esac\n+done\n+\n+if test -z \"$1\"; then\n+  if test -z \"$dir_arg\"; then\n+    echo \"$0: no input file specified.\" >&2\n+    exit 1\n+  fi\n+  # It's OK to call `install-sh -d' without argument.\n+  # This can happen when creating conditional directories.\n+  exit 0\n+fi\n+\n+test -n \"$dir_arg\" || trap '(exit $?); exit' 1 2 13 15\n+\n+for src\n+do\n+  # Protect names starting with `-'.\n+  case $src in\n+    -*) src=./$src ;;\n+  esac\n+\n+  if test -n \"$dir_arg\"; then\n+    dst=$src\n+    dstdir=$dst\n+    test -d \"$dstdir\"\n+    dstdir_status=$?\n+  else\n+\n+    # Waiting for this to be detected by the \"$cpprog $src $dsttmp\" command\n+    # might cause directories to be created, which would be especially bad\n+    # if $src (and thus $dsttmp) contains '*'.\n+    if test ! -f \"$src\" && test ! -d \"$src\"; then\n+      echo \"$0: $src does not exist.\" >&2\n+      exit 1\n+    fi\n+\n+    if test -z \"$dstarg\"; then\n+      echo \"$0: no destination specified.\" >&2\n+      exit 1\n+    fi\n+\n+    dst=$dstarg\n+    # Protect names starting with `-'.\n+    case $dst in\n+      -*) dst=./$dst ;;\n+    esac\n+\n+    # If destination is a directory, append the input filename; won't work\n+    # if double slashes aren't ignored.\n+    if test -d \"$dst\"; then\n+      if test -n \"$no_target_directory\"; then\n+\techo \"$0: $dstarg: Is a directory\" >&2\n+\texit 1\n+      fi\n+      dstdir=$dst\n+      dst=$dstdir/`basename \"$src\"`\n+      dstdir_status=0\n+    else\n+      # Prefer dirname, but fall back on a substitute if dirname fails.\n+      dstdir=`\n+\t(dirname \"$dst\") 2>/dev/null ||\n+\texpr X\"$dst\" : 'X\\(.*[^/]\\)//*[^/][^/]*/*$' \\| \\\n+\t     X\"$dst\" : 'X\\(//\\)[^/]' \\| \\\n+\t     X\"$dst\" : 'X\\(//\\)$' \\| \\\n+\t     X\"$dst\" : 'X\\(/\\)' \\| \\\n+\t     .       : '\\(.\\)' 2>/dev/null ||\n+\techo X\"$dst\" |\n+\t    sed '/^X\\(.*[^/]\\)\\/\\/*[^/][^/]*\\/*$/{ s//\\1/; q; }\n+\t\t  /^X\\(\\/\\/\\)[^/].*/{ s//\\1/; q; }\n+\t\t  /^X\\(\\/\\/\\)$/{ s//\\1/; q; }\n+\t\t  /^X\\(\\/\\).*/{ s//\\1/; q; }\n+\t\t  s/.*/./; q'\n+      `\n+\n+      test -d \"$dstdir\"\n+      dstdir_status=$?\n+    fi\n+  fi\n+\n+  obsolete_mkdir_used=false\n+\n+  if test $dstdir_status != 0; then\n+    case $posix_mkdir in\n+      '')\n+\tposix_mkdir=false\n+\tif $mkdirprog -m $test_mode -p -- / >/dev/null 2>&1; then\n+\t  posix_mkdir=true\n+\telse\n+\t  # Remove any dirs left behind by ancient mkdir implementations.\n+\t  rmdir ./-m \"$test_mode\" ./-p ./-- 2>/dev/null\n+\tfi ;;\n+    esac\n+\n+    if\n+      $posix_mkdir && {\n+\n+\t# With -d, create the new directory with the user-specified mode.\n+\t# Otherwise, create it using the same intermediate mode that\n+\t# mkdir -p would use when creating intermediate directories.\n+\t# POSIX says that this mode is \"$(umask -S),u+wx\", so use that\n+\t# if umask -S works.\n+\n+\tif test -n \"$dir_arg\"; then\n+\t  mkdir_mode=$mode\n+\telse\n+\t  case $intermediate_mode in\n+\t    '')\n+\t      if umask_S=`(umask -S) 2>/dev/null`; then\n+\t\tintermediate_mode=$umask_S,u+wx\n+\t      else\n+\t\tintermediate_mode=$test_mode\n+\t      fi ;;\n+\t  esac\n+\t  mkdir_mode=$intermediate_mode\n+\tfi\n+\n+\t$mkdirprog -m \"$mkdir_mode\" -p -- \"$dstdir\"\n+      }\n+    then :\n+    else\n+\n+      # mkdir does not conform to POSIX, or it failed possibly due to\n+      # a race condition.  Create the directory the slow way, step by\n+      # step, checking for races as we go.\n+\n+      case $dstdir in\n+\t/*) pathcomp=/ ;;\n+\t-*) pathcomp=./ ;;\n+\t*)  pathcomp= ;;\n+      esac\n+\n+      case $posix_glob in\n+        '')\n+\t  if (set -f) 2>/dev/null; then\n+\t    posix_glob=true\n+\t  else\n+\t    posix_glob=false\n+\t  fi ;;\n+      esac\n+\n+      oIFS=$IFS\n+      IFS=/\n+      $posix_glob && set -f\n+      set fnord $dstdir\n+      shift\n+      $posix_glob && set +f\n+      IFS=$oIFS\n+\n+      for d\n+      do\n+\ttest \"x$d\" = x && continue\n+\n+\tpathcomp=$pathcomp$d\n+\tif test ! -d \"$pathcomp\"; then\n+\t  $mkdirprog \"$pathcomp\"\n+\t  # Don't fail if two instances are running concurrently.\n+\t  test -d \"$pathcomp\" || exit 1\n+\tfi\n+\tpathcomp=$pathcomp/\n+      done\n+      obsolete_mkdir_used=true\n+    fi\n+  fi\n+\n+  if test -n \"$dir_arg\"; then\n+    { test -z \"$chowncmd\" || $doit $chowncmd \"$dst\"; } &&\n+    { test -z \"$chgrpcmd\" || $doit $chgrpcmd \"$dst\"; } &&\n+    { test \"$obsolete_mkdir_used$chowncmd$chgrpcmd\" = false ||\n+      test -z \"$chmodcmd\" || $doit $chmodcmd \"$mode\" \"$dst\"; } || exit 1\n+  else\n+\n+    # Make a couple of temp file names in the proper directory.\n+    dsttmp=$dstdir/_inst.$$_\n+    rmtmp=$dstdir/_rm.$$_\n+\n+    # Trap to clean up those temp files at exit.\n+    trap 'ret=$?; rm -f \"$dsttmp\" \"$rmtmp\" && exit $ret' 0\n+\n+    # Copy the file name to the temp name.\n+    $doit $cpprog \"$src\" \"$dsttmp\" &&\n+\n+    # and set any options; do chmod last to preserve setuid bits.\n+    #\n+    # If any of these fail, we abort the whole thing.  If we want to\n+    # ignore errors from any of these, just make sure not to ignore\n+    # errors from the above \"$doit $cpprog $src $dsttmp\" command.\n+    #\n+    { test -z \"$chowncmd\" || $doit $chowncmd \"$dsttmp\"; } \\\n+      && { test -z \"$chgrpcmd\" || $doit $chgrpcmd \"$dsttmp\"; } \\\n+      && { test -z \"$stripcmd\" || $doit $stripcmd \"$dsttmp\"; } \\\n+      && { test -z \"$chmodcmd\" || $doit $chmodcmd \"$mode\" \"$dsttmp\"; } &&\n+\n+    # Now rename the file to the real destination.\n+    { $doit $mvcmd -f \"$dsttmp\" \"$dst\" 2>/dev/null \\\n+      || {\n+\t   # The rename failed, perhaps because mv can't rename something else\n+\t   # to itself, or perhaps because mv is so ancient that it does not\n+\t   # support -f.\n+\n+\t   # Now remove or move aside any old file at destination location.\n+\t   # We try this two ways since rm can't unlink itself on some\n+\t   # systems and the destination file might be busy for other\n+\t   # reasons.  In this case, the final cleanup might fail but the new\n+\t   # file should still install successfully.\n+\t   {\n+\t     if test -f \"$dst\"; then\n+\t       $doit $rmcmd -f \"$dst\" 2>/dev/null \\\n+\t       || { $doit $mvcmd -f \"$dst\" \"$rmtmp\" 2>/dev/null \\\n+\t\t     && { $doit $rmcmd -f \"$rmtmp\" 2>/dev/null; :; }; }\\\n+\t       || {\n+\t\t echo \"$0: cannot unlink or rename $dst\" >&2\n+\t\t (exit 1); exit 1\n+\t       }\n+\t     else\n+\t       :\n+\t     fi\n+\t   } &&\n+\n+\t   # Now rename the file to the real destination.\n+\t   $doit $mvcmd \"$dsttmp\" \"$dst\"\n+\t }\n+    } || exit 1\n+\n+    trap '' 0\n+  fi\n+done\n+\n+# Local variables:\n+# eval: (add-hook 'write-file-hooks 'time-stamp)\n+# time-stamp-start: \"scriptversion=\"\n+# time-stamp-format: \"%:y-%02m-%02d.%02H\"\n+# time-stamp-end: \"$\"\n+# End:\n-- \n1.4.2\n"},{"id":"26538","messageId":"7v8xkvxwa7.fsf@assigned-by-dhcp.cox.net","threadId":"5512","inReplyTo":"200609071431.18343.jnareb@gmail.com","subject":"Re: [PATCH] autoconf: Add checking for BSD-compatibile 'install' program","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-09-07T20:21:36Z","receivedAt":"2006-09-07T20:21:36Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jakub Narebski <jnareb@gmail.com> writes:\n\n> Uncomment `AC_PROG_INSTALL' macro in configure.ac, and setting\n> `INSTALL' variable in config.mak.in\n>\n> Add `install-sh' shell script (required when using `AC_PROG_INSTALL'\n> macro) scriptversion=2005-11-07.23, taken from KDE SDK 3.5.3.\n>\n> Signed-off-by: Jakub Narebski <jnareb@gmail.com>\n> ---\n> Perhaps `install-sh' script should be replaced by something simplier,\n> for example by script which was sent to git mailing list, but AFAIK\n> not accepted.\n\nThat somehow sounds like whining.  I do not think it was never\nproposed for inclusion but was just offered as a friendly\n\"somebody else might find it useful\".\n\nIn any case, I have two issues, but one non-issue first.  I am\nnot opposed to including install-sh that is maintained somewhere\nupstream and GPLv2 compatible.\n\n - I do not particularly like to have too many autoconf related\n   cruft at the toplevel, and I am wondering if we can move it\n   to say compat/install-sh.\n\n - I suspect this fall-back would set \"INSTALL = ./install-sh\"\n   (if you have it in compat, \"INSTALL = compat/install-sh\").  I\n   wonder if it breaks builds in subdirectories\n   (i.e. Documentation/ and templates/).\n"},{"id":"26543","messageId":"edq3hk$1tm$2@sea.gmane.org","threadId":"5512","inReplyTo":"7v8xkvxwa7.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] autoconf: Add checking for BSD-compatibile 'install' program","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-09-07T21:39:28Z","receivedAt":"2006-09-07T21:39:28Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Junio C Hamano wrote:\n\n> Jakub Narebski <jnareb@gmail.com> writes:\n> \n>> Uncomment `AC_PROG_INSTALL' macro in configure.ac, and setting\n>> `INSTALL' variable in config.mak.in\n>>\n>> Add `install-sh' shell script (required when using `AC_PROG_INSTALL'\n>> macro) scriptversion=2005-11-07.23, taken from KDE SDK 3.5.3.\n>>\n>> Signed-off-by: Jakub Narebski <jnareb@gmail.com>\n>> ---\n>> Perhaps `install-sh' script should be replaced by something simplier,\n>> for example by script which was sent to git mailing list, but AFAIK\n>> not accepted.\n> \n> That somehow sounds like whining.  I do not think it was never\n> proposed for inclusion but was just offered as a friendly\n> \"somebody else might find it useful\".\n\nSorry, my mistake. I thought that the install-sh script was proposed as\nsolution for platforms lacking install program...\n\n> In any case, I have two issues, but one non-issue first.  I am\n> not opposed to including install-sh that is maintained somewhere\n> upstream and GPLv2 compatible.\n> \n>  - I do not particularly like to have too many autoconf related\n>    cruft at the toplevel, and I am wondering if we can move it\n>    to say compat/install-sh.\n\nWe can do this by adding AC_CONFIG_AUX_DIR(DIR) to configure.ac,\nwhere DIR would be for example 'compat/' or 'compat/autoconf/'\n\n>  - I suspect this fall-back would set \"INSTALL = ./install-sh\"\n>    (if you have it in compat, \"INSTALL = compat/install-sh\").  I\n>    wonder if it breaks builds in subdirectories\n>    (i.e. Documentation/ and templates/).\n\nYes, it sets \"INSTALL = ./install-sh -c\". And it does make problems for\ne.g. 'make install-doc'. I don't know how this should be resolved...\n-- \nJakub Narebski\nWarsaw, Poland\nShadeHawk on #git\n"}]}