makeself-header.sh 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717
  1. # SPDX-License-Identifier: GPL-2.0-or-later
  2. # shellcheck shell=sh
  3. # shellcheck disable=SC2154,SC2039
  4. cat << EOF > "$archname"
  5. #!/bin/sh
  6. # This script was generated using Makeself $MS_VERSION
  7. # The license covering this archive and its contents, if any, is wholly independent of the Makeself license (GPL)
  8. ORIG_UMASK=\`umask\`
  9. if test "$KEEP_UMASK" = n; then
  10. umask 077
  11. fi
  12. CRCsum="$CRCsum"
  13. MD5="$MD5sum"
  14. SHA="$SHAsum"
  15. SIGNATURE="$Signature"
  16. TMPROOT=\${TMPDIR:=/tmp}
  17. USER_PWD="\$PWD"
  18. export USER_PWD
  19. ARCHIVE_DIR=\`dirname "\$0"\`
  20. export ARCHIVE_DIR
  21. label="$LABEL"
  22. script="$SCRIPT"
  23. scriptargs="$SCRIPTARGS"
  24. cleanup_script="${CLEANUP_SCRIPT}"
  25. licensetxt="$LICENSE"
  26. helpheader="${HELPHEADER}"
  27. targetdir="$archdirname"
  28. filesizes="$filesizes"
  29. totalsize="$totalsize"
  30. keep="$KEEP"
  31. nooverwrite="$NOOVERWRITE"
  32. quiet="n"
  33. accept="n"
  34. nodiskspace="n"
  35. export_conf="$EXPORT_CONF"
  36. decrypt_cmd="$DECRYPT_CMD"
  37. skip="$SKIP"
  38. print_cmd_arg=""
  39. if type printf > /dev/null; then
  40. print_cmd="printf"
  41. elif test -x /usr/ucb/echo; then
  42. print_cmd="/usr/ucb/echo"
  43. else
  44. print_cmd="echo"
  45. fi
  46. if test -d /usr/xpg4/bin; then
  47. PATH=/usr/xpg4/bin:\$PATH
  48. export PATH
  49. fi
  50. if test -d /usr/sfw/bin; then
  51. PATH=\$PATH:/usr/sfw/bin
  52. export PATH
  53. fi
  54. unset CDPATH
  55. MS_Printf()
  56. {
  57. \$print_cmd \$print_cmd_arg "\$1"
  58. }
  59. MS_PrintLicense()
  60. {
  61. PAGER=\${PAGER:=more}
  62. if test x"\$licensetxt" != x; then
  63. PAGER_PATH=\`exec <&- 2>&-; which \$PAGER || command -v \$PAGER || type \$PAGER\`
  64. if test -x "\$PAGER_PATH" && test x"\$accept" != xy; then
  65. echo "\$licensetxt" | \$PAGER
  66. else
  67. echo "\$licensetxt"
  68. fi
  69. if test x"\$accept" != xy; then
  70. while true
  71. do
  72. MS_Printf "Please type y to accept, n otherwise: "
  73. read yn
  74. if test x"\$yn" = xn; then
  75. keep=n
  76. eval \$finish; exit 1
  77. break;
  78. elif test x"\$yn" = xy; then
  79. break;
  80. fi
  81. done
  82. fi
  83. fi
  84. }
  85. MS_diskspace()
  86. {
  87. (
  88. df -k "\$1" | tail -1 | awk '{ if (\$4 ~ /%/) {print \$3} else {print \$4} }'
  89. )
  90. }
  91. MS_dd()
  92. {
  93. blocks=\`expr \$3 / 1024\`
  94. bytes=\`expr \$3 % 1024\`
  95. # Test for ibs, obs and conv feature
  96. if dd if=/dev/zero of=/dev/null count=1 ibs=512 obs=512 conv=sync 2> /dev/null; then
  97. dd if="\$1" ibs=\$2 skip=1 obs=1024 conv=sync 2> /dev/null | \\
  98. { test \$blocks -gt 0 && dd ibs=1024 obs=1024 count=\$blocks ; \\
  99. test \$bytes -gt 0 && dd ibs=1 obs=1024 count=\$bytes ; } 2> /dev/null
  100. else
  101. dd if="\$1" bs=\$2 skip=1 2> /dev/null
  102. fi
  103. }
  104. MS_dd_Progress()
  105. {
  106. if test x"\$noprogress" = xy; then
  107. MS_dd "\$@"
  108. return \$?
  109. fi
  110. file="\$1"
  111. offset=\$2
  112. length=\$3
  113. pos=0
  114. bsize=4194304
  115. while test \$bsize -gt \$length; do
  116. bsize=\`expr \$bsize / 4\`
  117. done
  118. blocks=\`expr \$length / \$bsize\`
  119. bytes=\`expr \$length % \$bsize\`
  120. (
  121. dd ibs=\$offset skip=1 count=1 2>/dev/null
  122. pos=\`expr \$pos \+ \$bsize\`
  123. MS_Printf " 0%% " 1>&2
  124. if test \$blocks -gt 0; then
  125. while test \$pos -le \$length; do
  126. dd bs=\$bsize count=1 2>/dev/null
  127. pcent=\`expr \$length / 100\`
  128. pcent=\`expr \$pos / \$pcent\`
  129. if test \$pcent -lt 100; then
  130. MS_Printf "\b\b\b\b\b\b\b" 1>&2
  131. if test \$pcent -lt 10; then
  132. MS_Printf " \$pcent%% " 1>&2
  133. else
  134. MS_Printf " \$pcent%% " 1>&2
  135. fi
  136. fi
  137. pos=\`expr \$pos \+ \$bsize\`
  138. done
  139. fi
  140. if test \$bytes -gt 0; then
  141. dd bs=\$bytes count=1 2>/dev/null
  142. fi
  143. MS_Printf "\b\b\b\b\b\b\b" 1>&2
  144. MS_Printf " 100%% " 1>&2
  145. ) < "\$file"
  146. }
  147. MS_Help()
  148. {
  149. cat << EOH >&2
  150. Makeself version $MS_VERSION
  151. 1) Getting help or info about \$0 :
  152. \$0 --help Print this message
  153. \$0 --info Print embedded info : title, default target directory, embedded script ...
  154. \$0 --lsm Print embedded lsm entry (or no LSM)
  155. \$0 --list Print the list of files in the archive
  156. \$0 --check Checks integrity of the archive
  157. \$0 --verify-sig key Verify signature agains a provided key id
  158. 2) Running \$0 :
  159. \$0 [options] [--] [additional arguments to embedded script]
  160. with following options (in that order)
  161. --confirm Ask before running embedded script
  162. --quiet Do not print anything except error messages
  163. --accept Accept the license
  164. --noexec Do not run embedded script (implies --noexec-cleanup)
  165. --noexec-cleanup Do not run embedded cleanup script
  166. --keep Do not erase target directory after running
  167. the embedded script
  168. --noprogress Do not show the progress during the decompression
  169. --nox11 Do not spawn an xterm
  170. --nochown Do not give the target folder to the current user
  171. --chown Give the target folder to the current user recursively
  172. --nodiskspace Do not check for available disk space
  173. --target dir Extract directly to a target directory (absolute or relative)
  174. This directory may undergo recursive chown (see --nochown).
  175. --tar arg1 [arg2 ...] Access the contents of the archive through the tar command
  176. --ssl-pass-src src Use the given src as the source of password to decrypt the data
  177. using OpenSSL. See "PASS PHRASE ARGUMENTS" in man openssl.
  178. Default is to prompt the user to enter decryption password
  179. on the current terminal.
  180. --cleanup-args args Arguments to the cleanup script. Wrap in quotes to provide
  181. multiple arguments.
  182. -- Following arguments will be passed to the embedded script\${helpheader}
  183. EOH
  184. }
  185. MS_Verify_Sig()
  186. {
  187. GPG_PATH=\`exec <&- 2>&-; which gpg || command -v gpg || type gpg\`
  188. MKTEMP_PATH=\`exec <&- 2>&-; which mktemp || command -v mktemp || type mktemp\`
  189. test -x "\$GPG_PATH" || GPG_PATH=\`exec <&- 2>&-; which gpg || command -v gpg || type gpg\`
  190. test -x "\$MKTEMP_PATH" || MKTEMP_PATH=\`exec <&- 2>&-; which mktemp || command -v mktemp || type mktemp\`
  191. offset=\`head -n "\$skip" "\$1" | wc -c | sed "s/ //g"\`
  192. temp_sig=\`mktemp -t XXXXX\`
  193. echo \$SIGNATURE | base64 --decode > "\$temp_sig"
  194. gpg_output=\`MS_dd "\$1" \$offset \$totalsize | LC_ALL=C "\$GPG_PATH" --verify "\$temp_sig" - 2>&1\`
  195. gpg_res=\$?
  196. rm -f "\$temp_sig"
  197. if test \$gpg_res -eq 0 && test \`echo \$gpg_output | grep -c Good\` -eq 1; then
  198. if test \`echo \$gpg_output | grep -c \$sig_key\` -eq 1; then
  199. test x"\$quiet" = xn && echo "GPG signature is good" >&2
  200. else
  201. echo "GPG Signature key does not match" >&2
  202. exit 2
  203. fi
  204. else
  205. test x"\$quiet" = xn && echo "GPG signature failed to verify" >&2
  206. exit 2
  207. fi
  208. }
  209. MS_Check()
  210. {
  211. OLD_PATH="\$PATH"
  212. PATH=\${GUESS_MD5_PATH:-"\$OLD_PATH:/bin:/usr/bin:/sbin:/usr/local/ssl/bin:/usr/local/bin:/opt/openssl/bin"}
  213. MD5_ARG=""
  214. MD5_PATH=\`exec <&- 2>&-; which md5sum || command -v md5sum || type md5sum\`
  215. test -x "\$MD5_PATH" || MD5_PATH=\`exec <&- 2>&-; which md5 || command -v md5 || type md5\`
  216. test -x "\$MD5_PATH" || MD5_PATH=\`exec <&- 2>&-; which digest || command -v digest || type digest\`
  217. PATH="\$OLD_PATH"
  218. SHA_PATH=\`exec <&- 2>&-; which shasum || command -v shasum || type shasum\`
  219. test -x "\$SHA_PATH" || SHA_PATH=\`exec <&- 2>&-; which sha256sum || command -v sha256sum || type sha256sum\`
  220. if test x"\$quiet" = xn; then
  221. MS_Printf "Verifying archive integrity..."
  222. fi
  223. offset=\`head -n "\$skip" "\$1" | wc -c | sed "s/ //g"\`
  224. fsize=\`cat "\$1" | wc -c | sed "s/ //g"\`
  225. if test \$totalsize -ne \`expr \$fsize - \$offset\`; then
  226. echo " Unexpected archive size." >&2
  227. exit 2
  228. fi
  229. verb=\$2
  230. i=1
  231. for s in \$filesizes
  232. do
  233. crc=\`echo \$CRCsum | cut -d" " -f\$i\`
  234. if test -x "\$SHA_PATH"; then
  235. if test x"\`basename \$SHA_PATH\`" = xshasum; then
  236. SHA_ARG="-a 256"
  237. fi
  238. sha=\`echo \$SHA | cut -d" " -f\$i\`
  239. if test x"\$sha" = x0000000000000000000000000000000000000000000000000000000000000000; then
  240. test x"\$verb" = xy && echo " \$1 does not contain an embedded SHA256 checksum." >&2
  241. else
  242. shasum=\`MS_dd_Progress "\$1" \$offset \$s | eval "\$SHA_PATH \$SHA_ARG" | cut -b-64\`;
  243. if test x"\$shasum" != x"\$sha"; then
  244. echo "Error in SHA256 checksums: \$shasum is different from \$sha" >&2
  245. exit 2
  246. elif test x"\$quiet" = xn; then
  247. MS_Printf " SHA256 checksums are OK." >&2
  248. fi
  249. crc="0000000000";
  250. fi
  251. fi
  252. if test -x "\$MD5_PATH"; then
  253. if test x"\`basename \$MD5_PATH\`" = xdigest; then
  254. MD5_ARG="-a md5"
  255. fi
  256. md5=\`echo \$MD5 | cut -d" " -f\$i\`
  257. if test x"\$md5" = x00000000000000000000000000000000; then
  258. test x"\$verb" = xy && echo " \$1 does not contain an embedded MD5 checksum." >&2
  259. else
  260. md5sum=\`MS_dd_Progress "\$1" \$offset \$s | eval "\$MD5_PATH \$MD5_ARG" | cut -b-32\`;
  261. if test x"\$md5sum" != x"\$md5"; then
  262. echo "Error in MD5 checksums: \$md5sum is different from \$md5" >&2
  263. exit 2
  264. elif test x"\$quiet" = xn; then
  265. MS_Printf " MD5 checksums are OK." >&2
  266. fi
  267. crc="0000000000"; verb=n
  268. fi
  269. fi
  270. if test x"\$crc" = x0000000000; then
  271. test x"\$verb" = xy && echo " \$1 does not contain a CRC checksum." >&2
  272. else
  273. sum1=\`MS_dd_Progress "\$1" \$offset \$s | CMD_ENV=xpg4 cksum | awk '{print \$1}'\`
  274. if test x"\$sum1" != x"\$crc"; then
  275. echo "Error in checksums: \$sum1 is different from \$crc" >&2
  276. exit 2
  277. elif test x"\$quiet" = xn; then
  278. MS_Printf " CRC checksums are OK." >&2
  279. fi
  280. fi
  281. i=\`expr \$i + 1\`
  282. offset=\`expr \$offset + \$s\`
  283. done
  284. if test x"\$quiet" = xn; then
  285. echo " All good."
  286. fi
  287. }
  288. MS_Decompress()
  289. {
  290. if test x"\$decrypt_cmd" != x""; then
  291. { eval "\$decrypt_cmd" || echo " ... Decryption failed." >&2; } | eval "$GUNZIP_CMD"
  292. else
  293. eval "$GUNZIP_CMD"
  294. fi
  295. if test \$? -ne 0; then
  296. echo " ... Decompression failed." >&2
  297. fi
  298. }
  299. UnTAR()
  300. {
  301. if test x"\$quiet" = xn; then
  302. tar \$1vf - $UNTAR_EXTRA 2>&1 || { echo " ... Extraction failed." >&2; kill -15 \$$; }
  303. else
  304. tar \$1f - $UNTAR_EXTRA 2>&1 || { echo Extraction failed. >&2; kill -15 \$$; }
  305. fi
  306. }
  307. MS_exec_cleanup() {
  308. if test x"\$cleanup" = xy && test x"\$cleanup_script" != x""; then
  309. cleanup=n
  310. cd "\$tmpdir"
  311. eval "\"\$cleanup_script\" \$scriptargs \$cleanupargs"
  312. fi
  313. }
  314. MS_cleanup()
  315. {
  316. echo 'Signal caught, cleaning up' >&2
  317. MS_exec_cleanup
  318. cd "\$TMPROOT"
  319. rm -rf "\$tmpdir"
  320. eval \$finish; exit 15
  321. }
  322. finish=true
  323. xterm_loop=
  324. noprogress=$NOPROGRESS
  325. nox11=$NOX11
  326. copy=$COPY
  327. ownership=$OWNERSHIP
  328. verbose=n
  329. cleanup=y
  330. cleanupargs=
  331. sig_key=
  332. initargs="\$@"
  333. while true
  334. do
  335. case "\$1" in
  336. -h | --help)
  337. MS_Help
  338. exit 0
  339. ;;
  340. -q | --quiet)
  341. quiet=y
  342. noprogress=y
  343. shift
  344. ;;
  345. --accept)
  346. accept=y
  347. shift
  348. ;;
  349. --info)
  350. echo Identification: "\$label"
  351. echo Target directory: "\$targetdir"
  352. echo Uncompressed size: $USIZE KB
  353. echo Compression: $COMPRESS
  354. if test x"$ENCRYPT" != x""; then
  355. echo Encryption: $ENCRYPT
  356. fi
  357. echo Date of packaging: $DATE
  358. echo Built with Makeself version $MS_VERSION
  359. echo Build command was: "$MS_COMMAND"
  360. if test x"\$script" != x; then
  361. echo Script run after extraction:
  362. echo " " \$script \$scriptargs
  363. fi
  364. if test x"$copy" = xcopy; then
  365. echo "Archive will copy itself to a temporary location"
  366. fi
  367. if test x"$NEED_ROOT" = xy; then
  368. echo "Root permissions required for extraction"
  369. fi
  370. if test x"$KEEP" = xy; then
  371. echo "directory \$targetdir is permanent"
  372. else
  373. echo "\$targetdir will be removed after extraction"
  374. fi
  375. exit 0
  376. ;;
  377. --dumpconf)
  378. echo LABEL=\"\$label\"
  379. echo SCRIPT=\"\$script\"
  380. echo SCRIPTARGS=\"\$scriptargs\"
  381. echo CLEANUPSCRIPT=\"\$cleanup_script\"
  382. echo archdirname=\"$archdirname\"
  383. echo KEEP=$KEEP
  384. echo NOOVERWRITE=$NOOVERWRITE
  385. echo COMPRESS=$COMPRESS
  386. echo filesizes=\"\$filesizes\"
  387. echo totalsize=\"\$totalsize\"
  388. echo CRCsum=\"\$CRCsum\"
  389. echo MD5sum=\"\$MD5sum\"
  390. echo SHAsum=\"\$SHAsum\"
  391. echo SKIP=\"\$skip\"
  392. exit 0
  393. ;;
  394. --lsm)
  395. cat << EOLSM
  396. EOF
  397. eval "$LSM_CMD"
  398. cat << EOF >> "$archname"
  399. EOLSM
  400. exit 0
  401. ;;
  402. --list)
  403. echo Target directory: \$targetdir
  404. offset=\`head -n "\$skip" "\$0" | wc -c | sed "s/ //g"\`
  405. for s in \$filesizes
  406. do
  407. MS_dd "\$0" \$offset \$s | MS_Decompress | UnTAR t
  408. offset=\`expr \$offset + \$s\`
  409. done
  410. exit 0
  411. ;;
  412. --tar)
  413. offset=\`head -n "\$skip" "\$0" | wc -c | sed "s/ //g"\`
  414. arg1="\$2"
  415. shift 2 || { MS_Help; exit 1; }
  416. for s in \$filesizes
  417. do
  418. MS_dd "\$0" \$offset \$s | MS_Decompress | tar "\$arg1" - "\$@"
  419. offset=\`expr \$offset + \$s\`
  420. done
  421. exit 0
  422. ;;
  423. --check)
  424. MS_Check "\$0" y
  425. exit 0
  426. ;;
  427. --verify-sig)
  428. sig_key="\$2"
  429. shift 2 || { MS_Help; exit 1; }
  430. MS_Verify_Sig "\$0"
  431. ;;
  432. --confirm)
  433. verbose=y
  434. shift
  435. ;;
  436. --noexec)
  437. script=""
  438. cleanup_script=""
  439. shift
  440. ;;
  441. --noexec-cleanup)
  442. cleanup_script=""
  443. shift
  444. ;;
  445. --keep)
  446. keep=y
  447. shift
  448. ;;
  449. --target)
  450. keep=y
  451. targetdir="\${2:-.}"
  452. shift 2 || { MS_Help; exit 1; }
  453. ;;
  454. --noprogress)
  455. noprogress=y
  456. shift
  457. ;;
  458. --nox11)
  459. nox11=y
  460. shift
  461. ;;
  462. --nochown)
  463. ownership=n
  464. shift
  465. ;;
  466. --chown)
  467. ownership=y
  468. shift
  469. ;;
  470. --nodiskspace)
  471. nodiskspace=y
  472. shift
  473. ;;
  474. --xwin)
  475. if test "$NOWAIT" = n; then
  476. finish="echo Press Return to close this window...; read junk"
  477. fi
  478. xterm_loop=1
  479. shift
  480. ;;
  481. --phase2)
  482. copy=phase2
  483. shift
  484. ;;
  485. --ssl-pass-src)
  486. if test x"$ENCRYPT" != x"openssl"; then
  487. echo "Invalid option --ssl-pass-src: \$0 was not encrypted with OpenSSL!" >&2
  488. exit 1
  489. fi
  490. decrypt_cmd="\$decrypt_cmd -pass \$2"
  491. shift 2 || { MS_Help; exit 1; }
  492. ;;
  493. --cleanup-args)
  494. cleanupargs="\$2"
  495. shift 2 || { MS_Help; exit 1; }
  496. ;;
  497. --)
  498. shift
  499. break ;;
  500. -*)
  501. echo Unrecognized flag : "\$1" >&2
  502. MS_Help
  503. exit 1
  504. ;;
  505. *)
  506. break ;;
  507. esac
  508. done
  509. if test x"\$quiet" = xy -a x"\$verbose" = xy; then
  510. echo Cannot be verbose and quiet at the same time. >&2
  511. exit 1
  512. fi
  513. if test x"$NEED_ROOT" = xy -a \`id -u\` -ne 0; then
  514. echo "Administrative privileges required for this archive (use su or sudo)" >&2
  515. exit 1
  516. fi
  517. if test x"\$copy" \!= xphase2; then
  518. MS_PrintLicense
  519. fi
  520. case "\$copy" in
  521. copy)
  522. tmpdir="\$TMPROOT"/makeself.\$RANDOM.\`date +"%y%m%d%H%M%S"\`.\$\$
  523. mkdir "\$tmpdir" || {
  524. echo "Could not create temporary directory \$tmpdir" >&2
  525. exit 1
  526. }
  527. SCRIPT_COPY="\$tmpdir/makeself"
  528. echo "Copying to a temporary location..." >&2
  529. cp "\$0" "\$SCRIPT_COPY"
  530. chmod +x "\$SCRIPT_COPY"
  531. cd "\$TMPROOT"
  532. export USER_PWD="\$tmpdir"
  533. exec "\$SCRIPT_COPY" --phase2 -- \$initargs
  534. ;;
  535. phase2)
  536. finish="\$finish ; rm -rf \`dirname \$0\`"
  537. ;;
  538. esac
  539. if test x"\$nox11" = xn; then
  540. if test -t 1; then # Do we have a terminal on stdout?
  541. :
  542. else
  543. if test x"\$DISPLAY" != x -a x"\$xterm_loop" = x; then # No, but do we have X?
  544. if xset q > /dev/null 2>&1; then # Check for valid DISPLAY variable
  545. GUESS_XTERMS="xterm gnome-terminal rxvt dtterm eterm Eterm xfce4-terminal lxterminal kvt konsole aterm terminology"
  546. for a in \$GUESS_XTERMS; do
  547. if type \$a >/dev/null 2>&1; then
  548. XTERM=\$a
  549. break
  550. fi
  551. done
  552. chmod a+x \$0 || echo Please add execution rights on \$0 >&2
  553. if test \`echo "\$0" | cut -c1\` = "/"; then # Spawn a terminal!
  554. exec \$XTERM -e "\$0 --xwin \$initargs"
  555. else
  556. exec \$XTERM -e "./\$0 --xwin \$initargs"
  557. fi
  558. fi
  559. fi
  560. fi
  561. fi
  562. if test x"\$targetdir" = x.; then
  563. tmpdir="."
  564. else
  565. if test x"\$keep" = xy; then
  566. if test x"\$nooverwrite" = xy && test -d "\$targetdir"; then
  567. echo "Target directory \$targetdir already exists, aborting." >&2
  568. exit 1
  569. fi
  570. if test x"\$quiet" = xn; then
  571. echo "Creating directory \$targetdir" >&2
  572. fi
  573. tmpdir="\$targetdir"
  574. dashp="-p"
  575. else
  576. tmpdir="\$TMPROOT/selfgz\$\$\$RANDOM"
  577. dashp=""
  578. fi
  579. mkdir \$dashp "\$tmpdir" || {
  580. echo 'Cannot create target directory' \$tmpdir >&2
  581. echo 'You should try option --target dir' >&2
  582. eval \$finish
  583. exit 1
  584. }
  585. fi
  586. location="\`pwd\`"
  587. if test x"\$SETUP_NOCHECK" != x1; then
  588. MS_Check "\$0"
  589. fi
  590. offset=\`head -n "\$skip" "\$0" | wc -c | sed "s/ //g"\`
  591. if test x"\$verbose" = xy; then
  592. MS_Printf "About to extract $USIZE KB in \$tmpdir ... Proceed ? [Y/n] "
  593. read yn
  594. if test x"\$yn" = xn; then
  595. eval \$finish; exit 1
  596. fi
  597. fi
  598. if test x"\$quiet" = xn; then
  599. # Decrypting with openssl will ask for password,
  600. # the prompt needs to start on new line
  601. if test x"$ENCRYPT" = x"openssl"; then
  602. echo "Decrypting and uncompressing \$label..."
  603. else
  604. MS_Printf "Uncompressing \$label"
  605. fi
  606. fi
  607. res=3
  608. if test x"\$keep" = xn; then
  609. trap MS_cleanup 1 2 3 15
  610. fi
  611. if test x"\$nodiskspace" = xn; then
  612. leftspace=\`MS_diskspace "\$tmpdir"\`
  613. if test -n "\$leftspace"; then
  614. if test "\$leftspace" -lt $USIZE; then
  615. echo
  616. echo "Not enough space left in "\`dirname \$tmpdir\`" (\$leftspace KB) to decompress \$0 ($USIZE KB)" >&2
  617. echo "Use --nodiskspace option to skip this check and proceed anyway" >&2
  618. if test x"\$keep" = xn; then
  619. echo "Consider setting TMPDIR to a directory with more free space."
  620. fi
  621. eval \$finish; exit 1
  622. fi
  623. fi
  624. fi
  625. for s in \$filesizes
  626. do
  627. if MS_dd_Progress "\$0" \$offset \$s | MS_Decompress | ( cd "\$tmpdir"; umask \$ORIG_UMASK ; UnTAR xp ) 1>/dev/null; then
  628. if test x"\$ownership" = xy; then
  629. (cd "\$tmpdir"; chown -R \`id -u\` .; chgrp -R \`id -g\` .)
  630. fi
  631. else
  632. echo >&2
  633. echo "Unable to decompress \$0" >&2
  634. eval \$finish; exit 1
  635. fi
  636. offset=\`expr \$offset + \$s\`
  637. done
  638. if test x"\$quiet" = xn; then
  639. echo
  640. fi
  641. cd "\$tmpdir"
  642. res=0
  643. if test x"\$script" != x; then
  644. if test x"\$export_conf" = x"y"; then
  645. MS_BUNDLE="\$0"
  646. MS_LABEL="\$label"
  647. MS_SCRIPT="\$script"
  648. MS_SCRIPTARGS="\$scriptargs"
  649. MS_ARCHDIRNAME="\$archdirname"
  650. MS_KEEP="\$KEEP"
  651. MS_NOOVERWRITE="\$NOOVERWRITE"
  652. MS_COMPRESS="\$COMPRESS"
  653. MS_CLEANUP="\$cleanup"
  654. export MS_BUNDLE MS_LABEL MS_SCRIPT MS_SCRIPTARGS
  655. export MS_ARCHDIRNAME MS_KEEP MS_NOOVERWRITE MS_COMPRESS
  656. fi
  657. if test x"\$verbose" = x"y"; then
  658. MS_Printf "OK to execute: \$script \$scriptargs \$* ? [Y/n] "
  659. read yn
  660. if test x"\$yn" = x -o x"\$yn" = xy -o x"\$yn" = xY; then
  661. eval "\"\$script\" \$scriptargs \"\\\$@\""; res=\$?;
  662. fi
  663. else
  664. eval "\"\$script\" \$scriptargs \"\\\$@\""; res=\$?
  665. fi
  666. if test "\$res" -ne 0; then
  667. test x"\$verbose" = xy && echo "The program '\$script' returned an error code (\$res)" >&2
  668. fi
  669. fi
  670. MS_exec_cleanup
  671. if test x"\$keep" = xn; then
  672. cd "\$TMPROOT"
  673. rm -rf "\$tmpdir"
  674. fi
  675. eval \$finish; exit \$res
  676. EOF