packo 0.0.1.alpha.1 → 0.0.1.alpha.2
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/packo +13 -2
- data/lib/packo.rb +16 -52
- data/lib/packo/cli.rb +9 -3
- data/lib/packo/cli/base.rb +65 -66
- data/lib/packo/cli/build.rb +124 -128
- data/lib/packo/cli/files.rb +7 -7
- data/lib/packo/cli/repository.rb +40 -26
- data/lib/packo/do.rb +106 -73
- data/lib/packo/environment.rb +2 -2
- data/lib/packo/extensions.rb +20 -6
- data/lib/packo/host.rb +10 -0
- data/lib/packo/models.rb +8 -2
- data/lib/packo/models/repository.rb +17 -14
- data/lib/packo/package.rb +9 -3
- data/lib/packo/profile.rb +2 -2
- data/lib/packo/rbuild.rb +0 -2
- data/lib/packo/rbuild/behaviors/default.rb +3 -2
- data/lib/packo/rbuild/{modules/misc/fetching.rb → behaviors/python.rb} +8 -3
- data/lib/packo/rbuild/modules.rb +2 -3
- data/lib/packo/rbuild/modules/building.rb +5 -2
- data/lib/packo/rbuild/modules/building/autotools.rb +11 -11
- data/lib/packo/rbuild/modules/building/rake.rb +71 -7
- data/lib/packo/rbuild/modules/building/scons.rb +128 -0
- data/lib/packo/rbuild/modules/{misc/fetcher.rb → fetcher.rb} +5 -5
- data/lib/packo/rbuild/modules/fetching.rb +29 -0
- data/lib/packo/rbuild/modules/{misc/fetching → fetching}/git.rb +15 -9
- data/lib/packo/rbuild/modules/{misc/fetching → fetching}/github.rb +1 -1
- data/lib/packo/rbuild/modules/{misc/fetching → fetching}/gnu.rb +1 -1
- data/lib/packo/rbuild/modules/{misc/fetching → fetching}/mercurial.rb +11 -7
- data/lib/packo/rbuild/modules/{misc/fetching → fetching}/sourceforge.rb +1 -1
- data/lib/packo/rbuild/modules/{misc/fetching → fetching}/subversion.rb +23 -5
- data/lib/packo/rbuild/modules/misc.rb +0 -8
- data/lib/packo/rbuild/modules/packager.rb +63 -0
- data/lib/packo/rbuild/modules/packaging.rb +2 -0
- data/lib/packo/rbuild/modules/packaging/pko.rb +24 -44
- data/lib/packo/rbuild/modules/{misc/unpacker.rb → unpacker.rb} +2 -2
- data/lib/packo/rbuild/modules/{misc/unpacking.rb → unpacking.rb} +6 -4
- data/lib/packo/rbuild/modules/{misc/unpacking → unpacking}/lzma.rb +1 -1
- data/lib/packo/rbuild/modules/{misc/unpacking → unpacking}/tar.rb +1 -1
- data/lib/packo/rbuild/modules/{misc/unpacking → unpacking}/xz.rb +1 -1
- data/lib/packo/rbuild/modules/{misc/unpacking → unpacking}/zip.rb +1 -1
- data/lib/packo/rbuild/package.rb +17 -8
- data/lib/packo/repository.rb +1 -1
- data/lib/packo/repository/virtual.rb +16 -0
- data/lib/packo/utils.rb +106 -0
- data/lib/packo/version.rb +1 -1
- metadata +39 -25
- data/lib/packo/rbuild/modules/misc/fetching/wget.rb +0 -57
data/bin/packo
CHANGED
@@ -19,6 +19,8 @@
|
|
19
19
|
# along with packo. If not, see <http://www.gnu.org/licenses/>.
|
20
20
|
#++
|
21
21
|
|
22
|
+
require 'shellwords'
|
23
|
+
|
22
24
|
commands = Dir.glob('/usr/bin/packo-*').map {|path|
|
23
25
|
File.basename(path).sub('packo-', '')
|
24
26
|
}
|
@@ -49,12 +51,21 @@ if commands.member?(ARGV.first)
|
|
49
51
|
warn "sandbox isn't installed" if !sandbox
|
50
52
|
warn "fakeroot isn't installed" if !fakeroot
|
51
53
|
|
52
|
-
|
54
|
+
through = []
|
55
|
+
|
56
|
+
if !trusted.include?(command.to_sym)
|
57
|
+
through << 'sandbox'
|
58
|
+
end
|
59
|
+
|
60
|
+
through << 'fakeroot' << "packo-#{command}"
|
61
|
+
|
62
|
+
exit Kernel.system(*(through + ARGV.map {|arg|
|
63
|
+
arg.shellescape
|
64
|
+
}))
|
53
65
|
end
|
54
66
|
|
55
67
|
require 'rubygems' unless defined?(Gem)
|
56
68
|
|
57
|
-
require 'packo'
|
58
69
|
require 'packo/cli/base'
|
59
70
|
|
60
71
|
class Application < Packo::CLI::Base
|
data/lib/packo.rb
CHANGED
@@ -17,44 +17,10 @@
|
|
17
17
|
# along with packo. If not, see <http://www.gnu.org/licenses/>.
|
18
18
|
#++
|
19
19
|
|
20
|
-
require '
|
20
|
+
require 'packo/utils'
|
21
|
+
require 'packo/extensions'
|
21
22
|
|
22
23
|
module Packo
|
23
|
-
def self.sh (*cmd, &block)
|
24
|
-
options = (Hash === cmd.last) ? cmd.pop : {}
|
25
|
-
|
26
|
-
if !block_given?
|
27
|
-
show_command = cmd.join(' ')
|
28
|
-
show_command = show_command[0, 42] + '...' unless $trace
|
29
|
-
|
30
|
-
block = lambda {|ok, status|
|
31
|
-
ok or fail "Command failed with status (#{status.exitstatus}): [#{show_command}] in {#{Dir.pwd}}"
|
32
|
-
}
|
33
|
-
end
|
34
|
-
|
35
|
-
if options[:silent]
|
36
|
-
options[:out] = '/dev/null'
|
37
|
-
options[:err] = '/dev/null'
|
38
|
-
else
|
39
|
-
print "#{cmd.first} "
|
40
|
-
cmd[1 .. cmd.length].each {|cmd|
|
41
|
-
if cmd.match(/[ \$'`]/)
|
42
|
-
print %Q{"#{cmd}" }
|
43
|
-
else
|
44
|
-
print "#{cmd} "
|
45
|
-
end
|
46
|
-
}
|
47
|
-
print "\n"
|
48
|
-
end
|
49
|
-
|
50
|
-
options.delete :silent
|
51
|
-
|
52
|
-
result = Kernel.system(options[:env] || {}, *cmd, options)
|
53
|
-
status = $?
|
54
|
-
|
55
|
-
block.call(result, status)
|
56
|
-
end
|
57
|
-
|
58
24
|
def self.debug (argument, options={})
|
59
25
|
if !Packo.const_defined?(:System) || (!System.env[:DEBUG] && !options[:force])
|
60
26
|
return
|
@@ -82,27 +48,26 @@ module Packo
|
|
82
48
|
output << options[:separator]
|
83
49
|
end
|
84
50
|
|
85
|
-
puts output
|
86
|
-
end
|
87
|
-
|
88
|
-
def self.load (path, options={})
|
89
|
-
if !File.readable? path
|
90
|
-
raise LoadError.new("no such file to load -- #{path}")
|
91
|
-
end
|
92
|
-
|
93
|
-
eval("#{options[:before]}#{File.read(path, encoding: 'utf-8').split(/^__END__$/).first}#{options[:after]}", options[:binding] || binding, path, 1)
|
51
|
+
$stderr.puts output
|
94
52
|
end
|
95
53
|
|
96
54
|
def self.loadPackage (path, package=nil)
|
97
55
|
options = {
|
98
|
-
before:
|
99
|
-
|
56
|
+
before: %{
|
57
|
+
module ::Packo::RBuild
|
58
|
+
include ::Packo::RBuild::Modules
|
59
|
+
include ::Packo::RBuild::Behaviors
|
60
|
+
},
|
61
|
+
|
62
|
+
after: %{
|
63
|
+
end
|
64
|
+
}
|
100
65
|
}
|
101
66
|
|
102
67
|
files = {}
|
103
68
|
|
104
69
|
if package
|
105
|
-
if File.exists?("#{path}/digest.xml") && (digest = Nokogiri::XML.parse(File.read("#{path}/digest.xml")))
|
70
|
+
if File.exists?("#{path}/digest.xml") && (digest = Nokogiri::XML.parse(File.read("#{path}/digest.xml", encoding: 'utf-8')))
|
106
71
|
features = digest.xpath("//build[@version = '#{package.version}'][@slot = '#{package.slot}']/features").first
|
107
72
|
|
108
73
|
if features
|
@@ -137,7 +102,7 @@ module Packo
|
|
137
102
|
begin
|
138
103
|
Packo.load "#{path}/#{package.name}.rbuild", options
|
139
104
|
|
140
|
-
if (pkg = RBuild::Package.last) && (tmp = File.read("#{path}/#{package.name}.rbuild").split(/^__END__$/)).length > 1
|
105
|
+
if (pkg = RBuild::Package.last) && (tmp = File.read("#{path}/#{package.name}.rbuild", encoding: 'utf-8').split(/^__END__$/)).length > 1
|
141
106
|
pkg.filesystem.parse(tmp.last.lstrip)
|
142
107
|
end
|
143
108
|
rescue Exception => e
|
@@ -149,7 +114,7 @@ module Packo
|
|
149
114
|
if RBuild::Package.last.name == package.name && RBuild::Package.last.version == package.version
|
150
115
|
RBuild::Package.last.filesystem.merge!(pkg.filesystem)
|
151
116
|
|
152
|
-
if (tmp = File.read("#{path}/#{package.name}-#{package.version}.rbuild").split(/^__END__$/)).length > 1
|
117
|
+
if (tmp = File.read("#{path}/#{package.name}-#{package.version}.rbuild", encoding: 'utf-8').split(/^__END__$/)).length > 1
|
153
118
|
RBuild::Package.last.filesystem.parse(tmp.last.lstrip)
|
154
119
|
end
|
155
120
|
|
@@ -165,7 +130,7 @@ module Packo
|
|
165
130
|
begin
|
166
131
|
Packo.load path, options
|
167
132
|
|
168
|
-
if (pkg = RBuild::Package.last) && (tmp = File.read(path).split(/^__END__$/)).length > 1
|
133
|
+
if (pkg = RBuild::Package.last) && (tmp = File.read(path, encoding: 'utf-8').split(/^__END__$/)).length > 1
|
169
134
|
pkg.filesystem.parse(tmp.last.lstrip)
|
170
135
|
end
|
171
136
|
rescue Exception => e
|
@@ -178,7 +143,6 @@ module Packo
|
|
178
143
|
end
|
179
144
|
|
180
145
|
require 'packo/version'
|
181
|
-
require 'packo/extensions'
|
182
146
|
require 'packo/system'
|
183
147
|
require 'packo/do'
|
184
148
|
require 'packo/cli'
|
data/lib/packo/cli.rb
CHANGED
@@ -52,15 +52,21 @@ module Packo
|
|
52
52
|
|
53
53
|
module CLI
|
54
54
|
def self.info (text)
|
55
|
-
|
55
|
+
text.strip.lines.each {|line|
|
56
|
+
puts "#{'*'.green.bold} #{line.strip}"
|
57
|
+
}
|
56
58
|
end
|
57
59
|
|
58
60
|
def self.warn (text)
|
59
|
-
|
61
|
+
text.strip.lines.each {|line|
|
62
|
+
puts "#{'*'.yellow.bold} #{line.strip}"
|
63
|
+
}
|
60
64
|
end
|
61
65
|
|
62
66
|
def self.fatal (text)
|
63
|
-
|
67
|
+
text.strip.lines.each {|line|
|
68
|
+
puts "#{'*'.red} #{line.strip}"
|
69
|
+
}
|
64
70
|
end
|
65
71
|
end
|
66
72
|
|
data/lib/packo/cli/base.rb
CHANGED
@@ -37,7 +37,7 @@ class Base < Thor
|
|
37
37
|
method_option :ignore, type: :boolean, default: false, aliases: '-x', desc: 'Ignore the installation and do not add the package to the database'
|
38
38
|
method_option :nodeps, type: :boolean, default: false, aliases: '-N', desc: 'Ignore blockers and dependencies'
|
39
39
|
method_option :depsonly, type: :boolean, default: false, aliases: '-D', desc: 'Install only dependencies'
|
40
|
-
method_option :repository, type: :string,
|
40
|
+
method_option :repository, type: :string, aliases: '-r', desc: 'Set a specific repository'
|
41
41
|
def install (*names)
|
42
42
|
type = names.last.is_a?(Symbol) ? names.pop : :both
|
43
43
|
|
@@ -142,7 +142,7 @@ class Base < Thor
|
|
142
142
|
|
143
143
|
name = "#{env[:TMP]}/#{name}"
|
144
144
|
|
145
|
-
if (digest = _digest(package, env)) && (result =
|
145
|
+
if (digest = _digest(package, env)) && (result = Packo.digest(name)) != digest
|
146
146
|
CLI.fatal "Digest mismatch (got #{result} expected #{digest}), install this package from source, the mirror could be compromised"
|
147
147
|
exit 13
|
148
148
|
end
|
@@ -266,64 +266,56 @@ class Base < Thor
|
|
266
266
|
old = path
|
267
267
|
|
268
268
|
begin
|
269
|
-
Find.find("#{path}/dist") {|file|
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
CLI.fatal "#{path} belongs to #{tmp}, use --force to overwrite"
|
269
|
+
Packo.contents(Find.find("#{path}/dist")) {|file|
|
270
|
+
if !file[length, file.length]
|
271
|
+
{ next: true }
|
272
|
+
else
|
273
|
+
{ path: Path.clean(options[:destination] + file[length, file.length]) }
|
274
|
+
end
|
275
|
+
}.each {|file|
|
276
|
+
if !options[:force] && File.exists?(file.path) && !File.directory?(file.path)
|
277
|
+
if (tmp = _exists?(file.path))
|
278
|
+
CLI.fatal "#{file.path} belongs to #{tmp}, use --force to overwrite"
|
280
279
|
else
|
281
|
-
CLI.fatal "#{path} doesn't belong to any package, use --force to overwrite"
|
280
|
+
CLI.fatal "#{file.path} doesn't belong to any package, use --force to overwrite"
|
282
281
|
end
|
283
282
|
|
284
283
|
raise RuntimeError.new 'File collision'
|
285
284
|
end
|
286
285
|
|
287
|
-
|
288
|
-
|
286
|
+
case file.type
|
287
|
+
when :dir
|
288
|
+
begin
|
289
|
+
FileUtils.mkpath(file.path)
|
290
|
+
puts "--- #{file.path if file.path != '/'}/"
|
291
|
+
rescue
|
292
|
+
puts "--- #{file.path if file.path != '/'}/".red
|
293
|
+
end
|
289
294
|
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
end
|
306
|
-
elsif File.file?(file)
|
307
|
-
type = :obj
|
308
|
-
meta = Do.digest(file)
|
309
|
-
|
310
|
-
begin
|
311
|
-
FileUtils.cp file, path, preserve: true
|
312
|
-
puts ">>> #{path}".bold
|
313
|
-
rescue
|
314
|
-
puts ">>> #{path}".red
|
315
|
-
end
|
316
|
-
else
|
317
|
-
next
|
295
|
+
when :sym
|
296
|
+
begin
|
297
|
+
FileUtils.ln_sf file.meta, file.path
|
298
|
+
puts ">>> #{file.path} -> #{file.meta}".cyan.bold
|
299
|
+
rescue
|
300
|
+
puts ">>> #{file.path} -> #{file.meta}".red
|
301
|
+
end
|
302
|
+
|
303
|
+
when :obj
|
304
|
+
begin
|
305
|
+
FileUtils.cp file.source, file.path, preserve: true
|
306
|
+
puts ">>> #{file.path}".bold
|
307
|
+
rescue
|
308
|
+
puts ">>> #{file.path}".red
|
309
|
+
end
|
318
310
|
end
|
319
311
|
|
320
312
|
content = pkg.contents.first_or_create(
|
321
|
-
type: type,
|
322
|
-
path:
|
313
|
+
type: file.type,
|
314
|
+
path: file.path
|
323
315
|
)
|
324
316
|
|
325
317
|
content.update(
|
326
|
-
meta: meta
|
318
|
+
meta: file.meta
|
327
319
|
)
|
328
320
|
}
|
329
321
|
|
@@ -337,7 +329,7 @@ class Base < Thor
|
|
337
329
|
|
338
330
|
case content.type
|
339
331
|
when :obj
|
340
|
-
if File.exists?(path) && (options[:force] || content.meta ==
|
332
|
+
if File.exists?(path) && (options[:force] || content.meta == Packo.digest(path))
|
341
333
|
puts "<<< #{path}".bold
|
342
334
|
FileUtils.rm_f(path) rescue nil
|
343
335
|
else
|
@@ -371,7 +363,7 @@ class Base < Thor
|
|
371
363
|
if options[:ignore]
|
372
364
|
t.rollback
|
373
365
|
else
|
374
|
-
pkg.update(destination: options[:destination]
|
366
|
+
pkg.update(destination: Path.clean(options[:destination]))
|
375
367
|
end
|
376
368
|
}
|
377
369
|
}
|
@@ -386,17 +378,22 @@ class Base < Thor
|
|
386
378
|
|
387
379
|
if packages.empty?
|
388
380
|
CLI.fatal "No installed packages match #{name}"
|
381
|
+
|
389
382
|
exit 20
|
390
383
|
end
|
391
384
|
|
392
385
|
packages.each {|installed|
|
386
|
+
if installed.repository && installed.repository.type == :virtual
|
387
|
+
repository.uninstall(installed) or next
|
388
|
+
end
|
389
|
+
|
393
390
|
Models.transaction {
|
394
391
|
installed.model.contents.each {|content| content.check!
|
395
392
|
path = "#{installed.model.destination}/#{content.path}".gsub(%r{/*/}, '/')
|
396
393
|
|
397
394
|
case content.type
|
398
395
|
when :obj
|
399
|
-
if File.exists?(path) && (options[:force] || content.meta ==
|
396
|
+
if File.exists?(path) && (options[:force] || content.meta == Packo.digest(path))
|
400
397
|
puts "<<< #{path}".bold
|
401
398
|
FileUtils.rm_f(path) rescue nil
|
402
399
|
else
|
@@ -430,8 +427,8 @@ class Base < Thor
|
|
430
427
|
|
431
428
|
desc 'search [EXPRESSION] [OPTIONS]', 'Search through installed packages'
|
432
429
|
map '--search' => :search, '-Ss' => :search
|
433
|
-
method_option :type, type: :string,
|
434
|
-
method_option :repository, type: :string,
|
430
|
+
method_option :type, type: :string, aliases: '-t', desc: 'The repository type (binary, source, virtual)'
|
431
|
+
method_option :repository, type: :string, aliases: '-r', desc: 'Set a specific repository'
|
435
432
|
method_option :full, type: :boolean, default: false, aliases: '-F', desc: 'Include the repository that owns the package, features and flavor'
|
436
433
|
def search (expression='')
|
437
434
|
Models.search_installed(expression, options[:repository], options[:type]).group_by {|package|
|
@@ -447,7 +444,9 @@ class Base < Thor
|
|
447
444
|
print "#{"#{packages.first.tags}/" unless packages.first.tags.empty?}#{packages.first.name.bold}"
|
448
445
|
|
449
446
|
print ' ('
|
450
|
-
print packages.
|
447
|
+
print packages.sort {|a, b|
|
448
|
+
a.version <=> b.version
|
449
|
+
}.map {|package|
|
451
450
|
"#{package.version.to_s.red}" + (package.slot ? "%#{package.slot.to_s.blue.bold}" : '')
|
452
451
|
}.join(', ')
|
453
452
|
print ')'
|
@@ -461,7 +460,9 @@ class Base < Thor
|
|
461
460
|
else
|
462
461
|
print "#{packages.first.tags}/#{packages.first.name.bold} ("
|
463
462
|
|
464
|
-
print packages.
|
463
|
+
print packages.sort {|a, b|
|
464
|
+
a.version <=> b.version
|
465
|
+
}.map {|package|
|
465
466
|
"#{package.version.to_s.red}" + (package.slot ? "%#{package.slot.to_s.blue.bold}" : '')
|
466
467
|
}.join(', ')
|
467
468
|
|
@@ -503,21 +504,19 @@ class Base < Thor
|
|
503
504
|
end
|
504
505
|
|
505
506
|
def _build (package, env)
|
506
|
-
|
507
|
-
|
508
|
-
FileUtils.mkpath "#{System.env[:TMP]}/.__packo_build" rescue nil
|
507
|
+
FileUtils.rm_rf "#{System.env[:TMP]}/.__packo_build", secure: true rescue nil
|
508
|
+
FileUtils.mkpath "#{System.env[:TMP]}/.__packo_build" rescue nil
|
509
509
|
|
510
|
-
|
510
|
+
require 'packo/cli/build'
|
511
511
|
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
512
|
+
begin
|
513
|
+
System.env.sandbox(env) {
|
514
|
+
Packo::CLI::Build.start(['package', package.to_s(:whole), "--output=#{System.env[:TMP]}/.__packo_build", "--repository=#{package.repository}"])
|
515
|
+
}
|
516
|
+
rescue
|
517
|
+
end
|
518
518
|
|
519
|
-
|
520
|
-
}
|
519
|
+
Dir.glob("#{System.env[:TMP]}/.__packo_build/#{package.name}-#{package.version}*.pko").first
|
521
520
|
end
|
522
521
|
|
523
522
|
def _manifest (package, env)
|
data/lib/packo/cli/build.rb
CHANGED
@@ -18,9 +18,6 @@
|
|
18
18
|
# along with packo. If not, see <http://www.gnu.org/licenses/>.
|
19
19
|
#++
|
20
20
|
|
21
|
-
require 'nokogiri'
|
22
|
-
require 'digest/sha1'
|
23
|
-
|
24
21
|
require 'packo'
|
25
22
|
require 'packo/rbuild'
|
26
23
|
|
@@ -35,131 +32,8 @@ class Build < Thor
|
|
35
32
|
method_option :output, type: :string, default: System.env[:TMP], aliases: '-o', desc: 'The directory where to save packages'
|
36
33
|
method_option :wipe, type: :boolean, default: false, aliases: '-w', desc: 'Wipes the package directory before building it'
|
37
34
|
method_option :ask, type: :boolean, default: false, aliases: '-a', desc: 'Prompt the user if he want to continue building or not'
|
38
|
-
method_option :repository, type: :string,
|
39
|
-
method_option :execute, type: :string, aliases: '-x', desc: 'Create a package from an executed command instead of from an RBuild'
|
40
|
-
method_option :bump, type: :boolean, default: true, aliases: '-b', desc: 'Bump revision when creating a package from command if package is installed'
|
41
|
-
method_option :inspect, type: :boolean, default: false, aliases: '-i', desc: 'Inspect the list of files that will be included in the package in EDITOR'
|
35
|
+
method_option :repository, type: :string, aliases: '-r', desc: 'Set a specific source repository'
|
42
36
|
def package (*packages)
|
43
|
-
if command = options[:execute]
|
44
|
-
if System.env[:SANDBOX_ACTIVE] || System.env[:FAKED_MODE]
|
45
|
-
CLI.warn "`packo build -x` may not work properly, try with `packo-build -x` if it fails.\n\n"
|
46
|
-
end
|
47
|
-
|
48
|
-
package = Package.parse(packages.first)
|
49
|
-
|
50
|
-
unless package.name && package.version
|
51
|
-
CLI.fatal 'You have to pass a valid package name and version, like package-0.2'
|
52
|
-
exit 1
|
53
|
-
end
|
54
|
-
|
55
|
-
package = RBuild::Package.define(package.name, package.version) {
|
56
|
-
tags *package.tags
|
57
|
-
|
58
|
-
description "Built in: `#{Dir.pwd}` with `#{command}`"
|
59
|
-
maintainer ENV['USER']
|
60
|
-
}
|
61
|
-
|
62
|
-
package.avoid RBuild::Behaviors::Default
|
63
|
-
|
64
|
-
package.clean!
|
65
|
-
package.create!
|
66
|
-
|
67
|
-
tmp = Tempfile.new('packo')
|
68
|
-
dir = "#{System.env[:TMP]}/#{Process.pid}"
|
69
|
-
|
70
|
-
tmp.write %{
|
71
|
-
#! /bin/sh
|
72
|
-
|
73
|
-
cd "#{Dir.pwd}"
|
74
|
-
|
75
|
-
#{command}
|
76
|
-
|
77
|
-
exit $?
|
78
|
-
}
|
79
|
-
|
80
|
-
tmp.chmod 0700
|
81
|
-
tmp.close
|
82
|
-
|
83
|
-
Packo.sh 'installwatch', "--logfile=#{package.tempdir}/newfiles.log", "--exclude=#{Dir.pwd}",
|
84
|
-
"--root=#{package.workdir}", '--transl=yes', '--backup=no', tmp.path
|
85
|
-
|
86
|
-
inspect = options[:inspect]
|
87
|
-
|
88
|
-
package.before :pack, priority: -42 do
|
89
|
-
files = File.new("#{tempdir}/newfiles", 'w')
|
90
|
-
|
91
|
-
files.print File.new("#{tempdir}/newfiles.log", 'r').lines.map {|line| line.strip!
|
92
|
-
whole, type = line.match(/^.*?\t(.*?)\t/).to_a
|
93
|
-
|
94
|
-
case type
|
95
|
-
when 'chmod', 'open'
|
96
|
-
whole, file = line.match(/.*?\t.*?\t(.*?)(\t|$)/).to_a
|
97
|
-
|
98
|
-
next if file.match(%r[^(/dev|#{Regexp.escape(Dir.pwd)}|/tmp)(/|$)])
|
99
|
-
|
100
|
-
file
|
101
|
-
|
102
|
-
when 'symlink'
|
103
|
-
whole, to, file = line.match(/.*?\t.*?\t(.*?)\t(.*?)(\t|$)/).to_a
|
104
|
-
|
105
|
-
"#{file} -> #{to}"
|
106
|
-
end
|
107
|
-
}.compact.uniq.sort.join("\n")
|
108
|
-
|
109
|
-
files.close
|
110
|
-
|
111
|
-
if inspect
|
112
|
-
Packo.sh System.env[:EDITOR] || 'vi', files.path
|
113
|
-
end
|
114
|
-
|
115
|
-
links = []
|
116
|
-
|
117
|
-
File.new("#{tempdir}/newfiles", 'r').lines.each {|line|
|
118
|
-
whole, file, link = line.match(/^(.*?)(?: -> (.*?))?$/).to_a
|
119
|
-
|
120
|
-
FileUtils.mkpath "#{distdir}/#{File.dirname(file)}"
|
121
|
-
|
122
|
-
if link
|
123
|
-
links << [link, file]
|
124
|
-
else
|
125
|
-
FileUtils.cp "#{workdir}/TRANSL/#{file}", "#{distdir}/#{file}"
|
126
|
-
end
|
127
|
-
}
|
128
|
-
|
129
|
-
links.each {|(link, file)|
|
130
|
-
FileUtils.ln_sf link, "#{distdir}/#{file}" rescue nil
|
131
|
-
}
|
132
|
-
end
|
133
|
-
|
134
|
-
package.before :pack! do
|
135
|
-
if inspect
|
136
|
-
Packo.sh System.env[:EDITOR] || 'vi', "#{directory}/manifest.xml"
|
137
|
-
end
|
138
|
-
end
|
139
|
-
|
140
|
-
if options[:bump]
|
141
|
-
require 'packo/models'
|
142
|
-
|
143
|
-
if !Models.search_installed(package.to_s).empty?
|
144
|
-
package.revision = Models.search_installed(package.to_s).first.revision + 1
|
145
|
-
end
|
146
|
-
end
|
147
|
-
|
148
|
-
begin
|
149
|
-
package.build {|stage|
|
150
|
-
CLI.info "Executing #{stage.name}"
|
151
|
-
}
|
152
|
-
|
153
|
-
CLI.info "Succesfully built #{package}"
|
154
|
-
rescue Exception => e
|
155
|
-
CLI.fatal "Failed to build #{package}"
|
156
|
-
CLI.fatal e.message
|
157
|
-
Packo.debug e
|
158
|
-
end
|
159
|
-
|
160
|
-
exit 0
|
161
|
-
end
|
162
|
-
|
163
37
|
Environment.new {|env|
|
164
38
|
if !env[:ARCH] || !env[:KERNEL] || !env[:LIBC] || !env[:COMPILER]
|
165
39
|
CLI.fatal 'You have to set ARCH, KERNEL, LIBC and COMPILER to build packages.'
|
@@ -259,6 +133,128 @@ class Build < Thor
|
|
259
133
|
}
|
260
134
|
end
|
261
135
|
|
136
|
+
|
137
|
+
desc 'command PACKAGE COMMAND', 'Build package from an executed command'
|
138
|
+
method_option :bump, type: :boolean, default: true, aliases: '-b', desc: 'Bump revision when creating a package from command if package is installed'
|
139
|
+
method_option :inspect, type: :boolean, default: false, aliases: '-i', desc: 'Inspect the list of files that will be included in the package in EDITOR'
|
140
|
+
def command (package, command)
|
141
|
+
if Packo.protected?
|
142
|
+
CLI.warn "`packo build -x` may not work properly, try with `packo-build -x` if it fails.\n\n"
|
143
|
+
end
|
144
|
+
|
145
|
+
package = Package.parse(package)
|
146
|
+
|
147
|
+
unless package.name && package.version
|
148
|
+
CLI.fatal 'You have to pass a valid package name and version, like package-0.2'
|
149
|
+
exit 1
|
150
|
+
end
|
151
|
+
|
152
|
+
package = RBuild::Package.define(package.name, package.version) {
|
153
|
+
tags *package.tags
|
154
|
+
|
155
|
+
description "Built in: `#{Dir.pwd}` with `#{command}`"
|
156
|
+
maintainer ENV['USER']
|
157
|
+
}
|
158
|
+
|
159
|
+
package.avoid RBuild::Behaviors::Default
|
160
|
+
|
161
|
+
package.clean!
|
162
|
+
package.create!
|
163
|
+
|
164
|
+
tmp = Tempfile.new('packo')
|
165
|
+
dir = "#{System.env[:TMP]}/#{Process.pid}"
|
166
|
+
|
167
|
+
tmp.write %{
|
168
|
+
#! /bin/sh
|
169
|
+
|
170
|
+
cd "#{Dir.pwd}"
|
171
|
+
|
172
|
+
#{command}
|
173
|
+
|
174
|
+
exit $?
|
175
|
+
}
|
176
|
+
|
177
|
+
tmp.chmod 0700
|
178
|
+
tmp.close
|
179
|
+
|
180
|
+
Packo.sh 'installwatch', "--logfile=#{package.tempdir}/newfiles.log", "--exclude=#{Dir.pwd}",
|
181
|
+
"--root=#{package.workdir}", '--transl=yes', '--backup=no', tmp.path
|
182
|
+
|
183
|
+
inspect = options[:inspect]
|
184
|
+
|
185
|
+
package.before :pack, priority: -42 do
|
186
|
+
files = File.new("#{tempdir}/newfiles", 'w')
|
187
|
+
|
188
|
+
files.print File.new("#{tempdir}/newfiles.log", 'r').lines.map {|line| line.strip!
|
189
|
+
whole, type = line.match(/^.*?\t(.*?)\t/).to_a
|
190
|
+
|
191
|
+
case type
|
192
|
+
when 'chmod', 'open'
|
193
|
+
whole, file = line.match(/.*?\t.*?\t(.*?)(\t|$)/).to_a
|
194
|
+
|
195
|
+
next if file.match(%r[^(/dev|#{Regexp.escape(Dir.pwd)}|/tmp)(/|$)])
|
196
|
+
|
197
|
+
file
|
198
|
+
|
199
|
+
when 'symlink'
|
200
|
+
whole, to, file = line.match(/.*?\t.*?\t(.*?)\t(.*?)(\t|$)/).to_a
|
201
|
+
|
202
|
+
"#{file} -> #{to}"
|
203
|
+
end
|
204
|
+
}.compact.uniq.sort.join("\n")
|
205
|
+
|
206
|
+
files.close
|
207
|
+
|
208
|
+
if inspect
|
209
|
+
Packo.sh System.env[:EDITOR] || 'vi', files.path
|
210
|
+
end
|
211
|
+
|
212
|
+
links = []
|
213
|
+
|
214
|
+
File.new("#{tempdir}/newfiles", 'r').lines.each {|line|
|
215
|
+
whole, file, link = line.match(/^(.*?)(?: -> (.*?))?$/).to_a
|
216
|
+
|
217
|
+
FileUtils.mkpath "#{distdir}/#{File.dirname(file)}"
|
218
|
+
|
219
|
+
if link
|
220
|
+
links << [link, file]
|
221
|
+
else
|
222
|
+
FileUtils.cp "#{workdir}/TRANSL/#{file}", "#{distdir}/#{file}"
|
223
|
+
end
|
224
|
+
}
|
225
|
+
|
226
|
+
links.each {|(link, file)|
|
227
|
+
FileUtils.ln_sf link, "#{distdir}/#{file}" rescue nil
|
228
|
+
}
|
229
|
+
end
|
230
|
+
|
231
|
+
package.before :pack! do
|
232
|
+
if inspect
|
233
|
+
Packo.sh System.env[:EDITOR] || 'vi', "#{directory}/manifest.xml"
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
237
|
+
if options[:bump]
|
238
|
+
require 'packo/models'
|
239
|
+
|
240
|
+
if !Models.search_installed(package.to_s).empty?
|
241
|
+
package.revision = Models.search_installed(package.to_s).first.revision + 1
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
245
|
+
begin
|
246
|
+
package.build {|stage|
|
247
|
+
CLI.info "Executing #{stage.name}"
|
248
|
+
}
|
249
|
+
|
250
|
+
CLI.info "Succesfully built #{package}"
|
251
|
+
rescue Exception => e
|
252
|
+
CLI.fatal "Failed to build #{package}"
|
253
|
+
CLI.fatal e.message
|
254
|
+
Packo.debug e
|
255
|
+
end
|
256
|
+
end
|
257
|
+
|
262
258
|
desc 'clean PACKAGE... [OPTIONS]', 'Clean packages'
|
263
259
|
method_option :repository, type: :string, aliases: '-r', desc: 'Set a specific source repository'
|
264
260
|
def clean (*packages)
|
@@ -348,7 +344,7 @@ class Build < Thor
|
|
348
344
|
package.distfiles.to_a.each {|(name, file)|
|
349
345
|
file ||= name
|
350
346
|
|
351
|
-
xml.file({ name: File.basename(file.path), url: file.url },
|
347
|
+
xml.file({ name: File.basename(file.path), url: file.url }, Packo.digest(file.path))
|
352
348
|
} if package.distfiles
|
353
349
|
}
|
354
350
|
}
|