ruby-rpm 1.3.0 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +14 -0
- data/ext/rpm/db.c +119 -9
- data/ext/rpm/dependency.c +35 -0
- data/ext/rpm/extconf.rb +3 -3
- data/ext/rpm/file.c +86 -0
- data/ext/rpm/package.c +104 -10
- data/ext/rpm/private.h +30 -3
- data/ext/rpm/rpm.c +37 -3
- data/ext/rpm/source.c +34 -0
- data/ext/rpm/spec.c +80 -8
- data/ext/rpm/version.c +71 -0
- data/lib/rpm.rb +23 -1
- data/lib/rpm/version.rb +1 -1
- metadata +39 -19
data/ext/rpm/source.c
CHANGED
@@ -17,6 +17,16 @@ static ID id_fn;
|
|
17
17
|
static ID id_num;
|
18
18
|
static ID id_no;
|
19
19
|
|
20
|
+
/*
|
21
|
+
* Creates a new +Source+ object
|
22
|
+
* @param [String] url
|
23
|
+
* @param [Number] source number (index)
|
24
|
+
* @param [Boolean] nosource Sets the NoSource flag (default false)
|
25
|
+
*
|
26
|
+
* @example
|
27
|
+
* RPM::Source.new ('http://example.com/hoge/hoge.tar.bz2', 0)
|
28
|
+
* RPM:: Source.new ('http://example.com/fuga/fuga.tar.gz', 1, true)
|
29
|
+
*/
|
20
30
|
static VALUE
|
21
31
|
source_initialize(int argc, VALUE* argv, VALUE src)
|
22
32
|
{
|
@@ -93,12 +103,24 @@ rpm_icon_new(const char* fullname, unsigned int num, int no)
|
|
93
103
|
return src;
|
94
104
|
}
|
95
105
|
|
106
|
+
/*
|
107
|
+
* @return [String] Source's fullname
|
108
|
+
* @example
|
109
|
+
* src = RPM::Source.new('http://example.com/hoge/hoge.tar.bz2', 0)
|
110
|
+
* src.fullname => 'http://example.com/hoge/hoge.tar.bz2'
|
111
|
+
*/
|
96
112
|
VALUE
|
97
113
|
rpm_source_get_fullname(VALUE src)
|
98
114
|
{
|
99
115
|
return rb_ivar_get(src, id_full);
|
100
116
|
}
|
101
117
|
|
118
|
+
/*
|
119
|
+
* @return [String] Source's filename
|
120
|
+
* @example
|
121
|
+
* src = RPM::Source.new('http://example.com/hoge/hoge.tar.bz2', 0)
|
122
|
+
* src.filename => 'hoge.tar.bz2'
|
123
|
+
*/
|
102
124
|
VALUE
|
103
125
|
rpm_source_get_filename(VALUE src)
|
104
126
|
{
|
@@ -119,12 +141,24 @@ rpm_source_get_filename(VALUE src)
|
|
119
141
|
return fn;
|
120
142
|
}
|
121
143
|
|
144
|
+
/*
|
145
|
+
* @return [Number] Source's index
|
146
|
+
* @example
|
147
|
+
* src = RPM::Source.new ('http://example.com/hoge/hoge.tar.bz2', 0)
|
148
|
+
* src.num => 0
|
149
|
+
*/
|
122
150
|
VALUE
|
123
151
|
rpm_source_get_num(VALUE src)
|
124
152
|
{
|
125
153
|
return rb_ivar_get(src, id_num);
|
126
154
|
}
|
127
155
|
|
156
|
+
/*
|
157
|
+
* @return [Boolean] Whether the NoSource flag is set
|
158
|
+
* @example
|
159
|
+
* src = RPM::Source.new('http://example.com/hoge/hoge.tar.bz2', 0, true)
|
160
|
+
* src.no? => true
|
161
|
+
*/
|
128
162
|
VALUE
|
129
163
|
rpm_source_is_no(VALUE src)
|
130
164
|
{
|
data/ext/rpm/spec.c
CHANGED
@@ -17,6 +17,11 @@ static ID id_src;
|
|
17
17
|
static ID id_pkg;
|
18
18
|
static ID id_rest;
|
19
19
|
|
20
|
+
#if RPM_VERSION(5,0,0) <= RPM_VERSION_CODE
|
21
|
+
#define headerGetEntryMinMemory(hdr,tag,type,ptr,cnt) \
|
22
|
+
headerGetEntry(hdr,tag,type,(void**)ptr,cnt)
|
23
|
+
#endif
|
24
|
+
|
20
25
|
#if RPM_VERSION_CODE < RPM_VERSION(4,1,0)
|
21
26
|
static void
|
22
27
|
spec_free(Spec rspec)
|
@@ -33,6 +38,11 @@ ts_free(rpmts ts)
|
|
33
38
|
|
34
39
|
#endif
|
35
40
|
|
41
|
+
/*
|
42
|
+
* Create a spec file object from a spec file
|
43
|
+
* @param [String] filename Spec file path
|
44
|
+
* @return [Spec]
|
45
|
+
*/
|
36
46
|
static VALUE
|
37
47
|
spec_s_open(VALUE klass, VALUE filename)
|
38
48
|
{
|
@@ -59,7 +69,15 @@ spec_s_open(VALUE klass, VALUE filename)
|
|
59
69
|
return Data_Wrap_Struct(klass, NULL, spec_free, rspec);
|
60
70
|
#else
|
61
71
|
ts = rpmtsCreate();
|
72
|
+
#if RPM_VERSION_CODE < RPM_VERSION(4,4,8)
|
73
|
+
switch (parseSpec(ts, RSTRING_PTR(filename), "/", NULL, 0, "", NULL, 1, 1)) {
|
74
|
+
#elif RPM_VERSION_CODE < RPM_VERSION(4,5,90)
|
75
|
+
switch (parseSpec(ts, RSTRING_PTR(filename), "/", 0, "", NULL, 1, 1, 0)) {
|
76
|
+
#elif RPM_VERSION_CODE < RPM_VERSION(5,0,0)
|
62
77
|
switch (parseSpec(ts, RSTRING_PTR(filename), "/", NULL, 0, "", NULL, 1, 1)) {
|
78
|
+
#else
|
79
|
+
switch (parseSpec(ts, RSTRING_PTR(filename), "/", 0, "", NULL, 1, 1, 0)) {
|
80
|
+
#endif
|
63
81
|
case 0:
|
64
82
|
if (ts != NULL) {
|
65
83
|
break;
|
@@ -72,27 +90,46 @@ spec_s_open(VALUE klass, VALUE filename)
|
|
72
90
|
#endif
|
73
91
|
}
|
74
92
|
|
93
|
+
/*
|
94
|
+
*
|
95
|
+
* Alias for Spec#open
|
96
|
+
*/
|
75
97
|
VALUE
|
76
98
|
rpm_spec_open(const char* filename)
|
77
99
|
{
|
78
100
|
return spec_s_open(rpm_cSpec, rb_str_new2(filename));
|
79
101
|
}
|
80
102
|
|
103
|
+
/*
|
104
|
+
* @return [String] Return Build root defined in the spec file
|
105
|
+
*/
|
81
106
|
VALUE
|
82
107
|
rpm_spec_get_buildroot(VALUE spec)
|
83
108
|
{
|
84
|
-
#if RPM_VERSION_CODE
|
109
|
+
#if RPM_VERSION_CODE < RPM_VERSION(4,5,90)
|
110
|
+
if (RPM_SPEC(spec)->buildRootURL) {
|
111
|
+
return rb_str_new2(RPM_SPEC(spec)->buildRootURL);
|
112
|
+
}
|
113
|
+
#elif RPM_VERSION_CODE < RPM_VERSION(4,5,90)
|
114
|
+
if (RPM_SPEC(spec)->rootURL) {
|
115
|
+
return rb_str_new2(RPM_SPEC(spec)->rootURL);
|
116
|
+
}
|
117
|
+
#elif RPM_VERSION_CODE < RPM_VERSION(5,0,0)
|
85
118
|
if (RPM_SPEC(spec)->buildRoot) {
|
86
119
|
return rb_str_new2(RPM_SPEC(spec)->buildRoot);
|
87
120
|
}
|
88
121
|
#else
|
89
|
-
|
90
|
-
|
91
|
-
|
122
|
+
const char *buildRootURL = rpmGenPath(RPM_SPEC(spec)->rootURL, "%{?buildroot}", NULL);
|
123
|
+
VALUE result = rb_str_new2(buildRootURL);
|
124
|
+
buildRootURL = _free(buildRootURL);
|
125
|
+
return result;
|
92
126
|
#endif
|
93
127
|
return Qnil;
|
94
128
|
}
|
95
129
|
|
130
|
+
/*
|
131
|
+
* @return [String] Return Build subdirectory defined in the spec file
|
132
|
+
*/
|
96
133
|
VALUE
|
97
134
|
rpm_spec_get_buildsubdir(VALUE spec)
|
98
135
|
{
|
@@ -102,6 +139,9 @@ rpm_spec_get_buildsubdir(VALUE spec)
|
|
102
139
|
return Qnil;
|
103
140
|
}
|
104
141
|
|
142
|
+
/*
|
143
|
+
* @return [Array<String>] Return Build architectures defined in the spec file
|
144
|
+
*/
|
105
145
|
VALUE
|
106
146
|
rpm_spec_get_buildarchs(VALUE spec)
|
107
147
|
{
|
@@ -119,12 +159,15 @@ rpm_spec_get_buildarchs(VALUE spec)
|
|
119
159
|
return ba;
|
120
160
|
}
|
121
161
|
|
162
|
+
/*
|
163
|
+
* @return [Array<RPM::Require>] Return Build requires defined in the spec file
|
164
|
+
*/
|
122
165
|
VALUE
|
123
166
|
rpm_spec_get_buildrequires(VALUE spec)
|
124
167
|
{
|
125
168
|
VALUE br = rb_ivar_get(spec, id_br);
|
126
169
|
|
127
|
-
#if RPM_VERSION_CODE < RPM_VERSION(4,6,0)
|
170
|
+
#if RPM_VERSION_CODE < RPM_VERSION(4,6,0) || RPM_VERSION_CODE >= RPM_VERSION(5,0,0)
|
128
171
|
if (NIL_P(br)) {
|
129
172
|
const char** names;
|
130
173
|
const char** vers;
|
@@ -174,7 +217,7 @@ rpm_spec_get_buildrequires(VALUE spec)
|
|
174
217
|
versiontd);
|
175
218
|
get_entry(RPM_SPEC(spec)->buildRestrictions, RPMTAG_REQUIREFLAGS,
|
176
219
|
flagtd);
|
177
|
-
|
220
|
+
|
178
221
|
rpmtdInit(nametd);
|
179
222
|
while ( rpmtdNext(nametd) != -1 ) {
|
180
223
|
rb_ary_push(br, rpm_require_new(rpmtdGetString(nametd), rpm_version_new(rpmtdNextString(versiontd)), *rpmtdNextUint32(flagtd), spec));
|
@@ -191,11 +234,14 @@ rpm_spec_get_buildrequires(VALUE spec)
|
|
191
234
|
#endif
|
192
235
|
}
|
193
236
|
|
237
|
+
/*
|
238
|
+
* @return [Array<RPM::Conflict>] Return Build conflicts defined in the spec file
|
239
|
+
*/
|
194
240
|
VALUE
|
195
241
|
rpm_spec_get_buildconflicts(VALUE spec)
|
196
242
|
{
|
197
243
|
VALUE bc = rb_ivar_get(spec, id_bc);
|
198
|
-
#if RPM_VERSION_CODE < RPM_VERSION(4,6,0)
|
244
|
+
#if RPM_VERSION_CODE < RPM_VERSION(4,6,0) || RPM_VERSION_CODE >= RPM_VERSION(5,0,0)
|
199
245
|
if (NIL_P(bc)) {
|
200
246
|
const char** names;
|
201
247
|
const char** vers;
|
@@ -237,7 +283,7 @@ rpm_spec_get_buildconflicts(VALUE spec)
|
|
237
283
|
bc = rb_ary_new();
|
238
284
|
if (!headerGet(RPM_SPEC(spec)->buildRestrictions,
|
239
285
|
RPMTAG_CONFLICTNAME, nametd, HEADERGET_MINMEM)) {
|
240
|
-
|
286
|
+
|
241
287
|
goto leave;
|
242
288
|
}
|
243
289
|
|
@@ -275,6 +321,9 @@ rpm_spec_get_build_restrictions(VALUE spec)
|
|
275
321
|
return cache;
|
276
322
|
}
|
277
323
|
|
324
|
+
/*
|
325
|
+
* @return [Array<RPM::Source>] Sources defined in the spec file
|
326
|
+
*/
|
278
327
|
VALUE
|
279
328
|
rpm_spec_get_sources(VALUE spec)
|
280
329
|
{
|
@@ -305,6 +354,9 @@ rpm_spec_get_sources(VALUE spec)
|
|
305
354
|
return src;
|
306
355
|
}
|
307
356
|
|
357
|
+
/*
|
358
|
+
* @return [Array<RPM::Package>] Packages defined in the spec file
|
359
|
+
*/
|
308
360
|
VALUE
|
309
361
|
rpm_spec_get_packages(VALUE spec)
|
310
362
|
{
|
@@ -326,6 +378,16 @@ rpm_spec_get_packages(VALUE spec)
|
|
326
378
|
return pkg;
|
327
379
|
}
|
328
380
|
|
381
|
+
/*
|
382
|
+
* Builds the spec file
|
383
|
+
* @param [Number] flags bits to enable stages of build
|
384
|
+
* @param [Boolean] test When true, don't execute scripts or package
|
385
|
+
* @return [Number] exit code
|
386
|
+
*
|
387
|
+
* @example
|
388
|
+
* spec = RPM::Spec.open("foo.spec")
|
389
|
+
* spec.build(RPM::BUILD__UNTIL_BUILD)
|
390
|
+
*/
|
329
391
|
VALUE
|
330
392
|
rpm_spec_build(int argc, VALUE* argv, VALUE spec)
|
331
393
|
{
|
@@ -362,6 +424,16 @@ rpm_spec_build(int argc, VALUE* argv, VALUE spec)
|
|
362
424
|
return INT2NUM(rc);
|
363
425
|
}
|
364
426
|
|
427
|
+
/*
|
428
|
+
* Expands a macro in the spec file
|
429
|
+
* @param [String] name Name of the macro
|
430
|
+
* @return [String]
|
431
|
+
* @example
|
432
|
+
* spec.expand_macros("configure")
|
433
|
+
* => "\n CFLAGS=......."
|
434
|
+
* spec.expand_macros("_prefix")
|
435
|
+
* => "/usr"
|
436
|
+
*/
|
365
437
|
VALUE
|
366
438
|
rpm_spec_expand_macros(VALUE spec, VALUE name)
|
367
439
|
{
|
data/ext/rpm/version.c
CHANGED
@@ -83,6 +83,24 @@ version_parse(const char* str, VALUE* v, VALUE* r, VALUE* e)
|
|
83
83
|
}
|
84
84
|
}
|
85
85
|
|
86
|
+
/*
|
87
|
+
* @overload new(vr, e = nil)
|
88
|
+
* Creates a version object from a string representation
|
89
|
+
* @param [String] vr version and release in the form "v-r"
|
90
|
+
* @param [Number] e epoch
|
91
|
+
* @return [Version]
|
92
|
+
* @overload new(v, r, e = nil)
|
93
|
+
* Creates a version object from a string representation
|
94
|
+
* @param [String] v version
|
95
|
+
* @param [String] r release
|
96
|
+
* @param [Number] e epoch
|
97
|
+
* @return [Version]
|
98
|
+
* @example
|
99
|
+
* RPM:: Version.new "1.0.0-3"
|
100
|
+
* RPM:: Version.new "1.04"
|
101
|
+
* RPM:: Version.new "1.0.0-3k", 1
|
102
|
+
* RPM:: Version.new "2.0.3", "5k"
|
103
|
+
*/
|
86
104
|
static VALUE
|
87
105
|
version_initialize(int argc, VALUE* argv, VALUE ver)
|
88
106
|
{
|
@@ -184,6 +202,18 @@ rpm_version_new3(const char* v, const char* r, int e)
|
|
184
202
|
return ver;
|
185
203
|
}
|
186
204
|
|
205
|
+
/*
|
206
|
+
* Comparison between versions
|
207
|
+
* @param [Version] other
|
208
|
+
* @return [Number] -1 if +other+ is greater than, 0 if +other+ is equal to,
|
209
|
+
* and +1 if other is less than version.
|
210
|
+
*
|
211
|
+
* @example
|
212
|
+
* v1 = RPM::Version.new("3.0-0",1)
|
213
|
+
* v2 = RPM::Version.new("3.1-0",1)
|
214
|
+
* v1 <=> v2
|
215
|
+
* => -1
|
216
|
+
*/
|
187
217
|
VALUE
|
188
218
|
rpm_version_cmp(VALUE ver, VALUE other)
|
189
219
|
{
|
@@ -233,36 +263,63 @@ rpm_version_cmp(VALUE ver, VALUE other)
|
|
233
263
|
return INT2FIX(sense);
|
234
264
|
}
|
235
265
|
|
266
|
+
/*
|
267
|
+
* @param [Version] other Version to compare against
|
268
|
+
* @return [Boolean] true if the version is newer than +other+
|
269
|
+
*/
|
236
270
|
VALUE
|
237
271
|
rpm_version_is_newer(VALUE ver, VALUE other)
|
238
272
|
{
|
239
273
|
return (NUM2INT(rpm_version_cmp(ver, other)) > 0) ? Qtrue : Qfalse;
|
240
274
|
}
|
241
275
|
|
276
|
+
/*
|
277
|
+
* @param [Version] other Version to compare against
|
278
|
+
* @return [Boolean] true if the version is older than +other+
|
279
|
+
*/
|
242
280
|
VALUE
|
243
281
|
rpm_version_is_older(VALUE ver, VALUE other)
|
244
282
|
{
|
245
283
|
return rpm_version_is_newer(ver, other) ? Qfalse : Qtrue;
|
246
284
|
}
|
247
285
|
|
286
|
+
/*
|
287
|
+
* Access the version component
|
288
|
+
* @return [String] version component
|
289
|
+
*/
|
248
290
|
VALUE
|
249
291
|
rpm_version_get_v(VALUE ver)
|
250
292
|
{
|
251
293
|
return rb_ivar_get(ver, id_v);
|
252
294
|
}
|
253
295
|
|
296
|
+
/*
|
297
|
+
* Access the release component
|
298
|
+
* @return [String] release component or nil if the
|
299
|
+
* version does not have a release component
|
300
|
+
*/
|
254
301
|
VALUE
|
255
302
|
rpm_version_get_r(VALUE ver)
|
256
303
|
{
|
257
304
|
return rb_ivar_get(ver, id_r);
|
258
305
|
}
|
259
306
|
|
307
|
+
/*
|
308
|
+
* Access the epoch component
|
309
|
+
* @return [Number] epoch component or nil if the
|
310
|
+
* version does not have an epoch component
|
311
|
+
*/
|
260
312
|
VALUE
|
261
313
|
rpm_version_get_e(VALUE ver)
|
262
314
|
{
|
263
315
|
return rb_ivar_get(ver, id_e);
|
264
316
|
}
|
265
317
|
|
318
|
+
/*
|
319
|
+
* String representation in the form "v-r"
|
320
|
+
* @return [String]
|
321
|
+
* @note The epoch is not included
|
322
|
+
*/
|
266
323
|
VALUE
|
267
324
|
rpm_version_to_s(VALUE ver)
|
268
325
|
{
|
@@ -279,6 +336,11 @@ rpm_version_to_s(VALUE ver)
|
|
279
336
|
return rb_str_new2(buf);
|
280
337
|
}
|
281
338
|
|
339
|
+
/*
|
340
|
+
* String representation in the form "e:v-r"
|
341
|
+
* @return [String]
|
342
|
+
* @note The epoch is included
|
343
|
+
*/
|
282
344
|
VALUE
|
283
345
|
rpm_version_to_vre(VALUE ver)
|
284
346
|
{
|
@@ -300,6 +362,10 @@ rpm_version_to_vre(VALUE ver)
|
|
300
362
|
return rb_str_new2(buf);
|
301
363
|
}
|
302
364
|
|
365
|
+
/*
|
366
|
+
* Inspect the version object
|
367
|
+
* @return [String] object in the form "#<RPM::Version v=V, r=R, e=E>"
|
368
|
+
*/
|
303
369
|
VALUE
|
304
370
|
rpm_version_inspect(VALUE ver)
|
305
371
|
{
|
@@ -318,6 +384,11 @@ rpm_version_inspect(VALUE ver)
|
|
318
384
|
return rb_str_new2(buf);
|
319
385
|
}
|
320
386
|
|
387
|
+
/*
|
388
|
+
* Hash based on the version content
|
389
|
+
* @return [String]
|
390
|
+
*/
|
391
|
+
|
321
392
|
VALUE
|
322
393
|
rpm_version_hash(VALUE ver)
|
323
394
|
{
|
data/lib/rpm.rb
CHANGED
@@ -5,12 +5,34 @@
|
|
5
5
|
|
6
6
|
### $Id: rpm.rb 22 2004-03-29 03:42:35Z zaki $
|
7
7
|
|
8
|
+
require 'rbconfig'
|
8
9
|
# native
|
9
|
-
require
|
10
|
+
require "rpm.#{RbConfig::CONFIG['DLEXT']}"
|
10
11
|
require 'rpm/version'
|
11
12
|
|
12
13
|
module RPM
|
13
14
|
|
15
|
+
# @attr [Number] type Type of event
|
16
|
+
# @attr [Number] key Key transactions
|
17
|
+
# @attr [Package] package Package being processed
|
18
|
+
# @attr [Number] amount Progress
|
19
|
+
# @attr [Number] total Total size
|
20
|
+
class CallbackData
|
21
|
+
end
|
22
|
+
|
23
|
+
# @attr [Number] type Type of event
|
24
|
+
# @attr [Number] key Key in the transaction
|
25
|
+
# @attr [Package] package Package being processed
|
26
|
+
# @attr [Description] Description of the problem
|
27
|
+
class Problem
|
28
|
+
end
|
29
|
+
|
30
|
+
# @attr [Time] time Timestamp of the changelog entry
|
31
|
+
# @attr [String] name Name of the changelog entry
|
32
|
+
# @attr [Text] text description of the changelog entry
|
33
|
+
class Changelog
|
34
|
+
end
|
35
|
+
|
14
36
|
def vercmp(ver1, ver2)
|
15
37
|
unless String === ver1 and String === ver2 then
|
16
38
|
raise TypeError, 'illegal argument type'
|
data/lib/rpm/version.rb
CHANGED