Module: Debian::AptPkg::PkgCache

Defined in:
ext/apt_pkg/pkgcache.cpp

Class Method Summary collapse

Class Method Details

.depends_countInteger?

The total number of dependencies stored in the cache. Raise ‘Debian::AptPkg::InitError` when config, system, cache is not configured.

Debian::AptPkg::PkgCache.depends_count # => 551983

Returns:

  • (Integer, nil)


247
248
249
250
251
252
253
254
255
256
257
258
259
# File 'ext/apt_pkg/pkgcache.cpp', line 247

static VALUE
depends_count(VALUE self)
{
  if (!config_system_initialized()) {
    rb_raise(e_mDebianAptPkgInitError, "System not initialized");
  }
  pkgCacheFile CacheFile;
  pkgCache *Cache = CacheFile.GetPkgCache();
  if (Cache == NULL) {
    return Qnil;
  }
  return INT2FIX(Cache->HeaderP->DependsCount);
}

.gen_cachesBoolean

Call the main cache generator. Raise ‘Debian::AptPkg::InitError` when config, system, cache is not configured.

Debian::AptPkg::PkgCache.gen_caches # => false

Returns:

  • (Boolean)


28
29
30
31
32
33
34
35
36
37
# File 'ext/apt_pkg/pkgcache.cpp', line 28

static VALUE
gen_caches(VALUE self)
{
  if (!config_system_initialized()) {
    rb_raise(e_mDebianAptPkgInitError, "System not initialized");
  }
  pkgCacheFile CacheFile;
  int res = CacheFile.BuildCaches(NULL, true);
  return INT2BOOL(res);
}

.group_countInteger?

The number of groups in the cache. Raise ‘Debian::AptPkg::InitError` when config, system, cache is not configured.

Debian::AptPkg::PkgCache.group_count # => 16730

Returns:

  • (Integer, nil)


343
344
345
346
347
348
349
350
351
352
353
354
355
# File 'ext/apt_pkg/pkgcache.cpp', line 343

static VALUE
group_count(VALUE self)
{
  if (!config_system_initialized()) {
    rb_raise(e_mDebianAptPkgInitError, "System not initialized");
  }
  pkgCacheFile CacheFile;
  pkgCache *Cache = CacheFile.GetPkgCache();
  if (Cache == NULL) {
    return Qnil;
  }
  return INT2FIX(Cache->HeaderP->GroupCount);
}

.is_multi_archBoolean

An attribute determining whether the cache supports multi-arch. Raise ‘Debian::AptPkg::InitError` when config, system, cache is not configured.

Debian::AptPkg::PkgCache.is_multi_arch # => false

Returns:

  • (Boolean)


76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'ext/apt_pkg/pkgcache.cpp', line 76

static VALUE
is_multi_arch(VALUE self)
{
  if (!config_system_initialized()) {
    rb_raise(e_mDebianAptPkgInitError, "System not initialized");
  }
  pkgCacheFile CacheFile;
  pkgCache *Cache = CacheFile.GetPkgCache();
  if (Cache == NULL) {
    return Qnil;
  }
  int res = Cache->MultiArchCache();
  return INT2BOOL(res);
}

.package_countInteger?

The total number of packages available in the cache. Raise ‘Debian::AptPkg::InitError` when config, system, cache is not configured.

Debian::AptPkg::PkgCache.package_count # => 69511

Returns:

  • (Integer, nil)


199
200
201
202
203
204
205
206
207
208
209
210
211
# File 'ext/apt_pkg/pkgcache.cpp', line 199

static VALUE
package_count(VALUE self)
{
  if (!config_system_initialized()) {
    rb_raise(e_mDebianAptPkgInitError, "System not initialized");
  }
  pkgCacheFile CacheFile;
  pkgCache *Cache = CacheFile.GetPkgCache();
  if (Cache == NULL) {
    return Qnil;
  }
  return INT2FIX(Cache->HeaderP->PackageCount);
}

.package_file_countInteger?

The total number of packages files available. Raise ‘Debian::AptPkg::InitError` when config, system, cache is not configured.

