initial
[zsh.git] / .zsh / zsh-install.sh
1 #!/bin/sh
2 # This script was generated using Makeself 2.1.5
3
4 CRCsum="892806987"
5 MD5="7693a1a6a3059d119117a97087f0941d"
6 TMPROOT=${TMPDIR:=/tmp}
7
8 label="joerg ZSH config files"
9 script="zsh"
10 scriptargs="./install.zsh MAGIC"
11 targetdir="tmp.8fF7ppTk5s"
12 filesizes="43691"
13 keep=n
14
15 print_cmd_arg=""
16 if type printf > /dev/null; then
17 print_cmd="printf"
18 elif test -x /usr/ucb/echo; then
19 print_cmd="/usr/ucb/echo"
20 else
21 print_cmd="echo"
22 fi
23
24 unset CDPATH
25
26 MS_Printf()
27 {
28 $print_cmd $print_cmd_arg "$1"
29 }
30
31 MS_Progress()
32 {
33 while read a; do
34 MS_Printf .
35 done
36 }
37
38 MS_diskspace()
39 {
40 (
41 if test -d /usr/xpg4/bin; then
42 PATH=/usr/xpg4/bin:$PATH
43 fi
44 df -kP "$1" | tail -1 | awk '{print $4}'
45 )
46 }
47
48 MS_dd()
49 {
50 blocks=`expr $3 / 1024`
51 bytes=`expr $3 % 1024`
52 dd if="$1" ibs=$2 skip=1 obs=1024 conv=sync 2> /dev/null | \
53 { test $blocks -gt 0 && dd ibs=1024 obs=1024 count=$blocks ; \
54 test $bytes -gt 0 && dd ibs=1 obs=1024 count=$bytes ; } 2> /dev/null
55 }
56
57 MS_Help()
58 {
59 cat << EOH >&2
60 Makeself version 2.1.5
61 1) Getting help or info about $0 :
62 $0 --help Print this message
63 $0 --info Print embedded info : title, default target directory, embedded script ...
64 $0 --lsm Print embedded lsm entry (or no LSM)
65 $0 --list Print the list of files in the archive
66 $0 --check Checks integrity of the archive
67
68 2) Running $0 :
69 $0 [options] [--] [additional arguments to embedded script]
70 with following options (in that order)
71 --confirm Ask before running embedded script
72 --noexec Do not run embedded script
73 --keep Do not erase target directory after running
74 the embedded script
75 --nox11 Do not spawn an xterm
76 --nochown Do not give the extracted files to the current user
77 --target NewDirectory Extract in NewDirectory
78 --tar arg1 [arg2 ...] Access the contents of the archive through the tar command
79 -- Following arguments will be passed to the embedded script
80 EOH
81 }
82
83 MS_Check()
84 {
85 OLD_PATH="$PATH"
86 PATH=${GUESS_MD5_PATH:-"$OLD_PATH:/bin:/usr/bin:/sbin:/usr/local/ssl/bin:/usr/local/bin:/opt/openssl/bin"}
87 MD5_ARG=""
88 MD5_PATH=`exec <&- 2>&-; which md5sum || type md5sum`
89 test -x "$MD5_PATH" || MD5_PATH=`exec <&- 2>&-; which md5 || type md5`
90 test -x "$MD5_PATH" || MD5_PATH=`exec <&- 2>&-; which digest || type digest`
91 PATH="$OLD_PATH"
92
93 MS_Printf "Verifying archive integrity..."
94 offset=`head -n 404 "$1" | wc -c | tr -d " "`
95 verb=$2
96 i=1
97 for s in $filesizes
98 do
99 crc=`echo $CRCsum | cut -d" " -f$i`
100 if test -x "$MD5_PATH"; then
101 if test `basename $MD5_PATH` = digest; then
102 MD5_ARG="-a md5"
103 fi
104 md5=`echo $MD5 | cut -d" " -f$i`
105 if test $md5 = "00000000000000000000000000000000"; then
106 test x$verb = xy && echo " $1 does not contain an embedded MD5 checksum." >&2
107 else
108 md5sum=`MS_dd "$1" $offset $s | eval "$MD5_PATH $MD5_ARG" | cut -b-32`;
109 if test "$md5sum" != "$md5"; then
110 echo "Error in MD5 checksums: $md5sum is different from $md5" >&2
111 exit 2
112 else
113 test x$verb = xy && MS_Printf " MD5 checksums are OK." >&2
114 fi
115 crc="0000000000"; verb=n
116 fi
117 fi
118 if test $crc = "0000000000"; then
119 test x$verb = xy && echo " $1 does not contain a CRC checksum." >&2
120 else
121 sum1=`MS_dd "$1" $offset $s | CMD_ENV=xpg4 cksum | awk '{print $1}'`
122 if test "$sum1" = "$crc"; then
123 test x$verb = xy && MS_Printf " CRC checksums are OK." >&2
124 else
125 echo "Error in checksums: $sum1 is different from $crc"
126 exit 2;
127 fi
128 fi
129 i=`expr $i + 1`
130 offset=`expr $offset + $s`
131 done
132 echo " All good."
133 }
134
135 UnTAR()
136 {
137 tar $1vf - 2>&1 || { echo Extraction failed. > /dev/tty; kill -15 $$; }
138 }
139
140 finish=true
141 xterm_loop=
142 nox11=n
143 copy=none
144 ownership=y
145 verbose=n
146
147 initargs="$@"
148
149 while true
150 do
151 case "$1" in
152 -h | --help)
153 MS_Help
154 exit 0
155 ;;
156 --info)
157 echo Identification: "$label"
158 echo Target directory: "$targetdir"
159 echo Uncompressed size: 496 KB
160 echo Compression: gzip
161 echo Date of packaging: Sun Feb 24 23:39:23 CET 2013
162 echo Built with Makeself version 2.1.5 on
163 echo Build command was: "/usr/bin/makeself \\
164 \"--gzip\" \\
165 \"/home/joerg/tmp/tmp.8fF7ppTk5s\" \\
166 \"/home/joerg/.zsh/zsh-install.sh\" \\
167 \"joerg ZSH config files\" \\
168 \"zsh\" \\
169 \"./install.zsh\" \\
170 \"MAGIC\""
171 if test x$script != x; then
172 echo Script run after extraction:
173 echo " " $script $scriptargs
174 fi
175 if test x"" = xcopy; then
176 echo "Archive will copy itself to a temporary location"
177 fi
178 if test x"n" = xy; then
179 echo "directory $targetdir is permanent"
180 else
181 echo "$targetdir will be removed after extraction"
182 fi
183 exit 0
184 ;;
185 --dumpconf)
186 echo LABEL=\"$label\"
187 echo SCRIPT=\"$script\"
188 echo SCRIPTARGS=\"$scriptargs\"
189 echo archdirname=\"tmp.8fF7ppTk5s\"
190 echo KEEP=n
191 echo COMPRESS=gzip
192 echo filesizes=\"$filesizes\"
193 echo CRCsum=\"$CRCsum\"
194 echo MD5sum=\"$MD5\"
195 echo OLDUSIZE=496
196 echo OLDSKIP=405
197 exit 0
198 ;;
199 --lsm)
200 cat << EOLSM
201 No LSM.
202 EOLSM
203 exit 0
204 ;;
205 --list)
206 echo Target directory: $targetdir
207 offset=`head -n 404 "$0" | wc -c | tr -d " "`
208 for s in $filesizes
209 do
210 MS_dd "$0" $offset $s | eval "gzip -cd" | UnTAR t
211 offset=`expr $offset + $s`
212 done
213 exit 0
214 ;;
215 --tar)
216 offset=`head -n 404 "$0" | wc -c | tr -d " "`
217 arg1="$2"
218 shift 2
219 for s in $filesizes
220 do
221 MS_dd "$0" $offset $s | eval "gzip -cd" | tar "$arg1" - $*
222 offset=`expr $offset + $s`
223 done
224 exit 0
225 ;;
226 --check)
227 MS_Check "$0" y
228 exit 0
229 ;;
230 --confirm)
231 verbose=y
232 shift
233 ;;
234 --noexec)
235 script=""
236 shift
237 ;;
238 --keep)
239 keep=y
240 shift
241 ;;
242 --target)
243 keep=y
244 targetdir=${2:-.}
245 shift 2
246 ;;
247 --nox11)
248 nox11=y
249 shift
250 ;;
251 --nochown)
252 ownership=n
253 shift
254 ;;
255 --xwin)
256 finish="echo Press Return to close this window...; read junk"
257 xterm_loop=1
258 shift
259 ;;
260 --phase2)
261 copy=phase2
262 shift
263 ;;
264 --)
265 shift
266 break ;;
267 -*)
268 echo Unrecognized flag : "$1" >&2
269 MS_Help
270 exit 1
271 ;;
272 *)
273 break ;;
274 esac
275 done
276
277 case "$copy" in
278 copy)
279 tmpdir=$TMPROOT/makeself.$RANDOM.`date +"%y%m%d%H%M%S"`.$$
280 mkdir "$tmpdir" || {
281 echo "Could not create temporary directory $tmpdir" >&2
282 exit 1
283 }
284 SCRIPT_COPY="$tmpdir/makeself"
285 echo "Copying to a temporary location..." >&2
286 cp "$0" "$SCRIPT_COPY"
287 chmod +x "$SCRIPT_COPY"
288 cd "$TMPROOT"
289 exec "$SCRIPT_COPY" --phase2 -- $initargs
290 ;;
291 phase2)
292 finish="$finish ; rm -rf `dirname $0`"
293 ;;
294 esac
295
296 if test "$nox11" = "n"; then
297 if tty -s; then # Do we have a terminal?
298 :
299 else
300 if test x"$DISPLAY" != x -a x"$xterm_loop" = x; then # No, but do we have X?
301 if xset q > /dev/null 2>&1; then # Check for valid DISPLAY variable
302 GUESS_XTERMS="xterm rxvt dtterm eterm Eterm kvt konsole aterm"
303 for a in $GUESS_XTERMS; do
304 if type $a >/dev/null 2>&1; then
305 XTERM=$a
306 break
307 fi
308 done
309 chmod a+x $0 || echo Please add execution rights on $0
310 if test `echo "$0" | cut -c1` = "/"; then # Spawn a terminal!
311 exec $XTERM -title "$label" -e "$0" --xwin "$initargs"
312 else
313 exec $XTERM -title "$label" -e "./$0" --xwin "$initargs"
314 fi
315 fi
316 fi
317 fi
318 fi
319
320 if test "$targetdir" = "."; then
321 tmpdir="."
322 else
323 if test "$keep" = y; then
324 echo "Creating directory $targetdir" >&2
325 tmpdir="$targetdir"
326 dashp="-p"
327 else
328 tmpdir="$TMPROOT/selfgz$$$RANDOM"
329 dashp=""
330 fi
331 mkdir $dashp $tmpdir || {
332 echo 'Cannot create target directory' $tmpdir >&2
333 echo 'You should try option --target OtherDirectory' >&2
334 eval $finish
335 exit 1
336 }
337 fi
338
339 location="`pwd`"
340 if test x$SETUP_NOCHECK != x1; then
341 MS_Check "$0"
342 fi
343 offset=`head -n 404 "$0" | wc -c | tr -d " "`
344
345 if test x"$verbose" = xy; then
346 MS_Printf "About to extract 496 KB in $tmpdir ... Proceed ? [Y/n] "
347 read yn
348 if test x"$yn" = xn; then
349 eval $finish; exit 1
350 fi
351 fi
352
353 MS_Printf "Uncompressing $label"
354 res=3
355 if test "$keep" = n; then
356 trap 'echo Signal caught, cleaning up >&2; cd $TMPROOT; /bin/rm -rf $tmpdir; eval $finish; exit 15' 1 2 3 15
357 fi
358
359 leftspace=`MS_diskspace $tmpdir`
360 if test $leftspace -lt 496; then
361 echo
362 echo "Not enough space left in "`dirname $tmpdir`" ($leftspace KB) to decompress $0 (496 KB)" >&2
363 if test "$keep" = n; then
364 echo "Consider setting TMPDIR to a directory with more free space."
365 fi
366 eval $finish; exit 1
367 fi
368
369 for s in $filesizes
370 do
371 if MS_dd "$0" $offset $s | eval "gzip -cd" | ( cd "$tmpdir"; UnTAR x ) | MS_Progress; then
372 if test x"$ownership" = xy; then
373 (PATH=/usr/xpg4/bin:$PATH; cd "$tmpdir"; chown -R `id -u` .; chgrp -R `id -g` .)
374 fi
375 else
376 echo
377 echo "Unable to decompress $0" >&2
378 eval $finish; exit 1
379 fi
380 offset=`expr $offset + $s`
381 done
382 echo
383
384 cd "$tmpdir"
385 res=0
386 if test x"$script" != x; then
387 if test x"$verbose" = xy; then
388 MS_Printf "OK to execute: $script $scriptargs $* ? [Y/n] "
389 read yn
390 if test x"$yn" = x -o x"$yn" = xy -o x"$yn" = xY; then
391 eval $script $scriptargs $*; res=$?;
392 fi
393 else
394 eval $script $scriptargs $*; res=$?
395 fi
396 if test $res -ne 0; then
397 test x"$verbose" = xy && echo "The program '$script' returned an error code ($res)" >&2
398 fi
399 fi
400 if test "$keep" = n; then
401 cd $TMPROOT
402 /bin/rm -rf $tmpdir
403 fi
404 eval $finish; exit $res
405 \1f\8b\b