5 # install - install a program, script, or datafile
6 # This comes from X11R5; it is not part of GNU.
8 # $XConsortium: install.sh,v 1.2 89/12/18 14:47:22 jim Exp $
10 # This script is compatible with the BSD install script, but was written
15 # set DOITPROG to echo to test this script
17 # Don't use :- since 4.3BSD and earlier shells don't like it.
21 # put in absolute paths if you don't have them in your path; or use env. vars.
25 chmodprog
="${CHMODPROG-chmod}"
26 chownprog
="${CHOWNPROG-chown}"
27 chgrpprog
="${CHGRPPROG-chgrp}"
28 stripprog
="${STRIPPROG-strip}"
30 mkdirprog
="${MKDIRPROG-mkdir}"
44 while [ x
"$1" != x
]; do
50 -m) chmodcmd
="$chmodprog $2"
55 -o) chowncmd
="$chownprog $2"
60 -g) chgrpcmd
="$chgrpprog $2"
65 -s) stripcmd
="$stripprog"
69 -t=*) transformarg
=`echo $1 | sed 's/-t=//'`
73 -b=*) transformbasename
=`echo $1 | sed 's/-b=//'`
90 echo "install: no input file specified"
98 echo "install: no destination specified"
104 # If destination is a directory, append the input filename; if your system
105 # does not like double slashes in filenames, you may need to add some logic
109 dst
="$dst"/`basename $src`
115 # Make a temp file name in the proper directory.
117 ## this sed command emulates the dirname command
118 dstdir
=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
119 dsttmp
=$dstdir/#inst.$$#
121 # Make sure that the destination directory exists.
122 # this part is taken from Noah Friedman's mkinstalldirs script
126 IFS
="${IFS-${defaultIFS}}"
129 # Some sh's can't handle IFS=/ for some reason.
131 set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
136 while [ $# -ne 0 ] ; do
137 pathcomp
="${pathcomp}${1}"
140 if [ ! -d "${pathcomp}" ] ;
142 $mkdirprog "${pathcomp}"
147 pathcomp
="${pathcomp}/"
150 # If we're going to rename the final executable, determine the name now.
152 if [ x
"$transformarg" = x
]
154 dstfile
=`basename $dst`
156 dstfile
=`basename $dst $transformbasename | sed $transformarg`$transformbasename
159 # don't allow the sed command to completely eliminate the filename
161 if [ x
"$dstfile" = x
]
163 dstfile
=`basename $dst`
168 # Move or copy the file name to the temp name
170 $doit $instcmd $src $dsttmp
172 # and set any options; do chmod last to preserve setuid bits
174 if [ x
"$chowncmd" != x
]; then $doit $chowncmd $dsttmp; fi
175 if [ x
"$chgrpcmd" != x
]; then $doit $chgrpcmd $dsttmp; fi
176 if [ x
"$stripcmd" != x
]; then $doit $stripcmd $dsttmp; fi
177 if [ x
"$chmodcmd" != x
]; then $doit $chmodcmd $dsttmp; fi
179 # Now rename the file to the real destination.
181 $doit $rmcmd $dstdir/$dstfile
182 $doit $mvcmd $dsttmp $dstdir/$dstfile
This page took 0.032227 seconds and 4 git commands to generate.