Debian::AptPkg::PkgCache.package_file_count # => 17

Returns:

  • (Integer, nil)


271
272
273
274
275
276
277
278
279
280
281
282
283
# File 'ext/apt_pkg/pkgcache.cpp', line 271

static VALUE
package_file_count(VALUE self)
{
  if (!config_system_initialized()) {
    rb_raise(e_mDebianAptPkgInitError, "System not initialized");
  }
  pkgCacheFile CacheFile;
  pkgCache *Cache = CacheFile.GetPkgCache();
  if (Cache == NULL) {
    return Qnil;
  }
  return INT2FIX(Cache->HeaderP->PackageFileCount);
}

.packagesArray?

A list of Debian::AptPkg::Package objects stored in the cache Raise ‘Debian::AptPkg::InitError` when config, system, cache is not configured.

Debian::AptPkg::PkgCache.packages

Returns:

  • (Array, nil)


101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# File 'ext/apt_pkg/pkgcache.cpp', line 101

static VALUE
packages(int argc, VALUE *argv, VALUE self)
{
  if (!config_system_initialized()) {
    rb_raise(e_mDebianAptPkgInitError, "System not initialized");
  }
  VALUE result = rb_ary_new();
  pkgCacheFile CacheFile;
  if (CacheFile.GetPkgCache() == 0) {
    return Qnil;
  }
  for (pkgCache::PkgIterator Pkg = CacheFile.GetPkgCache()->PkgBegin(); not Pkg.end(); ++Pkg) {
    VALUE current_version;
    if (Pkg->CurrentVer == 0) {
      current_version = Qnil;
    } else {
      current_version = rb_struct_new(rb_cVersion,
          rb_str_new2(Pkg.CurrentVer().ParentPkg().Name()),
          rb_str_new2(Pkg.CurrentVer().VerStr()),
          rb_str_new2(Pkg.CurrentVer().Section()),
          rb_str_new2(Pkg.CurrentVer().Arch()),
          INT2FIX(Pkg.CurrentVer()->Size),
          INT2FIX(Pkg.CurrentVer()->InstalledSize),
          INT2FIX(Pkg.CurrentVer()->Hash),
          INT2FIX(Pkg.CurrentVer()->ID),
          INT2FIX(Pkg.CurrentVer()->Priority)
          );
    }
    VALUE rb_cPackage_args[7];
    rb_cPackage_args[0] = INT2FIX(Pkg->ID);
    rb_cPackage_args[1] = rb_str_new2(Pkg.Name());
    rb_cPackage_args[2] = rb_str_new2(Pkg.FullName().c_str());
    rb_cPackage_args[3] = rb_str_new2(Pkg.Arch());
    rb_cPackage_args[4] = INT2BOOL((Pkg->Flags & pkgCache::Flag::Essential) != 0);
    rb_cPackage_args[5] = INT2BOOL((Pkg->Flags & pkgCache::Flag::Important) != 0);
    rb_cPackage_args[6] = current_version;
    rb_ary_push(result, rb_class_new_instance(7,
          rb_cPackage_args,
          rb_cPackage
          ));
  }
  return result;
}

.pkg_namesArray?

Deprecated and will removed in 0.6.0 List the names of all packages in the system. Raise ‘Debian::AptPkg::InitError` when config, system, cache is not configured.

Debian::AptPkg::PkgCache.pkg_names('gcolor2') # => ["gcolor2"]

Returns:

  • (Array, nil)


156
157
158
159
160
161
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
# File 'ext/apt_pkg/pkgcache.cpp', line 156

