Class: RPM::Dependency

Inherits:
Object
  • Object
show all
Defined in:
ext/rpm/dependency.c

Direct Known Subclasses

Conflict, Obsolete, Provide, Require

Instance Method Summary collapse

Constructor Details

#initialize(name, version, flags, owner) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'ext/rpm/dependency.c', line 26

static VALUE
dependency_initialize(VALUE dep, VALUE name, VALUE version,
					  VALUE flags, VALUE owner)
{
	if (TYPE(name) != T_STRING
		|| (!NIL_P(version) && rb_obj_is_kind_of(version, rpm_cVersion) == Qfalse)) {
		rb_raise(rb_eTypeError, "illegal argument type");
	}

	rb_ivar_set(dep, id_name, name);
	rb_ivar_set(dep, id_ver, version);
	rb_ivar_set(dep, id_flags, rb_Integer(flags));
	rb_ivar_set(dep, id_owner, owner);
	return dep;
}

Instance Method Details

#eq?Boolean

Returns:

  • (Boolean)


266
267
268
269
270
# File 'ext/rpm/dependency.c', line 266

VALUE
rpm_dependency_is_eq(VALUE dep)
{
	return (NUM2INT(rb_ivar_get(dep, id_flags)) & RPMSENSE_EQUAL) ? Qtrue : Qfalse;
}

#flagsObject



224
225
226
227
228
# File 'ext/rpm/dependency.c', line 224

VALUE
rpm_dependency_get_flags(VALUE dep)
{
	return rb_ivar_get(dep, id_flags);
}

#flagstagObject



248
249
250
251
252
# File 'ext/rpm/dependency.c', line 248

VALUE
rpm_dependency_get_flagstag(VALUE dep)
{
	return rb_ivar_get(dep, id_flagstag);
}

#ge?Boolean

Returns:

  • (Boolean)


279
280
281
282
283
284
# File 'ext/rpm/dependency.c', line 279

VALUE
rpm_dependency_is_ge(VALUE dep)
{
	int flags = NUM2INT(rb_ivar_get(dep, id_flags));
	return ((flags & RPMSENSE_GREATER) && (flags & RPMSENSE_EQUAL)) ? Qtrue : Qfalse;
}

#gt?Boolean

Returns:

  • (Boolean)


260
261
262
263
264
# File 'ext/rpm/dependency.c', line 260

VALUE
rpm_dependency_is_gt(VALUE dep)
{
	return (NUM2INT(rb_ivar_get(dep, id_flags)) & RPMSENSE_GREATER) ? Qtrue : Qfalse;
}

#le?Boolean

Returns:

  • (Boolean)


272
273
274
275
276
277
# File 'ext/rpm/dependency.c', line 272

VALUE
rpm_dependency_is_le(VALUE dep)
{
	int flags = NUM2INT(rb_ivar_get(dep, id_flags));
	return ((flags & RPMSENSE_LESS) && (flags & RPMSENSE_EQUAL)) ? Qtrue : Qfalse;
}

#lt?Boolean

Returns:

  • (Boolean)


254
255
256
257
258
# File 'ext/rpm/dependency.c', line 254

VALUE
rpm_dependency_is_lt(VALUE dep)
{
	return (NUM2INT(rb_ivar_get(dep, id_flags)) & RPMSENSE_LESS) ? Qtrue : Qfalse;
}

#nameObject



212
213
214
215
216
# File 'ext/rpm/dependency.c', line 212

VALUE
rpm_dependency_get_name(VALUE dep)
{
	return rb_ivar_get(dep, id_name);
}

#nametagObject



236
237
238
239
240
# File 'ext/rpm/dependency.c', line 236

VALUE
rpm_dependency_get_nametag(VALUE dep)
{
	return rb_ivar_get(dep, id_nametag);
}

#ownerObject



230
231
232
233
234
# File 'ext/rpm/dependency.c', line 230

VALUE
rpm_dependency_get_owner(VALUE dep)
{
	return rb_ivar_get(dep, id_owner);
}

#satisfy?(other) ⇒ Boolean

Returns:

  • (Boolean)


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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
# File 'ext/rpm/dependency.c', line 162

VALUE
rpm_dependency_is_satisfy(VALUE dep,VALUE other)
{
	int oflag;
    int sflag;
	char *svre;
	char *ovre;
	char *name;
    char *oname;
	if (rb_obj_is_kind_of(other,rpm_cPackage) == Qtrue){
		VALUE provide;
		VALUE provides = rpm_package_get_provides(other);
		while (!NIL_P(provide = rb_ary_pop(provides))){
            if (rpm_dependency_is_satisfy(dep,provide) == Qtrue) {
                return Qtrue;
			}
		}
		return Qfalse;
	}

	name = RSTRING(rb_ivar_get(dep,id_name))->ptr;
	svre = RSTRING(rpm_version_to_vre(rb_ivar_get(dep,id_ver)))->ptr;
    sflag = NUM2INT(rb_ivar_get(dep, id_flags));

	if (rb_obj_is_kind_of(other,rpm_cDependency) == Qtrue){
		oflag = NUM2INT(rb_ivar_get(other, id_flags));
        oname = RSTRING(rb_ivar_get(other, id_name))->ptr;
		ovre = RSTRING(rpm_version_to_vre(rb_ivar_get(other,id_ver)))->ptr;
		other = rb_ivar_get(other,id_ver);
	} else if (rb_obj_is_kind_of(other,rpm_cVersion) == Qtrue){
		ovre = RSTRING(rpm_version_to_vre(other))->ptr;
        oname = name;
		if (!*ovre)
			oflag = 0;
		else
			oflag = RPMSENSE_EQUAL;
	} else {
		rb_raise(rb_eTypeError, "illegal argument type");
	}

#if RPM_VERSION_CODE < RPM_VERSION(4,1,0)
	if (rpmRangesOverlap(name,ovre,oflag, sname,svre,sflag))
#else
	if (rpmdsCompare(rpmdsSingle(RPMTAG_PROVIDENAME, oname, ovre, oflag),
			 rpmdsSingle(RPMTAG_PROVIDENAME, name, svre, sflag)))
#endif
		return Qtrue;
	return Qfalse;
}

#versionObject



218
219
220
221
222
# File 'ext/rpm/dependency.c', line 218

VALUE
rpm_dependency_get_version(VALUE dep)
{
	return rb_ivar_get(dep, id_ver);
}

#versiontagObject



242
243
244
245
246
# File 'ext/rpm/dependency.c', line 242

VALUE
rpm_dependency_get_versiontag(VALUE dep)
{
	return rb_ivar_get(dep, id_versiontag);
}