annotate CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/share/icu/67.1/install-sh @ 68:5028fdace37b

planemo upload commit 2e9511a184a1ca667c7be0c6321a36dc4e3d116d
author jpayne
date Tue, 18 Mar 2025 16:23:26 -0400
parents
children
rev   line source
jpayne@68 1 #!/bin/sh
jpayne@68 2 #
jpayne@68 3 # install - install a program, script, or datafile
jpayne@68 4 # This comes from X11R5 (mit/util/scripts/install.sh).
jpayne@68 5 #
jpayne@68 6 # Copyright 1991 by the Massachusetts Institute of Technology
jpayne@68 7 #
jpayne@68 8 # Permission to use, copy, modify, distribute, and sell this software and its
jpayne@68 9 # documentation for any purpose is hereby granted without fee, provided that
jpayne@68 10 # the above copyright notice appear in all copies and that both that
jpayne@68 11 # copyright notice and this permission notice appear in supporting
jpayne@68 12 # documentation, and that the name of M.I.T. not be used in advertising or
jpayne@68 13 # publicity pertaining to distribution of the software without specific,
jpayne@68 14 # written prior permission. M.I.T. makes no representations about the
jpayne@68 15 # suitability of this software for any purpose. It is provided "as is"
jpayne@68 16 # without express or implied warranty.
jpayne@68 17 #
jpayne@68 18 # Calling this script install-sh is preferred over install.sh, to prevent
jpayne@68 19 # `make' implicit rules from creating a file called install from it
jpayne@68 20 # when there is no Makefile.
jpayne@68 21 #
jpayne@68 22 # This script is compatible with the BSD install script, but was written
jpayne@68 23 # from scratch. It can only install one file at a time, a restriction
jpayne@68 24 # shared with many OS's install programs.
jpayne@68 25
jpayne@68 26
jpayne@68 27 # set DOITPROG to echo to test this script
jpayne@68 28
jpayne@68 29 # Don't use :- since 4.3BSD and earlier shells don't like it.
jpayne@68 30 doit="${DOITPROG-}"
jpayne@68 31
jpayne@68 32
jpayne@68 33 # put in absolute paths if you don't have them in your path; or use env. vars.
jpayne@68 34
jpayne@68 35 mvprog="${MVPROG-mv}"
jpayne@68 36 cpprog="${CPPROG-cp}"
jpayne@68 37 chmodprog="${CHMODPROG-chmod}"
jpayne@68 38 chownprog="${CHOWNPROG-chown}"
jpayne@68 39 chgrpprog="${CHGRPPROG-chgrp}"
jpayne@68 40 stripprog="${STRIPPROG-strip}"
jpayne@68 41 rmprog="${RMPROG-rm}"
jpayne@68 42 mkdirprog="${MKDIRPROG-mkdir}"
jpayne@68 43
jpayne@68 44 transformbasename=""
jpayne@68 45 transform_arg=""
jpayne@68 46 instcmd="$mvprog"
jpayne@68 47 chmodcmd="$chmodprog 0755"
jpayne@68 48 chowncmd=""
jpayne@68 49 chgrpcmd=""
jpayne@68 50 stripcmd=""
jpayne@68 51 rmcmd="$rmprog -f"
jpayne@68 52 mvcmd="$mvprog"
jpayne@68 53 src=""
jpayne@68 54 dst=""
jpayne@68 55 dir_arg=""
jpayne@68 56
jpayne@68 57 while [ x"$1" != x ]; do
jpayne@68 58 case $1 in
jpayne@68 59 -c) instcmd="$cpprog"
jpayne@68 60 shift
jpayne@68 61 continue;;
jpayne@68 62
jpayne@68 63 -d) dir_arg=true
jpayne@68 64 shift
jpayne@68 65 continue;;
jpayne@68 66
jpayne@68 67 -m) chmodcmd="$chmodprog $2"
jpayne@68 68 shift
jpayne@68 69 shift
jpayne@68 70 continue;;
jpayne@68 71
jpayne@68 72 -o) chowncmd="$chownprog $2"
jpayne@68 73 shift
jpayne@68 74 shift
jpayne@68 75 continue;;
jpayne@68 76
jpayne@68 77 -g) chgrpcmd="$chgrpprog $2"
jpayne@68 78 shift
jpayne@68 79 shift
jpayne@68 80 continue;;
jpayne@68 81
jpayne@68 82 -s) stripcmd="$stripprog"
jpayne@68 83 shift
jpayne@68 84 continue;;
jpayne@68 85
jpayne@68 86 -t=*) transformarg=`echo $1 | sed 's/-t=//'`
jpayne@68 87 shift
jpayne@68 88 continue;;
jpayne@68 89
jpayne@68 90 -b=*) transformbasename=`echo $1 | sed 's/-b=//'`
jpayne@68 91 shift
jpayne@68 92 continue;;
jpayne@68 93
jpayne@68 94 *) if [ x"$src" = x ]
jpayne@68 95 then
jpayne@68 96 src=$1
jpayne@68 97 else
jpayne@68 98 # this colon is to work around a 386BSD /bin/sh bug
jpayne@68 99 :
jpayne@68 100 dst=$1
jpayne@68 101 fi
jpayne@68 102 shift
jpayne@68 103 continue;;
jpayne@68 104 esac
jpayne@68 105 done
jpayne@68 106
jpayne@68 107 if [ x"$src" = x ]
jpayne@68 108 then
jpayne@68 109 echo "install: no input file specified"
jpayne@68 110 exit 1
jpayne@68 111 else
jpayne@68 112 true
jpayne@68 113 fi
jpayne@68 114
jpayne@68 115 if [ x"$dir_arg" != x ]; then
jpayne@68 116 dst=$src
jpayne@68 117 src=""
jpayne@68 118
jpayne@68 119 if [ -d $dst ]; then
jpayne@68 120 instcmd=:
jpayne@68 121 chmodcmd=""
jpayne@68 122 else
jpayne@68 123 instcmd=mkdir
jpayne@68 124 fi
jpayne@68 125 else
jpayne@68 126
jpayne@68 127 # Waiting for this to be detected by the "$instcmd $src $dsttmp" command
jpayne@68 128 # might cause directories to be created, which would be especially bad
jpayne@68 129 # if $src (and thus $dsttmp) contains '*'.
jpayne@68 130
jpayne@68 131 if [ -f $src -o -d $src ]
jpayne@68 132 then
jpayne@68 133 true
jpayne@68 134 else
jpayne@68 135 echo "install: $src does not exist"
jpayne@68 136 exit 1
jpayne@68 137 fi
jpayne@68 138
jpayne@68 139 if [ x"$dst" = x ]
jpayne@68 140 then
jpayne@68 141 echo "install: no destination specified"
jpayne@68 142 exit 1
jpayne@68 143 else
jpayne@68 144 true
jpayne@68 145 fi
jpayne@68 146
jpayne@68 147 # If destination is a directory, append the input filename; if your system
jpayne@68 148 # does not like double slashes in filenames, you may need to add some logic
jpayne@68 149
jpayne@68 150 if [ -d $dst ]
jpayne@68 151 then
jpayne@68 152 dst="$dst"/`basename $src`
jpayne@68 153 else
jpayne@68 154 true
jpayne@68 155 fi
jpayne@68 156 fi
jpayne@68 157
jpayne@68 158 ## this sed command emulates the dirname command
jpayne@68 159 dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
jpayne@68 160
jpayne@68 161 # Make sure that the destination directory exists.
jpayne@68 162 # this part is taken from Noah Friedman's mkinstalldirs script
jpayne@68 163
jpayne@68 164 # Skip lots of stat calls in the usual case.
jpayne@68 165 if [ ! -d "$dstdir" ]; then
jpayne@68 166 defaultIFS='
jpayne@68 167 '
jpayne@68 168 IFS="${IFS-${defaultIFS}}"
jpayne@68 169
jpayne@68 170 oIFS="${IFS}"
jpayne@68 171 # Some sh's can't handle IFS=/ for some reason.
jpayne@68 172 IFS='%'
jpayne@68 173 set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
jpayne@68 174 IFS="${oIFS}"
jpayne@68 175
jpayne@68 176 pathcomp=''
jpayne@68 177
jpayne@68 178 while [ $# -ne 0 ] ; do
jpayne@68 179 pathcomp="${pathcomp}${1}"
jpayne@68 180 shift
jpayne@68 181
jpayne@68 182 if [ ! -d "${pathcomp}" ] ;
jpayne@68 183 then
jpayne@68 184 $mkdirprog "${pathcomp}"
jpayne@68 185 else
jpayne@68 186 true
jpayne@68 187 fi
jpayne@68 188
jpayne@68 189 pathcomp="${pathcomp}/"
jpayne@68 190 done
jpayne@68 191 fi
jpayne@68 192
jpayne@68 193 if [ x"$dir_arg" != x ]
jpayne@68 194 then
jpayne@68 195 $doit $instcmd $dst &&
jpayne@68 196
jpayne@68 197 if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
jpayne@68 198 if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
jpayne@68 199 if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
jpayne@68 200 if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
jpayne@68 201 else
jpayne@68 202
jpayne@68 203 # If we're going to rename the final executable, determine the name now.
jpayne@68 204
jpayne@68 205 if [ x"$transformarg" = x ]
jpayne@68 206 then
jpayne@68 207 dstfile=`basename $dst`
jpayne@68 208 else
jpayne@68 209 dstfile=`basename $dst $transformbasename |
jpayne@68 210 sed $transformarg`$transformbasename
jpayne@68 211 fi
jpayne@68 212
jpayne@68 213 # don't allow the sed command to completely eliminate the filename
jpayne@68 214
jpayne@68 215 if [ x"$dstfile" = x ]
jpayne@68 216 then
jpayne@68 217 dstfile=`basename $dst`
jpayne@68 218 else
jpayne@68 219 true
jpayne@68 220 fi
jpayne@68 221
jpayne@68 222 # Make a temp file name in the proper directory.
jpayne@68 223
jpayne@68 224 dsttmp=$dstdir/#inst.$$#
jpayne@68 225
jpayne@68 226 # Move or copy the file name to the temp name
jpayne@68 227
jpayne@68 228 $doit $instcmd $src $dsttmp &&
jpayne@68 229
jpayne@68 230 trap "rm -f ${dsttmp}" 0 &&
jpayne@68 231
jpayne@68 232 # and set any options; do chmod last to preserve setuid bits
jpayne@68 233
jpayne@68 234 # If any of these fail, we abort the whole thing. If we want to
jpayne@68 235 # ignore errors from any of these, just make sure not to ignore
jpayne@68 236 # errors from the above "$doit $instcmd $src $dsttmp" command.
jpayne@68 237
jpayne@68 238 if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
jpayne@68 239 if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
jpayne@68 240 if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
jpayne@68 241 if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
jpayne@68 242
jpayne@68 243 # Now rename the file to the real destination.
jpayne@68 244
jpayne@68 245 $doit $rmcmd -f $dstdir/$dstfile &&
jpayne@68 246 $doit $mvcmd $dsttmp $dstdir/$dstfile
jpayne@68 247
jpayne@68 248 fi &&
jpayne@68 249
jpayne@68 250
jpayne@68 251 exit 0