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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a344960f6cb67186fdad797fd77c3608492d389d
4
- data.tar.gz: 7106dcb7cb0a6fc65d6539ac9ba302beb55f33cd
3
+ metadata.gz: 39a3493902116cd70169c7a1382cb5dad14706fa
4
+ data.tar.gz: 53206e6bee4946e2630bdf6595ca962c072507c6
5
5
  SHA512:
6
- metadata.gz: 2daaa37e0ad5630f907e06c4a48f469ba27370278ad7793f07faef74548379856f294b8846160e801e7dd511e7d6e390b0d12532905e42d82508e560cb31c57f
7
- data.tar.gz: ed557ee39ea6985bd629b6530c187e4a9946cc2f066639806e8d8ac99440dbd919a433544dcd7f71eb39a4f48421dc30a3ae86218be68fb9fec6458d4d4d8bd2
6
+ metadata.gz: 48ea7905fcac6b97925dd8d24deb305b615456a715c6dcd33925341a1f91aeecd540afc080138b8b9ff3ceb4a93aae430e6908359d721531a92bf108c2c123b2
7
+ data.tar.gz: 4058f0fb57b93b7df183de54bae4ef241fc483b47473d4b054b5443505236e13437f6fef92316dd9d67ae8ec0c823a53de18397d387a8dde1df2b662a9a94f71
@@ -1,3 +1,6 @@
1
+ # 0.2.1 (2014-01-19)
2
+ - Fix Repository#add to remove old entry with same pkgname
3
+
1
4
  # 0.2.0 (2014-01-19)
2
5
  - Add omakase mode
3
6
  - akabei omakase init
@@ -36,10 +36,6 @@ module Akabei
36
36
  raise NotFound.new(@path, '.PKGINFO')
37
37
  end
38
38
 
39
- def db_name
40
- "#{pkgname}-#{pkgver}"
41
- end
42
-
43
39
  def csize
44
40
  @path.size
45
41
  end
@@ -65,6 +65,10 @@ module Akabei
65
65
  end
66
66
  end
67
67
 
68
+ def db_name
69
+ "#{name}-#{version}"
70
+ end
71
+
68
72
  def write_desc(io)
69
73
  ARRAY_DESC_ATTRIBUTES.each do |attr|
70
74
  write_array(io, attr)
@@ -17,15 +17,7 @@ module Akabei
17
17
 
18
18
  extend Forwardable
19
19
  include Enumerable
20
- def_delegator(:@db, :each)
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
- pkgname, key = *entry.pathname.split('/', 2)
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
- @db[pkgname] ||= PackageEntry.new
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(@db[pkgname], archive.read_data)
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.db_name] = package.to_entry
76
+ @db[package.name] = package.to_entry
81
77
  end
82
78
 
83
79
  def remove(pkgname)
84
- @db.keys.each do |key|
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.each do |db_name, pkg_entry|
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 |db_name|
136
- pkg_entry = @db[db_name]
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|
@@ -1,3 +1,3 @@
1
1
  module Akabei
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
@@ -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(:db_name).and_return('nkf-2.1.3-1')
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(:db_name).and_return('nkf-2.1.3-1')
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
@@ -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.db_name).to eq('nkf-2.1.3-1')
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(:db_name).and_return('nkf-2.1.3-1')
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: akabei
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kohei Suzuki