software_smithy 1.1 → 1.6
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/smithy +140 -33
- data/etc/completion/smithy-completion.bash +106 -7
- data/etc/completion/zsh/_smithy +121 -27
- data/etc/templates/formula.rb.erb +11 -0
- data/etc/templates/web/machine_version_table.html.erb +0 -7
- data/etc/templates/web/version_table.html.erb +2 -2
- data/lib/smithy/config.rb +70 -13
- data/lib/smithy/description.rb +4 -4
- data/lib/smithy/download_cache.rb +120 -0
- data/lib/smithy/file_operations.rb +13 -6
- data/lib/smithy/formula.rb +203 -0
- data/lib/smithy/formula_command.rb +198 -0
- data/lib/smithy/helpers.rb +83 -37
- data/lib/smithy/module_file.rb +21 -10
- data/lib/smithy/package.rb +111 -86
- data/lib/smithy.rb +3 -0
- data/lib/smithy_version.rb +1 -1
- data/man/man1/smithy.1 +240 -53
- data/smithy.rdoc +107 -7
- metadata +84 -39
- data/README.rdoc +0 -114
- data/etc/smithyrc +0 -36
data/bin/smithy
CHANGED
@@ -54,8 +54,14 @@ require 'uri'
|
|
54
54
|
require 'kramdown'
|
55
55
|
require 'active_support/core_ext/hash'
|
56
56
|
require 'active_support/core_ext/string'
|
57
|
+
require 'active_support/inflector'
|
58
|
+
|
57
59
|
# require 'debugger' #XXX
|
58
60
|
# require 'awesome_print' #XXX
|
61
|
+
# require 'pry'
|
62
|
+
# require 'pry-doc'
|
63
|
+
|
64
|
+
@@global_argv = ARGV.dup
|
59
65
|
|
60
66
|
require 'gli'
|
61
67
|
include GLI::App
|
@@ -65,6 +71,8 @@ include Smithy
|
|
65
71
|
|
66
72
|
version Smithy::VERSION
|
67
73
|
|
74
|
+
subcommand_option_handling :normal
|
75
|
+
|
68
76
|
program_desc "Smithy will help you build, test, and install software with ease."
|
69
77
|
|
70
78
|
desc "Machine architecure to operate on"
|
@@ -94,7 +102,8 @@ desc "The root level directory global description files"
|
|
94
102
|
arg_name "PATH"
|
95
103
|
flag ["descriptions-root"]
|
96
104
|
|
97
|
-
desc "Disable or enable color output
|
105
|
+
desc "Disable or enable color output"
|
106
|
+
default_value true
|
98
107
|
switch "colors"
|
99
108
|
|
100
109
|
desc "Alternate config file, also set by $SMITHY_CONFIG"
|
@@ -104,6 +113,9 @@ flag [:"config-file"]
|
|
104
113
|
desc "Always overwrite existing files"
|
105
114
|
switch [:f, :force], :negatable => false
|
106
115
|
|
116
|
+
desc "Be more verbose"
|
117
|
+
switch [:v, :verbose], :negatable => false
|
118
|
+
|
107
119
|
desc "Search currently installed software"
|
108
120
|
arg_name "PATTERN"
|
109
121
|
command ['search'] do |c|
|
@@ -134,9 +146,9 @@ command ['search'] do |c|
|
|
134
146
|
formatter = output_formats[options[:format]]
|
135
147
|
raise "Unknow format \"#{options[:format]}\" valid formats include: #{output_formats.keys.join(',')}" if formatter.nil?
|
136
148
|
|
137
|
-
notice "Searching in #{swroot}" unless formatter.class == Format::Doku
|
149
|
+
notice "Searching in #{swroot}" unless formatter.class == Format::Doku || formatter.class == Format::Name
|
138
150
|
|
139
|
-
software = Package.all
|
151
|
+
software = Package.all
|
140
152
|
|
141
153
|
count = 0
|
142
154
|
formatter.before
|
@@ -152,7 +164,7 @@ command ['search'] do |c|
|
|
152
164
|
end
|
153
165
|
formatter.after
|
154
166
|
|
155
|
-
notice "#{count} Found" unless formatter.class == Format::Doku
|
167
|
+
notice "#{count} Found" unless formatter.class == Format::Doku || formatter.class == Format::Name
|
156
168
|
end
|
157
169
|
end
|
158
170
|
|
@@ -199,7 +211,7 @@ end
|
|
199
211
|
|
200
212
|
|
201
213
|
desc "Build software"
|
202
|
-
long_desc "The software to build may be either the absolute path or the full name of the software. The full name includes version numbers and build names using the format:
|
214
|
+
long_desc "The software to build may be either the absolute path or the full name of the software. The full name includes version numbers and build names using the format: APPLICATION/VERSION/BUILD."
|
203
215
|
arg_name "PATH"
|
204
216
|
command ['build'] do |c|
|
205
217
|
c.desc 'Build log file name located within the software prefix.'
|
@@ -243,9 +255,9 @@ end
|
|
243
255
|
|
244
256
|
desc "Generate a new build and all necessary files"
|
245
257
|
long_desc <<-EOS
|
246
|
-
The new command will create all necessary files needed to add a new software package. Some care should be given to naming new packages. Some considerations are package names, version numbers, and build names. New package names should be of the format
|
258
|
+
The new command will create all necessary files needed to add a new software package. Some care should be given to naming new packages. Some considerations are package names, version numbers, and build names. New package names should be of the format APPLICATION/VERSION/BUILD
|
247
259
|
|
248
|
-
-
|
260
|
+
- APPLICATION of the package should be all lower case and one word. If multiple words are necessary separate them with dashes '-'.
|
249
261
|
|
250
262
|
- VERSION numbers should be standard numbers separated by periods. If another format is necessary ensure that the numbers can be lexigraphically sorted in order of oldest release to newest.
|
251
263
|
|
@@ -267,42 +279,46 @@ command ['new'] do |c|
|
|
267
279
|
c.desc "Skip modulefile generation"
|
268
280
|
c.switch ["skip-modulefile"], :negatable => false
|
269
281
|
|
282
|
+
c.desc "Use an existing software's build scripts"
|
283
|
+
c.arg_name "PATH"
|
284
|
+
c.flag [:e, "existing-scripts"]
|
285
|
+
|
270
286
|
c.desc "Provide a tarball to unpack, either a file or URL (optional)"
|
271
287
|
c.arg_name "FILE|URL"
|
272
|
-
c.flag [:t, :tarball]
|
288
|
+
c.flag [:t, :tarball, :tarfile]
|
273
289
|
c.action do |global_options,options,args|
|
274
290
|
raise "You must supply a name to create new packages" if args.empty?
|
275
291
|
|
276
292
|
p = Package.new :path => args.first
|
277
|
-
|
278
293
|
p.valid?
|
279
|
-
|
280
|
-
if options[:tarball] =~ URI::ABS_URI
|
281
|
-
url = options[:tarball]
|
282
|
-
elsif options[:tarball]
|
283
|
-
archive = File.absolute_path options[:tarball]
|
284
|
-
raise "The archive #{archive} does not exist" unless File.exists? archive
|
285
|
-
end
|
286
294
|
p.create :dry_run => options[:"dry-run"],
|
295
|
+
:existing => options[:"existing-scripts"],
|
287
296
|
:web => options[:"web-description"]
|
288
297
|
|
289
298
|
if options[:tarball]
|
290
|
-
|
291
|
-
|
299
|
+
if options[:tarball] =~ URI::ABS_URI
|
300
|
+
d = DownloadCache.new(p)
|
301
|
+
archive = d.get(options[:tarball])
|
302
|
+
else
|
303
|
+
archive = File.absolute_path options[:tarball]
|
304
|
+
raise "The archive #{archive} does not exist" unless File.exists? archive
|
305
|
+
end
|
292
306
|
p.extract :archive => archive, :dry_run => options[:"dry-run"]
|
293
307
|
end
|
294
308
|
|
295
309
|
unless options[:"skip-modulefile"]
|
296
310
|
m = ModuleFile.new :package => p
|
297
|
-
m.create :dry_run => options[:"dry-run"]
|
311
|
+
m.create :dry_run => options[:"dry-run"], :existing => options[:"existing-scripts"]
|
298
312
|
end
|
299
313
|
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
314
|
+
if global_options[:verbose]
|
315
|
+
notice "Next Steps"
|
316
|
+
notice_command " smithy edit last" , "Edit build scripts or modulefile"
|
317
|
+
notice_command " smithy build last" , "Run build script"
|
318
|
+
notice_command " smithy module create" , "Generate a modulefile" if options[:"skip-modulefile"]
|
319
|
+
notice_command " smithy module deploy last" , "Install modulefile"
|
320
|
+
notice_command " smithy publish last" , "Publish web description"
|
321
|
+
end
|
306
322
|
end
|
307
323
|
end
|
308
324
|
|
@@ -337,7 +353,6 @@ command ['edit'] do |c|
|
|
337
353
|
p = Package.new :path => arguments.first
|
338
354
|
p.valid?
|
339
355
|
p.prefix_exists!
|
340
|
-
p.rebuild_script_exists!
|
341
356
|
|
342
357
|
# if no file, prompt
|
343
358
|
if operation.nil?
|
@@ -491,9 +506,11 @@ command ['module'] do |c|
|
|
491
506
|
m = ModuleFile.new :package => p
|
492
507
|
|
493
508
|
m.create :dry_run => options[:"dry-run"]
|
494
|
-
|
495
|
-
|
496
|
-
|
509
|
+
if global_options[:verbose]
|
510
|
+
notice "Next Steps"
|
511
|
+
notice_command " smithy edit modulefile last" , "Edit generated modulefile"
|
512
|
+
notice_command " smithy module deploy last" , "Install modulefile"
|
513
|
+
end
|
497
514
|
end
|
498
515
|
end
|
499
516
|
|
@@ -534,8 +551,94 @@ command ['show'] do |c|
|
|
534
551
|
|
535
552
|
c.desc "List all architectures know to smithy."
|
536
553
|
c.command :arch do |arch|
|
537
|
-
arch.
|
538
|
-
|
554
|
+
arch.desc "list all architectures"
|
555
|
+
arch.switch [:a, "all"], :negatable => false
|
556
|
+
arch.action do |global_options,options,args|
|
557
|
+
Smithy::Config.architectures(options)
|
558
|
+
end
|
559
|
+
end
|
560
|
+
|
561
|
+
c.desc "Display an example config file."
|
562
|
+
c.command :example_config do |example_config|
|
563
|
+
example_config.action do
|
564
|
+
puts Smithy::Config.example_config
|
565
|
+
end
|
566
|
+
end
|
567
|
+
end
|
568
|
+
|
569
|
+
desc "Install software from predefined formulas"
|
570
|
+
command ['formula'] do |c|
|
571
|
+
c.desc "Specify one or more additional formula directories separated with commas"
|
572
|
+
c.arg_name "PATH"
|
573
|
+
c.flag [:d, :directories], :type => Array
|
574
|
+
|
575
|
+
c.desc "List known formulas"
|
576
|
+
c.command :list do |subcommand|
|
577
|
+
subcommand.action do |global_options,options,args|
|
578
|
+
FormulaCommand.list_command(options,args)
|
579
|
+
end
|
580
|
+
end
|
581
|
+
|
582
|
+
c.desc "Display a formula location"
|
583
|
+
c.arg_name "FORMULA"
|
584
|
+
c.command :which do |subcommand|
|
585
|
+
subcommand.action do |global_options,options,args|
|
586
|
+
FormulaCommand.which_command(options,args)
|
587
|
+
end
|
588
|
+
end
|
589
|
+
|
590
|
+
c.desc "Display a formula"
|
591
|
+
c.arg_name "FORMULA"
|
592
|
+
c.command :display do |subcommand|
|
593
|
+
subcommand.action do |global_options,options,args|
|
594
|
+
FormulaCommand.display_command(options,args)
|
595
|
+
end
|
596
|
+
end
|
597
|
+
|
598
|
+
c.desc "Create a new formula"
|
599
|
+
c.arg_name "URL"
|
600
|
+
c.command :new do |subcommand|
|
601
|
+
subcommand.desc "Formula name"
|
602
|
+
subcommand.arg_name "NAME"
|
603
|
+
subcommand.flag [:n, "name"]
|
604
|
+
|
605
|
+
subcommand.desc "Formula homepage"
|
606
|
+
subcommand.arg_name "URL"
|
607
|
+
subcommand.flag [:h, "homepage"]
|
608
|
+
|
609
|
+
subcommand.action do |global_options,options,args|
|
610
|
+
FormulaCommand.new_command(options,args)
|
611
|
+
end
|
612
|
+
end
|
613
|
+
|
614
|
+
c.desc "Install a package using a formula"
|
615
|
+
c.arg_name "APPLICATION | APPLICATION/VERSION | APPLICATION/VERSION/BUILD"
|
616
|
+
c.command :install do |subcommand|
|
617
|
+
subcommand.desc "Formula name"
|
618
|
+
subcommand.arg_name "NAME"
|
619
|
+
subcommand.flag [:f, "formula-name"]
|
620
|
+
|
621
|
+
subcommand.desc "Create modulefiles as well"
|
622
|
+
subcommand.switch [:m, "modulefile"], :negatable => false
|
623
|
+
|
624
|
+
subcommand.desc "Clean exiting install prefix"
|
625
|
+
subcommand.default_value false
|
626
|
+
subcommand.switch [:c, "clean"]
|
627
|
+
|
628
|
+
subcommand.action do |global_options,options,args|
|
629
|
+
FormulaCommand.install_command(options,args)
|
630
|
+
end
|
631
|
+
end
|
632
|
+
|
633
|
+
c.desc "Create a modulefile for a given package"
|
634
|
+
c.arg_name "APPLICATION | APPLICATION/VERSION | APPLICATION/VERSION/BUILD"
|
635
|
+
c.command :create_modulefile do |subcommand|
|
636
|
+
subcommand.desc "Formula name"
|
637
|
+
subcommand.arg_name "NAME"
|
638
|
+
subcommand.flag [:f, "formula-name"]
|
639
|
+
|
640
|
+
subcommand.action do |global_options,options,args|
|
641
|
+
FormulaCommand.create_module_command(options,args)
|
539
642
|
end
|
540
643
|
end
|
541
644
|
end
|
@@ -557,12 +660,13 @@ end
|
|
557
660
|
# end
|
558
661
|
|
559
662
|
pre do |global,command,options,args|
|
560
|
-
# ap global #XXX
|
561
663
|
Sickill::Rainbow.enabled = false if global[:"colors"] == false
|
562
664
|
|
563
665
|
Smithy::Config.config_file_name = File.join(@@smithy_bin_root,"etc/smithyrc")
|
564
666
|
Smithy::Config.load_configuration(global)
|
565
667
|
|
668
|
+
@@global_config = global
|
669
|
+
|
566
670
|
# Pre logic here
|
567
671
|
# Return true to proceed; false to abort and not call the chosen command
|
568
672
|
# Use skips_pre before a command to skip this block on that command only
|
@@ -576,9 +680,12 @@ post do |global,command,options,args|
|
|
576
680
|
end
|
577
681
|
|
578
682
|
on_error do |exception|
|
683
|
+
notice_exception exception.message unless exception.message.blank?
|
684
|
+
|
685
|
+
log_exception(exception, @@global_argv, @@global_config)
|
579
686
|
# Error logic here
|
580
687
|
# return false to skip default error handling
|
581
|
-
|
688
|
+
false
|
582
689
|
end
|
583
690
|
|
584
691
|
exit run(ARGV)
|
@@ -83,25 +83,32 @@ _smithy ()
|
|
83
83
|
-*)
|
84
84
|
__smithycomp "
|
85
85
|
--arch=
|
86
|
+
--no-colors
|
87
|
+
--colors
|
86
88
|
--config-file=
|
89
|
+
--descriptions-root=
|
87
90
|
--disable-group-writable
|
91
|
+
--force
|
88
92
|
--file-group-name=
|
89
93
|
--help
|
90
|
-
--
|
94
|
+
--prgenv-prefix=
|
91
95
|
--software-root=
|
96
|
+
--verbose
|
92
97
|
--web-root="
|
93
98
|
return
|
94
99
|
;;
|
95
100
|
*)
|
96
101
|
__smithycomp "
|
97
102
|
build
|
98
|
-
deploy
|
99
103
|
edit
|
104
|
+
formula
|
100
105
|
help
|
101
106
|
module
|
102
107
|
new
|
108
|
+
publish
|
103
109
|
repair
|
104
110
|
search
|
111
|
+
show
|
105
112
|
test"
|
106
113
|
return
|
107
114
|
;;
|
@@ -113,11 +120,14 @@ _smithy ()
|
|
113
120
|
case "$cmd" in
|
114
121
|
build|test) _smithy_build ;;
|
115
122
|
edit) _smithy_edit ;;
|
123
|
+
formula) _smithy_formula ;;
|
116
124
|
help) _smithy_help ;;
|
117
125
|
module) _smithy_module ;;
|
118
126
|
new) _smithy_new ;;
|
119
|
-
|
127
|
+
publish) _smithy_publish ;;
|
128
|
+
repair) _smithy_repair ;;
|
120
129
|
search) _smithy_search ;;
|
130
|
+
show) _smithy_show ;;
|
121
131
|
*) ;;
|
122
132
|
esac
|
123
133
|
}
|
@@ -129,6 +139,13 @@ __smithy_complete_packages ()
|
|
129
139
|
COMPREPLY=($(compgen -W "$packages" -- "$cur"))
|
130
140
|
}
|
131
141
|
|
142
|
+
__smithy_complete_formulas ()
|
143
|
+
{
|
144
|
+
local cur="${COMP_WORDS[COMP_CWORD]}"
|
145
|
+
local packages=$(smithy formula list ${cur})
|
146
|
+
COMPREPLY=($(compgen -W "$packages" -- "$cur"))
|
147
|
+
}
|
148
|
+
|
132
149
|
_smithy_build () {
|
133
150
|
local cur="${COMP_WORDS[COMP_CWORD]}"
|
134
151
|
local prv="${COMP_WORDS[COMP_CWORD-1]}"
|
@@ -151,12 +168,25 @@ _smithy_build () {
|
|
151
168
|
__smithy_complete_packages
|
152
169
|
}
|
153
170
|
|
171
|
+
_smithy_publish () {
|
172
|
+
local cur="${COMP_WORDS[COMP_CWORD]}"
|
173
|
+
local prv="${COMP_WORDS[COMP_CWORD-1]}"
|
174
|
+
case "$cur" in
|
175
|
+
-*)
|
176
|
+
__smithycomp "
|
177
|
+
--dry-run"
|
178
|
+
return
|
179
|
+
;;
|
180
|
+
esac
|
181
|
+
__smithy_complete_packages
|
182
|
+
}
|
183
|
+
|
154
184
|
_smithy_module () {
|
155
185
|
local cur="${COMP_WORDS[COMP_CWORD]}"
|
156
186
|
local prv="${COMP_WORDS[COMP_CWORD-1]}"
|
157
187
|
case "$prv" in
|
158
188
|
module)
|
159
|
-
__smithycomp "create use
|
189
|
+
__smithycomp "create deploy edit use"
|
160
190
|
return
|
161
191
|
;;
|
162
192
|
esac
|
@@ -176,7 +206,7 @@ _smithy_edit () {
|
|
176
206
|
local prv="${COMP_WORDS[COMP_CWORD-1]}"
|
177
207
|
case "$prv" in
|
178
208
|
edit)
|
179
|
-
__smithycomp "build test
|
209
|
+
__smithycomp "build test env modulefile"
|
180
210
|
return
|
181
211
|
;;
|
182
212
|
-e)
|
@@ -192,6 +222,7 @@ _smithy_edit () {
|
|
192
222
|
;;
|
193
223
|
-*)
|
194
224
|
__smithycomp "
|
225
|
+
--split
|
195
226
|
--editor="
|
196
227
|
return
|
197
228
|
;;
|
@@ -199,13 +230,76 @@ _smithy_edit () {
|
|
199
230
|
__smithy_complete_packages
|
200
231
|
}
|
201
232
|
|
233
|
+
_smithy_formula () {
|
234
|
+
local cur="${COMP_WORDS[COMP_CWORD]}"
|
235
|
+
local prv="${COMP_WORDS[COMP_CWORD-1]}"
|
236
|
+
case "$prv" in
|
237
|
+
formula)
|
238
|
+
case "$cur" in
|
239
|
+
--directories=*)
|
240
|
+
local t=`echo "$cur" | sed -e 's/--directories=//g'`
|
241
|
+
COMPREPLY=($(compgen -f "$t"))
|
242
|
+
return
|
243
|
+
;;
|
244
|
+
-*)
|
245
|
+
__smithycomp "
|
246
|
+
--directories="
|
247
|
+
return
|
248
|
+
;;
|
249
|
+
esac
|
250
|
+
__smithycomp "create_modulefile display install list new which"
|
251
|
+
return
|
252
|
+
;;
|
253
|
+
new)
|
254
|
+
case "$cur" in
|
255
|
+
-*)
|
256
|
+
__smithycomp "
|
257
|
+
--name=
|
258
|
+
--homepage="
|
259
|
+
return
|
260
|
+
;;
|
261
|
+
esac
|
262
|
+
return
|
263
|
+
;;
|
264
|
+
install)
|
265
|
+
case "$cur" in
|
266
|
+
-*)
|
267
|
+
__smithycomp "
|
268
|
+
--no-clean
|
269
|
+
--clean
|
270
|
+
--formula-name=
|
271
|
+
--modulefile"
|
272
|
+
return
|
273
|
+
;;
|
274
|
+
esac
|
275
|
+
__smithy_complete_formulas
|
276
|
+
return
|
277
|
+
;;
|
278
|
+
create_modulefile)
|
279
|
+
case "$cur" in
|
280
|
+
-*)
|
281
|
+
__smithycomp "
|
282
|
+
--formula-name="
|
283
|
+
return
|
284
|
+
;;
|
285
|
+
esac
|
286
|
+
__smithy_complete_formulas
|
287
|
+
return
|
288
|
+
;;
|
289
|
+
-d)
|
290
|
+
COMPREPLY=($(compgen -f "$cur"))
|
291
|
+
return
|
292
|
+
;;
|
293
|
+
esac
|
294
|
+
}
|
295
|
+
|
202
296
|
_smithy_search () {
|
203
297
|
local cur="${COMP_WORDS[COMP_CWORD]}"
|
204
298
|
local prv="${COMP_WORDS[COMP_CWORD-1]}"
|
205
299
|
|
206
300
|
case "$prv" in
|
207
301
|
--format=*)
|
208
|
-
__smithycomp "path name table csv"
|
302
|
+
__smithycomp "path name table csv dokuwiki"
|
209
303
|
return
|
210
304
|
;;
|
211
305
|
esac
|
@@ -236,6 +330,7 @@ _smithy_new () {
|
|
236
330
|
;;
|
237
331
|
-*)
|
238
332
|
__smithycomp "
|
333
|
+
--existing-scripts=
|
239
334
|
--dry-run
|
240
335
|
--tarball=
|
241
336
|
--web-description
|
@@ -247,7 +342,11 @@ _smithy_new () {
|
|
247
342
|
}
|
248
343
|
|
249
344
|
_smithy_help () {
|
250
|
-
__smithycomp "build
|
345
|
+
__smithycomp "build edit formula help module new publish repair search show test"
|
346
|
+
}
|
347
|
+
|
348
|
+
_smithy_show () {
|
349
|
+
__smithycomp "arch example_config last"
|
251
350
|
}
|
252
351
|
|
253
352
|
_smithy_repair () {
|