source: git/install-sh @ fec53d

fieker-DuValspielwiese
Last change on this file since fec53d was 4b72f6, checked in by Olaf Bachmann <obachman@…>, 25 years ago
insatllation proocedure git-svn-id: file:///usr/local/Singular/svn/trunk@3918 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100755
File size: 5.0 KB
Line 
1#!/bin/sh
2#
3# install - install a program, script, or datafile
4# This comes from X11R5.
5#
6# Calling this script install-sh is preferred over install.sh, to prevent
7# `make' implicit rules from creating a file called install from it
8# when there is no Makefile.
9#
10# This script is compatible with the BSD install script, but was written
11# from scratch.
12#
13
14
15# set DOITPROG to echo to test this script
16
17# Don't use :- since 4.3BSD and earlier shells don't like it.
18doit="${DOITPROG-}"
19
20
21# put in absolute paths if you don't have them in your path; or use env. vars.
22
23mvprog="${MVPROG-mv}"
24cpprog="${CPPROG-cp}"
25chmodprog="${CHMODPROG-chmod}"
26chownprog="${CHOWNPROG-chown}"
27chgrpprog="${CHGRPPROG-chgrp}"
28stripprog="${STRIPPROG-strip}"
29rmprog="${RMPROG-rm}"
30mkdirprog="${MKDIRPROG-mkdir}"
31
32tranformbasename=""
33transform_arg=""
34instcmd="$mvprog"
35chmodcmd="$chmodprog 0755"
36chowncmd=""
37chgrpcmd=""
38stripcmd=""
39rmcmd="$rmprog -f"
40mvcmd="$mvprog"
41src=""
42dst=""
43dir_arg=""
44
45while [ x"$1" != x ]; do
46    case $1 in
47        -c) instcmd="$cpprog"
48            shift
49            continue;;
50
51        -d) dir_arg=true
52            shift
53            continue;;
54
55        -m) chmodcmd="$chmodprog $2"
56            shift
57            shift
58            continue;;
59
60        -o) chowncmd="$chownprog $2"
61            shift
62            shift
63            continue;;
64
65        -g) chgrpcmd="$chgrpprog $2"
66            shift
67            shift
68            continue;;
69
70        -s) stripcmd="$stripprog"
71            shift
72            continue;;
73
74        -t=*) transformarg=`echo $1 | sed 's/-t=//'`
75            shift
76            continue;;
77
78        -b=*) transformbasename=`echo $1 | sed 's/-b=//'`
79            shift
80            continue;;
81
82        *)  if [ x"$src" = x ]
83            then
84                src=$1
85            else
86                # this colon is to work around a 386BSD /bin/sh bug
87                :
88                dst=$1
89            fi
90            shift
91            continue;;
92    esac
93done
94
95if [ x"$src" = x ]
96then
97        echo "install:  no input file specified"
98        exit 1
99else
100        true
101fi
102
103if [ x"$dir_arg" != x ]; then
104        dst=$src
105        src=""
106       
107        if [ -d $dst ]; then
108                instcmd=:
109        else
110                instcmd=mkdir
111        fi
112else
113
114# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
115# might cause directories to be created, which would be especially bad
116# if $src (and thus $dsttmp) contains '*'.
117
118# obachman 6/15/98
119# Here is an ugly fix for a bug in cygwin
120# '[ test -f $src ]' evaluates to true, even if only $src.exe exists
121# However 'cp $src $dst' can  not find $src, if only $src.exe exists
122        if test -f "$src.exe" && test -x "$src.exe"; then
123                src="$src.exe"
124                true
125        elif [ -f $src -o -d $src ]
126        then
127                true
128        else
129                echo "install:  $src does not exist"
130                exit 1
131        fi
132       
133        if [ x"$dst" = x ]
134        then
135                echo "install:  no destination specified"
136                exit 1
137        else
138                true
139        fi
140
141# If destination is a directory, append the input filename; if your system
142# does not like double slashes in filenames, you may need to add some logic
143
144        if [ -d $dst ]
145        then
146                dst="$dst"/`basename $src`
147        else
148                true
149        fi
150fi
151
152## this sed command emulates the dirname command
153dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
154
155# Make sure that the destination directory exists.
156#  this part is taken from Noah Friedman's mkinstalldirs script
157
158# Skip lots of stat calls in the usual case.
159if [ ! -d "$dstdir" ]; then
160defaultIFS='   
161'
162IFS="${IFS-${defaultIFS}}"
163
164oIFS="${IFS}"
165# Some sh's can't handle IFS=/ for some reason.
166IFS='%'
167set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
168IFS="${oIFS}"
169
170pathcomp=''
171
172while [ $# -ne 0 ] ; do
173        pathcomp="${pathcomp}${1}"
174        shift
175
176        if [ ! -d "${pathcomp}" ] ;
177        then
178                $mkdirprog "${pathcomp}"
179        else
180                true
181        fi
182
183        pathcomp="${pathcomp}/"
184done
185fi
186
187if [ x"$dir_arg" != x ]
188then
189        $doit $instcmd $dst &&
190
191        if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
192        if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
193        if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
194        if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
195else
196
197# If we're going to rename the final executable, determine the name now.
198
199        if [ x"$transformarg" = x ] 
200        then
201                dstfile=`basename $dst`
202        else
203                echo "basename $dst $transformbasename | sed $transformarg$transformbasename"
204                dstfile=`basename $dst $transformbasename | 
205                        sed $transformarg`$transformbasename
206        fi
207
208# don't allow the sed command to completely eliminate the filename
209
210        if [ x"$dstfile" = x ] 
211        then
212                dstfile=`basename $dst`
213        else
214                true
215        fi
216
217# Make a temp file name in the proper directory.
218
219        dsttmp=$dstdir/#inst.$$#
220
221# Move or copy the file name to the temp name
222
223        $doit $instcmd $src $dsttmp &&
224
225        trap "rm -f ${dsttmp}" 0 &&
226
227# and set any options; do chmod last to preserve setuid bits
228
229# If any of these fail, we abort the whole thing.  If we want to
230# ignore errors from any of these, just make sure not to ignore
231# errors from the above "$doit $instcmd $src $dsttmp" command.
232
233        if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
234        if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
235        if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
236        if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
237
238# Now rename the file to the real destination.
239
240        $doit $rmcmd -f $dstdir/$dstfile &&
241        $doit $mvcmd $dsttmp $dstdir/$dstfile 
242
243fi &&
244
245
246exit 0
Note: See TracBrowser for help on using the repository browser.