pjam 0.1.0 → 0.1.3
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.
- data/bin/pjam +148 -41
- metadata +4 -5
data/bin/pjam
CHANGED
@@ -8,37 +8,108 @@ include Term::ANSIColor
|
|
8
8
|
|
9
9
|
opts = Trollop::options do
|
10
10
|
|
11
|
-
version "pjam 0.
|
11
|
+
version "pjam 0.1.3 (c) 2013 Alexey Melezhik / melezhik@gmail.com"
|
12
12
|
banner <<-EOS
|
13
|
-
|
13
|
+
Pjam is a tool which enables automatic creation of perl applications distribution archives from source code using pinto
|
14
14
|
|
15
15
|
Usage:
|
16
16
|
pjam [options]
|
17
17
|
where [options] are:
|
18
18
|
EOS
|
19
19
|
|
20
|
-
opt :p, "path to project", :type => :string
|
20
|
+
opt :p, "path to project root directory", :type => :string
|
21
|
+
opt :wd, "add dependencies for development", :default => false
|
22
|
+
opt :c, "path to pjam configuration file, should be relative to project root directory", :type => :string
|
21
23
|
opt :skip_pinto, "skip pinto phase, only do distibution phase", :default => false
|
22
|
-
opt :
|
24
|
+
opt :update, "update distibution archive if it alerady exists in repository", :default => true
|
25
|
+
opt :dry_run, "run in dry-run mode; only upcoming changes will be shown, no action will be taken", :default => false
|
26
|
+
opt :no_color, "disable colour output", :default => false
|
23
27
|
opt :no_misc, "do not add miscellaneous prerequisites", :default => false
|
24
28
|
opt :only, "only add given source(s). multiple sources are separated by comma", :type => :string, :default => nil
|
25
29
|
opt :only_pinto, "only do pinto phase, skip distribution phase", :default => false
|
30
|
+
opt :env, "set environmental varibales. use format env='a=1 b=2 c=3'", :type => :string, :default => nil
|
31
|
+
|
26
32
|
end
|
27
33
|
|
28
34
|
version_postfix = `date +-rev-%Y-%B-%d-%H-%M`.chomp!
|
29
35
|
|
36
|
+
if opts[:p].nil?
|
37
|
+
project_id = Dir.pwd
|
38
|
+
else
|
39
|
+
project_id = "#{Dir.pwd}/#{opts[:p]}"
|
40
|
+
end
|
41
|
+
|
42
|
+
wd_flag = ( opts[:wd] == true ) ? "--wd" : ""
|
43
|
+
|
44
|
+
local_lib = "#{project_id}/cpanlib"
|
45
|
+
|
46
|
+
if ((opts.has_key? :c) and (! opts[:c].nil? ))
|
47
|
+
config_path = "#{project_id}/#{opts[:c]}"
|
48
|
+
else
|
49
|
+
config_path = "#{project_id}/pjam.json"
|
50
|
+
end
|
51
|
+
|
52
|
+
env_string_arr = ['export PINTO_DEBUG=0']
|
53
|
+
|
54
|
+
unless opts[:env].nil?
|
55
|
+
opts[:env].split(' ').each do |ch|
|
56
|
+
env_string_arr << "export #{ch}"
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
env_string = env_string_arr.join ' && '
|
61
|
+
|
30
62
|
|
31
63
|
if opts[:no_color] == true
|
32
|
-
puts "
|
64
|
+
puts "path to pjam configuration file: #{config_path}"
|
33
65
|
else
|
34
|
-
puts dark {
|
66
|
+
puts dark { green { bold { "path to pjam configuration file: #{config_path}" } } }
|
35
67
|
end
|
36
68
|
|
37
|
-
|
38
|
-
local_lib = "#{project_id}/cpanlib"
|
69
|
+
config = JSON.parse(File.read(config_path))
|
39
70
|
|
40
|
-
if
|
41
|
-
|
71
|
+
if config.has_key? 'repository'
|
72
|
+
repo_root = "-r #{config['repository']}"
|
73
|
+
else
|
74
|
+
repo_root = "-r #{ENV['PINTO_REPOSITORY_ROOT']}"
|
75
|
+
end
|
76
|
+
|
77
|
+
if opts[:no_color] == true
|
78
|
+
puts "pinto repository root: #{repo_root}"
|
79
|
+
else
|
80
|
+
puts dark { green { bold { "pinto repository root: #{repo_root}" } } }
|
81
|
+
end
|
82
|
+
|
83
|
+
if config.has_key? 'override'
|
84
|
+
override = config['override']
|
85
|
+
else
|
86
|
+
override = true
|
87
|
+
end
|
88
|
+
|
89
|
+
if opts[:no_color] == true
|
90
|
+
puts "override mode: #{override}"
|
91
|
+
else
|
92
|
+
puts dark { cyan { bold { "override mode: #{override}" } } }
|
93
|
+
end
|
94
|
+
|
95
|
+
sources_list = []
|
96
|
+
only_list = []
|
97
|
+
if opts[:only].nil?
|
98
|
+
sources_list = config['sources']
|
99
|
+
else
|
100
|
+
p_only = opts[:only].split(' ')
|
101
|
+
only_list = p_only
|
102
|
+
sources_list = config['sources'].select {|i| p_only.include? i }
|
103
|
+
end
|
104
|
+
|
105
|
+
compile_list = []
|
106
|
+
compile_list_pp = {}
|
107
|
+
|
108
|
+
|
109
|
+
if opts[:no_color] == true
|
110
|
+
puts "generated version postfix: #{version_postfix}"
|
111
|
+
else
|
112
|
+
puts dark { yellow { bold { "generated version postfix: #{version_postfix}" } } }
|
42
113
|
end
|
43
114
|
|
44
115
|
|
@@ -48,16 +119,36 @@ else
|
|
48
119
|
color_flag = ''
|
49
120
|
end
|
50
121
|
|
51
|
-
config = JSON.parse(File.read("#{project_id}/pjam.json"))
|
52
|
-
|
53
122
|
misc_modules = []
|
54
123
|
|
55
|
-
if
|
124
|
+
if opts[:dry_run] == true
|
125
|
+
if opts[:no_color] == true
|
126
|
+
puts "dry-run mode is enabled; only upcoming changes will be shown; no action will be taken"
|
127
|
+
else
|
128
|
+
puts dark { magenta { bold { "dry-run mode is enabled; only upcoming changes will be shown; no action will be taken" } } }
|
129
|
+
end
|
130
|
+
|
131
|
+
sources_list.each do |src|
|
132
|
+
cmd = "cd #{project_id}/#{src} && svn log -r BASE:HEAD --verbose . > dry-run.log"
|
133
|
+
st = system(cmd) == true or raise "failed do cmd: #{cmd}"
|
134
|
+
|
135
|
+
if opts[:no_color] == true
|
136
|
+
puts "upcoming changes for #{src}:"
|
137
|
+
else
|
138
|
+
puts dark { magenta { bold { "upcoming changes for source #{src}:" } } }
|
139
|
+
end
|
140
|
+
|
141
|
+
puts File.read("#{project_id}/#{src}/dry-run.log")
|
142
|
+
end
|
143
|
+
exit(0)
|
144
|
+
end
|
145
|
+
|
146
|
+
if config.has_key? 'modules' and opts[:no_misc] == false
|
56
147
|
|
57
148
|
if opts[:no_color] == true
|
58
|
-
puts "
|
149
|
+
puts "pull misc modules to pinto repository"
|
59
150
|
else
|
60
|
-
puts dark { blue { bold { "
|
151
|
+
puts dark { blue { bold { "pull misc modules to pinto repository" } } }
|
61
152
|
end
|
62
153
|
|
63
154
|
config['modules'].each do |m|
|
@@ -67,7 +158,7 @@ if config.has_key? 'modules' and opts[:no_misc] == false and opts[:skip_pinto] =
|
|
67
158
|
else
|
68
159
|
puts dark { magenta { bold { "pull #{m}" } } }
|
69
160
|
end
|
70
|
-
cmd ="pinto pull -s #{config['stack']} -v --use-default-message #{m} #{color_flag}"
|
161
|
+
cmd ="pinto #{repo_root} pull -s #{config['stack']} -v #{wd_flag} --use-default-message #{m} #{color_flag}"
|
71
162
|
system(cmd) == true or raise "failed do cmd: #{cmd}"
|
72
163
|
|
73
164
|
misc_modules << m
|
@@ -75,18 +166,6 @@ if config.has_key? 'modules' and opts[:no_misc] == false and opts[:skip_pinto] =
|
|
75
166
|
end
|
76
167
|
end
|
77
168
|
|
78
|
-
sources_list = []
|
79
|
-
only_list = []
|
80
|
-
if opts[:only].nil?
|
81
|
-
sources_list = config['sources']
|
82
|
-
else
|
83
|
-
p_only = opts[:only].split(/\s+/)
|
84
|
-
only_list = p_only
|
85
|
-
sources_list = config['sources'].select {|i| p_only.include? i }
|
86
|
-
end
|
87
|
-
|
88
|
-
compile_list = []
|
89
|
-
compile_list_pp = {}
|
90
169
|
|
91
170
|
sources_list.each do |src|
|
92
171
|
|
@@ -107,16 +186,34 @@ sources_list.each do |src|
|
|
107
186
|
else
|
108
187
|
|
109
188
|
if opts[:no_color] == true
|
110
|
-
puts "add #{src} [#{distro_name}] to pinto"
|
189
|
+
puts "add source #{src} [#{distro_name}] to pinto"
|
111
190
|
else
|
112
|
-
puts dark { magenta { bold { "add #{src} [#{distro_name}] to pinto" } } }
|
191
|
+
puts dark { magenta { bold { "add source #{src} [#{distro_name}] to pinto" } } }
|
113
192
|
end
|
114
193
|
|
115
|
-
|
116
|
-
|
194
|
+
if opts[:update] == false
|
195
|
+
if ((system("cd #{project_id}/#{src} && pinto #{repo_root} list -D #{distro_name} --no-color | grep PINTO/#{distro_name}")) == true)
|
196
|
+
if opts[:no_color] == true
|
197
|
+
puts "[#{distro_name}] already in pinto; skip update due to --no-update is enabled"
|
198
|
+
else
|
199
|
+
puts dark { blue { bold { "[#{distro_name}] already in pinto; skip update due to --no-update is enabled" } } }
|
200
|
+
end
|
201
|
+
update_distro = false
|
202
|
+
else
|
203
|
+
update_distro = true
|
204
|
+
end
|
205
|
+
else
|
206
|
+
update_distro = true
|
207
|
+
end
|
117
208
|
|
118
|
-
|
119
|
-
|
209
|
+
if update_distro == true
|
210
|
+
unless override == false
|
211
|
+
cmd ="cd #{project_id}/#{src} && pinto #{repo_root} delete -v PINTO/#{distro_name} #{color_flag}"
|
212
|
+
system(cmd) == true
|
213
|
+
end
|
214
|
+
cmd ="cd #{project_id}/#{src} && pinto #{repo_root} add -s #{config['stack']} -v #{wd_flag} --use-default-message #{distro_name} #{color_flag}"
|
215
|
+
system(cmd) == true or raise "failed do cmd: #{cmd}"
|
216
|
+
end
|
120
217
|
|
121
218
|
compile_list << distro_name
|
122
219
|
compile_list_pp[distro_name] = src
|
@@ -125,6 +222,15 @@ sources_list.each do |src|
|
|
125
222
|
|
126
223
|
end
|
127
224
|
|
225
|
+
if opts[:no_color] == true
|
226
|
+
puts "update packages list file"
|
227
|
+
else
|
228
|
+
puts dark { magenta { bold { "update packages list file" } } }
|
229
|
+
end
|
230
|
+
|
231
|
+
cmd = "pinto #{repo_root} list -s #{config['stack']} --format %a/%f --no-color | sort | uniq > #{project_id}/packages.txt"
|
232
|
+
system(cmd) == true or raise "failed do cmd: #{cmd}"
|
233
|
+
|
128
234
|
unless opts[:only_pinto] == true
|
129
235
|
|
130
236
|
misc_modules.each do |m|
|
@@ -135,7 +241,7 @@ unless opts[:only_pinto] == true
|
|
135
241
|
puts green { bold { "compile #{m}" } }
|
136
242
|
end
|
137
243
|
|
138
|
-
cmd = "pinto install -s #{config['stack']} -l #{local_lib} -o '
|
244
|
+
cmd = "#{env_string} && pinto #{repo_root} install -s #{config['stack']} -l #{local_lib} -o 'q' #{m} #{color_flag}"
|
139
245
|
system(cmd) == true or raise "failed do cmd: #{cmd}"
|
140
246
|
end
|
141
247
|
|
@@ -148,7 +254,7 @@ unless opts[:only_pinto] == true
|
|
148
254
|
puts green { bold { "compile #{compile_list_pp[d]} [#{d}]" } }
|
149
255
|
end
|
150
256
|
|
151
|
-
cmd = "pinto install -s #{config['stack']} -l #{local_lib} -o 'q' PINTO/#{d} #{color_flag}"
|
257
|
+
cmd = "#{env_string} && pinto #{repo_root} install -s #{config['stack']} -l #{local_lib} -o 'q' PINTO/#{d} #{color_flag}"
|
152
258
|
system(cmd) == true or raise "failed do cmd: #{cmd}"
|
153
259
|
|
154
260
|
end
|
@@ -156,9 +262,9 @@ unless opts[:only_pinto] == true
|
|
156
262
|
if only_list.empty? or only_list.include? config['application']
|
157
263
|
|
158
264
|
if opts[:no_color] == true
|
159
|
-
puts "make distributive from #{config['application']}"
|
265
|
+
puts "make distributive from source #{config['application']}"
|
160
266
|
else
|
161
|
-
puts yellow { bold { "make distributive from #{config['application']}" } }
|
267
|
+
puts yellow { bold { "make distributive from source #{config['application']}" } }
|
162
268
|
end
|
163
269
|
|
164
270
|
cmd = "export version_postfix='#{version_postfix}' && cd #{project_id}/#{config['application']} && rm -rf cpanlib && mkdir cpanlib/ && cp -r #{local_lib}/* cpanlib/ && rm -rf *.gz && ./Build realclean --quiet 1>/dev/null && perl Build.PL --quiet 1>/dev/null 2>module_build.err.log && ./Build manifest --quiet 2>/dev/null 1>/dev/null && ./Build dist --quiet 1>/dev/null && ln -fs `ls #{project_id}/#{config['application']}/*.gz` #{project_id}/current.tar.gz && echo -n `ls *.gz` > #{project_id}/current.txt"
|
@@ -167,14 +273,15 @@ unless opts[:only_pinto] == true
|
|
167
273
|
|
168
274
|
|
169
275
|
if opts[:no_color] == true
|
170
|
-
puts "testing #{config['application']}"
|
276
|
+
puts "testing source #{config['application']}"
|
171
277
|
else
|
172
|
-
puts cyan { bold { "testing #{config['application']}" } }
|
278
|
+
puts cyan { bold { "testing source #{config['application']}" } }
|
173
279
|
end
|
174
280
|
|
175
|
-
cmd = "cd #{project_id} && pinto install -s #{config['stack']} -l #{local_lib} -o 'test-only' PINTO/`cat current.txt` #{color_flag}"
|
281
|
+
cmd = "cd #{project_id} && #{env_string} && pinto #{repo_root} install -s #{config['stack']} -l #{local_lib} -o 'test-only' PINTO/`cat current.txt` #{color_flag}"
|
176
282
|
system(cmd) == true or raise "failed do cmd: #{cmd}"
|
177
283
|
|
178
284
|
end
|
179
285
|
|
180
286
|
end
|
287
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pjam
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-12-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|
@@ -75,9 +75,8 @@ dependencies:
|
|
75
75
|
- - ! '>='
|
76
76
|
- !ruby/object:Gem::Version
|
77
77
|
version: '0'
|
78
|
-
description: Pjam is
|
79
|
-
|
80
|
-
code using pinto.
|
78
|
+
description: Pjam is a tool which enables automatic creation of perl applications
|
79
|
+
distribution archives from source code using pinto
|
81
80
|
email: melezhik@gmail.com
|
82
81
|
executables:
|
83
82
|
- pjam
|