Back to home page

MITgcm

 
 

    


Warning, /tools/cyrus-imapd-makedepend/install-sh is written in an unsupported language. File is not indexed.

view on githubraw file Latest commit bf5846c3 on 2004-02-25 18:19:54 UTC
bf5846c3a1 Ed H*0001 #!/bin/sh
                0002 # 
                0003 # Copyright (c) 2000 Carnegie Mellon University.  All rights reserved.
                0004 #
                0005 # Redistribution and use in source and binary forms, with or without
                0006 # modification, are permitted provided that the following conditions
                0007 # are met:
                0008 #
                0009 # 1. Redistributions of source code must retain the above copyright
                0010 #    notice, this list of conditions and the following disclaimer. 
                0011 #
                0012 # 2. Redistributions in binary form must reproduce the above copyright
                0013 #    notice, this list of conditions and the following disclaimer in
                0014 #    the documentation and/or other materials provided with the
                0015 #    distribution.
                0016 #
                0017 # 3. The name "Carnegie Mellon University" must not be used to
                0018 #    endorse or promote products derived from this software without
                0019 #    prior written permission. For permission or any other legal
                0020 #    details, please contact  
                0021 #      Office of Technology Transfer
                0022 #      Carnegie Mellon University
                0023 #      5000 Forbes Avenue
                0024 #      Pittsburgh, PA  15213-3890
                0025 #      (412) 268-4387, fax: (412) 268-7395
                0026 #      tech-transfer@andrew.cmu.edu
                0027 #
                0028 # 4. Redistributions of any form whatsoever must retain the following
                0029 #    acknowledgment:
                0030 #    "This product includes software developed by Computing Services
                0031 #     at Carnegie Mellon University (http://www.cmu.edu/computing/)."
                0032 #
                0033 # CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
                0034 # THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
                0035 # AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
                0036 # FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
                0037 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
                0038 # AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
                0039 # OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
                0040 #
                0041 # install - install a program, script, or datafile
                0042 # This comes from X11R5.
                0043 #
                0044 # Calling this script install-sh is preferred over install.sh, to prevent
                0045 # `make' implicit rules from creating a file called install from it
                0046 # when there is no Makefile.
                0047 #
                0048 # This script is compatible with the BSD install script, but was written
                0049 # from scratch.
                0050 #
                0051 
                0052 
                0053 # set DOITPROG to echo to test this script
                0054 
                0055 # Don't use :- since 4.3BSD and earlier shells don't like it.
                0056 doit="${DOITPROG-}"
                0057 
                0058 
                0059 # put in absolute paths if you don't have them in your path; or use env. vars.
                0060 
                0061 mvprog="${MVPROG-mv}"
                0062 cpprog="${CPPROG-cp}"
                0063 chmodprog="${CHMODPROG-chmod}"
                0064 chownprog="${CHOWNPROG-chown}"
                0065 chgrpprog="${CHGRPPROG-chgrp}"
                0066 stripprog="${STRIPPROG-strip}"
                0067 rmprog="${RMPROG-rm}"
                0068 mkdirprog="${MKDIRPROG-mkdir}"
                0069 
                0070 tranformbasename=""
                0071 transform_arg=""
                0072 instcmd="$mvprog"
                0073 chmodcmd="$chmodprog 0755"
                0074 chowncmd=""
                0075 chgrpcmd=""
                0076 stripcmd=""
                0077 rmcmd="$rmprog -f"
                0078 mvcmd="$mvprog"
                0079 src=""
                0080 dst=""
                0081 dir_arg=""
                0082 
                0083 while [ x"$1" != x ]; do
                0084     case $1 in
                0085         -c) instcmd="$cpprog"
                0086             shift
                0087             continue;;
                0088 
                0089         -d) dir_arg=true
                0090             shift
                0091             continue;;
                0092 
                0093         -m) chmodcmd="$chmodprog $2"
                0094             shift
                0095             shift
                0096             continue;;
                0097 
                0098         -o) chowncmd="$chownprog $2"
                0099             shift
                0100             shift
                0101             continue;;
                0102 
                0103         -g) chgrpcmd="$chgrpprog $2"
                0104             shift
                0105             shift
                0106             continue;;
                0107 
                0108         -s) stripcmd="$stripprog"
                0109             shift
                0110             continue;;
                0111 
                0112         -t=*) transformarg=`echo $1 | sed 's/-t=//'`
                0113             shift
                0114             continue;;
                0115 
                0116         -b=*) transformbasename=`echo $1 | sed 's/-b=//'`
                0117             shift
                0118             continue;;
                0119 
                0120         *)  if [ x"$src" = x ]
                0121             then
                0122                 src=$1
                0123             else
                0124                 # this colon is to work around a 386BSD /bin/sh bug
                0125                 :
                0126                 dst=$1
                0127             fi
                0128             shift
                0129             continue;;
                0130     esac
                0131 done
                0132 
                0133 if [ x"$src" = x ]
                0134 then
                0135         echo "install:  no input file specified"
                0136         exit 1
                0137 else
                0138         true
                0139 fi
                0140 
                0141 if [ x"$dir_arg" != x ]; then
                0142         dst=$src
                0143         src=""
                0144         
                0145         if [ -d $dst ]; then
                0146                 instcmd=:
                0147         else
                0148                 instcmd=mkdir
                0149         fi
                0150 else
                0151 
                0152 # Waiting for this to be detected by the "$instcmd $src $dsttmp" command
                0153 # might cause directories to be created, which would be especially bad 
                0154 # if $src (and thus $dsttmp) contains '*'.
                0155 
                0156         if [ -f $src -o -d $src ]
                0157         then
                0158                 true
                0159         else
                0160                 echo "install:  $src does not exist"
                0161                 exit 1
                0162         fi
                0163         
                0164         if [ x"$dst" = x ]
                0165         then
                0166                 echo "install:  no destination specified"
                0167                 exit 1
                0168         else
                0169                 true
                0170         fi
                0171 
                0172 # If destination is a directory, append the input filename; if your system
                0173 # does not like double slashes in filenames, you may need to add some logic
                0174 
                0175         if [ -d $dst ]
                0176         then
                0177                 dst="$dst"/`basename $src`
                0178         else
                0179                 true
                0180         fi
                0181 fi
                0182 
                0183 ## this sed command emulates the dirname command
                0184 dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
                0185 
                0186 # Make sure that the destination directory exists.
                0187 #  this part is taken from Noah Friedman's mkinstalldirs script
                0188 
                0189 # Skip lots of stat calls in the usual case.
                0190 if [ ! -d "$dstdir" ]; then
                0191 defaultIFS='    
                0192 '
                0193 IFS="${IFS-${defaultIFS}}"
                0194 
                0195 oIFS="${IFS}"
                0196 # Some sh's can't handle IFS=/ for some reason.
                0197 IFS='%'
                0198 set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
                0199 IFS="${oIFS}"
                0200 
                0201 pathcomp=''
                0202 
                0203 while [ $# -ne 0 ] ; do
                0204         pathcomp="${pathcomp}${1}"
                0205         shift
                0206 
                0207         if [ ! -d "${pathcomp}" ] ;
                0208         then
                0209                 $mkdirprog "${pathcomp}"
                0210         else
                0211                 true
                0212         fi
                0213 
                0214         pathcomp="${pathcomp}/"
                0215 done
                0216 fi
                0217 
                0218 if [ x"$dir_arg" != x ]
                0219 then
                0220         $doit $instcmd $dst &&
                0221 
                0222         if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
                0223         if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
                0224         if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
                0225         if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
                0226 else
                0227 
                0228 # If we're going to rename the final executable, determine the name now.
                0229 
                0230         if [ x"$transformarg" = x ] 
                0231         then
                0232                 dstfile=`basename $dst`
                0233         else
                0234                 dstfile=`basename $dst $transformbasename | 
                0235                         sed $transformarg`$transformbasename
                0236         fi
                0237 
                0238 # don't allow the sed command to completely eliminate the filename
                0239 
                0240         if [ x"$dstfile" = x ] 
                0241         then
                0242                 dstfile=`basename $dst`
                0243         else
                0244                 true
                0245         fi
                0246 
                0247 # Make a temp file name in the proper directory.
                0248 
                0249         dsttmp=$dstdir/#inst.$$#
                0250 
                0251 # Move or copy the file name to the temp name
                0252 
                0253         $doit $instcmd $src $dsttmp &&
                0254 
                0255         trap "rm -f ${dsttmp}" 0 &&
                0256 
                0257 # and set any options; do chmod last to preserve setuid bits
                0258 
                0259 # If any of these fail, we abort the whole thing.  If we want to
                0260 # ignore errors from any of these, just make sure not to ignore
                0261 # errors from the above "$doit $instcmd $src $dsttmp" command.
                0262 
                0263         if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
                0264         if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
                0265         if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
                0266         if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
                0267 
                0268 # Now rename the file to the real destination.
                0269 
                0270         $doit $rmcmd -f $dstdir/$dstfile &&
                0271         $doit $mvcmd $dsttmp $dstdir/$dstfile 
                0272 
                0273 fi &&
                0274 
                0275 
                0276 exit 0