bits-installer 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/ext/apt/extconf.rb +7 -2
- data/lib/bits/cache.rb +1 -1
- data/lib/bits/commands/manifest.rb +14 -21
- data/lib/bits/commands/sync.rb +7 -0
- data/lib/bits/installer_mixin.rb +7 -20
- data/lib/bits/manifest.rb +51 -0
- data/lib/bits/provider/homebrew.rb +1 -1
- data/lib/bits/provider/python.rb +31 -10
- data/lib/bits/provider/rubygems.rb +1 -1
- data/lib/bits/version.rb +1 -1
- metadata +2 -1
data/ext/apt/extconf.rb
CHANGED
@@ -4,8 +4,13 @@ require 'mkmf-rice'
|
|
4
4
|
reqs = []
|
5
5
|
reqs << have_library('apt-pkg')
|
6
6
|
|
7
|
-
|
8
|
-
File.open
|
7
|
+
unless reqs.all? then
|
8
|
+
File.open 'Makefile', 'w' do |f|
|
9
|
+
f.write "all:\n"
|
10
|
+
f.write "%:\n"
|
11
|
+
f.write "\t@echo \"$@: Not building APT extension\"\n"
|
12
|
+
end
|
13
|
+
|
9
14
|
exit 0
|
10
15
|
end
|
11
16
|
|
data/lib/bits/cache.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'bits/command'
|
2
2
|
require 'bits/logging'
|
3
3
|
require 'bits/installer_mixin'
|
4
|
+
require 'bits/manifest'
|
4
5
|
require 'yaml'
|
5
6
|
|
6
7
|
module Bits
|
@@ -27,38 +28,30 @@ module Bits
|
|
27
28
|
|
28
29
|
raise "No manifest in path: #{path}" unless File.file? path
|
29
30
|
|
30
|
-
manifest =
|
31
|
-
|
32
|
-
unless manifest.kind_of? Hash
|
33
|
-
raise "Manifest is not of type Hash: #{path}"
|
31
|
+
manifest = File.open(path) do |f|
|
32
|
+
Bits::Manifest.new YAML.load(f)
|
34
33
|
end
|
35
34
|
|
36
|
-
depends = manifest[:depends]
|
37
|
-
|
38
35
|
criteria = {
|
39
36
|
:compiled => ns[:compiled]
|
40
37
|
}
|
41
38
|
|
42
39
|
log.info "Running manifest: #{path}"
|
43
40
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
puts "Missing Dependencies:"
|
41
|
+
begin
|
42
|
+
packages = resolve_dependencies manifest, criteria
|
43
|
+
rescue Bits::MissingDependencies => e
|
44
|
+
puts "Missing Dependencies:"
|
49
45
|
|
50
|
-
|
51
|
-
|
52
|
-
end
|
53
|
-
|
54
|
-
return 1
|
46
|
+
e.missing.each do |dep|
|
47
|
+
puts " - #{dep.atom}"
|
55
48
|
end
|
56
49
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
50
|
+
return 1
|
51
|
+
end
|
52
|
+
|
53
|
+
packages.each do |package|
|
54
|
+
install_package package, force=ns[:force]
|
62
55
|
end
|
63
56
|
|
64
57
|
return 0
|
data/lib/bits/commands/sync.rb
CHANGED
@@ -25,9 +25,16 @@ module Bits
|
|
25
25
|
|
26
26
|
clone repo_dir unless File.directory? repo_dir
|
27
27
|
|
28
|
+
log.info "Syncing bits"
|
29
|
+
|
28
30
|
Dir.chdir(repo_dir) do
|
29
31
|
Bits.spawn [GIT, 'pull', 'origin', 'master']
|
30
32
|
end
|
33
|
+
|
34
|
+
providers.each do |provider|
|
35
|
+
log.info "Syncing provider: #{provider.to_s}"
|
36
|
+
provider.sync
|
37
|
+
end
|
31
38
|
end
|
32
39
|
|
33
40
|
def clone(repo_dir)
|
data/lib/bits/installer_mixin.rb
CHANGED
@@ -30,7 +30,7 @@ module Bits::InstallerMixin
|
|
30
30
|
|
31
31
|
# Resolve a hash of dependencies with a criteria to packages.
|
32
32
|
# Returns [<packages>, error]
|
33
|
-
def
|
33
|
+
def resolve_dependencies(manifest, criteria)
|
34
34
|
repository = ns[:repository]
|
35
35
|
|
36
36
|
raise "No repository in namespace" if repository.nil?
|
@@ -38,29 +38,16 @@ module Bits::InstallerMixin
|
|
38
38
|
packages = Array.new
|
39
39
|
missing = Array.new
|
40
40
|
|
41
|
-
|
42
|
-
raise ":depends should be a List"
|
43
|
-
end
|
44
|
-
|
45
|
-
depends.each do |spec|
|
46
|
-
unless spec.kind_of? Hash
|
47
|
-
raise "dependency should be of type Hash"
|
48
|
-
end
|
49
|
-
|
50
|
-
atom = spec[:atom]
|
51
|
-
|
52
|
-
if atom.nil?
|
53
|
-
raise "dependency must specify :atom"
|
54
|
-
end
|
55
|
-
|
41
|
+
manifest.depends.each do |dep|
|
56
42
|
crit = Hash.new
|
57
|
-
|
58
|
-
crit
|
43
|
+
|
44
|
+
crit.update criteria
|
45
|
+
crit.update dep.parameters
|
59
46
|
|
60
47
|
begin
|
61
|
-
packages << repository.find_package(atom, crit)
|
48
|
+
packages << repository.find_package(dep.atom, crit)
|
62
49
|
rescue Bits::MissingBit
|
63
|
-
missing <<
|
50
|
+
missing << dep
|
64
51
|
end
|
65
52
|
end
|
66
53
|
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module Bits
|
2
|
+
class Manifest
|
3
|
+
class Dependency
|
4
|
+
attr_reader :atom, :parameters
|
5
|
+
|
6
|
+
def initialize(atom, parameters)
|
7
|
+
@atom = atom
|
8
|
+
@parameters = parameters
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
attr_reader :depends
|
13
|
+
|
14
|
+
def initialize(root)
|
15
|
+
unless root.kind_of? Hash
|
16
|
+
raise "Manifest is not of type Hash: #{path}"
|
17
|
+
end
|
18
|
+
|
19
|
+
@depends = read_depends root
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def read_depends(root)
|
25
|
+
depends = root[:depends]
|
26
|
+
return [] if depends.nil?
|
27
|
+
|
28
|
+
unless depends.kind_of? Array
|
29
|
+
raise "Expected Array for :depends but got #{depends.inspect}"
|
30
|
+
end
|
31
|
+
|
32
|
+
list = Array.new
|
33
|
+
|
34
|
+
depends.each do |spec|
|
35
|
+
unless spec.kind_of? Hash
|
36
|
+
raise "Expected Hash for dependency spec but got #{spec.inspect}"
|
37
|
+
end
|
38
|
+
|
39
|
+
atom = spec[:atom]
|
40
|
+
|
41
|
+
if atom.nil?
|
42
|
+
raise "Expected :atom key for dependency"
|
43
|
+
end
|
44
|
+
|
45
|
+
list << Bits::Manifest::Dependency.new(atom, spec)
|
46
|
+
end
|
47
|
+
|
48
|
+
list
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
data/lib/bits/provider/python.rb
CHANGED
@@ -47,9 +47,16 @@ module Bits
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def sync
|
50
|
+
# TODO: currently fetching the candidate version is a very slow operation
|
51
|
+
# sinc the initial list of packages does not include it. This needs to
|
52
|
+
# be mitigated somehow.
|
53
|
+
|
54
|
+
log.warn "Syncing without candidate version information"
|
55
|
+
|
50
56
|
t = Time.new
|
51
57
|
|
52
58
|
sync_file = File.join ns[:bits_dir], "#{provider_id}.sync"
|
59
|
+
|
53
60
|
last_sync = get_last_sync sync_file
|
54
61
|
|
55
62
|
if last_sync.nil?
|
@@ -67,10 +74,19 @@ module Bits
|
|
67
74
|
end
|
68
75
|
|
69
76
|
def query(package_atom)
|
70
|
-
candidate =
|
71
|
-
|
77
|
+
candidate = @cache[package_atom]
|
78
|
+
|
79
|
+
candidate_version = if candidate.nil?
|
80
|
+
get_candidate_version package_atom
|
81
|
+
else
|
82
|
+
candidate['version']
|
83
|
+
end
|
84
|
+
|
85
|
+
raise MissingPackage.new package_atom if candidate_version.nil?
|
86
|
+
|
72
87
|
current = get_installed_version package_atom
|
73
|
-
|
88
|
+
|
89
|
+
Bits::Package.new package_atom, current, candidate_version
|
74
90
|
end
|
75
91
|
|
76
92
|
def install(package)
|
@@ -121,36 +137,41 @@ module Bits
|
|
121
137
|
def read_partial(last_sync)
|
122
138
|
result = @client.call :changelog, last_sync
|
123
139
|
|
140
|
+
log.info "PARTIAL: Syncing #{result.size} python packages"
|
141
|
+
|
124
142
|
releases = Hash.new
|
125
143
|
|
126
144
|
result.each do |name, version, timestamp, purpose|
|
127
145
|
next if purpose != 'new release'
|
128
146
|
|
129
147
|
releases[name] = {
|
130
|
-
|
131
|
-
|
148
|
+
'atom' => name,
|
149
|
+
'version' => version,
|
132
150
|
}
|
133
151
|
end
|
134
152
|
|
135
153
|
releases
|
136
154
|
end
|
137
155
|
|
138
|
-
# TODO: works really slowly right now, fix it
|
139
156
|
def read_full
|
140
157
|
remote_packages = @client.call :list_packages
|
141
158
|
|
142
|
-
|
159
|
+
log.info "FULL: Syncing #{remote_packages.size} python packages"
|
143
160
|
|
144
161
|
packages = Hash.new
|
145
162
|
|
146
163
|
remote_packages.each do |name|
|
147
|
-
candidate
|
164
|
+
# TODO: currently syncing candidate version is very slow. This needs
|
165
|
+
# to be mitigated.
|
166
|
+
|
167
|
+
#candidate = get_candidate_version name
|
168
|
+
candidate = "0.0.0"
|
148
169
|
|
149
170
|
next if candidate.nil?
|
150
171
|
|
151
172
|
packages[name] = {
|
152
|
-
|
153
|
-
|
173
|
+
'atom' => name,
|
174
|
+
'version' => candidate,
|
154
175
|
}
|
155
176
|
end
|
156
177
|
|
data/lib/bits/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bits-installer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -113,6 +113,7 @@ files:
|
|
113
113
|
- lib/bits/commands/manifest.rb
|
114
114
|
- lib/bits/commands/show.rb
|
115
115
|
- lib/bits/commands/setup.rb
|
116
|
+
- lib/bits/manifest.rb
|
116
117
|
- lib/bits/package.rb
|
117
118
|
- lib/bits/cache.rb
|
118
119
|
- lib/bits/user.rb
|