apt-pkg 0.0.4 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/History.md +51 -2
- data/LICENSE +1 -1
- data/README.md +35 -22
- data/ext/apt_pkg/apt-pkg.cpp +148 -88
- data/ext/apt_pkg/apt-pkg.h +3 -1
- data/ext/apt_pkg/configuration.cpp +94 -86
- data/ext/apt_pkg/extconf.rb +2 -5
- data/ext/apt_pkg/pkgcache.cpp +379 -38
- data/ext/apt_pkg/pkgcache.h +1 -0
- data/lib/debian/apt_pkg.rb +4 -0
- data/lib/debian/apt_pkg/gem_version.rb +9 -0
- data/lib/debian/apt_pkg/package.rb +47 -0
- data/test/apt_pkg_cache_not_init_integration.rb +24 -0
- data/test/apt_pkg_configuration_test.rb +35 -31
- data/test/apt_pkg_test.rb +67 -47
- data/test/debian/apt_pkg/package_test.rb +56 -0
- data/test/debian/apt_pkg/pkg_cache_test.rb +114 -0
- data/test/test_helper.rb +1 -1
- metadata +15 -12
- data/test/apt_pkg_cache_test.rb +0 -40
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 16cd206a5d9b3137497d05f937ef5b78fcac7aa6bd62e4177b73ef98ff0d917e
|
4
|
+
data.tar.gz: b0bcc23a93c8112321c890487ee385c7cede6da1b3179da4e5f0ebf11b723161
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e650327a185fca89e757e30659c8c61371e7d2950e47b72e463a6ed598da4656e7fcc2f831830acea7de9e045242636077746d9f692ab5ca55dc9f62182db56
|
7
|
+
data.tar.gz: 8ab515778e66c88f8b53f10d03d65e95db89db8061f166bd4235b2dd47f18433187162b645d663a8f38bcf937d06d4a7fbdd14391b887eafadc4652b35cad80c
|
data/History.md
CHANGED
@@ -1,6 +1,55 @@
|
|
1
1
|
|
2
|
+
0.5.0 / 2020-07-22
|
3
|
+
==================
|
4
|
+
|
5
|
+
* Debian::AptPkg::PkgCache.pkg_names deprecated
|
6
|
+
* Add all maintained Rubies on gitlab-ci
|
7
|
+
* Init listing packages on cache
|
8
|
+
* Quick fix gitlab ci
|
9
|
+
* Add .gitlab-ci.yml
|
10
|
+
* Rename lib/debian/apt_pkg/{version,gem_version}.rb
|
11
|
+
* Update README
|
12
|
+
* Tidy tests remove should
|
13
|
+
* Debian::AptPkg.init returns a boolean
|
14
|
+
* Fix mimitest warnings
|
15
|
+
* Remove cppcheck on CI version conflict
|
16
|
+
* Fix code lint
|
17
|
+
* Fix CI and update Rubies
|
18
|
+
* Fix libapt-pkg 2.1 compat
|
19
|
+
* Update apt-pkg deps
|
20
|
+
* Update doc Debian::AptPkg::InitError
|
21
|
+
* README: Bundler is not needed
|
22
|
+
* Use Debian::AptPkg::InitError instead of RuntimeError
|
23
|
+
* Fix rb_mDebianAptPkgCache name
|
24
|
+
|
25
|
+
0.4.0 / 2016-10-06
|
26
|
+
==================
|
27
|
+
|
28
|
+
* Raise RuntimeError instead of returning `nil`
|
29
|
+
|
30
|
+
0.3.0 / 2016-01-23
|
31
|
+
==================
|
32
|
+
|
33
|
+
* Prefer prefix ++/-- operators for non-primitive types
|
34
|
+
* Add Debian::AptPkg::PkgCache.update
|
35
|
+
|
36
|
+
0.2.0 / 2016-01-04
|
37
|
+
==================
|
38
|
+
|
39
|
+
* Fix cache count methods when not init
|
40
|
+
* Add init, init_{config,system}
|
41
|
+
* Add PkgCache.is_multi_arch method
|
42
|
+
|
43
|
+
0.1.0 / 2015-12-20
|
44
|
+
==================
|
45
|
+
|
46
|
+
* Change VERSION, APT_VERSION and LIBAPT_PKG_VERSION
|
47
|
+
* Add cache count methods
|
48
|
+
* Fix rake lint task exit status
|
49
|
+
* Fix syntax offences
|
50
|
+
|
2
51
|
0.0.4 / 2015-12-19
|
3
52
|
==================
|
4
53
|
|
5
|
-
* Simple search with `Debian::AptPkg::PkgCache.pkg_names("vim")`
|
6
|
-
* Documentation update
|
54
|
+
* Simple search with `Debian::AptPkg::PkgCache.pkg_names("vim")`
|
55
|
+
* Documentation update
|
data/LICENSE
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
The MIT License
|
2
2
|
|
3
|
-
Copyright (c) 2014-
|
3
|
+
Copyright (c) 2014-2020 Laurent Arnoud <laurent@spkdev.net>
|
4
4
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining
|
6
6
|
a copy of this software and associated documentation files (the
|
data/README.md
CHANGED
@@ -1,50 +1,63 @@
|
|
1
1
|
# Ruby interface to apt-pkg
|
2
2
|
|
3
3
|
Goal of this project is to have a proper Ruby binding to APT like in
|
4
|
-
[Python](https://
|
4
|
+
[Python](https://tracker.debian.org/pkg/python-apt).
|
5
5
|
|
6
6
|
Currently install, remove packages commands are **not** implemented.
|
7
7
|
|
8
8
|
## INSTALL
|
9
9
|
|
10
|
-
|
11
|
-
|
10
|
+
```
|
11
|
+
apt install build-essential ruby-dev libapt-pkg-dev (>= 1.0)
|
12
12
|
gem install apt-pkg
|
13
|
-
|
13
|
+
```
|
14
14
|
|
15
15
|
## USING
|
16
16
|
|
17
|
-
|
17
|
+
Basic usage:
|
18
18
|
|
19
|
-
|
20
|
-
require 'apt_pkg'
|
19
|
+
``` ruby
|
20
|
+
require 'debian/apt_pkg'
|
21
|
+
|
22
|
+
# Initialize the configuration and system of apt
|
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
|
21
29
|
Debian::AptPkg::PkgCache.pkg_names("vim")
|
22
|
-
~~~
|
23
30
|
|
24
|
-
|
31
|
+
# List packages stored in the cache
|
32
|
+
Debian::AptPkg::PkgCache.packages
|
33
|
+
|
34
|
+
# List installed packages
|
35
|
+
Debian::AptPkg::PkgCache.packages.select {|pkg| pkg.is_installed }
|
36
|
+
```
|
37
|
+
|
38
|
+
[Documentation](http://www.rubydoc.info/gems/apt-pkg)
|
25
39
|
|
26
40
|
## BUILD
|
27
41
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
bundle exec rake compile
|
32
|
-
~~~
|
42
|
+
``` console
|
43
|
+
rake compile
|
44
|
+
```
|
33
45
|
|
34
46
|
## TEST
|
35
47
|
|
36
|
-
|
37
|
-
|
38
|
-
|
48
|
+
``` console
|
49
|
+
rake test
|
50
|
+
```
|
39
51
|
|
40
52
|
## LICENSE
|
41
53
|
|
42
54
|
The MIT License
|
43
55
|
|
44
|
-
Copyright (c) 2014-
|
56
|
+
Copyright (c) 2014-2020 Laurent Arnoud <laurent@spkdev.net>
|
45
57
|
|
46
58
|
---
|
47
|
-
[](https://travis-ci.org/spk/ruby-apt-pkg)
|
60
|
+
[](https://rubygems.org/gems/apt-pkg)
|
61
|
+
[](http://www.rubydoc.info/gems/apt-pkg)
|
62
|
+
[](http://opensource.org/licenses/MIT "MIT")
|
63
|
+
[](https://github.com/spk/ruby-apt-pkg)
|
data/ext/apt_pkg/apt-pkg.cpp
CHANGED
@@ -2,6 +2,51 @@
|
|
2
2
|
#include "configuration.h"
|
3
3
|
#include "pkgcache.h"
|
4
4
|
|
5
|
+
/*
|
6
|
+
* call-seq: init() -> bool
|
7
|
+
*
|
8
|
+
* Shorthand for doing init_config() and init_system().
|
9
|
+
*
|
10
|
+
* Debian::AptPkg.init # => true
|
11
|
+
*
|
12
|
+
**/
|
13
|
+
static VALUE
|
14
|
+
init(VALUE self)
|
15
|
+
{
|
16
|
+
int res = pkgInitConfig(*_config) && pkgInitSystem(*_config, _system);
|
17
|
+
return INT2BOOL(res);
|
18
|
+
}
|
19
|
+
|
20
|
+
/*
|
21
|
+
* call-seq: init_config() -> bool
|
22
|
+
*
|
23
|
+
* Load the default configuration and the config file.
|
24
|
+
*
|
25
|
+
* Debian::AptPkg.init_config # => false
|
26
|
+
*
|
27
|
+
**/
|
28
|
+
static VALUE
|
29
|
+
init_config(VALUE self)
|
30
|
+
{
|
31
|
+
int res = pkgInitConfig(*_config);
|
32
|
+
return INT2BOOL(res);
|
33
|
+
}
|
34
|
+
|
35
|
+
/*
|
36
|
+
* call-seq: init_system() -> bool
|
37
|
+
*
|
38
|
+
* Construct the apt_pkg system.
|
39
|
+
*
|
40
|
+
* Debian::AptPkg.init_system # => false
|
41
|
+
*
|
42
|
+
**/
|
43
|
+
static VALUE
|
44
|
+
init_system(VALUE self)
|
45
|
+
{
|
46
|
+
int res = pkgInitSystem(*_config, _system);
|
47
|
+
return INT2BOOL(res);
|
48
|
+
}
|
49
|
+
|
5
50
|
/*
|
6
51
|
* call-seq: cmp_version(pkg_version_a, pkg_version_b) -> int
|
7
52
|
*
|
@@ -15,11 +60,12 @@
|
|
15
60
|
* Debian::AptPkg.cmp_version('1.0', '1.1') # => -1
|
16
61
|
*
|
17
62
|
**/
|
18
|
-
static
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
63
|
+
static VALUE
|
64
|
+
cmp_version(VALUE self, VALUE pkg_version_a, VALUE pkg_version_b)
|
65
|
+
{
|
66
|
+
int res = debVS.CmpVersion(StringValuePtr(pkg_version_a),
|
67
|
+
StringValuePtr(pkg_version_b));
|
68
|
+
return INT2FIX(res);
|
23
69
|
}
|
24
70
|
|
25
71
|
/*
|
@@ -37,24 +83,26 @@ VALUE cmp_version(VALUE self, VALUE pkg_version_a, VALUE pkg_version_b) {
|
|
37
83
|
* Debian::AptPkg.check_dep('1', Debian::AptPkg::NOT_EQUALS, '2') # => true
|
38
84
|
*
|
39
85
|
**/
|
40
|
-
static
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
86
|
+
static VALUE
|
87
|
+
check_dep(VALUE self, VALUE pkg_version_a, VALUE cmp_type, VALUE pkg_version_b)
|
88
|
+
{
|
89
|
+
unsigned int op = 0;
|
90
|
+
if (TYPE(cmp_type) == T_FIXNUM) {
|
91
|
+
op = NUM2INT(cmp_type);
|
92
|
+
} else {
|
93
|
+
const char *op_str = StringValuePtr(cmp_type);
|
94
|
+
if (strcmp(op_str, ">") == 0)
|
95
|
+
op_str = ">>";
|
96
|
+
if (strcmp(op_str, "<") == 0)
|
97
|
+
op_str = "<<";
|
98
|
+
if (*debListParser::ConvertRelation(op_str, op) != 0) {
|
99
|
+
rb_raise(rb_eArgError, "Bad comparison operation");
|
100
|
+
return 0;
|
54
101
|
}
|
55
|
-
|
56
|
-
|
57
|
-
|
102
|
+
}
|
103
|
+
int res = debVS.CheckDep(StringValuePtr(pkg_version_a), op,
|
104
|
+
StringValuePtr(pkg_version_b));
|
105
|
+
return INT2BOOL(res);
|
58
106
|
}
|
59
107
|
|
60
108
|
/*
|
@@ -65,9 +113,10 @@ VALUE check_dep(VALUE self, VALUE pkg_version_a, VALUE cmp_type, VALUE pkg_versi
|
|
65
113
|
* Debian::AptPkg.uri_to_filename('http://debian.org/index.html') # => 'debian.org_index.html'
|
66
114
|
*
|
67
115
|
**/
|
68
|
-
static
|
69
|
-
|
70
|
-
|
116
|
+
static VALUE
|
117
|
+
uri_to_filename(VALUE self, VALUE uri)
|
118
|
+
{
|
119
|
+
return rb_str_new2(URItoFileName(StringValuePtr(uri)).c_str());
|
71
120
|
}
|
72
121
|
|
73
122
|
/*
|
@@ -78,9 +127,10 @@ VALUE uri_to_filename(VALUE self, VALUE uri) {
|
|
78
127
|
* Debian::AptPkg.upstream_version('3.4.15-1+b1') # => '3.4.15'
|
79
128
|
*
|
80
129
|
**/
|
81
|
-
static
|
82
|
-
|
83
|
-
|
130
|
+
static VALUE
|
131
|
+
upstream_version(VALUE self, VALUE ver)
|
132
|
+
{
|
133
|
+
return rb_str_new2(debVS.UpstreamVersion(StringValuePtr(ver)).c_str());
|
84
134
|
}
|
85
135
|
|
86
136
|
/*
|
@@ -91,9 +141,10 @@ VALUE upstream_version(VALUE self, VALUE ver) {
|
|
91
141
|
* Debian::AptPkg.time_to_str(3601) # => '1h 0min 1s'
|
92
142
|
*
|
93
143
|
**/
|
94
|
-
static
|
95
|
-
|
96
|
-
|
144
|
+
static VALUE
|
145
|
+
time_to_str(VALUE self, VALUE secondes)
|
146
|
+
{
|
147
|
+
return rb_str_new2(TimeToStr(NUM2INT(secondes)).c_str());
|
97
148
|
}
|
98
149
|
|
99
150
|
/*
|
@@ -104,9 +155,10 @@ VALUE time_to_str(VALUE self, VALUE secondes) {
|
|
104
155
|
* Debian::AptPkg.size_to_str(10000) # => '10.0 k'
|
105
156
|
*
|
106
157
|
**/
|
107
|
-
static
|
108
|
-
|
109
|
-
|
158
|
+
static VALUE
|
159
|
+
size_to_str(VALUE self, VALUE size)
|
160
|
+
{
|
161
|
+
return rb_str_new2(SizeToStr(NUM2INT(size)).c_str());
|
110
162
|
}
|
111
163
|
|
112
164
|
/*
|
@@ -119,9 +171,10 @@ VALUE size_to_str(VALUE self, VALUE size) {
|
|
119
171
|
* Debian::AptPkg.string_to_bool('no-recognized') # => false
|
120
172
|
*
|
121
173
|
**/
|
122
|
-
static
|
123
|
-
|
124
|
-
|
174
|
+
static VALUE
|
175
|
+
string_to_bool(VALUE self, VALUE text)
|
176
|
+
{
|
177
|
+
return INT2BOOL(StringToBool(StringValuePtr(text)) == 1);
|
125
178
|
}
|
126
179
|
|
127
180
|
/*
|
@@ -132,58 +185,65 @@ VALUE string_to_bool(VALUE self, VALUE text) {
|
|
132
185
|
* Debian::AptPkg.check_domain_list("alioth.debian.org", "debian.net,debian.org") # => true
|
133
186
|
*
|
134
187
|
**/
|
135
|
-
static
|
136
|
-
|
137
|
-
|
138
|
-
|
188
|
+
static VALUE
|
189
|
+
check_domain_list(VALUE self, VALUE host, VALUE list)
|
190
|
+
{
|
191
|
+
int res = CheckDomainList(StringValuePtr(host), StringValuePtr(list));
|
192
|
+
return INT2BOOL(res);
|
139
193
|
}
|
140
194
|
|
141
195
|
void
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
196
|
+
// cppcheck-suppress unusedFunction
|
197
|
+
Init_apt_pkg()
|
198
|
+
{
|
199
|
+
VALUE rb_mDebian = rb_define_module("Debian");
|
200
|
+
VALUE rb_mDebianAptPkg = rb_define_module_under(rb_mDebian, "AptPkg");
|
201
|
+
|
202
|
+
rb_define_singleton_method(rb_mDebianAptPkg, "init",
|
203
|
+
RUBY_METHOD_FUNC(init), 0);
|
204
|
+
rb_define_singleton_method(rb_mDebianAptPkg, "init_config",
|
205
|
+
RUBY_METHOD_FUNC(init_config), 0);
|
206
|
+
rb_define_singleton_method(rb_mDebianAptPkg, "init_system",
|
207
|
+
RUBY_METHOD_FUNC(init_system), 0);
|
208
|
+
|
209
|
+
rb_define_singleton_method(rb_mDebianAptPkg, "uri_to_filename",
|
210
|
+
RUBY_METHOD_FUNC(uri_to_filename), 1);
|
211
|
+
rb_define_singleton_method(rb_mDebianAptPkg, "time_to_str",
|
212
|
+
RUBY_METHOD_FUNC(time_to_str), 1);
|
213
|
+
rb_define_singleton_method(rb_mDebianAptPkg, "size_to_str",
|
214
|
+
RUBY_METHOD_FUNC(size_to_str), 1);
|
215
|
+
rb_define_singleton_method(rb_mDebianAptPkg, "string_to_bool",
|
216
|
+
RUBY_METHOD_FUNC(string_to_bool), 1);
|
217
|
+
rb_define_singleton_method(rb_mDebianAptPkg, "check_domain_list",
|
218
|
+
RUBY_METHOD_FUNC(check_domain_list), 2);
|
219
|
+
rb_define_singleton_method(rb_mDebianAptPkg, "cmp_version",
|
220
|
+
RUBY_METHOD_FUNC(cmp_version), 2);
|
221
|
+
rb_define_singleton_method(rb_mDebianAptPkg, "check_dep",
|
222
|
+
RUBY_METHOD_FUNC(check_dep), 3);
|
223
|
+
rb_define_singleton_method(rb_mDebianAptPkg, "upstream_version",
|
224
|
+
RUBY_METHOD_FUNC(upstream_version), 1);
|
225
|
+
|
226
|
+
/* Represents less equal operator. */
|
227
|
+
rb_define_const(rb_mDebianAptPkg, "LESS_EQ", INT2FIX(pkgCache::Dep::LessEq));
|
228
|
+
/* Represents greater equal operator. */
|
229
|
+
rb_define_const(rb_mDebianAptPkg, "GREATER_EQ",
|
230
|
+
INT2FIX(pkgCache::Dep::GreaterEq));
|
231
|
+
/* Represents less operator. */
|
232
|
+
rb_define_const(rb_mDebianAptPkg, "LESS", INT2FIX(pkgCache::Dep::Less));
|
233
|
+
/* Represents greater operator. */
|
234
|
+
rb_define_const(rb_mDebianAptPkg, "GREATER", INT2FIX(pkgCache::Dep::Greater));
|
235
|
+
/* Represents equals operator. */
|
236
|
+
rb_define_const(rb_mDebianAptPkg, "EQUALS", INT2FIX(pkgCache::Dep::Equals));
|
237
|
+
/* Represents not equals operator. */
|
238
|
+
rb_define_const(rb_mDebianAptPkg, "NOT_EQUALS",
|
239
|
+
INT2FIX(pkgCache::Dep::NotEquals));
|
240
|
+
|
241
|
+
/* Represents the version of apt. */
|
242
|
+
rb_define_const(rb_mDebianAptPkg, "APT_VERSION", rb_str_new2(pkgVersion));
|
243
|
+
/* Represents the version of apt_pkg library. */
|
244
|
+
rb_define_const(rb_mDebianAptPkg, "LIBAPT_PKG_VERSION",
|
245
|
+
rb_str_new2(pkgLibVersion));
|
246
|
+
|
247
|
+
init_apt_pkg_configuration();
|
248
|
+
init_apt_pkg_pkgcache();
|
189
249
|
}
|