4 * Copyright (c) 2007 VOROSKOI Andras <voroskoi@frugalware.org>
6 * Copyright: See COPYING file that comes with this distribution.
12 #include "kfpm_pacman.h"
14 QValueVector
<PM_DB
*> pm_dblist
;
16 FPM::FPM(char *root
, char *configfile
) {
17 pacman_init(root
, configfile
);
18 LocalDB
= pacman_db_register((char*)"local");
23 std::cout
<< "FPM destructor called" << std::endl
;
26 void FPM::setSync(QValueVector
<PM_DB
*> syncs
)
31 QValueVector
<PM_DB
*> FPM::getSync(void) {
35 QStrList
FPM::sync_group(QValueVector
<PM_DB
*> syncs
)
38 for(QValueVector
<PM_DB
*>::iterator it
= syncs
.begin(); it
!= syncs
.end(); ++it
) {
40 for(lp
= pacman_db_getgrpcache(*it
); lp
; lp
= pacman_list_next(lp
)) {
41 grpnames
.append((char*)pacman_list_getdata(lp
));
47 QStrList
FPM::sync_group(QValueVector
<PM_DB
*> syncs
, QStrList
*targets
)
50 if (targets
->isEmpty()) {
54 for(char *target
= targets
->first(); target
; target
= targets
->next()) {
55 for(QValueVector
<PM_DB
*>::iterator jt
= syncs
.begin(); jt
!= syncs
.end(); ++jt
) {
56 PM_GRP
*grp
= pacman_db_readgrp(*jt
, target
);
58 for(packages
= (PM_LIST
*)pacman_grp_getinfo(grp
, PM_GRP_PKGNAMES
); packages
; packages
= pacman_list_next(packages
)) {
59 pkgnames
.append((char*)pacman_list_getdata(packages
));
66 void cb_db_register(char *section
, PM_DB
*db
)
68 pm_dblist
.push_back(db
);
71 void FPM::pacman_init(char *root
, char *configfile
)
73 pacman_initialize(root
);
74 /* FIXME - exception handling */
75 if(pacman_parse_config(configfile
, cb_db_register
, "") != 0) {
76 std::cerr
<< "failed to parse config (" << pacman_strerror(pm_errno
) << ")" << std::endl
;
81 /* FIXME - do i need this at all?
82 QStrList FPM::PM_LISTtoQStringList(PM_LIST* pmlist)
85 for(pmlist = pacman_list_next(pmlist); pmlist; pmlist = pacman_list_next(pmlist)) {
86 stringlist.append((char*)pacman_list_getdata(pmlist));
91 QString
FPM::PM_LISTtoQString(PM_LIST
* pmlist
) {
93 for (pmlist
= pacman_list_first(pmlist
); pmlist
; pmlist
= pacman_list_next(pmlist
)) {
94 string
+= (char*)pacman_list_getdata(pmlist
);
100 int FPM::sync_synctree(int force
, QValueVector
<PM_DB
*> syncs
) {
101 std::cout
<< "FPM::sync_synctree called\n";
103 for(QValueVector
<PM_DB
*>::iterator it
= syncs
.begin(); it
!= syncs
.end(); ++it
) {
104 // FIXME - check return values for all db - exceptions
105 ret
= pacman_db_update (force
, *it
);
110 int FPM::sync_upgrade() {
111 std::cout
<< "FPM::sync_upgrade called\n";
112 // FIXME - pff, quite shitty atm
113 if(pacman_trans_init(PM_TRANS_TYPE_SYNC
, 0, NULL
, NULL
, NULL
) == -1) {
114 std::cout
<< "pacman_trans_init failed";
117 if (pacman_trans_sysupgrade() == -1) {
118 std::cout
<< "pacman_trans_sysupgrade failed";
121 if (pacman_trans_release() == -1) {
122 std::cout
<< "pacman_trans_release failed";
128 // vim: sw=4 ts=4 noet