本文整理汇总了C++中AptIntf::resolvePackageIds方法的典型用法代码示例。如果您正苦于以下问题:C++ AptIntf::resolvePackageIds方法的具体用法?C++ AptIntf::resolvePackageIds怎么用?C++ AptIntf::resolvePackageIds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AptIntf
的用法示例。
在下文中一共展示了AptIntf::resolvePackageIds方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: backend_get_details_thread
static void backend_get_details_thread(PkBackendJob *job, GVariant *params, gpointer user_data)
{
gchar **package_ids;
PkRoleEnum role;
role = pk_backend_job_get_role(job);
g_variant_get(params, "(^a&s)",
&package_ids);
AptIntf *apt = static_cast<AptIntf*>(pk_backend_job_get_user_data(job));
if (!apt->init()) {
g_debug ("Failed to create apt cache");
return;
}
if (package_ids == NULL) {
pk_backend_job_error_code(job,
PK_ERROR_ENUM_PACKAGE_ID_INVALID,
"Invalid package id");
return;
}
pk_backend_job_set_status(job, PK_STATUS_ENUM_QUERY);
PkgList pkgs = apt->resolvePackageIds(package_ids);
if (role == PK_ROLE_ENUM_GET_UPDATE_DETAIL) {
apt->emitUpdateDetails(pkgs);
} else {
apt->emitDetails(pkgs);
}
}
示例2: backend_get_details_thread
static void backend_get_details_thread(PkBackendJob *job, GVariant *params, gpointer user_data)
{
gchar **package_ids = nullptr;
gchar **files = nullptr;
PkRoleEnum role;
role = pk_backend_job_get_role(job);
if (role == PK_ROLE_ENUM_GET_DETAILS_LOCAL) {
g_variant_get(params, "(^a&s)",
&files);
} else {
g_variant_get(params, "(^a&s)",
&package_ids);
}
AptIntf *apt = static_cast<AptIntf*>(pk_backend_job_get_user_data(job));
if (!apt->init(files)) {
g_debug ("Failed to create apt cache");
return;
}
pk_backend_job_set_status(job, PK_STATUS_ENUM_QUERY);
PkgList pkgs;
if (role == PK_ROLE_ENUM_GET_DETAILS_LOCAL) {
pkgs = apt->resolveLocalFiles(files);
} else {
pkgs = apt->resolvePackageIds(package_ids);
}
if (role == PK_ROLE_ENUM_GET_UPDATE_DETAIL) {
apt->emitUpdateDetails(pkgs);
} else {
apt->emitDetails(pkgs);
}
}
示例3: pk_backend_resolve_thread
static void pk_backend_resolve_thread(PkBackendJob *job, GVariant *params, gpointer user_data)
{
gchar **search;
PkBitfield filters;
g_variant_get(params, "(t^a&s)",
&filters,
&search);
pk_backend_job_set_allow_cancel(job, true);
AptIntf *apt = static_cast<AptIntf*>(pk_backend_job_get_user_data(job));
if (!apt->init()) {
g_debug("Failed to create apt cache");
return;
}
PkgList pkgs = apt->resolvePackageIds(search);
// It's faster to emit the packages here rather than in the matching part
apt->emitPackages(pkgs, filters);
}
示例4: backend_manage_packages_thread
static void backend_manage_packages_thread(PkBackendJob *job, GVariant *params, gpointer user_data)
{
// Transaction flags
PkBitfield transaction_flags = 0;
gboolean allow_deps = false;
gboolean autoremove = false;
bool fileInstall = false;
gchar **full_paths = NULL;
gchar **package_ids = NULL;
// Get the transaction role since this method is called by install/remove/update/repair
PkRoleEnum role = pk_backend_job_get_role(job);
if (role == PK_ROLE_ENUM_INSTALL_FILES) {
g_variant_get(params, "(t^a&s)",
&transaction_flags,
&full_paths);
fileInstall = true;
} else if (role == PK_ROLE_ENUM_REMOVE_PACKAGES) {
g_variant_get(params, "(t^a&sbb)",
&transaction_flags,
&package_ids,
&allow_deps,
&autoremove);
} else if (role == PK_ROLE_ENUM_INSTALL_PACKAGES) {
g_variant_get(params, "(t^a&s)",
&transaction_flags,
&package_ids);
} else if (role == PK_ROLE_ENUM_UPDATE_PACKAGES) {
g_variant_get(params, "(t^a&s)",
&transaction_flags,
&package_ids);
}
// Check if we should only simulate the install (calculate dependencies)
bool simulate;
simulate = pk_bitfield_contain(transaction_flags, PK_TRANSACTION_FLAG_ENUM_SIMULATE);
// Check if we should only download all the required packages for this transaction
bool downloadOnly;
downloadOnly = pk_bitfield_contain(transaction_flags, PK_TRANSACTION_FLAG_ENUM_ONLY_DOWNLOAD);
// Check if we should fix broken packages
bool fixBroken = false;
if (role == PK_ROLE_ENUM_REPAIR_SYSTEM) {
// On fix broken mode no package to remove/install is allowed
fixBroken = true;
}
g_debug("FILE INSTALL: %i", fileInstall);
pk_backend_job_set_allow_cancel(job, true);
AptIntf *apt = static_cast<AptIntf*>(pk_backend_job_get_user_data(job));
if (!apt->init()) {
g_debug("Failed to create apt cache");
return;
}
pk_backend_job_set_status(job, PK_STATUS_ENUM_QUERY);
PkgList installPkgs, removePkgs;
if (fileInstall) {
// File installation EXPERIMENTAL
// GDebi can not install more than one package at time
if (g_strv_length(full_paths) > 1) {
pk_backend_job_error_code(job,
PK_ERROR_ENUM_NOT_SUPPORTED,
"The backend can only process one file at time.");
return;
}
// get the list of packages to install
if (!apt->markFileForInstall(full_paths[0], installPkgs, removePkgs)) {
return;
}
cout << "installPkgs.size: " << installPkgs.size() << endl;
cout << "removePkgs.size: " << removePkgs.size() << endl;
} else if (!fixBroken) {
// Resolve the given packages
if (role == PK_ROLE_ENUM_REMOVE_PACKAGES) {
removePkgs = apt->resolvePackageIds(package_ids);
} else {
installPkgs = apt->resolvePackageIds(package_ids);
}
if (removePkgs.size() == 0 && installPkgs.size() == 0) {
pk_backend_job_error_code(job,
PK_ERROR_ENUM_PACKAGE_NOT_FOUND,
"Could not find package(s)");
return;
}
}
// Install/Update/Remove packages, or just simulate
bool ret;
ret = apt->runTransaction(installPkgs,
removePkgs,
fileInstall, // Mark newly installed packages as auto-installed
//.........这里部分代码省略.........
示例5: backend_manage_packages_thread
static void backend_manage_packages_thread(PkBackendJob *job, GVariant *params, gpointer user_data)
{
// Transaction flags
PkBitfield transaction_flags = 0;
gboolean allow_deps = false;
gboolean autoremove = false;
bool fileInstall = false;
gchar **full_paths = NULL;
gchar **package_ids = NULL;
// Get the transaction role since this method is called by install/remove/update/repair
PkRoleEnum role = pk_backend_job_get_role(job);
if (role == PK_ROLE_ENUM_INSTALL_FILES) {
g_variant_get(params, "(t^a&s)",
&transaction_flags,
&full_paths);
fileInstall = true;
} else if (role == PK_ROLE_ENUM_REMOVE_PACKAGES) {
g_variant_get(params, "(t^a&sbb)",
&transaction_flags,
&package_ids,
&allow_deps,
&autoremove);
} else if (role == PK_ROLE_ENUM_INSTALL_PACKAGES) {
g_variant_get(params, "(t^a&s)",
&transaction_flags,
&package_ids);
} else if (role == PK_ROLE_ENUM_UPDATE_PACKAGES) {
g_variant_get(params, "(t^a&s)",
&transaction_flags,
&package_ids);
}
// Check if we should only simulate the install (calculate dependencies)
bool simulate;
simulate = pk_bitfield_contain(transaction_flags, PK_TRANSACTION_FLAG_ENUM_SIMULATE);
// Check if we should only download all the required packages for this transaction
bool downloadOnly;
downloadOnly = pk_bitfield_contain(transaction_flags, PK_TRANSACTION_FLAG_ENUM_ONLY_DOWNLOAD);
// Check if we should fix broken packages
bool fixBroken = false;
if (role == PK_ROLE_ENUM_REPAIR_SYSTEM) {
// On fix broken mode no package to remove/install is allowed
fixBroken = true;
}
pk_backend_job_set_allow_cancel(job, true);
AptIntf *apt = static_cast<AptIntf*>(pk_backend_job_get_user_data(job));
if (!apt->init(full_paths)) {
g_debug("Failed to create apt cache");
return;
}
pk_backend_job_set_status(job, PK_STATUS_ENUM_QUERY);
PkgList installPkgs, removePkgs, updatePkgs;
if (!fixBroken) {
// Resolve the given packages
if (role == PK_ROLE_ENUM_REMOVE_PACKAGES) {
removePkgs = apt->resolvePackageIds(package_ids);
} else if (role == PK_ROLE_ENUM_INSTALL_PACKAGES) {
installPkgs = apt->resolvePackageIds(package_ids);
} else if (role == PK_ROLE_ENUM_UPDATE_PACKAGES) {
updatePkgs = apt->resolvePackageIds(package_ids);
} else if (role == PK_ROLE_ENUM_INSTALL_FILES) {
installPkgs = apt->resolveLocalFiles(full_paths);
} else {
pk_backend_job_error_code(job,
PK_ERROR_ENUM_PACKAGE_NOT_FOUND,
"Could not figure out what to do to apply the change.");
return;
}
if (removePkgs.size() == 0 && installPkgs.size() == 0 && updatePkgs.size() == 0) {
pk_backend_job_error_code(job,
PK_ERROR_ENUM_PACKAGE_NOT_FOUND,
"Could not find package(s)");
return;
}
}
// Install/Update/Remove packages, or just simulate
bool ret = apt->runTransaction(installPkgs,
removePkgs,
updatePkgs,
fixBroken,
transaction_flags,
autoremove);
if (!ret) {
// Print transaction errors
g_debug("AptIntf::runTransaction() failed: %i", _error->PendingError());
return;
}
}