ruby-rpm 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,330 @@
1
+ /* -*- mode: C; c-basic-offset: 4; tab-width: 4; -*- */
2
+ /* Ruby/RPM
3
+ *
4
+ * Copyright (C) 2002 Kenta MURATA <muraken2@nifty.com>.
5
+ */
6
+
7
+ /* $Id: dependency.c 42 2004-06-03 14:26:37Z kazuhiko $ */
8
+
9
+ #include "private.h"
10
+
11
+ VALUE rpm_cDependency;
12
+ VALUE rpm_cProvide;
13
+ VALUE rpm_cRequire;
14
+ VALUE rpm_cConflict;
15
+ VALUE rpm_cObsolete;
16
+
17
+ static ID id_name;
18
+ static ID id_ver;
19
+ static ID id_flags;
20
+ static ID id_owner;
21
+
22
+ static ID id_nametag;
23
+ static ID id_versiontag;
24
+ static ID id_flagstag;
25
+
26
+ static VALUE
27
+ dependency_initialize(VALUE dep, VALUE name, VALUE version,
28
+ VALUE flags, VALUE owner)
29
+ {
30
+ if (TYPE(name) != T_STRING
31
+ || (!NIL_P(version) && rb_obj_is_kind_of(version, rpm_cVersion) == Qfalse)) {
32
+ rb_raise(rb_eTypeError, "illegal argument type");
33
+ }
34
+
35
+ rb_ivar_set(dep, id_name, name);
36
+ rb_ivar_set(dep, id_ver, version);
37
+ rb_ivar_set(dep, id_flags, rb_Integer(flags));
38
+ rb_ivar_set(dep, id_owner, owner);
39
+ return dep;
40
+ }
41
+
42
+ static VALUE
43
+ provide_initialize(VALUE dep, VALUE name, VALUE version,
44
+ VALUE flags, VALUE owner)
45
+ {
46
+ dependency_initialize(dep,name,version,flags,owner);
47
+ rb_ivar_set(dep, id_nametag, INT2NUM(RPMTAG_PROVIDENAME));
48
+ rb_ivar_set(dep, id_versiontag, INT2NUM(RPMTAG_PROVIDEVERSION));
49
+ rb_ivar_set(dep, id_flagstag, INT2NUM(RPMTAG_PROVIDEFLAGS));
50
+ return dep;
51
+ }
52
+
53
+ static VALUE
54
+ require_initialize(VALUE dep, VALUE name, VALUE version,
55
+ VALUE flags, VALUE owner)
56
+ {
57
+ dependency_initialize(dep,name,version,flags,owner);
58
+ rb_ivar_set(dep, id_nametag, INT2NUM(RPMTAG_REQUIRENAME));
59
+ rb_ivar_set(dep, id_versiontag, INT2NUM(RPMTAG_REQUIREVERSION));
60
+ rb_ivar_set(dep, id_flagstag, INT2NUM(RPMTAG_REQUIREFLAGS));
61
+ return dep;
62
+ }
63
+
64
+ static VALUE
65
+ obsolete_initialize(VALUE dep, VALUE name, VALUE version,
66
+ VALUE flags, VALUE owner)
67
+ {
68
+ dependency_initialize(dep,name,version,flags,owner);
69
+ rb_ivar_set(dep, id_nametag, INT2NUM(RPMTAG_OBSOLETENAME));
70
+ rb_ivar_set(dep, id_versiontag, INT2NUM(RPMTAG_OBSOLETEVERSION));
71
+ rb_ivar_set(dep, id_flagstag, INT2NUM(RPMTAG_OBSOLETEFLAGS));
72
+ return dep;
73
+ }
74
+
75
+ static VALUE
76
+ conflict_initialize(VALUE dep, VALUE name, VALUE version,
77
+ VALUE flags, VALUE owner)
78
+ {
79
+ dependency_initialize(dep,name,version,flags,owner);
80
+ rb_ivar_set(dep, id_nametag, INT2NUM(RPMTAG_CONFLICTNAME));
81
+ rb_ivar_set(dep, id_versiontag, INT2NUM(RPMTAG_CONFLICTVERSION));
82
+ rb_ivar_set(dep, id_flagstag, INT2NUM(RPMTAG_CONFLICTFLAGS));
83
+ return dep;
84
+ }
85
+
86
+ VALUE
87
+ rpm_provide_new(const char* name, VALUE version, int flags, VALUE target)
88
+ {
89
+ VALUE prov, argv[4];
90
+
91
+ argv[0] = rb_str_new2(name);
92
+ argv[1] = version;
93
+ argv[2] = INT2NUM(flags);
94
+ argv[3] = target;
95
+
96
+ prov = rb_newobj();
97
+ OBJSETUP(prov, rpm_cProvide, T_OBJECT);
98
+ rb_obj_call_init(prov, 4, argv);
99
+ rb_ivar_set(prov, id_nametag, INT2NUM(RPMTAG_PROVIDENAME));
100
+ rb_ivar_set(prov, id_versiontag, INT2NUM(RPMTAG_PROVIDEVERSION));
101
+ rb_ivar_set(prov, id_flagstag, INT2NUM(RPMTAG_PROVIDEFLAGS));
102
+ return prov;
103
+ }
104
+
105
+ VALUE
106
+ rpm_require_new(const char* name, VALUE version, int flags, VALUE target)
107
+ {
108
+ VALUE req, argv[4];
109
+
110
+ argv[0] = rb_str_new2(name);
111
+ argv[1] = version;
112
+ argv[2] = INT2NUM(flags);
113
+ argv[3] = target;
114
+
115
+ req = rb_newobj();
116
+ OBJSETUP(req, rpm_cRequire, T_OBJECT);
117
+ rb_obj_call_init(req, 4, argv);
118
+ rb_ivar_set(req, id_nametag, INT2NUM(RPMTAG_REQUIRENAME));
119
+ rb_ivar_set(req, id_versiontag, INT2NUM(RPMTAG_REQUIREVERSION));
120
+ rb_ivar_set(req, id_flagstag, INT2NUM(RPMTAG_REQUIREFLAGS));
121
+ return req;
122
+ }
123
+
124
+ VALUE
125
+ rpm_conflict_new(const char* name, VALUE version, int flags, VALUE target)
126
+ {
127
+ VALUE conf, argv[4];
128
+
129
+ argv[0] = rb_str_new2(name);
130
+ argv[1] = version;
131
+ argv[2] = INT2NUM(flags);
132
+ argv[3] = target;
133
+
134
+ conf = rb_newobj();
135
+ OBJSETUP(conf, rpm_cConflict, T_OBJECT);
136
+ rb_obj_call_init(conf, 4, argv);
137
+ rb_ivar_set(conf, id_nametag, INT2NUM(RPMTAG_CONFLICTNAME));
138
+ rb_ivar_set(conf, id_versiontag, INT2NUM(RPMTAG_CONFLICTVERSION));
139
+ rb_ivar_set(conf, id_flagstag, INT2NUM(RPMTAG_CONFLICTFLAGS));
140
+ return conf;
141
+ }
142
+
143
+ VALUE
144
+ rpm_obsolete_new(const char* name, VALUE version, int flags, VALUE target)
145
+ {
146
+ VALUE obso, argv[4];
147
+
148
+ argv[0] = rb_str_new2(name);
149
+ argv[1] = version;
150
+ argv[2] = INT2NUM(flags);
151
+ argv[3] = target;
152
+
153
+ obso = rb_newobj();
154
+ OBJSETUP(obso, rpm_cObsolete, T_OBJECT);
155
+ rb_obj_call_init(obso, 4, argv);
156
+ rb_ivar_set(obso, id_nametag, INT2NUM(RPMTAG_OBSOLETENAME));
157
+ rb_ivar_set(obso, id_versiontag, INT2NUM(RPMTAG_OBSOLETEVERSION));
158
+ rb_ivar_set(obso, id_flagstag, INT2NUM(RPMTAG_OBSOLETEFLAGS));
159
+ return obso;
160
+ }
161
+
162
+ VALUE
163
+ rpm_dependency_is_satisfy(VALUE dep,VALUE other)
164
+ {
165
+ int oflag;
166
+ int sflag;
167
+ char *svre;
168
+ char *ovre;
169
+ char *name;
170
+ char *oname;
171
+ if (rb_obj_is_kind_of(other,rpm_cPackage) == Qtrue){
172
+ VALUE provide;
173
+ VALUE provides = rpm_package_get_provides(other);
174
+ while (!NIL_P(provide = rb_ary_pop(provides))){
175
+ if (rpm_dependency_is_satisfy(dep,provide) == Qtrue) {
176
+ return Qtrue;
177
+ }
178
+ }
179
+ return Qfalse;
180
+ }
181
+
182
+ name = RSTRING(rb_ivar_get(dep,id_name))->ptr;
183
+ svre = RSTRING(rpm_version_to_vre(rb_ivar_get(dep,id_ver)))->ptr;
184
+ sflag = NUM2INT(rb_ivar_get(dep, id_flags));
185
+
186
+ if (rb_obj_is_kind_of(other,rpm_cDependency) == Qtrue){
187
+ oflag = NUM2INT(rb_ivar_get(other, id_flags));
188
+ oname = RSTRING(rb_ivar_get(other, id_name))->ptr;
189
+ ovre = RSTRING(rpm_version_to_vre(rb_ivar_get(other,id_ver)))->ptr;
190
+ other = rb_ivar_get(other,id_ver);
191
+ } else if (rb_obj_is_kind_of(other,rpm_cVersion) == Qtrue){
192
+ ovre = RSTRING(rpm_version_to_vre(other))->ptr;
193
+ oname = name;
194
+ if (!*ovre)
195
+ oflag = 0;
196
+ else
197
+ oflag = RPMSENSE_EQUAL;
198
+ } else {
199
+ rb_raise(rb_eTypeError, "illegal argument type");
200
+ }
201
+
202
+ #if RPM_VERSION_CODE < RPM_VERSION(4,1,0)
203
+ if (rpmRangesOverlap(name,ovre,oflag, sname,svre,sflag))
204
+ #else
205
+ if (rpmdsCompare(rpmdsSingle(RPMTAG_PROVIDENAME, oname, ovre, oflag),
206
+ rpmdsSingle(RPMTAG_PROVIDENAME, name, svre, sflag)))
207
+ #endif
208
+ return Qtrue;
209
+ return Qfalse;
210
+ }
211
+
212
+ VALUE
213
+ rpm_dependency_get_name(VALUE dep)
214
+ {
215
+ return rb_ivar_get(dep, id_name);
216
+ }
217
+
218
+ VALUE
219
+ rpm_dependency_get_version(VALUE dep)
220
+ {
221
+ return rb_ivar_get(dep, id_ver);
222
+ }
223
+
224
+ VALUE
225
+ rpm_dependency_get_flags(VALUE dep)
226
+ {
227
+ return rb_ivar_get(dep, id_flags);
228
+ }
229
+
230
+ VALUE
231
+ rpm_dependency_get_owner(VALUE dep)
232
+ {
233
+ return rb_ivar_get(dep, id_owner);
234
+ }
235
+
236
+ VALUE
237
+ rpm_dependency_get_nametag(VALUE dep)
238
+ {
239
+ return rb_ivar_get(dep, id_nametag);
240
+ }
241
+
242
+ VALUE
243
+ rpm_dependency_get_versiontag(VALUE dep)
244
+ {
245
+ return rb_ivar_get(dep, id_versiontag);
246
+ }
247
+
248
+ VALUE
249
+ rpm_dependency_get_flagstag(VALUE dep)
250
+ {
251
+ return rb_ivar_get(dep, id_flagstag);
252
+ }
253
+
254
+ VALUE
255
+ rpm_dependency_is_lt(VALUE dep)
256
+ {
257
+ return (NUM2INT(rb_ivar_get(dep, id_flags)) & RPMSENSE_LESS) ? Qtrue : Qfalse;
258
+ }
259
+
260
+ VALUE
261
+ rpm_dependency_is_gt(VALUE dep)
262
+ {
263
+ return (NUM2INT(rb_ivar_get(dep, id_flags)) & RPMSENSE_GREATER) ? Qtrue : Qfalse;
264
+ }
265
+
266
+ VALUE
267
+ rpm_dependency_is_eq(VALUE dep)
268
+ {
269
+ return (NUM2INT(rb_ivar_get(dep, id_flags)) & RPMSENSE_EQUAL) ? Qtrue : Qfalse;
270
+ }
271
+
272
+ VALUE
273
+ rpm_dependency_is_le(VALUE dep)
274
+ {
275
+ int flags = NUM2INT(rb_ivar_get(dep, id_flags));
276
+ return ((flags & RPMSENSE_LESS) && (flags & RPMSENSE_EQUAL)) ? Qtrue : Qfalse;
277
+ }
278
+
279
+ VALUE
280
+ rpm_dependency_is_ge(VALUE dep)
281
+ {
282
+ int flags = NUM2INT(rb_ivar_get(dep, id_flags));
283
+ return ((flags & RPMSENSE_GREATER) && (flags & RPMSENSE_EQUAL)) ? Qtrue : Qfalse;
284
+ }
285
+
286
+ VALUE
287
+ rpm_require_is_pre(VALUE req)
288
+ {
289
+ return (NUM2INT(rb_ivar_get(req, id_flags)) & RPMSENSE_PREREQ) ? Qtrue : Qfalse;
290
+ }
291
+
292
+ void
293
+ Init_rpm_dependency(void)
294
+ {
295
+ rpm_cDependency = rb_define_class_under(rpm_mRPM, "Dependency", rb_cObject);
296
+ rb_define_method(rpm_cDependency, "initialize", dependency_initialize, 4);
297
+ rb_define_method(rpm_cDependency, "name", rpm_dependency_get_name, 0);
298
+ rb_define_method(rpm_cDependency, "version", rpm_dependency_get_version, 0);
299
+ rb_define_method(rpm_cDependency, "flags", rpm_dependency_get_flags, 0);
300
+ rb_define_method(rpm_cDependency, "owner", rpm_dependency_get_owner, 0);
301
+ rb_define_method(rpm_cDependency, "lt?", rpm_dependency_is_lt, 0);
302
+ rb_define_method(rpm_cDependency, "gt?", rpm_dependency_is_gt, 0);
303
+ rb_define_method(rpm_cDependency, "eq?", rpm_dependency_is_eq, 0);
304
+ rb_define_method(rpm_cDependency, "le?", rpm_dependency_is_le, 0);
305
+ rb_define_method(rpm_cDependency, "ge?", rpm_dependency_is_ge, 0);
306
+ rb_define_method(rpm_cDependency, "satisfy?", rpm_dependency_is_satisfy, 1);
307
+ rb_define_method(rpm_cDependency, "nametag", rpm_dependency_get_nametag, 0);
308
+ rb_define_method(rpm_cDependency, "versiontag", rpm_dependency_get_versiontag, 0);
309
+ rb_define_method(rpm_cDependency, "flagstag", rpm_dependency_get_flagstag, 0);
310
+
311
+ rpm_cProvide = rb_define_class_under(rpm_mRPM, "Provide", rpm_cDependency);
312
+ rb_define_method(rpm_cProvide, "initialize", provide_initialize, 4);
313
+ rpm_cRequire = rb_define_class_under(rpm_mRPM, "Require", rpm_cDependency);
314
+ rb_define_method(rpm_cRequire, "initialize", require_initialize, 4);
315
+ rpm_cConflict = rb_define_class_under(rpm_mRPM, "Conflict", rpm_cDependency);
316
+ rb_define_method(rpm_cConflict, "initialize", conflict_initialize, 4);
317
+ rpm_cObsolete = rb_define_class_under(rpm_mRPM, "Obsolete", rpm_cDependency);
318
+ rb_define_method(rpm_cObsolete, "initialize", obsolete_initialize, 4);
319
+
320
+ rb_define_method(rpm_cRequire, "pre?", rpm_require_is_pre, 0);
321
+
322
+ id_name = rb_intern("name");
323
+ id_ver = rb_intern("version");
324
+ id_flags = rb_intern("flags");
325
+ id_owner = rb_intern("owner");
326
+
327
+ id_nametag = rb_intern("nametag");
328
+ id_versiontag = rb_intern("versiontag");
329
+ id_flagstag = rb_intern("flagstag");
330
+ }
@@ -0,0 +1,78 @@
1
+ ### -*- mode: ruby; indent-tabs-mode: nil; -*-
2
+ ### Ruby/RPM
3
+ ###
4
+ ### Copyright (C) 2002 Kenta MURATA <muraken2@nifty.com>.
5
+
6
+ ### $Id: extconf.rb 19 2004-03-28 10:01:23Z zaki $
7
+
8
+ require 'mkmf'
9
+
10
+ dir_config('popt')
11
+ dir_config("rpm", "/usr/include/rpm", "/usr/lib")
12
+
13
+ def check_popt
14
+ if have_header('popt.h') and have_library('popt') then
15
+ true
16
+ else
17
+ STDERR.puts "libpopt not found"
18
+ false
19
+ end
20
+ end
21
+
22
+ def check_db
23
+ dir_config('db')
24
+ if have_library("db-4.2","db_version")
25
+ return true
26
+ end
27
+ 4.downto(2) do |i|
28
+ if have_library("db-#{i}.0", "db_version") or
29
+ have_library("db#{i}", "db_version") then
30
+ return true
31
+ end
32
+ end
33
+ if have_library("db", "db_version") then
34
+ true
35
+ else
36
+ STDERR.puts "db not found"
37
+ end
38
+ end
39
+
40
+ def check_rpm
41
+ return false unless check_db
42
+ $libs = append_library($libs, 'rpmdb')
43
+ $libs = append_library($libs, 'rpm')
44
+ if have_header('rpmlib.h') and
45
+ have_library('rpmio') and
46
+ have_library('rpmbuild', 'getBuildTime') then
47
+ true
48
+ else
49
+ STDERR.puts "rpm library not found"
50
+ false
51
+ end
52
+ end
53
+
54
+ def check_rpm_version
55
+ version_string=`LANG=C rpm --version| cut -d' ' -f 3`
56
+ ver=version_string.split(/\./)
57
+ # TODO: zaki: strict checking is requires
58
+ $CFLAGS="#{$CFLAGS} -DRPM_VERSION_CODE=#{(ver[0].to_i<<16) + (ver[1].to_i<<8) + (ver[2].to_i<<0)}"
59
+ end
60
+
61
+ def check_debug
62
+ if ENV["RUBYRPM_DEBUG"] then
63
+ puts "debug mode\n"
64
+ $CFLAGS="#{$CFLAGS} -O0 -g -ggdb"
65
+ else
66
+ puts "non-debug mode\n"
67
+ end
68
+ end
69
+
70
+ exit unless check_popt
71
+ exit unless check_rpm
72
+ exit unless check_rpm_version
73
+
74
+ check_debug
75
+
76
+ system 'gcc -MM *.c >depend 2>/dev/null'
77
+
78
+ create_makefile('rpmmodule')
@@ -0,0 +1,281 @@
1
+ /* -*- mode: C; c-basic-offset: 4; tab-width: 4; -*- */
2
+ /* Ruby/RPM
3
+ *
4
+ * Copyright (C) 2002 Kenta MURATA <muraken2@nifty.com>.
5
+ */
6
+
7
+ /* $Id: file.c 9 2004-03-13 14:19:20Z zaki $ */
8
+
9
+ #include "private.h"
10
+
11
+ VALUE rpm_cFile;
12
+
13
+ static ID id_path;
14
+ static ID id_md5sum;
15
+ static ID id_link_to;
16
+ static ID id_size;
17
+ static ID id_mtime;
18
+ static ID id_owner;
19
+ static ID id_group;
20
+ static ID id_rdev;
21
+ static ID id_mode;
22
+ static ID id_attr;
23
+ static ID id_state;
24
+
25
+ static VALUE
26
+ file_initialize(VALUE file, VALUE path, VALUE md5sum, VALUE link_to,
27
+ VALUE size, VALUE mtime, VALUE owner, VALUE group,
28
+ VALUE rdev, VALUE mode, VALUE attr, VALUE state)
29
+ {
30
+ if (TYPE(path) != T_STRING
31
+ || TYPE(md5sum) != T_STRING
32
+ || (!NIL_P(link_to) && TYPE(link_to) != T_STRING)
33
+ || (!NIL_P(owner) && TYPE(owner) != T_STRING)
34
+ || (!NIL_P(group) && TYPE(group) != T_STRING)) {
35
+ rb_raise(rb_eTypeError, "illegal argument type");
36
+ }
37
+ rb_ivar_set(file, id_path, path);
38
+ rb_ivar_set(file, id_md5sum, md5sum);
39
+ rb_ivar_set(file, id_link_to, (!NIL_P(link_to) && RSTRING(link_to)->len) ? link_to : Qnil);
40
+ rb_ivar_set(file, id_size, rb_Integer(size));
41
+ if (rb_obj_is_kind_of(mtime, rb_cTime) == Qfalse) {
42
+ mtime = rb_time_new(NUM2INT(rb_Integer(mtime)), (time_t)0);
43
+ }
44
+ rb_ivar_set(file, id_mtime, mtime);
45
+ rb_ivar_set(file, id_owner, owner);
46
+ rb_ivar_set(file, id_group, group);
47
+ rb_ivar_set(file, id_rdev, rb_Integer(rdev));
48
+ rb_ivar_set(file, id_mode, UINT2NUM(NUM2UINT(rb_Integer(mode))&0777));
49
+ rb_ivar_set(file, id_attr, rb_Integer(attr));
50
+ rb_ivar_set(file, id_state, rb_Integer(state));
51
+
52
+ return file;
53
+ }
54
+
55
+ VALUE
56
+ rpm_file_new(const char* path, const char* md5sum, const char* link_to,
57
+ size_t size, time_t mtime, const char* owner, const char* group,
58
+ dev_t rdev, mode_t mode, rpmfileAttrs attr, rpmfileState state)
59
+ {
60
+ VALUE file, argv[11];
61
+
62
+ argv[0] = rb_str_new2(path);
63
+ argv[1] = rb_str_new2(md5sum);
64
+ argv[2] = link_to ? rb_str_new2(link_to) : Qnil;
65
+ argv[3] = UINT2NUM(size);
66
+ argv[4] = rb_time_new(mtime, (time_t)0);
67
+ argv[5] = owner ? rb_str_new2(owner) : Qnil;
68
+ argv[6] = group ? rb_str_new2(group) : Qnil;
69
+ argv[7] = UINT2NUM(rdev);
70
+ argv[8] = UINT2NUM(mode);
71
+ argv[9] = INT2NUM(attr);
72
+ argv[10] = INT2NUM(state);
73
+
74
+ file = rb_newobj();
75
+ OBJSETUP(file, rpm_cFile, T_OBJECT);
76
+ rb_obj_call_init(file, 11, argv);
77
+
78
+ return file;
79
+ }
80
+
81
+ VALUE
82
+ rpm_file_get_path(VALUE file)
83
+ {
84
+ return rb_ivar_get(file, id_path);
85
+ }
86
+
87
+ VALUE
88
+ rpm_file_get_md5sum(VALUE file)
89
+ {
90
+ return rb_ivar_get(file, id_md5sum);
91
+ }
92
+
93
+ VALUE
94
+ rpm_file_get_link_to(VALUE file)
95
+ {
96
+ return rb_ivar_get(file, id_link_to);
97
+ }
98
+
99
+ VALUE
100
+ rpm_file_get_size(VALUE file)
101
+ {
102
+ return rb_ivar_get(file, id_size);
103
+ }
104
+
105
+ VALUE
106
+ rpm_file_get_mtime(VALUE file)
107
+ {
108
+ return rb_ivar_get(file, id_mtime);
109
+ }
110
+
111
+ VALUE
112
+ rpm_file_get_owner(VALUE file)
113
+ {
114
+ return rb_ivar_get(file, id_owner);
115
+ }
116
+
117
+ VALUE
118
+ rpm_file_get_group(VALUE file)
119
+ {
120
+ return rb_ivar_get(file, id_group);
121
+ }
122
+
123
+ VALUE
124
+ rpm_file_get_rdev(VALUE file)
125
+ {
126
+ return rb_ivar_get(file, id_rdev);
127
+ }
128
+
129
+ VALUE
130
+ rpm_file_get_mode(VALUE file)
131
+ {
132
+ return rb_ivar_get(file, id_mode);
133
+ }
134
+
135
+ VALUE
136
+ rpm_file_get_attr(VALUE file)
137
+ {
138
+ return rb_ivar_get(file, id_attr);
139
+ }
140
+
141
+ VALUE
142
+ rpm_file_get_state(VALUE file)
143
+ {
144
+ return rb_ivar_get(file, id_state);
145
+ }
146
+
147
+ VALUE
148
+ rpm_file_is_symlink(VALUE file)
149
+ {
150
+ return NIL_P(rb_ivar_get(file, id_link_to)) ? Qfalse : Qtrue;
151
+ }
152
+
153
+ VALUE
154
+ rpm_file_is_config(VALUE file)
155
+ {
156
+ return (NUM2INT(rb_ivar_get(file, id_attr)) & RPMFILE_CONFIG) ? Qtrue : Qfalse;
157
+ }
158
+
159
+ VALUE
160
+ rpm_file_is_doc(VALUE file)
161
+ {
162
+ return (NUM2INT(rb_ivar_get(file, id_attr)) & RPMFILE_DOC) ? Qtrue : Qfalse;
163
+ }
164
+
165
+ VALUE
166
+ rpm_file_is_donotuse(VALUE file)
167
+ {
168
+ #if RPM_VERSION_CODE < RPM_VERSION(4,1,0)
169
+ return (NUM2INT(rb_ivar_get(file, id_attr)) & RPMFILE_DONOTUSE) ? Qtrue : Qfalse;
170
+ #else
171
+ return Qfalse;
172
+ #endif
173
+ }
174
+
175
+ VALUE
176
+ rpm_file_is_missingok(VALUE file)
177
+ {
178
+ return (NUM2INT(rb_ivar_get(file, id_attr)) & RPMFILE_MISSINGOK) ? Qtrue : Qfalse;
179
+ }
180
+
181
+ VALUE
182
+ rpm_file_is_noreplace(VALUE file)
183
+ {
184
+ return (NUM2INT(rb_ivar_get(file, id_attr)) & RPMFILE_NOREPLACE) ? Qtrue : Qfalse;
185
+ }
186
+
187
+ VALUE
188
+ rpm_file_is_specfile(VALUE file)
189
+ {
190
+ return (NUM2INT(rb_ivar_get(file, id_attr)) & RPMFILE_SPECFILE) ? Qtrue : Qfalse;
191
+ }
192
+
193
+ VALUE
194
+ rpm_file_is_ghost(VALUE file)
195
+ {
196
+ return (NUM2INT(rb_ivar_get(file, id_attr)) & RPMFILE_GHOST) ? Qtrue : Qfalse;
197
+ }
198
+
199
+ VALUE
200
+ rpm_file_is_license(VALUE file)
201
+ {
202
+ return (NUM2INT(rb_ivar_get(file, id_attr)) & RPMFILE_LICENSE) ? Qtrue : Qfalse;
203
+ }
204
+
205
+ VALUE
206
+ rpm_file_is_readme(VALUE file)
207
+ {
208
+ return (NUM2INT(rb_ivar_get(file, id_attr)) & RPMFILE_README) ? Qtrue : Qfalse;
209
+ }
210
+
211
+ VALUE
212
+ rpm_file_is_exclude(VALUE file)
213
+ {
214
+ return (NUM2INT(rb_ivar_get(file, id_attr)) & RPMFILE_EXCLUDE) ? Qtrue : Qfalse;
215
+ }
216
+
217
+ VALUE
218
+ rpm_file_is_replaced(VALUE file)
219
+ {
220
+ return (NUM2INT(rb_ivar_get(file, id_state))
221
+ == RPMFILE_STATE_REPLACED) ? Qtrue : Qfalse;
222
+ }
223
+
224
+ VALUE
225
+ rpm_file_is_notinstalled(VALUE file)
226
+ {
227
+ return (NUM2INT(rb_ivar_get(file, id_state))
228
+ == RPMFILE_STATE_NOTINSTALLED) ? Qtrue : Qfalse;
229
+ }
230
+
231
+ VALUE
232
+ rpm_file_is_netshared(VALUE file)
233
+ {
234
+ return (NUM2INT(rb_ivar_get(file, id_state))
235
+ == RPMFILE_STATE_NETSHARED) ? Qtrue : Qfalse;
236
+ }
237
+
238
+ void
239
+ Init_rpm_file(void)
240
+ {
241
+ rpm_cFile = rb_define_class_under(rpm_mRPM, "File", rb_cObject);
242
+ rb_define_method(rpm_cFile, "initialize", file_initialize, 11);
243
+ rb_define_method(rpm_cFile, "path", rpm_file_get_path, 0);
244
+ rb_define_alias(rpm_cFile, "to_s", "path");
245
+ rb_define_method(rpm_cFile, "md5sum", rpm_file_get_md5sum, 0);
246
+ rb_define_method(rpm_cFile, "link_to", rpm_file_get_link_to, 0);
247
+ rb_define_method(rpm_cFile, "size", rpm_file_get_size, 0);
248
+ rb_define_method(rpm_cFile, "mtime", rpm_file_get_mtime, 0);
249
+ rb_define_method(rpm_cFile, "owner", rpm_file_get_owner, 0);
250
+ rb_define_method(rpm_cFile, "group", rpm_file_get_group, 0);
251
+ rb_define_method(rpm_cFile, "rdev", rpm_file_get_rdev, 0);
252
+ rb_define_method(rpm_cFile, "mode", rpm_file_get_mode, 0);
253
+ rb_define_method(rpm_cFile, "attr", rpm_file_get_attr, 0);
254
+ rb_define_method(rpm_cFile, "state", rpm_file_get_state, 0);
255
+ rb_define_method(rpm_cFile, "symlink?", rpm_file_is_symlink, 0);
256
+ rb_define_method(rpm_cFile, "config?", rpm_file_is_config, 0);
257
+ rb_define_method(rpm_cFile, "doc?", rpm_file_is_doc, 0);
258
+ rb_define_method(rpm_cFile, "donotuse?", rpm_file_is_donotuse, 0);
259
+ rb_define_method(rpm_cFile, "missingok?", rpm_file_is_missingok, 0);
260
+ rb_define_method(rpm_cFile, "noreplace?", rpm_file_is_noreplace, 0);
261
+ rb_define_method(rpm_cFile, "specfile?", rpm_file_is_specfile, 0);
262
+ rb_define_method(rpm_cFile, "ghost?", rpm_file_is_ghost, 0);
263
+ rb_define_method(rpm_cFile, "license?", rpm_file_is_license, 0);
264
+ rb_define_method(rpm_cFile, "readme?", rpm_file_is_readme, 0);
265
+ rb_define_method(rpm_cFile, "exclude?", rpm_file_is_exclude, 0);
266
+ rb_define_method(rpm_cFile, "replaced?", rpm_file_is_replaced, 0);
267
+ rb_define_method(rpm_cFile, "notinstalled?", rpm_file_is_notinstalled, 0);
268
+ rb_define_method(rpm_cFile, "netshared?", rpm_file_is_netshared, 0);
269
+
270
+ id_path = rb_intern("path");
271
+ id_md5sum = rb_intern("md5sum");
272
+ id_link_to = rb_intern("link_to");
273
+ id_size = rb_intern("size");
274
+ id_mtime = rb_intern("mtime");
275
+ id_owner = rb_intern("owner");
276
+ id_group = rb_intern("group");
277
+ id_rdev = rb_intern("rdev");
278
+ id_mode = rb_intern("mode");
279
+ id_attr = rb_intern("attr");
280
+ id_state = rb_intern("state");
281
+ }