{"thread":{"id":"10252","subject":"[PATCH] add simple install replacement","startedAt":"2007-10-11T21:52:37Z","lastAt":"2007-10-12T15:07:39Z","messageCount":3,"participants":["Robert Schiele","Jan Hudec"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"55515","messageId":"20071011215237.GI20753@schiele.dyndns.org","threadId":"10252","inReplyTo":null,"subject":"[PATCH] add simple install replacement","fromName":"Robert Schiele","fromEmail":"rschiele@gmail.com","sentAt":"2007-10-11T21:52:37Z","receivedAt":"2007-10-11T21:52:37Z","isPatch":true,"sender":{"key":"rschiele@gmail.com","avatar":"https://gravatar.com/avatar/409473567eb2287d5f0157b51f5b703994b347f24f92172e3a0588741c27a492?d=mp&s=160"},"body":"This patch adds a very simple install replacement script to git.\nThis allows more easy installation on systems that don't have a\ncompatible install.\n\nSigned-off-by: Robert Schiele <rschiele@gmail.com>\n---\n gitinstall |   35 +++++++++++++++++++++++++++++++++++\n 1 files changed, 35 insertions(+), 0 deletions(-)\n create mode 100755 gitinstall\n\ndiff --git a/gitinstall b/gitinstall\nnew file mode 100755\nindex 0000000..8b346d6\n--- /dev/null\n+++ b/gitinstall\n@@ -0,0 +1,35 @@\n+#!/bin/sh\n+\n+MKDIRMODE=0\n+MODE=755\n+while getopts 'dm:' FLAG; do\n+    case \"$FLAG\" in\n+        d) MKDIRMODE=1;;\n+        m) MODE=\"$OPTARG\";;\n+\t*) exit 1;;\n+    esac\n+done\n+if test \"$OPTIND\" != 1; then\n+    shift `expr $OPTIND - 1`\n+fi\n+if test $MKDIRMODE = 1; then\n+    mkdir -p \"$@\"\n+    chmod \"$MODE\" \"$@\"\n+else\n+    if test $# = 2 && ! test -d \"$2\"; then\n+\trm -rf \"$2\"\n+\tcp \"$1\" \"$2\"\n+\tchmod \"$MODE\" \"$2\"\n+    else\n+\tFILES=\n+\twhile test $# != 1; do\n+\t    FILES=\"$FILES $1\"\n+\t    shift\n+\tdone\n+\tfor i in $FILES; do\n+\t    rm -rf \"$1/\"`basename \"$i\"`\n+\t    cp \"$i\" \"$1\"\n+\t    chmod \"$MODE\" \"$1/\"`basename \"$i\"`\n+\tdone\n+    fi\n+fi\n-- \n1.5.2.4\n"},{"id":"55558","messageId":"20071012140647.GC7865@efreet.light.src","threadId":"10252","inReplyTo":"20071011215237.GI20753@schiele.dyndns.org","subject":"Re: [PATCH] add simple install replacement","fromName":"Jan Hudec","fromEmail":"bulb@ucw.cz","sentAt":"2007-10-12T14:06:47Z","receivedAt":"2007-10-12T14:06:47Z","isPatch":true,"sender":{"key":"bulb@ucw.cz","avatar":null},"body":"On Thu, Oct 11, 2007 at 23:52:37 +0200, Robert Schiele wrote:\n> This patch adds a very simple install replacement script to git.\n> This allows more easy installation on systems that don't have a\n> compatible install.\n\nDo you have a particular case where you need it?\n\n> Signed-off-by: Robert Schiele <rschiele@gmail.com>\n> ---\n>  gitinstall |   35 +++++++++++++++++++++++++++++++++++\n>  1 files changed, 35 insertions(+), 0 deletions(-)\n>  create mode 100755 gitinstall\n> \n> diff --git a/gitinstall b/gitinstall\n> new file mode 100755\n> index 0000000..8b346d6\n> --- /dev/null\n> +++ b/gitinstall\n> @@ -0,0 +1,35 @@\n> +#!/bin/sh\n> +\n> +MKDIRMODE=0\n> +MODE=755\n> +while getopts 'dm:' FLAG; do\n\nNo such thing here:\nzsh$ /bin/sh\n$ which getopts\n$\n\nYes, bash and zsh do have that, but my (and I suspect many git users')\n/bin/sh is neither of those. Git scripts should use just POSIX shell\nfeatures for portability.\n\nWhich is particularly important when you are trying to replace a common\nutility, because the systems that won't have it are likely to not have bash\neither.\n\nYou may want to have a look at /usr/share/automake-1.9/install-sh (or\n/usr/share/automake<something>/install-sh). It shows how to portably process\noptions in shell and since it's in fact covered by the MIT/X license (and FSF\nchanges are public domain), git could just use it if necessary.\n\n> +    case \"$FLAG\" in\n> +        d) MKDIRMODE=1;;\n> +        m) MODE=\"$OPTARG\";;\n> +\t*) exit 1;;\n> +    esac\n> +done\n> +if test \"$OPTIND\" != 1; then\n> +    shift `expr $OPTIND - 1`\n> +fi\n> +if test $MKDIRMODE = 1; then\n> +    mkdir -p \"$@\"\n> +    chmod \"$MODE\" \"$@\"\n> +else\n> +    if test $# = 2 && ! test -d \"$2\"; then\n> +\trm -rf \"$2\"\n\nAre you sure reall install would do this? The maual (install(1)) states\nfollowing usage variants:\n\n    install [OPTION]... [-T] SOURCE DEST\n    install [OPTION]... SOURCE... DIRECTORY\n    install [OPTION]... -t DIRECTORY SOURCE...\n    install [OPTION]... -d DIRECTORY...\n\nNow however there is nothing saying that SOURCE... is at least two, so is\n\n    install git /usr/bin\n\na case of the first or second usage? I would say the second, but your code\nwould:\n\n    rm -rf /usr/bin\n    cp git /usr/bin\n\n> +\tcp \"$1\" \"$2\"\n> +\tchmod \"$MODE\" \"$2\"\n> +    else\n> +\tFILES=\n> +\twhile test $# != 1; do\n> +\t    FILES=\"$FILES $1\"\n> +\t    shift\n> +\tdone\n> +\tfor i in $FILES; do\n\n    touch \"foo*bar\" \"a b c\"\n    ./gitinstall \"b*c\" \"a b c\" /tmp\n\n... will copy a lot of files to /tmp (presuming we are in git source\ndirectory, where tons of files are called builtin-<something>.c) and complain\nthat there is no 'a', no 'b' and no 'c'.\n\n> +\t    rm -rf \"$1/\"`basename \"$i\"`\n> +\t    cp \"$i\" \"$1\"\n> +\t    chmod \"$MODE\" \"$1/\"`basename \"$i\"`\n> +\tdone\n> +    fi\n> +fi\n\n-- \n\t\t\t\t\t\t Jan 'Bulb' Hudec <bulb@ucw.cz>\n"},{"id":"55564","messageId":"20071012150739.GJ20753@schiele.dyndns.org","threadId":"10252","inReplyTo":"20071012140647.GC7865@efreet.light.src","subject":"Re: [PATCH] add simple install replacement","fromName":"Robert Schiele","fromEmail":"rschiele@gmail.com","sentAt":"2007-10-12T15:07:39Z","receivedAt":"2007-10-12T15:07:39Z","isPatch":true,"sender":{"key":"rschiele@gmail.com","avatar":"https://gravatar.com/avatar/409473567eb2287d5f0157b51f5b703994b347f24f92172e3a0588741c27a492?d=mp&s=160"},"body":"On Fri, Oct 12, 2007 at 04:06:47PM +0200, Jan Hudec wrote:\n> On Thu, Oct 11, 2007 at 23:52:37 +0200, Robert Schiele wrote:\n> > This patch adds a very simple install replacement script to git.\n> > This allows more easy installation on systems that don't have a\n> > compatible install.\n> \n> Do you have a particular case where you need it?\n\nWe have some machines here where no compatible install was installed.  Sure I\ncould have built GNU coreutils on all of them but writing this script was just\nmore convenient for me.\n\n> No such thing here:\n> zsh$ /bin/sh\n> $ which getopts\n> $\n> \n> Yes, bash and zsh do have that, but my (and I suspect many git users')\n> /bin/sh is neither of those. Git scripts should use just POSIX shell\n> features for portability.\n\nI just used it because the shells on my machines had it.  My idea was that if\nsomeone has a shell with less features we could still replace parts with even\nmore basic ways of doing things.\n\n> You may want to have a look at /usr/share/automake-1.9/install-sh (or\n> /usr/share/automake<something>/install-sh). It shows how to portably process\n> options in shell and since it's in fact covered by the MIT/X license (and FSF\n> changes are public domain), git could just use it if necessary.\n\nOh, forgot about that implementation.  Since this version is definitely more\nadvanced I retract my patch and propose to use that one instead.\n\n> Are you sure reall install would do this? The maual (install(1)) states\n> following usage variants:\n> \n>     install [OPTION]... [-T] SOURCE DEST\n>     install [OPTION]... SOURCE... DIRECTORY\n>     install [OPTION]... -t DIRECTORY SOURCE...\n>     install [OPTION]... -d DIRECTORY...\n\nI did not intend to write a full replacement for install but cover only the\ncases needed to install git.\n\n> Now however there is nothing saying that SOURCE... is at least two, so is\n> \n>     install git /usr/bin\n> \n> a case of the first or second usage? I would say the second, but your code\n> would:\n> \n>     rm -rf /usr/bin\n>     cp git /usr/bin\n\nNo, in your example /usr/bin is a directory and thus this is:\n\nrm -rf /usr/bin/git\ncp git /usr/bin\n\n>     touch \"foo*bar\" \"a b c\"\n>     ./gitinstall \"b*c\" \"a b c\" /tmp\n> \n> ... will copy a lot of files to /tmp (presuming we are in git source\n> directory, where tons of files are called builtin-<something>.c) and complain\n> that there is no 'a', no 'b' and no 'c'.\n\nThere are no files with special characters in git to be installed.  Again this\nwas meant a _simple_ replacement for install on systems without a compatible\ninstall just to install _git_, not to reinvent the wheel.\n\nRobert\n\n-- \nRobert Schiele\nDipl.-Wirtsch.informatiker\tmailto:rschiele@gmail.com\n\n\"Quidquid latine dictum sit, altum sonatur.\"\n"}]}