apt-pkg 0.0.4 → 0.5.0

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
- SHA1:
3
- metadata.gz: 746f8355732d3706f08ed9a0448074b5cc809650
4
- data.tar.gz: 4e790f19af21ca58fb505e253b0063a9f37a403c
2
+ SHA256:
3
+ metadata.gz: 16cd206a5d9b3137497d05f937ef5b78fcac7aa6bd62e4177b73ef98ff0d917e
4
+ data.tar.gz: b0bcc23a93c8112321c890487ee385c7cede6da1b3179da4e5f0ebf11b723161
5
5
  SHA512:
6
- metadata.gz: 0847ba542a425cf905fc8b1f9878e61d95567ad5edc8701d787b7aeb6890a8907f31a535b7159b43443b79a22c29f0d69ce7df77baec6801318ce42550acfa0e
7
- data.tar.gz: c78871b2f29b15180af494de3d6b822c257da1dca3fb3a43af0e6890219ce10e6e44a8ab33658bd4932688241897d6f36e8992da3b672e8365d70470601ca35c
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-2015 Laurent Arnoud <laurent@spkdev.net>
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://apt.alioth.debian.org/python-apt-doc/library/apt_pkg.html).
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
- ~~~ console
11
- aptitude install build-essential ruby-dev libapt-pkg-dev (~> 1.0)
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
- Simple search is implemented with:
17
+ Basic usage:
18
18
 
