bundix 2.0.3 → 2.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/bundix/source.rb +16 -42
- data/lib/bundix/version.rb +3 -0
- data/lib/bundix.rb +30 -17
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 396e7d0bc64e702a8aa6be3de6d01557828e74d9
|
4
|
+
data.tar.gz: 8c269513efaa9958b835273768a3ce1bd8fe2137
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 76ce621cbfcf70d908e0ce94416a021bf9599133bb4922ece0c01ef2fcf4a3c8ab5cf62ccaafe13f14fe592f1de0e4113e636d50362a30324fc9a277327a3455
|
7
|
+
data.tar.gz: 86534b85654782d92eea6e773a7ace2b0d1edb69db5dfb16d0268f5bb7d9a91ab7b5e3357977b75c509266ecf30354cc9fd2a73e67f57091c41f1c8c26e44efc
|
data/lib/bundix/source.rb
CHANGED
@@ -18,6 +18,8 @@ class Bundix
|
|
18
18
|
|
19
19
|
def nix_prefetch_url(*args)
|
20
20
|
sh(NIX_PREFETCH_URL, '--type', 'sha256', *args)
|
21
|
+
rescue
|
22
|
+
nil
|
21
23
|
end
|
22
24
|
|
23
25
|
def nix_prefetch_git(uri, revision)
|
@@ -32,10 +34,8 @@ class Bundix
|
|
32
34
|
spec.source.caches.each do |cache|
|
33
35
|
path = File.join(cache, "#{spec.name}-#{spec.version}.gem")
|
34
36
|
next unless File.file?(path)
|
35
|
-
|
36
|
-
|
37
|
-
rescue
|
38
|
-
end
|
37
|
+
hash = nix_prefetch_url("file://#{path}")[SHA256_32]
|
38
|
+
return hash if hash
|
39
39
|
end
|
40
40
|
|
41
41
|
nil
|
@@ -43,55 +43,31 @@ class Bundix
|
|
43
43
|
|
44
44
|
def fetch_remotes_hash(spec, remotes)
|
45
45
|
remotes.each do |remote|
|
46
|
-
|
47
|
-
|
48
|
-
rescue
|
49
|
-
end
|
46
|
+
hash = fetch_remote_hash(spec, remote)
|
47
|
+
return remote, hash if hash
|
50
48
|
end
|
51
49
|
|
52
50
|
nil
|
53
51
|
end
|
54
52
|
|
55
53
|
def fetch_remote_hash(spec, remote)
|
56
|
-
hash = nil
|
57
|
-
|
58
|
-
if URI(remote).host == 'rubygems.org'
|
59
|
-
uri = "#{remote}/api/v1/versions/#{spec.name}.json"
|
60
|
-
puts "Getting SHA256 from: #{uri}" if $VERBOSE
|
61
|
-
open uri do |io|
|
62
|
-
versions = JSON.parse(io.read)
|
63
|
-
if found_version = versions.find{|obj| obj['number'] == spec.version.to_s }
|
64
|
-
hash = found_version['sha']
|
65
|
-
break
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
54
|
uri = "#{remote}/gems/#{spec.name}-#{spec.version}.gem"
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
nix_prefetch_url(uri, hash)[SHA256_16]
|
75
|
-
rescue
|
76
|
-
nix_prefetch_url(uri)[SHA256_32]
|
77
|
-
end
|
78
|
-
else
|
79
|
-
nix_prefetch_url(uri)[SHA256_32]
|
80
|
-
end
|
55
|
+
nix_prefetch_url(uri)[SHA256_32]
|
56
|
+
rescue
|
57
|
+
nil
|
81
58
|
end
|
82
59
|
|
83
60
|
def convert_rubygems
|
84
61
|
remotes = spec.source.remotes.map{|remote| remote.to_s.sub(/\/+$/, '') }
|
85
|
-
hash = fetch_local_hash(spec)
|
62
|
+
hash = fetch_local_hash(spec)
|
63
|
+
remote, hash = fetch_remotes_hash(spec, remotes) unless hash
|
86
64
|
hash = sh(NIX_HASH, '--type', 'sha256', '--to-base32', hash)[SHA256_32]
|
87
65
|
fail "couldn't fetch hash for #{spec.name}-#{spec.version}" unless hash
|
88
66
|
puts "#{hash} => #{spec.name}-#{spec.version}.gem" if $VERBOSE
|
89
67
|
|
90
|
-
{
|
91
|
-
|
92
|
-
|
93
|
-
sha256: hash
|
94
|
-
}
|
68
|
+
{ type: 'gem',
|
69
|
+
remotes: (remote ? [remote] : remotes),
|
70
|
+
sha256: hash }
|
95
71
|
end
|
96
72
|
|
97
73
|
def convert_git
|
@@ -102,13 +78,11 @@ class Bundix
|
|
102
78
|
fail "couldn't fetch hash for #{spec.name}-#{spec.version}" unless hash
|
103
79
|
puts "#{hash} => #{uri}" if $VERBOSE
|
104
80
|
|
105
|
-
{
|
106
|
-
type: 'git',
|
81
|
+
{ type: 'git',
|
107
82
|
url: uri.to_s,
|
108
83
|
rev: revision,
|
109
84
|
sha256: hash,
|
110
|
-
fetchSubmodules: false
|
111
|
-
}
|
85
|
+
fetchSubmodules: false }
|
112
86
|
end
|
113
87
|
end
|
114
88
|
end
|
data/lib/bundix.rb
CHANGED
@@ -4,11 +4,10 @@ require 'open-uri'
|
|
4
4
|
require 'open3'
|
5
5
|
require 'pp'
|
6
6
|
|
7
|
+
require_relative 'bundix/version'
|
7
8
|
require_relative 'bundix/source'
|
8
9
|
|
9
10
|
class Bundix
|
10
|
-
VERSION = '2.0.3'
|
11
|
-
|
12
11
|
NIX_INSTANTIATE = 'nix-instantiate'
|
13
12
|
NIX_PREFETCH_URL = 'nix-prefetch-url'
|
14
13
|
NIX_PREFETCH_GIT = 'nix-prefetch-git'
|
@@ -35,21 +34,8 @@ class Bundix
|
|
35
34
|
|
36
35
|
# reverse so git comes last
|
37
36
|
lock.specs.reverse_each.with_object({}) do |spec, gems|
|
38
|
-
|
39
|
-
|
40
|
-
v['version'] == spec.version.to_s &&
|
41
|
-
v['source'] && v['source']['sha256'].to_s.size == 52
|
42
|
-
}
|
43
|
-
|
44
|
-
if cached
|
45
|
-
gems[name] = cached
|
46
|
-
next
|
47
|
-
end
|
48
|
-
|
49
|
-
gems[spec.name] = {
|
50
|
-
version: spec.version.to_s,
|
51
|
-
source: Source.new(spec).convert
|
52
|
-
}
|
37
|
+
gem = find_cached_spec(spec, cache) || convert_spec(spec, cache)
|
38
|
+
gems.merge!(gem)
|
53
39
|
|
54
40
|
if options[:deps] && spec.dependencies.any?
|
55
41
|
gems[spec.name][:dependencies] = spec.dependencies.map(&:name) - ['bundler']
|
@@ -57,6 +43,33 @@ class Bundix
|
|
57
43
|
end
|
58
44
|
end
|
59
45
|
|
46
|
+
def convert_spec(spec, cache)
|
47
|
+
{spec.name => {version: spec.version.to_s, source: Source.new(spec).convert}}
|
48
|
+
rescue => ex
|
49
|
+
warn "Skipping #{spec.name}: #{ex}"
|
50
|
+
puts ex.backtrace
|
51
|
+
{spec.name => {}}
|
52
|
+
end
|
53
|
+
|
54
|
+
def find_cached_spec(spec, cache)
|
55
|
+
name, cached = cache.find{|k, v|
|
56
|
+
next unless k == spec.name
|
57
|
+
next unless cached_source = v['source']
|
58
|
+
|
59
|
+
case spec_source = spec.source
|
60
|
+
when Bundler::Source::Git
|
61
|
+
next unless cached_rev = cached_source['rev']
|
62
|
+
next unless spec_rev = spec_source.options['revision']
|
63
|
+
spec_rev == cached_rev
|
64
|
+
when Bundler::Source::Rubygems
|
65
|
+
v['version'] == spec.version.to_s
|
66
|
+
end
|
67
|
+
}
|
68
|
+
|
69
|
+
{name => cached} if cached
|
70
|
+
end
|
71
|
+
|
72
|
+
|
60
73
|
def parse_gemset
|
61
74
|
path = File.expand_path(options[:gemset])
|
62
75
|
return {} unless File.file?(path)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bundix
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael 'manveru' Fellinger
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-02-
|
11
|
+
date: 2016-02-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -34,6 +34,7 @@ files:
|
|
34
34
|
- bin/bundix
|
35
35
|
- lib/bundix.rb
|
36
36
|
- lib/bundix/source.rb
|
37
|
+
- lib/bundix/version.rb
|
37
38
|
homepage: https://github.com/manveru/bundix
|
38
39
|
licenses:
|
39
40
|
- MIT
|
@@ -54,7 +55,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
54
55
|
version: '0'
|
55
56
|
requirements: []
|
56
57
|
rubyforge_project:
|
57
|
-
rubygems_version: 2.4.5
|
58
|
+
rubygems_version: 2.4.5.1
|
58
59
|
signing_key:
|
59
60
|
specification_version: 4
|
60
61
|
summary: Creates Nix packages from Gemfiles.
|