1 /*#############################################################################
3 # Pakfire - The IPFire package management system #
4 # Copyright (C) 2013 Pakfire development team #
6 # This program is free software: you can redistribute it and/or modify #
7 # it under the terms of the GNU General Public License as published by #
8 # the Free Software Foundation, either version 3 of the License, or #
9 # (at your option) any later version. #
11 # This program is distributed in the hope that it will be useful, #
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
14 # GNU General Public License for more details. #
16 # You should have received a copy of the GNU General Public License #
17 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
19 #############################################################################*/
21 #include <solv/transaction.h>
23 #include <pakfire/package.h>
24 #include <pakfire/packagelist.h>
25 #include <pakfire/step.h>
26 #include <pakfire/transaction.h>
27 #include <pakfire/types.h>
28 #include <pakfire/util.h>
30 PakfireTransaction
pakfire_transaction_create(PakfirePool pool
, Transaction
* trans
) {
31 PakfireTransaction transaction
= pakfire_calloc(1, sizeof(*transaction
));
32 transaction
->pool
= pool
;
34 // Clone the transaction, so we get independent from what ever called this.
36 transaction
->transaction
= transaction_create_clone(trans
);
37 transaction_order(transaction
->transaction
, 0);
39 transaction
->transaction
= transaction_create(trans
->pool
);
45 void pakfire_transaction_free(PakfireTransaction transaction
) {
46 transaction_free(transaction
->transaction
);
47 pakfire_free(transaction
);
50 int pakfire_transaction_count(PakfireTransaction transaction
) {
51 return transaction
->transaction
->steps
.count
;
54 int pakfire_transaction_installsizechange(PakfireTransaction transaction
) {
55 int sizechange
= transaction_calc_installsizechange(transaction
->transaction
);
56 printf("SIZECHANGE %d\n", sizechange
);
58 // Convert from kbytes to bytes
59 return sizechange
* 1024;
62 PakfireStep
pakfire_transaction_get_step(PakfireTransaction transaction
, int index
) {
63 Transaction
* trans
= transaction
->transaction
;
65 if (index
>= trans
->steps
.count
)
68 return pakfire_step_create(transaction
, trans
->steps
.elements
[index
]);
71 PakfirePackageList
pakfire_transaction_get_packages(PakfireTransaction transaction
, int type
) {
72 PakfirePool pool
= pakfire_transaction_pool(transaction
);
73 Transaction
* trans
= transaction
->transaction
;
75 PakfirePackageList packagelist
= pakfire_packagelist_create();
77 for (int i
= 0; i
< trans
->steps
.count
; i
++) {
78 Id p
= trans
->steps
.elements
[i
];
79 Id t
= transaction_type(trans
, p
,
80 SOLVER_TRANSACTION_SHOW_ACTIVE
|SOLVER_TRANSACTION_CHANGE_IS_REINSTALL
);
83 PakfirePackage package
= pakfire_package_create(pool
, p
);
84 pakfire_packagelist_push(packagelist
, package
);