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)

190
191
192
193
194
195
196
197
198
199
200
201
202
# File 'ext/apt_pkg/pkgcache.cpp', line 190

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)

286
287
288
289
290
291
292
293
294
295
296
297
298
# File 'ext/apt_pkg/pkgcache.cpp', line 286

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)

142
143
144
145
146
147
148
149
150
151
152
153
154
# File 'ext/apt_pkg/pkgcache.cpp', line 142

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)

214
215
216
217
218
219
220
221
222
223
224
225
226
# File 'ext/apt_pkg/pkgcache.cpp', line 214

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);
}

.pkg_namesArray?

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)

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
# File 'ext/apt_pkg/pkgcache.cpp', line 101

static VALUE
pkg_names(int argc, VALUE *argv, VALUE self)
{
  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)

262
263
264
265
266
267
268
269
270
271
272
273
274
# File 'ext/apt_pkg/pkgcache.cpp', line 262

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)

238
239
240
241
242
243
244
245
246
247
248
249
250
# File 'ext/apt_pkg/pkgcache.cpp', line 238

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)

166
167
168
169
170
171
172
173
174
175
176
177
178
# File 'ext/apt_pkg/pkgcache.cpp', line 166

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);
}