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