tpkg 1.16.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +18 -0
- data/bin/cpan2tpkg +348 -0
- data/bin/gem2tpkg +445 -0
- data/bin/tpkg +560 -0
- data/lib/tpkg.rb +3966 -0
- data/lib/tpkg/deployer.rb +220 -0
- data/lib/tpkg/metadata.rb +436 -0
- data/lib/tpkg/thread_pool.rb +108 -0
- data/lib/tpkg/versiontype.rb +84 -0
- metadata +85 -0
@@ -0,0 +1,108 @@
|
|
1
|
+
require 'thread'
|
2
|
+
begin
|
3
|
+
require 'fastthread'
|
4
|
+
rescue LoadError
|
5
|
+
# $stderr.puts "Using the ruby-core thread implementation"
|
6
|
+
end
|
7
|
+
|
8
|
+
class ThreadPool
|
9
|
+
class Worker
|
10
|
+
def initialize(thread_queue)
|
11
|
+
@block = nil
|
12
|
+
@mutex = Mutex.new
|
13
|
+
@cv = ConditionVariable.new
|
14
|
+
@queue = thread_queue
|
15
|
+
@running = true
|
16
|
+
@thread = Thread.new do
|
17
|
+
@mutex.synchronize do
|
18
|
+
while @running
|
19
|
+
@cv.wait(@mutex)
|
20
|
+
block = get_block
|
21
|
+
if block
|
22
|
+
@mutex.unlock
|
23
|
+
block.call
|
24
|
+
@mutex.lock
|
25
|
+
reset_block
|
26
|
+
end
|
27
|
+
@queue << self
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def name
|
34
|
+
@thread.inspect
|
35
|
+
end
|
36
|
+
|
37
|
+
def get_block
|
38
|
+
@block
|
39
|
+
end
|
40
|
+
|
41
|
+
def set_block(block)
|
42
|
+
@mutex.synchronize do
|
43
|
+
raise RuntimeError, "Thread already busy." if @block
|
44
|
+
@block = block
|
45
|
+
# Signal the thread in this class, that there's a job to be done
|
46
|
+
@cv.signal
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def reset_block
|
51
|
+
@block = nil
|
52
|
+
end
|
53
|
+
|
54
|
+
def busy?
|
55
|
+
@mutex.synchronize { !@block.nil? }
|
56
|
+
end
|
57
|
+
|
58
|
+
def stop
|
59
|
+
@mutex.synchronize do
|
60
|
+
@running = false
|
61
|
+
@cv.signal
|
62
|
+
end
|
63
|
+
@thread.join
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
attr_accessor :max_size
|
68
|
+
|
69
|
+
def initialize(max_size = 10)
|
70
|
+
@max_size = max_size
|
71
|
+
@queue = Queue.new
|
72
|
+
@workers = []
|
73
|
+
end
|
74
|
+
|
75
|
+
def size
|
76
|
+
@workers.size
|
77
|
+
end
|
78
|
+
|
79
|
+
def busy?
|
80
|
+
@queue.size < @workers.size
|
81
|
+
end
|
82
|
+
|
83
|
+
def shutdown
|
84
|
+
@workers.each { |w| w.stop }
|
85
|
+
@workers = []
|
86
|
+
end
|
87
|
+
|
88
|
+
alias :join :shutdown
|
89
|
+
|
90
|
+
def process(block=nil,&blk)
|
91
|
+
block = blk if block_given?
|
92
|
+
worker = get_worker
|
93
|
+
worker.set_block(block)
|
94
|
+
end
|
95
|
+
|
96
|
+
private
|
97
|
+
|
98
|
+
def get_worker
|
99
|
+
if !@queue.empty? or @workers.size == @max_size
|
100
|
+
return @queue.pop
|
101
|
+
else
|
102
|
+
worker = Worker.new(@queue)
|
103
|
+
@workers << worker
|
104
|
+
worker
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
# This class stores numbers with multiple decimal points, a format
|
2
|
+
# commonly used for version numbers. For example '2.5.1'.
|
3
|
+
|
4
|
+
class Version
|
5
|
+
include Comparable
|
6
|
+
|
7
|
+
def initialize(version)
|
8
|
+
@version = version.to_s
|
9
|
+
end
|
10
|
+
|
11
|
+
def to_s
|
12
|
+
@version
|
13
|
+
end
|
14
|
+
|
15
|
+
def <=>(other)
|
16
|
+
ourfields = @version.split('.')
|
17
|
+
otherfields = other.to_s.split('.')
|
18
|
+
# Convert anything like '.5' to '0.5'
|
19
|
+
# '.5'.split('.') returns ['', '5']
|
20
|
+
[ourfields, otherfields].each do |fields|
|
21
|
+
if fields[0] == ''
|
22
|
+
fields[0] = '0'
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
convert_and_split!(ourfields, otherfields)
|
27
|
+
|
28
|
+
# Array conveniently implements <=>
|
29
|
+
ourfields <=> otherfields
|
30
|
+
end
|
31
|
+
|
32
|
+
# Private methods below
|
33
|
+
private
|
34
|
+
|
35
|
+
|
36
|
+
# Loops over two arrays in parallel. If the entry at a given
|
37
|
+
# position in both arrays is numeric it is converted from a string to
|
38
|
+
# a number, or if either entry is a mixture of numeric and
|
39
|
+
# non-numeric characters then both are split into an array consisting
|
40
|
+
# of the numeric and non-numeric components.
|
41
|
+
def convert_and_split!(fields0, fields1)
|
42
|
+
# Pad the shorter of two arrays with zeros so that both arrays are
|
43
|
+
# the same length. This ensures that '1' == '1.0', etc.
|
44
|
+
if fields0.length != fields1.length
|
45
|
+
larger = [fields0.length, fields1.length].max
|
46
|
+
# For the longer number this depends on something like (3...1).each
|
47
|
+
# doing nothing. That currently works, but is not documented behavior.
|
48
|
+
(fields0.length...larger).each { fields0 << '0' }
|
49
|
+
(fields1.length...larger).each { fields1 << '0' }
|
50
|
+
end
|
51
|
+
|
52
|
+
# Squish both arrays together
|
53
|
+
bothfields = []
|
54
|
+
(0...fields0.length).each { |i| bothfields << [fields0[i], fields1[i]] }
|
55
|
+
|
56
|
+
bothfields.map! do |fields|
|
57
|
+
# Convert fields of all digits from string to number to get a numeric
|
58
|
+
# rather than string comparison. This ensures that 5.9 < 5.10
|
59
|
+
# Unless either start with a zero, as 1.1 != 1.01, but converting
|
60
|
+
# 01 to a number turns it into 1.
|
61
|
+
if fields[0] =~ /^[1-9]\d*$/ && fields[1] =~ /^[1-9]\d*$/
|
62
|
+
fields.map! { |f| f.to_i }
|
63
|
+
else
|
64
|
+
# If the field is a mixture of numeric and non-numeric
|
65
|
+
# characters then split it up into an array of those components
|
66
|
+
# so that we compare "naturally". I.e. 9a < 10a
|
67
|
+
# This is similar to the method used by most "natural sort"
|
68
|
+
# algorithms that aim to sort file9 above file10.
|
69
|
+
if fields[0] =~ /\d\D/ || fields[0] =~ /\D\d/ ||
|
70
|
+
fields[1] =~ /\d\D/ || fields[1] =~ /\D\d/
|
71
|
+
fields.map! { |f| f.scan(/\d+|\D+/) }
|
72
|
+
# Pass back through this method to convert the numeric
|
73
|
+
# entries to numbers
|
74
|
+
convert_and_split!(fields[0], fields[1])
|
75
|
+
end
|
76
|
+
end
|
77
|
+
fields
|
78
|
+
end
|
79
|
+
# Unsquish back to separate arrays
|
80
|
+
fields0.clear
|
81
|
+
fields1.clear
|
82
|
+
bothfields.each { |fields| fields0 << fields[0]; fields1 << fields[1] }
|
83
|
+
end
|
84
|
+
end
|
metadata
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: tpkg
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.16.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Darren Dao
|
8
|
+
- Jason Heiss
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2009-12-16 00:00:00 -08:00
|
14
|
+
default_executable:
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: facter
|
18
|
+
type: :runtime
|
19
|
+
version_requirement:
|
20
|
+
version_requirements: !ruby/object:Gem::Requirement
|
21
|
+
requirements:
|
22
|
+
- - ">="
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: "0"
|
25
|
+
version:
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: net-ssh
|
28
|
+
type: :runtime
|
29
|
+
version_requirement:
|
30
|
+
version_requirements: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: "0"
|
35
|
+
version:
|
36
|
+
description:
|
37
|
+
email: tpkg-users@lists.sourceforge.net
|
38
|
+
executables:
|
39
|
+
- tpkg
|
40
|
+
- cpan2tpkg
|
41
|
+
- gem2tpkg
|
42
|
+
extensions: []
|
43
|
+
|
44
|
+
extra_rdoc_files: []
|
45
|
+
|
46
|
+
files:
|
47
|
+
- bin/cpan2tpkg
|
48
|
+
- bin/gem2tpkg
|
49
|
+
- bin/tpkg
|
50
|
+
- lib/tpkg/deployer.rb
|
51
|
+
- lib/tpkg/metadata.rb
|
52
|
+
- lib/tpkg/thread_pool.rb
|
53
|
+
- lib/tpkg/versiontype.rb
|
54
|
+
- lib/tpkg.rb
|
55
|
+
- Rakefile
|
56
|
+
has_rdoc: true
|
57
|
+
homepage: http://tpkg.sourceforge.net
|
58
|
+
licenses: []
|
59
|
+
|
60
|
+
post_install_message:
|
61
|
+
rdoc_options: []
|
62
|
+
|
63
|
+
require_paths:
|
64
|
+
- lib
|
65
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: "1.8"
|
70
|
+
version:
|
71
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: "0"
|
76
|
+
version:
|
77
|
+
requirements: []
|
78
|
+
|
79
|
+
rubyforge_project: tpkg
|
80
|
+
rubygems_version: 1.3.5
|
81
|
+
signing_key:
|
82
|
+
specification_version: 3
|
83
|
+
summary: tpkg Application Packaging & Deployment
|
84
|
+
test_files: []
|
85
|
+
|