tpkg 1.22.1 → 1.23.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/bin/gem2tpkg +10 -4
- data/bin/tpkg +28 -5
- data/lib/tpkg.rb +32 -10
- data/lib/tpkg/deployer.rb +9 -3
- data/schema/schema-1.0.6.yml +87 -0
- data/schema/schema.yml +1 -0
- data/schema/tpkg-1.0.6.dtd +42 -0
- data/schema/tpkg.dtd +2 -1
- metadata +4 -2
data/Rakefile
CHANGED
@@ -5,7 +5,7 @@ spec = Gem::Specification.new do |s|
|
|
5
5
|
s.add_dependency('facter')
|
6
6
|
s.add_dependency('net-ssh')
|
7
7
|
s.add_dependency('ddao-kwalify')
|
8
|
-
s.version = '1.
|
8
|
+
s.version = '1.23.2'
|
9
9
|
s.authors = ['Darren Dao', 'Jason Heiss']
|
10
10
|
s.email = 'tpkg-users@lists.sourceforge.net'
|
11
11
|
s.homepage = 'http://tpkg.sourceforge.net'
|
data/bin/gem2tpkg
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/ruby -w
|
2
2
|
|
3
3
|
# Ensure we can find tpkg.rb
|
4
|
-
$:.unshift File.dirname(__FILE__)
|
4
|
+
$:.unshift File.join(File.dirname(__FILE__), "..", "lib")
|
5
5
|
|
6
6
|
require 'fileutils' # FileUtils.cp, rm, etc.
|
7
7
|
require 'tempfile' # Tempfile
|
@@ -321,10 +321,16 @@ def package(gem)
|
|
321
321
|
end
|
322
322
|
when '~>'
|
323
323
|
# ~> 2.2 is equivalent to >= 2.2 and < 3
|
324
|
+
# ~> 2.2.0 is equivalent to >= 2.2.0 and < 2.3.0
|
324
325
|
deps[depgem][:minimum_version] = depver
|
325
|
-
|
326
|
-
|
327
|
-
|
326
|
+
# '2.2.0' -> ['2', '2', '0']
|
327
|
+
depverparts = depver.split('.')
|
328
|
+
# ['2', '2', '0'] -> ['2', '2']
|
329
|
+
depverparts.pop
|
330
|
+
# ['2', '2'] -> ['2', '2', '9999']
|
331
|
+
depverparts << '9999'
|
332
|
+
# ['2', '2', '9999'] -> '2.2.9999'
|
333
|
+
deps[depgem][:maximum_version] = depverparts.join('.')
|
328
334
|
end
|
329
335
|
end
|
330
336
|
end
|
data/bin/tpkg
CHANGED
@@ -239,9 +239,13 @@ end
|
|
239
239
|
opts.on('--force', 'Force the execution of a given task') do |opt|
|
240
240
|
@force = opt
|
241
241
|
end
|
242
|
-
opts.on('
|
243
|
-
@
|
244
|
-
|
242
|
+
opts.on('-o', '--out', '=DIR', 'Output directory for the -m option') do |opt|
|
243
|
+
@other_options[:out] = opt
|
244
|
+
end
|
245
|
+
opts.on('--use-ssh-key [FILE]', 'Use ssh key for deploying instead of password') do |opt|
|
246
|
+
@deploy_options["use-ssh-key"] = true
|
247
|
+
@deploy_options["ssh-key"] = opt
|
248
|
+
@deploy_params = @deploy_params - ['--use-ssh-key', opt, "--use-ssh-key=#{opt}"]
|
245
249
|
end
|
246
250
|
opts.on('--deploy-as', '=USERNAME', 'What username to use for deploying to remote server') do |opt|
|
247
251
|
@deploy_options["deploy-as"] = opt
|
@@ -341,6 +345,18 @@ if @deploy
|
|
341
345
|
# puts "Creating deployer with #{@worker_count} number of worker"
|
342
346
|
@deploy_options["max-worker"] = @worker_count
|
343
347
|
@deploy_options["abort-on-fail"] = false
|
348
|
+
|
349
|
+
# check to see if ssh-key is accessible
|
350
|
+
ssh_key = @deploy_options["use-ssh-key"]
|
351
|
+
if ssh_key && ssh_key.is_a?(String)
|
352
|
+
if !File.readable?(ssh_key) && Process.euid == 0
|
353
|
+
raise "Unable to read ssh key from #{ssh_key}"
|
354
|
+
elsif !File.readable?(ssh_key)
|
355
|
+
warn "Warning: Unable to read ssh key from #{ssh_key}. Attempting to rerun tpkg with sudo."
|
356
|
+
rerun_with_sudo_if_necessary
|
357
|
+
end
|
358
|
+
end
|
359
|
+
|
344
360
|
Tpkg::deploy(@deploy_params, @deploy_options, @servers)
|
345
361
|
exit
|
346
362
|
end
|
@@ -349,10 +365,17 @@ if @action_value.is_a?(Array)
|
|
349
365
|
@action_value.uniq!
|
350
366
|
end
|
351
367
|
|
368
|
+
# tell tpkg not to prompt if stdin is not tty
|
369
|
+
if !$stdin.tty?
|
370
|
+
Tpkg::set_prompt(false)
|
371
|
+
end
|
372
|
+
|
352
373
|
ret_val = 0
|
353
374
|
case @action
|
354
375
|
when :make
|
355
|
-
|
376
|
+
@other_options[:force] = @force
|
377
|
+
@other_options[:compress] = @compress
|
378
|
+
pkgfile = Tpkg::make_package(@action_value, passphrase_callback, @other_options)
|
356
379
|
if pkgfile
|
357
380
|
puts "Package is #{pkgfile}"
|
358
381
|
else
|
@@ -493,7 +516,7 @@ when :query_who_owns_file
|
|
493
516
|
tpkg = instantiate_tpkg(@tpkg_options)
|
494
517
|
tpkg.files_for_installed_packages.each do |pkgfile, fip|
|
495
518
|
fip[:normalized].each do |file|
|
496
|
-
if file == @action_value
|
519
|
+
if file == File.expand_path(@action_value)
|
497
520
|
puts "#{file}: #{pkgfile}"
|
498
521
|
end
|
499
522
|
end
|
data/lib/tpkg.rb
CHANGED
@@ -56,7 +56,7 @@ require 'kwalify' # for validating yaml
|
|
56
56
|
|
57
57
|
class Tpkg
|
58
58
|
|
59
|
-
VERSION = '1.
|
59
|
+
VERSION = '1.23.2'
|
60
60
|
CONFIGDIR = '/etc'
|
61
61
|
|
62
62
|
GENERIC_ERR = 1
|
@@ -225,6 +225,17 @@ class Tpkg
|
|
225
225
|
# Makes a package from a directory containing the files to put into the package
|
226
226
|
def self.make_package(pkgsrcdir, passphrase=nil, options = {})
|
227
227
|
pkgfile = nil
|
228
|
+
|
229
|
+
# validate the output directory if the user has specified one
|
230
|
+
outdir = options[:out]
|
231
|
+
if outdir
|
232
|
+
outdir = File.expand_path(outdir)
|
233
|
+
if !File.directory?(outdir)
|
234
|
+
raise "#{outdir} is not a valid directory"
|
235
|
+
elsif !File.writable?(outdir)
|
236
|
+
raise "#{outdir} is not writable"
|
237
|
+
end
|
238
|
+
end
|
228
239
|
|
229
240
|
# Make a working directory
|
230
241
|
workdir = nil
|
@@ -341,7 +352,13 @@ class Tpkg
|
|
341
352
|
package_filename = metadata.generate_package_filename
|
342
353
|
package_directory = File.join(workdir, package_filename)
|
343
354
|
Dir.mkdir(package_directory)
|
344
|
-
|
355
|
+
|
356
|
+
if outdir
|
357
|
+
pkgfile = File.join(outdir, package_filename + '.tpkg')
|
358
|
+
else
|
359
|
+
pkgfile = File.join(File.dirname(pkgsrcdir), package_filename + '.tpkg')
|
360
|
+
end
|
361
|
+
|
345
362
|
if File.exist?(pkgfile) || File.symlink?(pkgfile)
|
346
363
|
if @@prompt
|
347
364
|
print "Package file #{pkgfile} already exists, overwrite? [y/N]"
|
@@ -383,7 +400,7 @@ class Tpkg
|
|
383
400
|
# Remove our working directory
|
384
401
|
FileUtils.rm_rf(workdir)
|
385
402
|
end
|
386
|
-
|
403
|
+
|
387
404
|
# Return the filename of the package
|
388
405
|
pkgfile
|
389
406
|
end
|
@@ -1382,9 +1399,10 @@ class Tpkg
|
|
1382
1399
|
if Tpkg::get_os =~ /RedHat|CentOS|Fedora/
|
1383
1400
|
[ {:arg => 'installed', :header => 'Installed', :source => :native_installed},
|
1384
1401
|
{:arg => 'available', :header => 'Available', :source => :native_available} ].each do |yum|
|
1385
|
-
|
1402
|
+
cmd = "yum info #{yum[:arg]} #{pkgname}"
|
1403
|
+
puts "available_native_packages running '#{cmd}'" if @@debug
|
1386
1404
|
stderr_first_line = nil
|
1387
|
-
Open3.popen3(
|
1405
|
+
Open3.popen3(cmd) do |stdin, stdout, stderr|
|
1388
1406
|
stdin.close
|
1389
1407
|
read_packages = false
|
1390
1408
|
name = version = package_version = nil
|
@@ -3784,7 +3802,7 @@ class Tpkg
|
|
3784
3802
|
if options[:remove_all_dep]
|
3785
3803
|
packages_to_remove |= get_dependents(packages_to_remove)
|
3786
3804
|
elsif options[:remove_all_prereq]
|
3787
|
-
puts "
|
3805
|
+
puts "Attempting to remove #{packages_to_remove.map do |pkg| pkg[:metadata][:filename] end} and all prerequisites."
|
3788
3806
|
# Get list of dependency prerequisites
|
3789
3807
|
ptr = packages_to_remove | get_prerequisites(packages_to_remove)
|
3790
3808
|
pkg_files_to_remove = ptr.map { |pkg| pkg[:metadata][:filename] }
|
@@ -4113,10 +4131,14 @@ class Tpkg
|
|
4113
4131
|
packages_to_execute_on.concat(installed_packages_that_meet_requirement(req))
|
4114
4132
|
end
|
4115
4133
|
end
|
4116
|
-
|
4117
|
-
packages_to_execute_on.
|
4118
|
-
|
4119
|
-
|
4134
|
+
|
4135
|
+
if packages_to_execute_on.empty?
|
4136
|
+
warn "Warning: Unable to find package(s) \"#{requested_packages.join(",")}\"."
|
4137
|
+
else
|
4138
|
+
packages_to_execute_on.each do |pkg|
|
4139
|
+
ret_val |= execute_init_for_package(pkg, action, requested_init_scripts)
|
4140
|
+
end
|
4141
|
+
end
|
4120
4142
|
return ret_val
|
4121
4143
|
end
|
4122
4144
|
|
data/lib/tpkg/deployer.rb
CHANGED
@@ -34,6 +34,7 @@ class Deployer
|
|
34
34
|
@max_worker = options["max-worker"]
|
35
35
|
@abort_on_failure = options["abort-on-failure"]
|
36
36
|
@use_ssh_key = options["use-ssh-key"]
|
37
|
+
@ssh_key = options["ssh-key"]
|
37
38
|
end
|
38
39
|
end
|
39
40
|
|
@@ -79,13 +80,17 @@ class Deployer
|
|
79
80
|
end
|
80
81
|
|
81
82
|
# Return a block that can be used for executing a cmd on the remote server
|
82
|
-
def ssh_execute(server, username, password, cmd)
|
83
|
+
def ssh_execute(server, username, password, key, cmd)
|
83
84
|
return lambda {
|
84
85
|
exit_status = 0
|
85
86
|
result = []
|
86
87
|
|
88
|
+
params = {}
|
89
|
+
params[:password] = password if password
|
90
|
+
params[:keys] = [key] if key
|
91
|
+
|
87
92
|
begin
|
88
|
-
Net::SSH.start(server, username,
|
93
|
+
Net::SSH.start(server, username, params) do |ssh|
|
89
94
|
puts "Connecting to #{server}"
|
90
95
|
ch = ssh.open_channel do |channel|
|
91
96
|
# now we request a "pty" (i.e. interactive) session so we can send data
|
@@ -176,6 +181,7 @@ class Deployer
|
|
176
181
|
if servers.kind_of?(Proc)
|
177
182
|
deploy_to = servers.call
|
178
183
|
elsif servers.size == 1 && File.exists?(servers[0])
|
184
|
+
puts "Reading server list from file #{servers[0]}"
|
179
185
|
File.open(servers[0], 'r') do |f|
|
180
186
|
while line = f.gets
|
181
187
|
deploy_to << line.chomp.split(",")
|
@@ -188,7 +194,7 @@ class Deployer
|
|
188
194
|
|
189
195
|
deploy_to.each do | server |
|
190
196
|
tp.process do
|
191
|
-
status = ssh_execute(server, @user, @password, cmd).call
|
197
|
+
status = ssh_execute(server, @user, @password, @ssh_key, cmd).call
|
192
198
|
statuses[server] = status
|
193
199
|
end
|
194
200
|
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
type: map
|
2
|
+
mapping:
|
3
|
+
"schema_file": { type: text }
|
4
|
+
"name": { type: str, required: yes }
|
5
|
+
"version": { type: text, required: yes }
|
6
|
+
"package_version": { type: text }
|
7
|
+
"maintainer": { type: str, required: yes }
|
8
|
+
"operatingsystem": { type: seq, sequence: [ {type: str} ] }
|
9
|
+
"architecture": { type: seq, sequence: [ {type: str} ] }
|
10
|
+
"description": { type: str }
|
11
|
+
"bugreporting": { type: str }
|
12
|
+
"dependencies":
|
13
|
+
type: seq
|
14
|
+
sequence:
|
15
|
+
- type: map
|
16
|
+
mapping:
|
17
|
+
"name": { type: str, required: yes }
|
18
|
+
"minimum_version": { type: text }
|
19
|
+
"maximum_version": { type: text }
|
20
|
+
"minimum_package_version": { type: text }
|
21
|
+
"maximum_package_version": { type: text }
|
22
|
+
"allowed_versions": { type: text }
|
23
|
+
"native": { type: bool }
|
24
|
+
"type": { type: any, pattern: /(native|tpkg)$/ }
|
25
|
+
"conflicts":
|
26
|
+
type: seq
|
27
|
+
sequence:
|
28
|
+
- type: map
|
29
|
+
mapping:
|
30
|
+
"name": { type: str, required: yes }
|
31
|
+
"minimum_version": { type: text }
|
32
|
+
"maximum_version": { type: text }
|
33
|
+
"minimum_package_version": { type: text }
|
34
|
+
"maximum_package_version": { type: text }
|
35
|
+
"native": { type: bool }
|
36
|
+
"type": { type: any, pattern: /(native|tpkg)$/ }
|
37
|
+
"externals":
|
38
|
+
type: seq
|
39
|
+
sequence:
|
40
|
+
- type: map
|
41
|
+
mapping:
|
42
|
+
"name": { type: text, required: yes }
|
43
|
+
"data": { type: text }
|
44
|
+
"datascript": { type: text }
|
45
|
+
"datafile": { type: text }
|
46
|
+
"files":
|
47
|
+
type: map
|
48
|
+
mapping:
|
49
|
+
"file_defaults":
|
50
|
+
type: map
|
51
|
+
mapping:
|
52
|
+
"posix":
|
53
|
+
type: map
|
54
|
+
mapping:
|
55
|
+
"owner": { type: text }
|
56
|
+
"group": { type: text }
|
57
|
+
"perms": { type: text }
|
58
|
+
"dirs_defaults":
|
59
|
+
type: map
|
60
|
+
mapping:
|
61
|
+
"posix":
|
62
|
+
type: map
|
63
|
+
mapping:
|
64
|
+
"owner": { type: text }
|
65
|
+
"group": { type: text }
|
66
|
+
"perms": { type: text }
|
67
|
+
"files":
|
68
|
+
type: seq
|
69
|
+
sequence:
|
70
|
+
- type: map
|
71
|
+
mapping:
|
72
|
+
"path": { type: text, required: yes }
|
73
|
+
"encrypt": { type: any, pattern: /^true$|^precrypt$/ }
|
74
|
+
"init":
|
75
|
+
type: map
|
76
|
+
mapping:
|
77
|
+
"start": { type: int }
|
78
|
+
"levels": { type: seq, sequence: [ { type: int } ] }
|
79
|
+
"crontab":
|
80
|
+
type: map
|
81
|
+
mapping: { "user": { type: str } }
|
82
|
+
"posix":
|
83
|
+
type: map
|
84
|
+
mapping: { "owner": { type: text },
|
85
|
+
"group": { type: text },
|
86
|
+
"perms": { type: text } }
|
87
|
+
|
data/schema/schema.yml
CHANGED
@@ -19,6 +19,7 @@ mapping:
|
|
19
19
|
"maximum_version": { type: text }
|
20
20
|
"minimum_package_version": { type: text }
|
21
21
|
"maximum_package_version": { type: text }
|
22
|
+
"allowed_versions": { type: text }
|
22
23
|
"native": { type: bool }
|
23
24
|
"type": { type: any, pattern: /(native|tpkg)$/ }
|
24
25
|
"conflicts":
|
@@ -0,0 +1,42 @@
|
|
1
|
+
<!ELEMENT tpkg (name, version, package_version?, maintainer+, operatingsystem*, architecture*, description?, bugreporting?, dependencies?, externals?, files?)>
|
2
|
+
|
3
|
+
<!ELEMENT name (#PCDATA)>
|
4
|
+
<!ELEMENT version (#PCDATA)>
|
5
|
+
<!ELEMENT package_version (#PCDATA)>
|
6
|
+
<!ELEMENT maintainer (#PCDATA)>
|
7
|
+
<!ELEMENT operatingsystem (#PCDATA)>
|
8
|
+
<!ELEMENT architecture (#PCDATA)>
|
9
|
+
<!ELEMENT description (#PCDATA)>
|
10
|
+
<!ELEMENT bugreporting (#PCDATA)>
|
11
|
+
|
12
|
+
<!ELEMENT dependencies (dependency*)>
|
13
|
+
<!ELEMENT dependency (name, minimum_version?, maximum_version?, minimum_package_version?, maximum_package_version?, allowed_versions?, native?)>
|
14
|
+
<!ELEMENT minimum_version (#PCDATA)>
|
15
|
+
<!ELEMENT maximum_version (#PCDATA)>
|
16
|
+
<!ELEMENT minimum_package_version (#PCDATA)>
|
17
|
+
<!ELEMENT maximum_package_version (#PCDATA)>
|
18
|
+
<!ELEMENT allowed_versions (#PCDATA)>
|
19
|
+
<!ELEMENT native EMPTY>
|
20
|
+
|
21
|
+
<!ELEMENT externals (external*)>
|
22
|
+
<!ELEMENT external (name, (data|datafile|datascript))>
|
23
|
+
<!ELEMENT data (#PCDATA)>
|
24
|
+
<!ELEMENT datafile (#PCDATA)>
|
25
|
+
<!ELEMENT datascript (#PCDATA)>
|
26
|
+
|
27
|
+
<!ELEMENT files (file_defaults?, file*)>
|
28
|
+
<!ELEMENT file_defaults (posix?)>
|
29
|
+
<!ELEMENT posix (owner?, group?, perms?)>
|
30
|
+
<!ELEMENT owner (#PCDATA)>
|
31
|
+
<!ELEMENT group (#PCDATA)>
|
32
|
+
<!ELEMENT perms (#PCDATA)>
|
33
|
+
<!ELEMENT file (path, encrypt?, init?, crontab?, posix?)>
|
34
|
+
<!ELEMENT path (#PCDATA)>
|
35
|
+
<!ELEMENT encrypt EMPTY>
|
36
|
+
<!ATTLIST encrypt precrypt (true|false) #IMPLIED>
|
37
|
+
<!ELEMENT init (start?, levels?)>
|
38
|
+
<!ELEMENT start (#PCDATA)>
|
39
|
+
<!ELEMENT levels (#PCDATA)>
|
40
|
+
<!ELEMENT crontab (user?)>
|
41
|
+
<!ELEMENT user (#PCDATA)>
|
42
|
+
|
data/schema/tpkg.dtd
CHANGED
@@ -10,11 +10,12 @@
|
|
10
10
|
<!ELEMENT bugreporting (#PCDATA)>
|
11
11
|
|
12
12
|
<!ELEMENT dependencies (dependency*)>
|
13
|
-
<!ELEMENT dependency (name, minimum_version?, maximum_version?, minimum_package_version?, maximum_package_version?, native?)>
|
13
|
+
<!ELEMENT dependency (name, minimum_version?, maximum_version?, minimum_package_version?, maximum_package_version?, allowed_versions?, native?)>
|
14
14
|
<!ELEMENT minimum_version (#PCDATA)>
|
15
15
|
<!ELEMENT maximum_version (#PCDATA)>
|
16
16
|
<!ELEMENT minimum_package_version (#PCDATA)>
|
17
17
|
<!ELEMENT maximum_package_version (#PCDATA)>
|
18
|
+
<!ELEMENT allowed_versions (#PCDATA)>
|
18
19
|
<!ELEMENT native EMPTY>
|
19
20
|
|
20
21
|
<!ELEMENT externals (external*)>
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tpkg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.23.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Darren Dao
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2010-
|
13
|
+
date: 2010-05-17 00:00:00 +00:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -68,7 +68,9 @@ files:
|
|
68
68
|
- schema/tpkg-1.0.3.dtd
|
69
69
|
- schema/schema.yml
|
70
70
|
- schema/tpkg-1.0.2.dtd
|
71
|
+
- schema/schema-1.0.6.yml
|
71
72
|
- schema/schema-1.0.yml
|
73
|
+
- schema/tpkg-1.0.6.dtd
|
72
74
|
- schema/schema-1.0.5.yml
|
73
75
|
- bin/tpkg
|
74
76
|
- bin/cpan2tpkg
|