Exemple #1
0
/*
 * call-seq: init() -> nil
 *
 * Shorthand for doing init_config() and init_system().
 *
 *   Debian::AptPkg.init # => nil
 *
 **/
static VALUE
init(VALUE self)
{
  pkgInitConfig(*_config);
  pkgInitSystem(*_config, _system);
  return Qnil;
}
/**
 * pk_backend_initialize:
 */
void pk_backend_initialize(GKeyFile *conf, PkBackend *backend)
{
    g_debug("APTcc Initializing");

    // Disable apt-listbugs as it freezes PK
    setenv("APT_LISTBUGS_FRONTEND", "none", 1);

    // Set apt-listchanges frontend to "debconf" to make it's output visible
    // (without using the debconf frontend, PK will freeze)
    setenv("APT_LISTCHANGES_FRONTEND", "debconf", 1);

    // pkgInitConfig makes sure the config is ready for the
    // get-filters call which needs to know about multi-arch
    if (!pkgInitConfig(*_config)) {
        g_debug("ERROR initializing backend configuration");
    }

    // pkgInitSystem is needed to compare the changelog verstion to
    // current package using DoCmpVersion()
    if (!pkgInitSystem(*_config, _system)) {
        g_debug("ERROR initializing backend system");
    }

    spawn = pk_backend_spawn_new(conf);
    //     pk_backend_spawn_set_job(spawn, backend);
    pk_backend_spawn_set_name(spawn, "aptcc");
}
Exemple #3
0
int main(int argc, char *argv[]) {

    if (2 != argc || '-' != argv[1][0] || strlen(argv[1]) != 2) {
        usage();
        return 1;
    }

    const char mode = argv[1][1];

    // _config and _system are defined in the libapt header files
    pkgInitConfig(*_config);
    pkgInitSystem(*_config, _system);

    pkgCacheFile cache_file;
//    pkgCache* cache = cache_file.GetPkgCache();

    if ('s' == mode) {
        src(cache_file.GetSourceList());
    }

    if ('b' == mode) {
        bin(cache_file.GetPkgCache());
    }
    return 0;
}
Exemple #4
0
int main(const int argc, const char ** const argv) {
	CommandLine CmdL(Args, _config);
	if (!pkgInitConfig(*_config) ||
	    !CmdL.Parse(argc, argv) ||
	    !ensure_command(CmdL) ||
	    !pkgInitSystem(*_config, _system) ||
	    !CmdL.DispatchArg(Cmds)) {
		_error->DumpErrors();
		return 1;
	}
}
/**
 * backend_initialize:
 */
static void
backend_initialize (PkBackend *backend)
{
	egg_debug ("APTcc Initializing");

	// make sure we do not get a graphical debconf
	setenv("DEBIAN_FRONTEND", "noninteractive", 1);
	setenv("APT_LISTCHANGES_FRONTEND", "none", 1);

	if (pkgInitConfig(*_config) == false ||
	    pkgInitSystem(*_config, _system) == false)
	{
		egg_debug ("ERROR initializing backend");
	}
}
Exemple #6
0
QueryData genAptSrcs(QueryContext& context) {
  QueryData results;

  // Load our apt configuration into memory
  // Note: _config comes from apt-pkg/configuration.h
  //       _system comes from apt-pkg/pkgsystem.h
  pkgInitConfig(*_config);
  if (pkgInitSystem(*_config, _system) == false)
  {
      return results;
  }

  pkgCacheFile cache_file;
  pkgCache* cache = cache_file.GetPkgCache();
  pkgSourceList* src_list = cache_file.GetSourceList();
  if (cache == nullptr || src_list == nullptr) {
    cache_file.Close();
    closeConfig();
    return results;
  }

  // For each apt cache file that contains packages
  for (pkgCache::PkgFileIterator file = cache->FileBegin(); file && !file.end();
       ++file) {

    // Locate the associated index files to ensure the repository is installed
    pkgIndexFile* pkgIndex;
    if (!src_list->FindIndex(file, pkgIndex)) {
      continue;
    }

    extractAptSourceInfo(file, pkgIndex, results);
  }

  // Cleanup
  cache_file.Close();
  closeConfig();

  return results;
}
Exemple #7
0
/*
 * call-seq: init_system() -> bool
 *
 * Construct the apt_pkg system.
 *
 *   Debian::AptPkg.init_system # => false
 *
 **/
static VALUE
init_system(VALUE self)
{
  int res = pkgInitSystem(*_config, _system);
  return INT2BOOL(res);
}