omnibus 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. checksums.yaml +15 -0
  2. data/.gitignore +9 -0
  3. data/.rspec +1 -0
  4. data/.yardopts +7 -0
  5. data/CHANGELOG.md +3 -0
  6. data/Gemfile +9 -0
  7. data/LICENSE +201 -0
  8. data/NOTICE +9 -0
  9. data/README.md +186 -0
  10. data/Rakefile +7 -0
  11. data/bin/makeself-header.sh +401 -0
  12. data/bin/makeself.sh +407 -0
  13. data/bin/omnibus +11 -0
  14. data/lib/omnibus.rb +280 -0
  15. data/lib/omnibus/build_version.rb +281 -0
  16. data/lib/omnibus/builder.rb +323 -0
  17. data/lib/omnibus/clean_tasks.rb +30 -0
  18. data/lib/omnibus/cli.rb +35 -0
  19. data/lib/omnibus/cli/application.rb +136 -0
  20. data/lib/omnibus/cli/base.rb +112 -0
  21. data/lib/omnibus/cli/build.rb +66 -0
  22. data/lib/omnibus/cli/cache.rb +60 -0
  23. data/lib/omnibus/config.rb +186 -0
  24. data/lib/omnibus/exceptions.rb +54 -0
  25. data/lib/omnibus/fetcher.rb +184 -0
  26. data/lib/omnibus/fetchers.rb +22 -0
  27. data/lib/omnibus/fetchers/git_fetcher.rb +212 -0
  28. data/lib/omnibus/fetchers/net_fetcher.rb +191 -0
  29. data/lib/omnibus/fetchers/path_fetcher.rb +65 -0
  30. data/lib/omnibus/fetchers/s3_cache_fetcher.rb +42 -0
  31. data/lib/omnibus/health_check.rb +260 -0
  32. data/lib/omnibus/library.rb +70 -0
  33. data/lib/omnibus/overrides.rb +69 -0
  34. data/lib/omnibus/project.rb +566 -0
  35. data/lib/omnibus/reports.rb +99 -0
  36. data/lib/omnibus/s3_cacher.rb +136 -0
  37. data/lib/omnibus/software.rb +430 -0
  38. data/lib/omnibus/templates/Berksfile.erb +3 -0
  39. data/lib/omnibus/templates/Gemfile.erb +4 -0
  40. data/lib/omnibus/templates/README.md.erb +102 -0
  41. data/lib/omnibus/templates/Vagrantfile.erb +95 -0
  42. data/lib/omnibus/templates/gitignore.erb +8 -0
  43. data/lib/omnibus/templates/omnibus.rb.example.erb +5 -0
  44. data/lib/omnibus/templates/package_scripts/makeselfinst.erb +27 -0
  45. data/lib/omnibus/templates/package_scripts/postinst.erb +17 -0
  46. data/lib/omnibus/templates/package_scripts/postrm.erb +9 -0
  47. data/lib/omnibus/templates/project.rb.erb +21 -0
  48. data/lib/omnibus/templates/software/c-example.rb.erb +42 -0
  49. data/lib/omnibus/templates/software/erlang-example.rb.erb +38 -0
  50. data/lib/omnibus/templates/software/ruby-example.rb.erb +24 -0
  51. data/lib/omnibus/util.rb +61 -0
  52. data/lib/omnibus/version.rb +20 -0
  53. data/omnibus.gemspec +34 -0
  54. data/spec/build_version_spec.rb +228 -0
  55. data/spec/data/overrides/bad_line.overrides +3 -0
  56. data/spec/data/overrides/good.overrides +5 -0
  57. data/spec/data/overrides/with_dupes.overrides +4 -0
  58. data/spec/data/software/erchef.rb +40 -0
  59. data/spec/overrides_spec.rb +114 -0
  60. data/spec/software_spec.rb +71 -0
  61. data/spec/spec_helper.rb +28 -0
  62. metadata +239 -0
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ require 'bundler/setup'
2
+ require 'bundler/gem_tasks'
3
+ require 'rspec/core/rake_task'
4
+ require 'yard'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+ YARD::Rake::YardocTask.new
@@ -0,0 +1,401 @@
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
+ unset CDPATH
26
+
27
+ MS_Printf()
28
+ {
29
+ \$print_cmd \$print_cmd_arg "\$1"
30
+ }
31
+
32
+ MS_Progress()
33
+ {
34
+ while read a; do
35
+ MS_Printf .
36
+ done
37
+ }
38
+
39
+ MS_diskspace()
40
+ {
41
+ (
42
+ if test -d /usr/xpg4/bin; then
43
+ PATH=/usr/xpg4/bin:\$PATH
44
+ fi
45
+ df -kP "\$1" | tail -1 | awk '{print \$4}'
46
+ )
47
+ }
48
+
49
+ MS_dd()
50
+ {
51
+ blocks=\`expr \$3 / 1024\`
52
+ bytes=\`expr \$3 % 1024\`
53
+ dd if="\$1" ibs=\$2 skip=1 obs=1024 conv=sync 2> /dev/null | \\
54
+ { test \$blocks -gt 0 && dd ibs=1024 obs=1024 count=\$blocks ; \\
55
+ test \$bytes -gt 0 && dd ibs=1 obs=1024 count=\$bytes ; } 2> /dev/null
56
+ }
57
+
58
+ MS_Help()
59
+ {
60
+ cat << EOH >&2
61
+ Makeself version $MS_VERSION
62
+ 1) Getting help or info about \$0 :
63
+ \$0 --help Print this message
64
+ \$0 --info Print embedded info : title, default target directory, embedded script ...
65
+ \$0 --lsm Print embedded lsm entry (or no LSM)
66
+ \$0 --list Print the list of files in the archive
67
+ \$0 --check Checks integrity of the archive
68
+
69
+ 2) Running \$0 :
70
+ \$0 [options] [--] [additional arguments to embedded script]
71
+ with following options (in that order)
72
+ --confirm Ask before running embedded script
73
+ --noexec Do not run embedded script
74
+ --keep Do not erase target directory after running
75
+ the embedded script
76
+ --nox11 Do not spawn an xterm
77
+ --nochown Do not give the extracted files to the current user
78
+ --target NewDirectory Extract in NewDirectory
79
+ --tar arg1 [arg2 ...] Access the contents of the archive through the tar command
80
+ -- Following arguments will be passed to the embedded script
81
+ EOH
82
+ }
83
+
84
+ MS_Check()
85
+ {
86
+ OLD_PATH="\$PATH"
87
+ PATH=\${GUESS_MD5_PATH:-"\$OLD_PATH:/bin:/usr/bin:/sbin:/usr/local/ssl/bin:/usr/local/bin:/opt/openssl/bin"}
88
+ MD5_ARG=""
89
+ MD5_PATH=\`exec <&- 2>&-; which md5sum || type md5sum\`
90
+ test -x "\$MD5_PATH" || MD5_PATH=\`exec <&- 2>&-; which md5 || type md5\`
91
+ test -x "\$MD5_PATH" || MD5_PATH=\`exec <&- 2>&-; which digest || type digest\`
92
+ PATH="\$OLD_PATH"
93
+
94
+ MS_Printf "Verifying archive integrity..."
95
+ offset=\`head -n $SKIP "\$1" | wc -c | tr -d " "\`
96
+ verb=\$2
97
+ i=1
98
+ for s in \$filesizes
99
+ do
100
+ crc=\`echo \$CRCsum | cut -d" " -f\$i\`
101
+ if test -x "\$MD5_PATH"; then
102
+ if test \`basename \$MD5_PATH\` = digest; then
103
+ MD5_ARG="-a md5"
104
+ fi
105
+ md5=\`echo \$MD5 | cut -d" " -f\$i\`
106
+ if test \$md5 = "00000000000000000000000000000000"; then
107
+ test x\$verb = xy && echo " \$1 does not contain an embedded MD5 checksum." >&2
108
+ else
109
+ md5sum=\`MS_dd "\$1" \$offset \$s | eval "\$MD5_PATH \$MD5_ARG" | cut -b-32\`;
110
+ if test "\$md5sum" != "\$md5"; then
111
+ echo "Error in MD5 checksums: \$md5sum is different from \$md5" >&2
112
+ exit 2
113
+ else
114
+ test x\$verb = xy && MS_Printf " MD5 checksums are OK." >&2
115
+ fi
116
+ crc="0000000000"; verb=n
117
+ fi
118
+ fi
119
+ if test \$crc = "0000000000"; then
120
+ test x\$verb = xy && echo " \$1 does not contain a CRC checksum." >&2
121
+ else
122
+ sum1=\`MS_dd "\$1" \$offset \$s | CMD_ENV=xpg4 cksum | awk '{print \$1}'\`
123
+ if test "\$sum1" = "\$crc"; then
124
+ test x\$verb = xy && MS_Printf " CRC checksums are OK." >&2
125
+ else
126
+ echo "Error in checksums: \$sum1 is different from \$crc"
127
+ exit 2;
128
+ fi
129
+ fi
130
+ i=\`expr \$i + 1\`
131
+ offset=\`expr \$offset + \$s\`
132
+ done
133
+ echo " All good."
134
+ }
135
+
136
+ UnTAR()
137
+ {
138
+ tar \$1vf - 2>&1 || { echo Extraction failed. > /dev/tty; kill -15 \$$; }
139
+ }
140
+
141
+ finish=true
142
+ xterm_loop=
143
+ nox11=$NOX11
144
+ copy=$COPY
145
+ ownership=y
146
+ verbose=n
147
+
148
+ initargs="\$@"
149
+
150
+ while true
151
+ do
152
+ case "\$1" in
153
+ -h | --help)
154
+ MS_Help
155
+ exit 0
156
+ ;;
157
+ --info)
158
+ echo Identification: "\$label"
159
+ echo Target directory: "\$targetdir"
160
+ echo Uncompressed size: $USIZE KB
161
+ echo Compression: $COMPRESS
162
+ echo Date of packaging: $DATE
163
+ echo Built with Makeself version $MS_VERSION on $OSTYPE
164
+ echo Build command was: "$MS_COMMAND"
165
+ if test x\$script != x; then
166
+ echo Script run after extraction:
167
+ echo " " \$script \$scriptargs
168
+ fi
169
+ if test x"$copy" = xcopy; then
170
+ echo "Archive will copy itself to a temporary location"
171
+ fi
172
+ if test x"$KEEP" = xy; then
173
+ echo "directory \$targetdir is permanent"
174
+ else
175
+ echo "\$targetdir will be removed after extraction"
176
+ fi
177
+ exit 0
178
+ ;;
179
+ --dumpconf)
180
+ echo LABEL=\"\$label\"
181
+ echo SCRIPT=\"\$script\"
182
+ echo SCRIPTARGS=\"\$scriptargs\"
183
+ echo archdirname=\"$archdirname\"
184
+ echo KEEP=$KEEP
185
+ echo COMPRESS=$COMPRESS
186
+ echo filesizes=\"\$filesizes\"
187
+ echo CRCsum=\"\$CRCsum\"
188
+ echo MD5sum=\"\$MD5\"
189
+ echo OLDUSIZE=$USIZE
190
+ echo OLDSKIP=`expr $SKIP + 1`
191
+ exit 0
192
+ ;;
193
+ --lsm)
194
+ cat << EOLSM
195
+ EOF
196
+ eval "$LSM_CMD"
197
+ cat << EOF >> "$archname"
198
+ EOLSM
199
+ exit 0
200
+ ;;
201
+ --list)
202
+ echo Target directory: \$targetdir
203
+ offset=\`head -n $SKIP "\$0" | wc -c | tr -d " "\`
204
+ for s in \$filesizes
205
+ do
206
+ MS_dd "\$0" \$offset \$s | eval "$GUNZIP_CMD" | UnTAR t
207
+ offset=\`expr \$offset + \$s\`
208
+ done
209
+ exit 0
210
+ ;;
211
+ --tar)
212
+ offset=\`head -n $SKIP "\$0" | wc -c | tr -d " "\`
213
+ arg1="\$2"
214
+ shift 2
215
+ for s in \$filesizes
216
+ do
217
+ MS_dd "\$0" \$offset \$s | eval "$GUNZIP_CMD" | tar "\$arg1" - \$*
218
+ offset=\`expr \$offset + \$s\`
219
+ done
220
+ exit 0
221
+ ;;
222
+ --check)
223
+ MS_Check "\$0" y
224
+ exit 0
225
+ ;;
226
+ --confirm)
227
+ verbose=y
228
+ shift
229
+ ;;
230
+ --noexec)
231
+ script=""
232
+ shift
233
+ ;;
234
+ --keep)
235
+ keep=y
236
+ shift
237
+ ;;
238
+ --target)
239
+ keep=y
240
+ targetdir=\${2:-.}
241
+ shift 2
242
+ ;;
243
+ --nox11)
244
+ nox11=y
245
+ shift
246
+ ;;
247
+ --nochown)
248
+ ownership=n
249
+ shift
250
+ ;;
251
+ --xwin)
252
+ finish="echo Press Return to close this window...; read junk"
253
+ xterm_loop=1
254
+ shift
255
+ ;;
256
+ --phase2)
257
+ copy=phase2
258
+ shift
259
+ ;;
260
+ --)
261
+ shift
262
+ break ;;
263
+ -*)
264
+ echo Unrecognized flag : "\$1" >&2
265
+ MS_Help
266
+ exit 1
267
+ ;;
268
+ *)
269
+ break ;;
270
+ esac
271
+ done
272
+
273
+ case "\$copy" in
274
+ copy)
275
+ tmpdir=\$TMPROOT/makeself.\$RANDOM.\`date +"%y%m%d%H%M%S"\`.\$\$
276
+ mkdir "\$tmpdir" || {
277
+ echo "Could not create temporary directory \$tmpdir" >&2
278
+ exit 1
279
+ }
280
+ SCRIPT_COPY="\$tmpdir/makeself"
281
+ echo "Copying to a temporary location..." >&2
282
+ cp "\$0" "\$SCRIPT_COPY"
283
+ chmod +x "\$SCRIPT_COPY"
284
+ cd "\$TMPROOT"
285
+ exec "\$SCRIPT_COPY" --phase2 -- \$initargs
286
+ ;;
287
+ phase2)
288
+ finish="\$finish ; rm -rf \`dirname \$0\`"
289
+ ;;
290
+ esac
291
+
292
+ if test "\$nox11" = "n"; then
293
+ if tty -s; then # Do we have a terminal?
294
+ :
295
+ else
296
+ if test x"\$DISPLAY" != x -a x"\$xterm_loop" = x; then # No, but do we have X?
297
+ if xset q > /dev/null 2>&1; then # Check for valid DISPLAY variable
298
+ GUESS_XTERMS="xterm rxvt dtterm eterm Eterm kvt konsole aterm"
299
+ for a in \$GUESS_XTERMS; do
300
+ if type \$a >/dev/null 2>&1; then
301
+ XTERM=\$a
302
+ break
303
+ fi
304
+ done
305
+ chmod a+x \$0 || echo Please add execution rights on \$0
306
+ if test \`echo "\$0" | cut -c1\` = "/"; then # Spawn a terminal!
307
+ exec \$XTERM -title "\$label" -e "\$0" --xwin "\$initargs"
308
+ else
309
+ exec \$XTERM -title "\$label" -e "./\$0" --xwin "\$initargs"
310
+ fi
311
+ fi
312
+ fi
313
+ fi
314
+ fi
315
+
316
+ if test "\$targetdir" = "."; then
317
+ tmpdir="."
318
+ else
319
+ if test "\$keep" = y; then
320
+ echo "Creating directory \$targetdir" >&2
321
+ tmpdir="\$targetdir"
322
+ dashp="-p"
323
+ else
324
+ tmpdir="\$TMPROOT/selfgz\$\$\$RANDOM"
325
+ dashp=""
326
+ fi
327
+ mkdir \$dashp \$tmpdir || {
328
+ echo 'Cannot create target directory' \$tmpdir >&2
329
+ echo 'You should try option --target OtherDirectory' >&2
330
+ eval \$finish
331
+ exit 1
332
+ }
333
+ fi
334
+
335
+ location="\`pwd\`"
336
+ if test x\$SETUP_NOCHECK != x1; then
337
+ MS_Check "\$0"
338
+ fi
339
+ offset=\`head -n $SKIP "\$0" | wc -c | tr -d " "\`
340
+
341
+ if test x"\$verbose" = xy; then
342
+ MS_Printf "About to extract $USIZE KB in \$tmpdir ... Proceed ? [Y/n] "
343
+ read yn
344
+ if test x"\$yn" = xn; then
345
+ eval \$finish; exit 1
346
+ fi
347
+ fi
348
+
349
+ MS_Printf "Uncompressing \$label"
350
+ res=3
351
+ if test "\$keep" = n; then
352
+ trap 'echo Signal caught, cleaning up >&2; cd \$TMPROOT; /bin/rm -rf \$tmpdir; eval \$finish; exit 15' 1 2 3 15
353
+ fi
354
+
355
+ leftspace=\`MS_diskspace \$tmpdir\`
356
+ if test \$leftspace -lt $USIZE; then
357
+ echo
358
+ echo "Not enough space left in "\`dirname \$tmpdir\`" (\$leftspace KB) to decompress \$0 ($USIZE KB)" >&2
359
+ if test "\$keep" = n; then
360
+ echo "Consider setting TMPDIR to a directory with more free space."
361
+ fi
362
+ eval \$finish; exit 1
363
+ fi
364
+
365
+ for s in \$filesizes
366
+ do
367
+ if MS_dd "\$0" \$offset \$s | eval "$GUNZIP_CMD" | ( cd "\$tmpdir"; UnTAR x ) | MS_Progress; then
368
+ if test x"\$ownership" = xy; then
369
+ (PATH=/usr/xpg4/bin:\$PATH; cd "\$tmpdir"; chown -R \`id -u\` .; chgrp -R \`id -g\` .)
370
+ fi
371
+ else
372
+ echo
373
+ echo "Unable to decompress \$0" >&2
374
+ eval \$finish; exit 1
375
+ fi
376
+ offset=\`expr \$offset + \$s\`
377
+ done
378
+ echo
379
+
380
+ cd "\$tmpdir"
381
+ res=0
382
+ if test x"\$script" != x; then
383
+ if test x"\$verbose" = xy; then
384
+ MS_Printf "OK to execute: \$script \$scriptargs \$* ? [Y/n] "
385
+ read yn
386
+ if test x"\$yn" = x -o x"\$yn" = xy -o x"\$yn" = xY; then
387
+ eval \$script \$scriptargs \$*; res=\$?;
388
+ fi
389
+ else
390
+ eval \$script \$scriptargs \$*; res=\$?
391
+ fi
392
+ if test \$res -ne 0; then
393
+ test x"\$verbose" = xy && echo "The program '\$script' returned an error code (\$res)" >&2
394
+ fi
395
+ fi
396
+ if test "\$keep" = n; then
397
+ cd \$TMPROOT
398
+ /bin/rm -rf \$tmpdir
399
+ fi
400
+ eval \$finish; exit \$res
401
+ EOF
data/bin/makeself.sh ADDED
@@ -0,0 +1,407 @@
1
+ #!/bin/sh
2
+ #
3
+ # Makeself version 2.1.x
4
+ # by Stephane Peter <megastep@megastep.org>
5
+ #
6
+ # $Id: makeself.sh,v 1.64 2008/01/04 23:52:14 megastep Exp $
7
+ #
8
+ # Utility to create self-extracting tar.gz archives.
9
+ # The resulting archive is a file holding the tar.gz archive with
10
+ # a small Shell script stub that uncompresses the archive to a temporary
11
+ # directory and then executes a given script from withing that directory.
12
+ #
13
+ # Makeself home page: http://www.megastep.org/makeself/
14
+ #
15
+ # Version 2.0 is a rewrite of version 1.0 to make the code easier to read and maintain.
16
+ #
17
+ # Version history :
18
+ # - 1.0 : Initial public release
19
+ # - 1.1 : The archive can be passed parameters that will be passed on to
20
+ # the embedded script, thanks to John C. Quillan
21
+ # - 1.2 : Package distribution, bzip2 compression, more command line options,
22
+ # support for non-temporary archives. Ideas thanks to Francois Petitjean
23
+ # - 1.3 : More patches from Bjarni R. Einarsson and Francois Petitjean:
24
+ # Support for no compression (--nocomp), script is no longer mandatory,
25
+ # automatic launch in an xterm, optional verbose output, and -target
26
+ # archive option to indicate where to extract the files.
27
+ # - 1.4 : Improved UNIX compatibility (Francois Petitjean)
28
+ # Automatic integrity checking, support of LSM files (Francois Petitjean)
29
+ # - 1.5 : Many bugfixes. Optionally disable xterm spawning.
30
+ # - 1.5.1 : More bugfixes, added archive options -list and -check.
31
+ # - 1.5.2 : Cosmetic changes to inform the user of what's going on with big
32
+ # archives (Quake III demo)
33
+ # - 1.5.3 : Check for validity of the DISPLAY variable before launching an xterm.
34
+ # More verbosity in xterms and check for embedded command's return value.
35
+ # Bugfix for Debian 2.0 systems that have a different "print" command.
36
+ # - 1.5.4 : Many bugfixes. Print out a message if the extraction failed.
37
+ # - 1.5.5 : More bugfixes. Added support for SETUP_NOCHECK environment variable to
38
+ # bypass checksum verification of archives.
39
+ # - 1.6.0 : Compute MD5 checksums with the md5sum command (patch from Ryan Gordon)
40
+ # - 2.0 : Brand new rewrite, cleaner architecture, separated header and UNIX ports.
41
+ # - 2.0.1 : Added --copy
42
+ # - 2.1.0 : Allow multiple tarballs to be stored in one archive, and incremental updates.
43
+ # Added --nochown for archives
44
+ # Stopped doing redundant checksums when not necesary
45
+ # - 2.1.1 : Work around insane behavior from certain Linux distros with no 'uncompress' command
46
+ # Cleaned up the code to handle error codes from compress. Simplified the extraction code.
47
+ # - 2.1.2 : Some bug fixes. Use head -n to avoid problems.
48
+ # - 2.1.3 : Bug fixes with command line when spawning terminals.
49
+ # Added --tar for archives, allowing to give arbitrary arguments to tar on the contents of the archive.
50
+ # Added --noexec to prevent execution of embedded scripts.
51
+ # Added --nomd5 and --nocrc to avoid creating checksums in archives.
52
+ # Added command used to create the archive in --info output.
53
+ # Run the embedded script through eval.
54
+ # - 2.1.4 : Fixed --info output.
55
+ # Generate random directory name when extracting files to . to avoid problems. (Jason Trent)
56
+ # Better handling of errors with wrong permissions for the directory containing the files. (Jason Trent)
57
+ # Avoid some race conditions (Ludwig Nussel)
58
+ # Unset the $CDPATH variable to avoid problems if it is set. (Debian)
59
+ # Better handling of dot files in the archive directory.
60
+ # - 2.1.5 : Made the md5sum detection consistent with the header code.
61
+ # Check for the presence of the archive directory
62
+ # Added --encrypt for symmetric encryption through gpg (Eric Windisch)
63
+ # Added support for the digest command on Solaris 10 for MD5 checksums
64
+ # Check for available disk space before extracting to the target directory (Andreas Schweitzer)
65
+ # Allow extraction to run asynchronously (patch by Peter Hatch)
66
+ # Use file descriptors internally to avoid error messages (patch by Kay Tiong Khoo)
67
+ #
68
+ # (C) 1998-2008 by St�phane Peter <megastep@megastep.org>
69
+ #
70
+ # This software is released under the terms of the GNU GPL version 2 and above
71
+ # Please read the license at http://www.gnu.org/copyleft/gpl.html
72
+ #
73
+
74
+ MS_VERSION=2.1.5
75
+ MS_COMMAND="$0"
76
+ unset CDPATH
77
+
78
+ for f in "${1+"$@"}"; do
79
+ MS_COMMAND="$MS_COMMAND \\\\
80
+ \\\"$f\\\""
81
+ done
82
+
83
+ # Procedures
84
+
85
+ MS_Usage()
86
+ {
87
+ echo "Usage: $0 [params] archive_dir file_name label [startup_script] [args]"
88
+ echo "params can be one or more of the following :"
89
+ echo " --version | -v : Print out Makeself version number and exit"
90
+ echo " --help | -h : Print out this help message"
91
+ echo " --gzip : Compress using gzip (default if detected)"
92
+ echo " --bzip2 : Compress using bzip2 instead of gzip"
93
+ echo " --compress : Compress using the UNIX 'compress' command"
94
+ echo " --nocomp : Do not compress the data"
95
+ echo " --notemp : The archive will create archive_dir in the"
96
+ echo " current directory and uncompress in ./archive_dir"
97
+ echo " --copy : Upon extraction, the archive will first copy itself to"
98
+ echo " a temporary directory"
99
+ echo " --append : Append more files to an existing Makeself archive"
100
+ echo " The label and startup scripts will then be ignored"
101
+ echo " --current : Files will be extracted to the current directory."
102
+ echo " Implies --notemp."
103
+ echo " --nomd5 : Don't calculate an MD5 for archive"
104
+ echo " --nocrc : Don't calculate a CRC for archive"
105
+ echo " --header file : Specify location of the header script"
106
+ echo " --follow : Follow the symlinks in the archive"
107
+ echo " --nox11 : Disable automatic spawn of a xterm"
108
+ echo " --nowait : Do not wait for user input after executing embedded"
109
+ echo " program from an xterm"
110
+ echo " --lsm file : LSM file describing the package"
111
+ echo
112
+ echo "Do not forget to give a fully qualified startup script name"
113
+ echo "(i.e. with a ./ prefix if inside the archive)."
114
+ exit 1
115
+ }
116
+
117
+ # Default settings
118
+ if type gzip 2>&1 > /dev/null; then
119
+ COMPRESS=gzip
120
+ else
121
+ COMPRESS=Unix
122
+ fi
123
+ KEEP=n
124
+ CURRENT=n
125
+ NOX11=n
126
+ APPEND=n
127
+ COPY=none
128
+ TAR_ARGS=cvf
129
+ HEADER=`dirname $0`/makeself-header.sh
130
+
131
+ # LSM file stuff
132
+ LSM_CMD="echo No LSM. >> \"\$archname\""
133
+
134
+ while true
135
+ do
136
+ case "$1" in
137
+ --version | -v)
138
+ echo Makeself version $MS_VERSION
139
+ exit 0
140
+ ;;
141
+ --bzip2)
142
+ COMPRESS=bzip2
143
+ shift
144
+ ;;
145
+ --gzip)
146
+ COMPRESS=gzip
147
+ shift
148
+ ;;
149
+ --compress)
150
+ COMPRESS=Unix
151
+ shift
152
+ ;;
153
+ --encrypt)
154
+ COMPRESS=gpg
155
+ shift
156
+ ;;
157
+ --nocomp)
158
+ COMPRESS=none
159
+ shift
160
+ ;;
161
+ --notemp)
162
+ KEEP=y
163
+ shift
164
+ ;;
165
+ --copy)
166
+ COPY=copy
167
+ shift
168
+ ;;
169
+ --current)
170
+ CURRENT=y
171
+ KEEP=y
172
+ shift
173
+ ;;
174
+ --header)
175
+ HEADER="$2"
176
+ shift 2
177
+ ;;
178
+ --follow)
179
+ TAR_ARGS=cvfh
180
+ shift
181
+ ;;
182
+ --nox11)
183
+ NOX11=y
184
+ shift
185
+ ;;
186
+ --nowait)
187
+ shift
188
+ ;;
189
+ --nomd5)
190
+ NOMD5=y
191
+ shift
192
+ ;;
193
+ --nocrc)
194
+ NOCRC=y
195
+ shift
196
+ ;;
197
+ --append)
198
+ APPEND=y
199
+ shift
200
+ ;;
201
+ --lsm)
202
+ LSM_CMD="cat \"$2\" >> \"\$archname\""
203
+ shift 2
204
+ ;;
205
+ -h | --help)
206
+ MS_Usage
207
+ ;;
208
+ -*)
209
+ echo Unrecognized flag : "$1"
210
+ MS_Usage
211
+ ;;
212
+ *)
213
+ break
214
+ ;;
215
+ esac
216
+ done
217
+
218
+ if test $# -lt 1; then
219
+ MS_Usage
220
+ else
221
+ if test -d "$1"; then
222
+ archdir="$1"
223
+ else
224
+ echo "Directory $1 does not exist."
225
+ exit 1
226
+ fi
227
+ fi
228
+ archname="$2"
229
+
230
+ if test "$APPEND" = y; then
231
+ if test $# -lt 2; then
232
+ MS_Usage
233
+ fi
234
+
235
+ # Gather the info from the original archive
236
+ OLDENV=`sh "$archname" --dumpconf`
237
+ if test $? -ne 0; then
238
+ echo "Unable to update archive: $archname" >&2
239
+ exit 1
240
+ else
241
+ eval "$OLDENV"
242
+ fi
243
+ else
244
+ if test "$KEEP" = n -a $# = 3; then
245
+ echo "ERROR: Making a temporary archive with no embedded command does not make sense!" >&2
246
+ echo
247
+ MS_Usage
248
+ fi
249
+ # We don't really want to create an absolute directory...
250
+ if test "$CURRENT" = y; then
251
+ archdirname="."
252
+ else
253
+ archdirname=`basename "$1"`
254
+ fi
255
+
256
+ if test $# -lt 3; then
257
+ MS_Usage
258
+ fi
259
+
260
+ LABEL="$3"
261
+ SCRIPT="$4"
262
+ test x$SCRIPT = x || shift 1
263
+ shift 3
264
+ SCRIPTARGS="$*"
265
+ fi
266
+
267
+ if test "$KEEP" = n -a "$CURRENT" = y; then
268
+ echo "ERROR: It is A VERY DANGEROUS IDEA to try to combine --notemp and --current." >&2
269
+ exit 1
270
+ fi
271
+
272
+ case $COMPRESS in
273
+ gzip)
274
+ GZIP_CMD="gzip -c9"
275
+ GUNZIP_CMD="gzip -cd"
276
+ ;;
277
+ bzip2)
278
+ GZIP_CMD="bzip2 -9"
279
+ GUNZIP_CMD="bzip2 -d"
280
+ ;;
281
+ gpg)
282
+ GZIP_CMD="gpg -ac -z9"
283
+ GUNZIP_CMD="gpg -d"
284
+ ;;
285
+ Unix)
286
+ GZIP_CMD="compress -cf"
287
+ GUNZIP_CMD="exec 2>&-; uncompress -c || test \\\$? -eq 2 || gzip -cd"
288
+ ;;
289
+ none)
290
+ GZIP_CMD="cat"
291
+ GUNZIP_CMD="cat"
292
+ ;;
293
+ esac
294
+
295
+ tmpfile="${TMPDIR:=/tmp}/mkself$$"
296
+
297
+ if test -f $HEADER; then
298
+ oldarchname="$archname"
299
+ archname="$tmpfile"
300
+ # Generate a fake header to count its lines
301
+ SKIP=0
302
+ . $HEADER
303
+ SKIP=`cat "$tmpfile" |wc -l`
304
+ # Get rid of any spaces
305
+ SKIP=`expr $SKIP`
306
+ rm -f "$tmpfile"
307
+ echo Header is $SKIP lines long >&2
308
+
309
+ archname="$oldarchname"
310
+ else
311
+ echo "Unable to open header file: $HEADER" >&2
312
+ exit 1
313
+ fi
314
+
315
+ echo
316
+
317
+ if test "$APPEND" = n; then
318
+ if test -f "$archname"; then
319
+ echo "WARNING: Overwriting existing file: $archname" >&2
320
+ fi
321
+ fi
322
+
323
+ USIZE=`du -ks $archdir | cut -f1`
324
+ DATE=`LC_ALL=C date`
325
+
326
+ if test "." = "$archdirname"; then
327
+ if test "$KEEP" = n; then
328
+ archdirname="makeself-$$-`date +%Y%m%d%H%M%S`"
329
+ fi
330
+ fi
331
+
332
+ test -d "$archdir" || { echo "Error: $archdir does not exist."; rm -f "$tmpfile"; exit 1; }
333
+ echo About to compress $USIZE KB of data...
334
+ echo Adding files to archive named \"$archname\"...
335
+ exec 3<> "$tmpfile"
336
+ (cd "$archdir" && ( tar $TAR_ARGS - . | eval "$GZIP_CMD" >&3 ) ) || { echo Aborting: Archive directory not found or temporary file: "$tmpfile" could not be created.; exec 3>&-; rm -f "$tmpfile"; exit 1; }
337
+ exec 3>&- # try to close the archive
338
+
339
+ fsize=`cat "$tmpfile" | wc -c | tr -d " "`
340
+
341
+ # Compute the checksums
342
+
343
+ md5sum=00000000000000000000000000000000
344
+ crcsum=0000000000
345
+
346
+ if test "$NOCRC" = y; then
347
+ echo "skipping crc at user request"
348
+ else
349
+ crcsum=`cat "$tmpfile" | CMD_ENV=xpg4 cksum | sed -e 's/ /Z/' -e 's/ /Z/' | cut -dZ -f1`
350
+ echo "CRC: $crcsum"
351
+ fi
352
+
353
+ if test "$NOMD5" = y; then
354
+ echo "skipping md5sum at user request"
355
+ else
356
+ # Try to locate a MD5 binary
357
+ OLD_PATH=$PATH
358
+ PATH=${GUESS_MD5_PATH:-"$OLD_PATH:/bin:/usr/bin:/sbin:/usr/local/ssl/bin:/usr/local/bin:/opt/openssl/bin"}
359
+ MD5_ARG=""
360
+ MD5_PATH=`exec <&- 2>&-; which md5sum || type md5sum`
361
+ test -x $MD5_PATH || MD5_PATH=`exec <&- 2>&-; which md5 || type md5`
362
+ test -x $MD5_PATH || MD5_PATH=`exec <&- 2>&-; which digest || type digest`
363
+ PATH=$OLD_PATH
364
+ if test `basename $MD5_PATH` = digest; then
365
+ MD5_ARG="-a md5"
366
+ fi
367
+ if test -x "$MD5_PATH"; then
368
+ md5sum=`cat "$tmpfile" | eval "$MD5_PATH $MD5_ARG" | cut -b-32`;
369
+ echo "MD5: $md5sum"
370
+ else
371
+ echo "MD5: none, MD5 command not found"
372
+ fi
373
+ fi
374
+
375
+ if test "$APPEND" = y; then
376
+ mv "$archname" "$archname".bak || exit
377
+
378
+ # Prepare entry for new archive
379
+ filesizes="$filesizes $fsize"
380
+ CRCsum="$CRCsum $crcsum"
381
+ MD5sum="$MD5sum $md5sum"
382
+ USIZE=`expr $USIZE + $OLDUSIZE`
383
+ # Generate the header
384
+ . $HEADER
385
+ # Append the original data
386
+ tail -n +$OLDSKIP "$archname".bak >> "$archname"
387
+ # Append the new data
388
+ cat "$tmpfile" >> "$archname"
389
+
390
+ chmod +x "$archname"
391
+ rm -f "$archname".bak
392
+ echo Self-extractible archive \"$archname\" successfully updated.
393
+ else
394
+ filesizes="$fsize"
395
+ CRCsum="$crcsum"
396
+ MD5sum="$md5sum"
397
+
398
+ # Generate the header
399
+ . $HEADER
400
+
401
+ # Append the compressed tar data after the stub
402
+ echo
403
+ cat "$tmpfile" >> "$archname"
404
+ chmod +x "$archname"
405
+ echo Self-extractible archive \"$archname\" successfully created.
406
+ fi
407
+ rm -f "$tmpfile"