static VALUE
pkg_names(int argc, VALUE *argv, VALUE self)
{
  rb_warn("Debian::AptPkg::PkgCache.pkg_names is deprecated; " \
          "use Debian::AptPkg::PkgCache.packages instead");
  if (!config_system_initialized()) {
    rb_raise(e_mDebianAptPkgInitError, "System not initialized");
  }
  if (argc > 1 || argc == 0) {
    rb_raise(rb_eArgError, "You must give at least one search argument");
  }
  VALUE name;
  rb_scan_args(argc, argv, "01", &name);
  if (NIL_P(name) || RSTRING_LEN(name) < 1) {
    rb_raise(rb_eArgError, "You must give at least one search pattern");
  }
  VALUE result = rb_ary_new();

  pkgCacheFile CacheFile;
  if (CacheFile.GetPkgCache() == 0) {
    return Qnil;
  }
  pkgCache::GrpIterator I = CacheFile.GetPkgCache()->GrpBegin();

  const char *pkgname = StringValuePtr(name);
  for (; I.end() != true; ++I) {
    if (strncmp(I.Name(), pkgname, strlen(pkgname)) == 0) {
      rb_ary_push(result, rb_str_new2(I.Name()));
    }
  }
  return result;
}

.provides_countInteger?

The number of provided packages. Raise ‘Debian::AptPkg::InitError` when config, system, cache is not configured.

Debian::AptPkg::PkgCache.provides_count # => 69511

Returns:

  • (Integer, nil)


319
320
321
322
323
324
325
326
327
328
329
330
331
# File 'ext/apt_pkg/pkgcache.cpp', line 319

static VALUE
provides_count(VALUE self)
{
  if (!config_system_initialized()) {
    rb_raise(e_mDebianAptPkgInitError, "System not initialized");
  }
  pkgCacheFile CacheFile;
  pkgCache *Cache = CacheFile.GetPkgCache();
  if (Cache == NULL) {
    return Qnil;
  }
  return INT2FIX(Cache->HeaderP->ProvidesCount);
}

.updateBoolean

Update the index files used by the cache. Raise ‘Debian::AptPkg::InitError` when config, system, cache is not configured.

Debian::AptPkg::PkgCache.update # => false

Returns:

  • (Boolean)


49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'ext/apt_pkg/pkgcache.cpp', line 49

static VALUE
update(VALUE self)
{
  if (!config_system_initialized()) {
    rb_raise(e_mDebianAptPkgInitError, "System not initialized");
  }
  pkgCacheFile CacheFile;
  // Get the source list
  if (CacheFile.BuildSourceList() == false) {
    return Qnil;
  }
  pkgAcquireStatus *Stat(NULL);
  pkgSourceList *List = CacheFile.GetSourceList();
  int res = ListUpdate(*Stat, *List);
  return INT2BOOL(res);
}

.ver_file_countInteger?

The total number of version and package file relations stored in the cache. Raise ‘Debian::AptPkg::InitError` when config, system, cache is not configured.

Debian::AptPkg::PkgCache.ver_file_count # => 11274

Returns:

  • (Integer, nil)


295
296
297
298
299
300
301
302
303
304
305
306
307
# File 'ext/apt_pkg/pkgcache.cpp', line 295

static VALUE
ver_file_count(VALUE self)
{
  if (!config_system_initialized()) {
    rb_raise(e_mDebianAptPkgInitError, "System not initialized");
  }
  pkgCacheFile CacheFile;
  pkgCache *Cache = CacheFile.GetPkgCache();
  if (Cache == NULL) {
    return Qnil;
  }
  return INT2FIX(Cache->HeaderP->VerFileCount);
}

.version_countInteger?

The total number of package versions available in the cache. Raise ‘Debian::AptPkg::InitError` when config, system, cache is not configured.

Debian::AptPkg::PkgCache.version_count # => 84630

Returns:

  • (Integer, nil)


223
224
225
226
227
228
229
230
231
232
233
234
235
# File 'ext/apt_pkg/pkgcache.cpp', line 223

static VALUE
version_count(VALUE self)
{
  if (!config_system_initialized()) {
    rb_raise(e_mDebianAptPkgInitError, "System not initialized");
  }
  pkgCacheFile CacheFile;
  pkgCache *Cache = CacheFile.GetPkgCache();
  if (Cache == NULL) {
    return Qnil;
  }
  return INT2FIX(Cache->HeaderP->VersionCount);
}