#include <solv/pooltypes.h>
-#include <pakfire/transaction.h>
#include <pakfire/types.h>
-typedef enum _pakfire_step_types {
- PAKFIRE_STEP_IGNORE = 0,
- PAKFIRE_STEP_INSTALL,
- PAKFIRE_STEP_REINSTALL,
- PAKFIRE_STEP_ERASE,
- PAKFIRE_STEP_UPGRADE,
- PAKFIRE_STEP_DOWNGRADE,
- PAKFIRE_STEP_OBSOLETE,
-} pakfire_step_type_t;
-
PakfireStep pakfire_step_create(PakfireTransaction transaction, Id id);
void pakfire_step_free(PakfireStep step);
ssize_t pakfire_transaction_installsizechange(PakfireTransaction transaction);
PakfireStep pakfire_transaction_get_step(PakfireTransaction transaction, int index);
-PakfirePackageList pakfire_transaction_get_packages(PakfireTransaction transaction, int type);
+PakfirePackageList pakfire_transaction_get_packages(PakfireTransaction transaction, pakfire_step_type_t type);
char* pakfire_transaction_dump(PakfireTransaction transaction, size_t width);
#ifdef PAKFIRE_PRIVATE
-typedef enum _pakfire_action_types {
- PAKFIRE_ACTION_NOOP = 0,
- PAKFIRE_ACTION_VERIFY = 1 << 0,
- PAKFIRE_ACTION_EXECUTE = 1 << 1,
- PAKFIRE_ACTION_PRETRANS = 1 << 2,
- PAKFIRE_ACTION_POSTTRANS = 1 << 3,
-} pakfire_action_type;
-
Transaction* pakfire_transaction_get_transaction(PakfireTransaction transaction);
#endif
PAKFIRE_GLOB = 1 << 12,
};
+typedef enum _pakfire_action_types {
+ PAKFIRE_ACTION_NOOP = 0,
+ PAKFIRE_ACTION_VERIFY = 1 << 0,
+ PAKFIRE_ACTION_EXECUTE = 1 << 1,
+ PAKFIRE_ACTION_PRETRANS = 1 << 2,
+ PAKFIRE_ACTION_POSTTRANS = 1 << 3,
+} pakfire_action_type;
+
+typedef enum _pakfire_step_types {
+ PAKFIRE_STEP_IGNORE = 0,
+ PAKFIRE_STEP_INSTALL,
+ PAKFIRE_STEP_REINSTALL,
+ PAKFIRE_STEP_ERASE,
+ PAKFIRE_STEP_UPGRADE,
+ PAKFIRE_STEP_DOWNGRADE,
+ PAKFIRE_STEP_OBSOLETE,
+} pakfire_step_type_t;
+
#define PAKFIRE_SOLVABLE_FILEMARKER "solvable:filemarker"
#endif /* PAKFIRE_TYPES_H */
PAKFIRE_EXPORT ssize_t pakfire_transaction_downloadsize(PakfireTransaction transaction) {
ssize_t size = 0;
- for (int i = 0; i < transaction->transaction->steps.count; i++) {
- Id p = transaction->transaction->steps.elements[i];
- Id t = transaction_type(transaction->transaction, p,
- SOLVER_TRANSACTION_SHOW_OBSOLETES |
- SOLVER_TRANSACTION_CHANGE_IS_REINSTALL |
- SOLVER_TRANSACTION_SHOW_ALL |
- SOLVER_TRANSACTION_SHOW_ACTIVE);
-
- // Erasing a package does not require us to download it
- if (t == SOLVER_TRANSACTION_ERASE)
- continue;
-
- // Get the package for this step
- PakfirePackage pkg = pakfire_package_create(transaction->pool, p);
-
- if (!pakfire_package_is_cached(pkg))
- size += pakfire_package_get_downloadsize(pkg);
+ size_t steps = pakfire_transaction_count(transaction);
+ for (unsigned int i = 0; i < steps; i++) {
+ PakfireStep step = pakfire_transaction_get_step(transaction, i);
+ size += pakfire_step_get_downloadsize(step);
- pakfire_package_free(pkg);
+ pakfire_step_free(step);
}
return size;
return pakfire_step_create(transaction, trans->steps.elements[index]);
}
-PAKFIRE_EXPORT PakfirePackageList pakfire_transaction_get_packages(PakfireTransaction transaction, int type) {
+PAKFIRE_EXPORT PakfirePackageList pakfire_transaction_get_packages(PakfireTransaction transaction, pakfire_step_type_t type) {
PakfirePackageList packagelist = pakfire_packagelist_create();
- for (int i = 0; i < transaction->transaction->steps.count; i++) {
- Id p = transaction->transaction->steps.elements[i];
- Id t = transaction_type(transaction->transaction, p,
- SOLVER_TRANSACTION_SHOW_OBSOLETES |
- SOLVER_TRANSACTION_CHANGE_IS_REINSTALL |
- SOLVER_TRANSACTION_SHOW_ALL |
- SOLVER_TRANSACTION_SHOW_ACTIVE);
+ size_t steps = pakfire_transaction_count(transaction);
+ for (unsigned int i = 0; i < steps; i++) {
+ PakfireStep step = pakfire_transaction_get_step(transaction, i);
- if (t == type) {
- PakfirePackage package = pakfire_package_create(transaction->pool, p);
+ if (pakfire_step_get_type(step) == type) {
+ PakfirePackage package = pakfire_step_get_package(step);
pakfire_packagelist_push(packagelist, package);
+
+ pakfire_package_free(package);
}
+
+ pakfire_step_free(step);
}
// Sort list in place