apt-pkg 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.md +6 -0
- data/README.md +11 -2
- data/ext/apt_pkg/apt-pkg.cpp +1 -0
- data/ext/apt_pkg/configuration.cpp +3 -3
- data/ext/apt_pkg/pkgcache.cpp +28 -0
- data/ext/apt_pkg/pkgcache.h +1 -0
- data/lib/debian/apt_pkg/version.rb +1 -1
- data/test/apt_pkg_cache_not_init_test.rb +6 -0
- data/test/apt_pkg_cache_test.rb +6 -0
- data/test/apt_pkg_configuration_test.rb +12 -6
- data/test/apt_pkg_test.rb +8 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d4ad2f07af4117ef4391ccac21f05f0aa7b7d5f2
|
4
|
+
data.tar.gz: 841edb14b431b6b07c0362b06f6b1f0fa250bf97
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c90cc55dd8670bc11f0eb3085c0c9f65bd9aa1424365f1eca496c2cf02a218f3aaf5dd5ea4e5d7399106d4a44e68db6d43d003157e3b7ab61cb815d488103ad
|
7
|
+
data.tar.gz: 449d404c254233e5a9c2628b834d15f61e27e0012f7f1d9edb440da5a03591a0fff43e712cbdf82be237abbda26892ba7edd69b79897002faf55c221a5676ad2
|
data/History.md
CHANGED
data/README.md
CHANGED
@@ -14,15 +14,22 @@ gem install apt-pkg
|
|
14
14
|
|
15
15
|
## USING
|
16
16
|
|
17
|
-
|
17
|
+
Basic usage:
|
18
18
|
|
19
19
|
``` ruby
|
20
20
|
require 'debian/apt_pkg'
|
21
|
+
|
22
|
+
# Initialize the configuration and system of apt
|
21
23
|
Debian::AptPkg.init
|
24
|
+
|
25
|
+
# Update the index files used by the cache
|
26
|
+
Debian::AptPkg::PkgCache.update
|
27
|
+
|
28
|
+
# Search package by names
|
22
29
|
Debian::AptPkg::PkgCache.pkg_names("vim")
|
23
30
|
```
|
24
31
|
|
25
|
-
[Documentation](
|
32
|
+
[Documentation](http://www.rubydoc.info/gems/apt-pkg)
|
26
33
|
|
27
34
|
## BUILD
|
28
35
|
|
@@ -47,5 +54,7 @@ Copyright (c) 2014-2016 Laurent Arnoud <laurent@spkdev.net>
|
|
47
54
|
---
|
48
55
|
[![Build](https://img.shields.io/travis-ci/spk/ruby-apt-pkg.svg)](https://travis-ci.org/spk/ruby-apt-pkg)
|
49
56
|
[![Version](https://img.shields.io/gem/v/apt-pkg.svg)](https://rubygems.org/gems/apt-pkg)
|
57
|
+
[![Documentation](https://img.shields.io/badge/doc-rubydoc-blue.svg)](http://www.rubydoc.info/gems/apt-pkg)
|
50
58
|
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](http://opensource.org/licenses/MIT "MIT")
|
51
59
|
[![IRC Network](https://img.shields.io/badge/irc-oftc-blue.svg)](https://webchat.oftc.net/ "#ruby-apt-pkg")
|
60
|
+
[![Project status](http://img.shields.io/status/experimental.png?color=red)](https://github.com/spk/ruby-apt-pkg)
|
data/ext/apt_pkg/apt-pkg.cpp
CHANGED
@@ -14,7 +14,7 @@ architectures(VALUE self)
|
|
14
14
|
VALUE result = rb_ary_new();
|
15
15
|
std::vector < std::string > arches = APT::Configuration::getArchitectures();
|
16
16
|
std::vector < std::string >::const_iterator I;
|
17
|
-
for (I = arches.begin(); I != arches.end(); I
|
17
|
+
for (I = arches.begin(); I != arches.end(); ++I) {
|
18
18
|
rb_ary_push(result, rb_str_new2((*I).c_str()));
|
19
19
|
}
|
20
20
|
return result;
|
@@ -57,7 +57,7 @@ languages(int argc, VALUE *argv, VALUE self)
|
|
57
57
|
std::vector < std::string > const langs =
|
58
58
|
APT::Configuration::getLanguages(all);
|
59
59
|
std::vector < std::string >::const_iterator I;
|
60
|
-
for (I = langs.begin(); I != langs.end(); I
|
60
|
+
for (I = langs.begin(); I != langs.end(); ++I) {
|
61
61
|
rb_ary_push(result, rb_str_new2((*I).c_str()));
|
62
62
|
}
|
63
63
|
return result;
|
@@ -97,7 +97,7 @@ compressors(VALUE self)
|
|
97
97
|
VALUE result = rb_ary_new();
|
98
98
|
std::vector < std::string > cmps = APT::Configuration::getCompressionTypes();
|
99
99
|
std::vector < std::string >::const_iterator I;
|
100
|
-
for (I = cmps.begin(); I != cmps.end(); I
|
100
|
+
for (I = cmps.begin(); I != cmps.end(); ++I) {
|
101
101
|
rb_ary_push(result, rb_str_new2((*I).c_str()));
|
102
102
|
}
|
103
103
|
return result;
|
data/ext/apt_pkg/pkgcache.cpp
CHANGED
@@ -33,6 +33,32 @@ gen_caches(VALUE self)
|
|
33
33
|
return INT2BOOL(res);
|
34
34
|
}
|
35
35
|
|
36
|
+
/*
|
37
|
+
* call-seq: update() -> bool
|
38
|
+
*
|
39
|
+
* Update the index files used by the cache.
|
40
|
+
* Return `nil` when config, system, cache is not configured.
|
41
|
+
*
|
42
|
+
* Debian::AptPkg::PkgCache.update # => false
|
43
|
+
*
|
44
|
+
**/
|
45
|
+
static VALUE
|
46
|
+
update(VALUE self)
|
47
|
+
{
|
48
|
+
if (!config_system_initialized()) {
|
49
|
+
return Qnil;
|
50
|
+
}
|
51
|
+
pkgCacheFile CacheFile;
|
52
|
+
// Get the source list
|
53
|
+
if (CacheFile.BuildSourceList() == false) {
|
54
|
+
return Qnil;
|
55
|
+
}
|
56
|
+
pkgAcquireStatus *Stat(NULL);
|
57
|
+
pkgSourceList *List = CacheFile.GetSourceList();
|
58
|
+
int res = ListUpdate(*Stat, *List);
|
59
|
+
return INT2BOOL(res);
|
60
|
+
}
|
61
|
+
|
36
62
|
/*
|
37
63
|
* call-seq: is_multi_arch() -> bool
|
38
64
|
*
|
@@ -268,6 +294,8 @@ init_apt_pkg_pkgcache()
|
|
268
294
|
|
269
295
|
rb_define_singleton_method(rb_mDebianAptPkgConfiguration, "gen_caches",
|
270
296
|
RUBY_METHOD_FUNC(gen_caches), 0);
|
297
|
+
rb_define_singleton_method(rb_mDebianAptPkgConfiguration, "update",
|
298
|
+
RUBY_METHOD_FUNC(update), 0);
|
271
299
|
rb_define_singleton_method(rb_mDebianAptPkgConfiguration, "is_multi_arch",
|
272
300
|
RUBY_METHOD_FUNC(is_multi_arch), 0);
|
273
301
|
rb_define_singleton_method(rb_mDebianAptPkgConfiguration, "pkg_names",
|
data/ext/apt_pkg/pkgcache.h
CHANGED
@@ -2,6 +2,12 @@ require_relative 'test_helper'
|
|
2
2
|
|
3
3
|
describe Debian::AptPkg::PkgCache do
|
4
4
|
describe 'not init' do
|
5
|
+
describe '.update' do
|
6
|
+
it 'can be called' do
|
7
|
+
Debian::AptPkg::PkgCache.update
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
5
11
|
%i(package version depends package_file ver_file provides group).each do |m|
|
6
12
|
describe ".#{m}_count" do
|
7
13
|
it 'can be called' do
|
data/test/apt_pkg_cache_test.rb
CHANGED
@@ -55,13 +55,17 @@ describe Debian::AptPkg::Configuration do
|
|
55
55
|
Debian::AptPkg::Configuration.config_find
|
56
56
|
end.must_raise ArgumentError
|
57
57
|
|
58
|
-
Debian::AptPkg::Configuration
|
58
|
+
Debian::AptPkg::Configuration
|
59
|
+
.config_find('Dir::Etc::main')
|
59
60
|
.must_equal 'apt.conf'
|
60
|
-
Debian::AptPkg::Configuration
|
61
|
+
Debian::AptPkg::Configuration
|
62
|
+
.config_find('Dir::Etc::netrc')
|
61
63
|
.must_equal 'auth.conf'
|
62
|
-
Debian::AptPkg::Configuration
|
64
|
+
Debian::AptPkg::Configuration
|
65
|
+
.config_find('Dir::Etc::parts')
|
63
66
|
.must_equal 'apt.conf.d'
|
64
|
-
Debian::AptPkg::Configuration
|
67
|
+
Debian::AptPkg::Configuration
|
68
|
+
.config_find('Spk', 'DebianUser')
|
65
69
|
.must_equal 'DebianUser'
|
66
70
|
end
|
67
71
|
|
@@ -70,9 +74,11 @@ describe Debian::AptPkg::Configuration do
|
|
70
74
|
Debian::AptPkg::Configuration.config_find_file
|
71
75
|
end.must_raise ArgumentError
|
72
76
|
|
73
|
-
Debian::AptPkg::Configuration
|
77
|
+
Debian::AptPkg::Configuration
|
78
|
+
.config_find_file('Dir::Etc::main')
|
74
79
|
.must_equal '/etc/apt/apt.conf'
|
75
|
-
Debian::AptPkg::Configuration
|
80
|
+
Debian::AptPkg::Configuration
|
81
|
+
.config_find_file('Dir::Etc::netrc')
|
76
82
|
.must_equal '/etc/apt/auth.conf'
|
77
83
|
end
|
78
84
|
end
|
data/test/apt_pkg_test.rb
CHANGED
@@ -64,11 +64,14 @@ describe Debian::AptPkg do
|
|
64
64
|
|
65
65
|
describe 'NotEquals' do
|
66
66
|
it 'should compare Debian version' do
|
67
|
-
Debian::AptPkg
|
67
|
+
Debian::AptPkg
|
68
|
+
.check_dep('1', Debian::AptPkg::NOT_EQUALS, '2')
|
68
69
|
.must_equal true
|
69
|
-
Debian::AptPkg
|
70
|
+
Debian::AptPkg
|
71
|
+
.check_dep('2', Debian::AptPkg::NOT_EQUALS, '1')
|
70
72
|
.must_equal true
|
71
|
-
Debian::AptPkg
|
73
|
+
Debian::AptPkg
|
74
|
+
.check_dep('1', Debian::AptPkg::NOT_EQUALS, '1')
|
72
75
|
.must_equal false
|
73
76
|
end
|
74
77
|
end
|
@@ -84,7 +87,8 @@ describe Debian::AptPkg do
|
|
84
87
|
|
85
88
|
describe '.uri_to_filename' do
|
86
89
|
it 'should return a filename which can be used to store the file' do
|
87
|
-
Debian::AptPkg
|
90
|
+
Debian::AptPkg
|
91
|
+
.uri_to_filename('http://debian.org/index.html')
|
88
92
|
.must_equal 'debian.org_index.html'
|
89
93
|
end
|
90
94
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: apt-pkg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Laurent Arnoud
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|