add simple install replacement
PATCH 1/1 add simple install replacement
This patch adds a very simple install replacement script to git. This allows more easy installation on systems that don't have a compatible install.
--- gitinstall | 35 +++++++++++++++++++++++++++++++++++ 1 files changed, 35 insertions(+), 0 deletions(-) create mode 100755 gitinstall
gitinstall new file +35 -0
@@ -0,0 +1,35 @@ +#!/bin/sh + +MKDIRMODE=0 +MODE=755 +while getopts 'dm:' FLAG; do + case "$FLAG" in + d) MKDIRMODE=1;; + m) MODE="$OPTARG";; + *) exit 1;; + esac +done +if test "$OPTIND" != 1; then + shift `expr $OPTIND - 1` +fi +if test $MKDIRMODE = 1; then + mkdir -p "$@" + chmod "$MODE" "$@" +else + if test $# = 2 && ! test -d "$2"; then + rm -rf "$2" + cp "$1" "$2" + chmod "$MODE" "$2" + else + FILES= + while test $# != 1; do + FILES="$FILES $1" + shift + done + for i in $FILES; do + rm -rf "$1/"`basename "$i"` + cp "$i" "$1" + chmod "$MODE" "$1/"`basename "$i"` + done + fi +fi
Signature · 1 line
1.5.2.4
Quoted 3 lines · Robert Schiele
This patch adds a very simple install replacement script to git. This allows more easy installation on systems that don't have a compatible install.
Do you have a particular case where you need it?
Quoted 12 lines
Signed-off-by Robert Schiele <[email protected]>--- gitinstall | 35 +++++++++++++++++++++++++++++++++++ 1 files changed, 35 insertions(+), 0 deletions(-) create mode 100755 gitinstallgitinstall new file +0
-0
gitinstall line 5
Quoted 5 lines
gitinstall new file +5
-0@@ -0,0 +1,35 @@ +#!/bin/sh + +MKDIRMODE=0 +MODE=755 +while getopts 'dm:' FLAG; do
No such thing here:
zsh$ /bin/sh
$ which getopts $
Yes, bash and zsh do have that, but my (and I suspect many git users') /bin/sh is neither of those. Git scripts should use just POSIX shell features for portability.
Which is particularly important when you are trying to replace a common utility, because the systems that won't have it are likely to not have bash either.
You may want to have a look at /usr/share/automake-1.9/install-sh (or /usr/share/automake<something>/install-sh). It shows how to portably process options in shell and since it's in fact covered by the MIT/X license (and FSF changes are public domain), git could just use it if necessary.
Quoted 5 lines
gitinstall new file +5
-0+ case "$FLAG" in + d) MKDIRMODE=1;; + m) MODE="$OPTARG";; + *) exit 1;; + esac
gitinstall line 20
Quoted 10 lines
gitinstall new file +10
-0+done +if test "$OPTIND" != 1; then + shift `expr $OPTIND - 1` +fi +if test $MKDIRMODE = 1; then + mkdir -p "$@" + chmod "$MODE" "$@" +else + if test $# = 2 && ! test -d "$2"; then + rm -rf "$2"
Are you sure reall install would do this? The maual (install(1)) states following usage variants:
install [OPTION]... [-T] SOURCE DEST
install [OPTION]... SOURCE... DIRECTORY
install [OPTION]... -t DIRECTORY SOURCE...
install [OPTION]... -d DIRECTORY...
Now however there is nothing saying that SOURCE... is at least two, so is
install git /usr/bin
a case of the first or second usage? I would say the second, but your code would:
rm -rf /usr/bin
cp git /usr/bin
gitinstall line 29
Quoted 9 lines
gitinstall new file +9
-0+ cp "$1" "$2" + chmod "$MODE" "$2" + else + FILES= + while test $# != 1; do + FILES="$FILES $1" + shift + done + for i in $FILES; do
touch "foo*bar" "a b c"
./gitinstall "b*c" "a b c" /tmp
... will copy a lot of files to /tmp (presuming we are in git source directory, where tons of files are called builtin-<something>.c) and complain that there is no 'a', no 'b' and no 'c'.
Quoted 6 lines
gitinstall new file +6
-0+ rm -rf "$1/"`basename "$i"` + cp "$i" "$1" + chmod "$MODE" "$1/"`basename "$i"` + done + fi +fi
Signature · 1 line
Jan 'Bulb' Hudec <[email protected]>
Quoted 6 lines · Jan Hudec
Quoted 3 lines · Robert Schiele
This patch adds a very simple install replacement script to git. This allows more easy installation on systems that don't have a compatible install.
Do you have a particular case where you need it?
We have some machines here where no compatible install was installed. Sure I could have built GNU coreutils on all of them but writing this script was just more convenient for me.
Quoted 8 lines
No such thing here:
zsh$/bin/sh$ which getopts $Yes, bash and zsh do have that, but my (and I suspect many git users')
/bin/shis neither of those. Git scripts should use just POSIX shell features for portability.
I just used it because the shells on my machines had it. My idea was that if someone has a shell with less features we could still replace parts with even more basic ways of doing things.
Quoted 4 lines
You may want to have a look at
/usr/share/automake-1.9/install-sh(or /usr/share/automake<something>/install-sh). It shows how to portably process options in shell and since it's in fact covered by the MIT/X license (and FSF changes are public domain), git could just use it if necessary.
Oh, forgot about that implementation. Since this version is definitely more advanced I retract my patch and propose to use that one instead.
Quoted 7 lines
Are you sure reall install would do this? The maual (install(1)) states following usage variants:
install [OPTION]... [-T] SOURCE DEST
install [OPTION]... SOURCE... DIRECTORY
install [OPTION]... -t DIRECTORY SOURCE...
install [OPTION]... -d DIRECTORY...
I did not intend to write a full replacement for install but cover only the cases needed to install git.
Quoted 9 lines
Now however there is nothing saying that SOURCE... is at least two, so is
install git
/usr/bina case of the first or second usage? I would say the second, but your code would:
rm -rf
/usr/bin
cp git/usr/bin
No, in your example /usr/bin is a directory and thus this is:
rm -rf /usr/bin/git
cp git /usr/bin
Quoted 6 lines
touch "foo*bar" "a b c"
./gitinstall "b*c" "a b c" /tmp... will copy a lot of files to /tmp (presuming we are in git source directory, where tons of files are called builtin-<something>.c) and complain that there is no 'a', no 'b' and no 'c'.
There are no files with special characters in git to be installed. Again this was meant a _simple_ replacement for install on systems without a compatible install just to install _git_, not to reinvent the wheel.
Robert
Signature · 4 lines
Robert Schiele Dipl.-Wirtsch.informatiker mailto:[email protected] "Quidquid latine dictum sit, altum sonatur."