19
- ~~~ ruby
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
- [Documentation](https://spk.github.io/ruby-apt-pkg/)
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
- ~~~ console
29
- gem install bundler
30
- bundle install
31
- bundle exec rake compile
32
- ~~~
42
+ ``` console
43
+ rake compile
44
+ ```
33
45
 
34
46
  ## TEST
35
47
 
36
- ~~~ console
37
- bundle exec rake test
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-2015 Laurent Arnoud <laurent@spkdev.net>
56
+ Copyright (c) 2014-2020 Laurent Arnoud <laurent@spkdev.net>
45
57
 
46
58
  ---
47
- [![Gem Version](https://badge.fury.io/rb/apt-pkg.svg)](https://rubygems.org/gems/apt-pkg)
48
- [![Build Status](https://secure.travis-ci.org/spk/ruby-apt-pkg.svg?branch=master)](https://travis-ci.org/spk/ruby-apt-pkg)
49
- [![License](https://img.shields.io/github/license/spk/ruby-apt-pkg.svg)](http://opensource.org/licenses/MIT "MIT")
50
- [![IRC Network](https://img.shields.io/badge/irc-oftc-blue.svg)](https://webchat.oftc.net/ "#ruby-apt-pkg")
59
+ [![Build](https://img.shields.io/travis/spk/ruby-apt-pkg.svg)](https://travis-ci.org/spk/ruby-apt-pkg)
60
+ [![Version](https://img.shields.io/gem/v/apt-pkg.svg)](https://rubygems.org/gems/apt-pkg)
61
+ [![Documentation](https://img.shields.io/badge/doc-rubydoc-blue.svg)](http://www.rubydoc.info/gems/apt-pkg)
62
+ [![License](https://img.shields.io/badge/license-MIT-blue.svg)](http://opensource.org/licenses/MIT "MIT")
63
+ [![Project status](https://img.shields.io/badge/status-experimental-red)](https://github.com/spk/ruby-apt-pkg)
@@ -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
- VALUE cmp_version(VALUE self, VALUE pkg_version_a, VALUE pkg_version_b) {
20
- int res = debVS.CmpVersion(StringValuePtr(pkg_version_a),
21
- StringValuePtr(pkg_version_b));
22
- return INT2FIX(res);
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
- VALUE check_dep(VALUE self, VALUE pkg_version_a, VALUE cmp_type, VALUE pkg_version_b) {
42
- unsigned int op = 0;
43
- if (TYPE(cmp_type) == T_FIXNUM) {
44
- op = NUM2INT(cmp_type);
45
- } else {
46
- const char *op_str = StringValuePtr(cmp_type);
47
- if (strcmp(op_str, ">") == 0) op_str = ">>";
48
- if (strcmp(op_str, "<") == 0) op_str = "<<";
49
- if (*debListParser::ConvertRelation(op_str, op) != 0)
50
- {
51
- rb_raise(rb_eArgError, "Bad comparison operation");
52
- return 0;
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
- int res = debVS.CheckDep(StringValuePtr(pkg_version_a), op,
56
- StringValuePtr(pkg_version_b));
57
- return INT2BOOL(res);
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
- VALUE uri_to_filename(VALUE self, VALUE uri) {
70
- return rb_str_new2(URItoFileName(StringValuePtr(uri)).c_str());
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
- VALUE upstream_version(VALUE self, VALUE ver) {
83
- return rb_str_new2(debVS.UpstreamVersion(StringValuePtr(ver)).c_str());
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
- VALUE time_to_str(VALUE self, VALUE secondes) {
96
- return rb_str_new2(TimeToStr(NUM2INT(secondes)).c_str());
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
- VALUE size_to_str(VALUE self, VALUE size) {
109
- return rb_str_new2(SizeToStr(NUM2INT(size)).c_str());
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
- VALUE string_to_bool(VALUE self, VALUE text) {
124
- return INT2BOOL(StringToBool(StringValuePtr(text)) == 1);
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
- VALUE check_domain_list(VALUE self, VALUE host, VALUE list) {
137
- int res = CheckDomainList(StringValuePtr(host), StringValuePtr(list));
138
- return INT2BOOL(res);
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
- Init_apt_pkg() {
143
- pkgInitConfig(*_config);
144
- pkgInitSystem(*_config, _system);
145
-
146
- /* Base module */
147
- VALUE rb_mDebian = rb_define_module("Debian");
148
- VALUE rb_mDebianAptPkg = rb_define_module_under(rb_mDebian, "AptPkg");
149
- VALUE rb_mDebianAptPkgConfiguration
150
- = rb_define_module_under(rb_mDebianAptPkg, "Configuration");
151
-
152
- rb_define_singleton_method(rb_mDebianAptPkg, "uri_to_filename",
153
- RUBY_METHOD_FUNC(uri_to_filename), 1);
154
- rb_define_singleton_method(rb_mDebianAptPkg, "time_to_str",
155
- RUBY_METHOD_FUNC(time_to_str), 1);
156
- rb_define_singleton_method(rb_mDebianAptPkg, "size_to_str",
157
- RUBY_METHOD_FUNC(size_to_str), 1);
158
- rb_define_singleton_method(rb_mDebianAptPkg, "string_to_bool",
159
- RUBY_METHOD_FUNC(string_to_bool), 1);
160
- rb_define_singleton_method(rb_mDebianAptPkg, "check_domain_list",
161
- RUBY_METHOD_FUNC(check_domain_list), 2);
162
- rb_define_singleton_method(rb_mDebianAptPkg, "cmp_version",
163
- RUBY_METHOD_FUNC(cmp_version), 2);
164
- rb_define_singleton_method(rb_mDebianAptPkg, "check_dep",
165
- RUBY_METHOD_FUNC(check_dep), 3);
166
- rb_define_singleton_method(rb_mDebianAptPkg, "upstream_version",
167
- RUBY_METHOD_FUNC(upstream_version), 1);
168
-
169
- /* Represents less equal operator. */
170
- rb_define_const(rb_mDebianAptPkg, "LESS_EQ", INT2FIX(pkgCache::Dep::LessEq));
171
- /* Represents greater equal operator. */
172
- rb_define_const(rb_mDebianAptPkg, "GREATER_EQ", INT2FIX(pkgCache::Dep::GreaterEq));
173
- /* Represents less operator. */
174
- rb_define_const(rb_mDebianAptPkg, "LESS", INT2FIX(pkgCache::Dep::Less));
175
- /* Represents greater operator. */
176
- rb_define_const(rb_mDebianAptPkg, "GREATER", INT2FIX(pkgCache::Dep::Greater));
177
- /* Represents equals operator. */
178
- rb_define_const(rb_mDebianAptPkg, "EQUALS", INT2FIX(pkgCache::Dep::Equals));
179
- /* Represents not equals operator. */
180
- rb_define_const(rb_mDebianAptPkg, "NOT_EQUALS", INT2FIX(pkgCache::Dep::NotEquals));
181
-
182
- /* Represents the version of apt. */
183
- rb_define_const(rb_mDebianAptPkg, "VERSION", rb_str_new2(pkgVersion));
184
- /* Represents the version of apt_pkg library. */
185
- rb_define_const(rb_mDebianAptPkg, "LIB_VERSION", rb_str_new2(pkgLibVersion));
186
-
187
- init_apt_pkg_configuration();
188
- init_apt_pkg_pkgcache();
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
  }