akabei 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/akabei/package.rb +0 -4
- data/lib/akabei/package_entry.rb +4 -0
- data/lib/akabei/repository.rb +16 -26
- data/lib/akabei/version.rb +1 -1
- data/spec/akabei/cli_spec.rb +1 -1
- data/spec/akabei/omakase/cli_spec.rb +1 -1
- data/spec/akabei/package_spec.rb +2 -1
- data/spec/akabei/repository_spec.rb +21 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 39a3493902116cd70169c7a1382cb5dad14706fa
|
4
|
+
data.tar.gz: 53206e6bee4946e2630bdf6595ca962c072507c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 48ea7905fcac6b97925dd8d24deb305b615456a715c6dcd33925341a1f91aeecd540afc080138b8b9ff3ceb4a93aae430e6908359d721531a92bf108c2c123b2
|
7
|
+
data.tar.gz: 4058f0fb57b93b7df183de54bae4ef241fc483b47473d4b054b5443505236e13437f6fef92316dd9d67ae8ec0c823a53de18397d387a8dde1df2b662a9a94f71
|
data/CHANGELOG.md
CHANGED
data/lib/akabei/package.rb
CHANGED
data/lib/akabei/package_entry.rb
CHANGED
data/lib/akabei/repository.rb
CHANGED
@@ -17,15 +17,7 @@ module Akabei
|
|
17
17
|
|
18
18
|
extend Forwardable
|
19
19
|
include Enumerable
|
20
|
-
|
21
|
-
|
22
|
-
def [](package_name)
|
23
|
-
@db.each do |_, entry|
|
24
|
-
if entry.name == package_name
|
25
|
-
return entry
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
20
|
+
def_delegators(:@db, :each, :[])
|
29
21
|
|
30
22
|
def ==(other)
|
31
23
|
other.is_a?(self.class) &&
|
@@ -38,21 +30,25 @@ module Akabei
|
|
38
30
|
path = Pathname.new(path)
|
39
31
|
return unless path.readable?
|
40
32
|
verify!(path)
|
33
|
+
db = {}
|
41
34
|
ArchiveUtils.each_entry(path) do |entry, archive|
|
42
|
-
|
35
|
+
db_name, key = *entry.pathname.split('/', 2)
|
43
36
|
if key.include?('/')
|
44
37
|
raise Error.new("Malformed repository database: #{path}: #{entry.pathname}")
|
45
38
|
end
|
46
|
-
|
39
|
+
db[db_name] ||= PackageEntry.new
|
47
40
|
case key
|
48
41
|
when ''
|
49
42
|
# Ignore
|
50
43
|
when 'desc', 'depends', 'files'
|
51
|
-
load_entries(
|
44
|
+
load_entries(db[db_name], archive.read_data)
|
52
45
|
else
|
53
46
|
raise Error.new("Unknown repository database key: #{key}")
|
54
47
|
end
|
55
48
|
end
|
49
|
+
db.each_value do |entry|
|
50
|
+
@db[entry.name] = entry
|
51
|
+
end
|
56
52
|
nil
|
57
53
|
end
|
58
54
|
|
@@ -77,17 +73,11 @@ module Akabei
|
|
77
73
|
end
|
78
74
|
|
79
75
|
def add(package)
|
80
|
-
@db[package.
|
76
|
+
@db[package.name] = package.to_entry
|
81
77
|
end
|
82
78
|
|
83
79
|
def remove(pkgname)
|
84
|
-
@db.
|
85
|
-
if @db[key].name == pkgname
|
86
|
-
@db.delete(key)
|
87
|
-
return true
|
88
|
-
end
|
89
|
-
end
|
90
|
-
false
|
80
|
+
@db.delete(pkgname)
|
91
81
|
end
|
92
82
|
|
93
83
|
def verify!(path)
|
@@ -114,8 +104,8 @@ module Akabei
|
|
114
104
|
end
|
115
105
|
|
116
106
|
def store_tree(topdir)
|
117
|
-
@db.
|
118
|
-
pkgdir = topdir.join(db_name)
|
107
|
+
@db.each_value do |pkg_entry|
|
108
|
+
pkgdir = topdir.join(pkg_entry.db_name)
|
119
109
|
pkgdir.mkpath
|
120
110
|
pkgdir.join('desc').open('w') do |f|
|
121
111
|
pkg_entry.write_desc(f)
|
@@ -132,15 +122,15 @@ module Akabei
|
|
132
122
|
end
|
133
123
|
|
134
124
|
def create_db(topdir, archive)
|
135
|
-
@db.keys.sort.each do |
|
136
|
-
pkg_entry = @db[
|
125
|
+
@db.keys.sort.each do |pkgname|
|
126
|
+
pkg_entry = @db[pkgname]
|
137
127
|
archive.new_entry do |entry|
|
138
|
-
entry.pathname = "#{db_name}/"
|
128
|
+
entry.pathname = "#{pkg_entry.db_name}/"
|
139
129
|
entry.copy_stat(topdir.join(entry.pathname).to_s)
|
140
130
|
archive.write_header(entry)
|
141
131
|
end
|
142
132
|
%w[desc depends files].each do |fname|
|
143
|
-
pathname = "#{db_name}/#{fname}"
|
133
|
+
pathname = "#{pkg_entry.db_name}/#{fname}"
|
144
134
|
path = topdir.join(pathname)
|
145
135
|
if path.readable?
|
146
136
|
archive.new_entry do |entry|
|
data/lib/akabei/version.rb
CHANGED
data/spec/akabei/cli_spec.rb
CHANGED
@@ -19,7 +19,7 @@ describe Akabei::CLI do
|
|
19
19
|
# Disable warning
|
20
20
|
entry.add('files', 'usr/bin/nkf')
|
21
21
|
|
22
|
-
allow(package).to receive(:
|
22
|
+
allow(package).to receive(:name).and_return('nkf')
|
23
23
|
allow(package).to receive(:to_entry).and_return(entry)
|
24
24
|
|
25
25
|
allow_any_instance_of(Akabei::ChrootTree).to receive(:with_chroot) { |chroot, &block|
|
@@ -80,7 +80,7 @@ describe Akabei::Omakase::CLI do
|
|
80
80
|
tar('xf', test_input('nkf.tar.gz').to_s, '-C', config.pkgbuild.to_s)
|
81
81
|
|
82
82
|
packages.each do |arch, package|
|
83
|
-
allow(package).to receive(:
|
83
|
+
allow(package).to receive(:name).and_return('nkf')
|
84
84
|
allow(package).to receive(:to_entry).and_return(entry)
|
85
85
|
allow(package).to receive(:path).and_return(Pathname.new("test/os/#{arch}/nkf-2.1.3-1-#{arch}.pkg.tar.xz"))
|
86
86
|
end
|
data/spec/akabei/package_spec.rb
CHANGED
@@ -8,7 +8,8 @@ describe Akabei::Package do
|
|
8
8
|
describe '#pkginfo' do
|
9
9
|
it 'returns PackageInfo' do
|
10
10
|
pkginfo = package.pkginfo
|
11
|
-
expect(package.
|
11
|
+
expect(package.name).to eq('nkf')
|
12
|
+
expect(package.version).to eq('2.1.3-1')
|
12
13
|
end
|
13
14
|
|
14
15
|
context "when pkg_path doesn't exist" do
|
@@ -81,13 +81,33 @@ describe Akabei::Repository do
|
|
81
81
|
it 'adds an entry' do
|
82
82
|
package = double('package')
|
83
83
|
entry = double('entry')
|
84
|
-
allow(package).to receive(:
|
84
|
+
allow(package).to receive(:name).and_return('nkf')
|
85
85
|
expect(package).to receive(:to_entry).and_return(entry)
|
86
86
|
allow(entry).to receive(:name).and_return('nkf')
|
87
87
|
|
88
88
|
repo.add(package)
|
89
89
|
expect(repo['nkf']).to eql(entry)
|
90
90
|
end
|
91
|
+
|
92
|
+
context 'with old version' do
|
93
|
+
let(:old_package) { double('old package') }
|
94
|
+
let(:old_entry) { double('old entry') }
|
95
|
+
|
96
|
+
before do
|
97
|
+
allow(old_package).to receive(:name).and_return('nkf')
|
98
|
+
allow(old_package).to receive(:to_entry).and_return(old_entry)
|
99
|
+
repo.add(old_package)
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'replaces old version' do
|
103
|
+
package = double('package')
|
104
|
+
entry = double('entry')
|
105
|
+
allow(package).to receive(:name).and_return('nkf')
|
106
|
+
allow(package).to receive(:to_entry).and_return(entry)
|
107
|
+
|
108
|
+
expect { repo.add(package) }.to change { repo['nkf'] }.from(old_entry).to(entry)
|
109
|
+
end
|
110
|
+
end
|
91
111
|
end
|
92
112
|
|
93
113
|
describe '#remove' do
|