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 true if ‘=’, ‘=<’ or ‘>=’ are used to compare the version.

Returns:

  • (Boolean)

    true if ‘=’, ‘=<’ or ‘>=’ are used to compare the version



292
293
294
295
296
# File 'ext/rpm/dependency.c', line 292

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

#flagsNumber

Returns dependency flags.

Returns:

  • (Number)

    dependency flags



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

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

#flagstagObject



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

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

#ge?Boolean

Returns true if ‘>=’ is used to compare the version.

Returns:

  • (Boolean)

    true if ‘>=’ is used to compare the version



311
312
313
314
315
316
# File 'ext/rpm/dependency.c', line 311

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 true if ‘>’ or ‘>=’ are used to compare the version.

Returns:

  • (Boolean)

    true if ‘>’ or ‘>=’ are used to compare the version



283
284
285
286
287
# File 'ext/rpm/dependency.c', line 283

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

#le?Boolean

Returns true if ‘=<’ is used to compare the version.

Returns:

  • (Boolean)

    true if ‘=<’ is used to compare the version



301
302
303
304
305
306
# File 'ext/rpm/dependency.c', line 301

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 true if ‘<’ or ‘=<’ are used to compare the version.

Returns:

  • (Boolean)

    true if ‘<’ or ‘=<’ are used to compare the version



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

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

#nameString

Returns dependency name.

Returns:

  • (String)

    dependency name



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

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

#nametagObject



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

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

#ownerPackage

Returns package this dependency belongs to.

Returns:

  • (Package)

    package this dependency belongs to



246
247
248
249
250
# File 'ext/rpm/dependency.c', line 246

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

#satisfy?(other) ⇒ Boolean

Returns true if other satisfies this dependency.

Parameters:

Returns:

  • (Boolean)

    true if other satisfies this dependency



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
211
212
213
214
# File 'ext/rpm/dependency.c', line 166

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_PTR(rb_ivar_get(dep,id_name));
	svre = RSTRING_PTR(rpm_version_to_vre(rb_ivar_get(dep,id_ver)));
    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_PTR(rb_ivar_get(other, id_name));
		ovre = RSTRING_PTR(rpm_version_to_vre(rb_ivar_get(other,id_ver)));
		other = rb_ivar_get(other,id_ver);
	} else if (rb_obj_is_kind_of(other,rpm_cVersion) == Qtrue){
		ovre = RSTRING_PTR(rpm_version_to_vre(other));
        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;
}

#versionString

Returns dependency version.

Returns:

  • (String)

    dependency version



228
229
230
231
232
# File 'ext/rpm/dependency.c', line 228

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

#versiontagObject



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

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