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