Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
Chakra
Akabei
Akabei frontend
Commits
745374b3
Commit
745374b3
authored
Apr 20, 2011
by
Lukas Appelhans
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Now there we got with basic removing
parent
046609cd
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
246 additions
and
13 deletions
+246
-13
CMakeLists.txt
CMakeLists.txt
+1
-1
apm.cpp
apm.cpp
+6
-0
apm.h
apm.h
+8
-2
main.cpp
main.cpp
+18
-0
removeoperation.cpp
removeoperation.cpp
+135
-0
removeoperation.h
removeoperation.h
+34
-0
syncoperation.cpp
syncoperation.cpp
+43
-10
syncoperation.h
syncoperation.h
+1
-0
No files found.
CMakeLists.txt
View file @
745374b3
...
...
@@ -15,7 +15,7 @@ include_directories(${QT_INCLUDES}
${
AKABEICLIENT_INCLUDE_DIR
}
${
AKABEICORE_INCLUDE_DIR
}
)
set
(
apm_SRCS syncoperation.cpp apm.cpp queryoperation.cpp main.cpp
)
set
(
apm_SRCS
removeoperation.cpp
syncoperation.cpp apm.cpp queryoperation.cpp main.cpp
)
#qt4_automoc(${guzuta_SRCS})
kde4_add_executable
(
akabei
${
apm_SRCS
}
)
target_link_libraries
(
akabei
${
KDE4_KDEUI_LIBRARY
}
${
KDE4_KIO_LIBRARY
}
${
AKABEICLIENT_LIBRARIES
}
)
apm.cpp
View file @
745374b3
...
...
@@ -11,6 +11,7 @@
#include "queryoperation.h"
#include "syncoperation.h"
#include "removeoperation.h"
#include <akabeiclient/akabeiclientbackend.h>
...
...
@@ -52,6 +53,11 @@ void APM::start()
query
->
start
(
m_operations
,
m_args
);
break
;
}
case
RemoveOperationType
:
{
RemoveOperation
*
remove
=
new
RemoveOperation
(
this
);
remove
->
start
(
m_operations
,
m_options
,
m_args
);
break
;
}
case
SyncOperationType
:
{
SyncOperation
*
sync
=
new
SyncOperation
(
this
);
sync
->
start
(
m_operations
,
m_options
,
m_args
);
...
...
apm.h
View file @
745374b3
...
...
@@ -48,7 +48,7 @@ public:
AsExplicit
,
RemoveOldPackages
,
RemoveAllPackages
,
SkipDependencyCheck
,
SkipDependencyCheck
,
//Also in Remove
Force
,
ListRepo
,
Search
,
...
...
@@ -57,7 +57,13 @@ public:
Ignore
,
IgnoreGroup
,
UpdateDatabases
,
UpdateSystem
UpdateSystem
,
///Remove operations
Cascade
,
DatabaseOnly
,
RemoveConfig
,
Recursive
,
Unneeded
};
explicit
APM
(
OperationType
type
,
QList
<
Operation
>
operations
,
QMultiHash
<
Operation
,
QString
>
options
,
QStringList
args
,
QObject
*
parent
=
0
);
virtual
~
APM
();
...
...
main.cpp
View file @
745374b3
...
...
@@ -47,6 +47,12 @@ int main(int argc, char** argv)
options
.
add
(
"q"
,
ki18n
(
"Shows less information in queries and searches"
));
options
.
add
(
"R"
,
ki18n
(
"Remove operation"
));
options
.
add
(
"c"
,
ki18n
(
"Removes all packages and those depending on them"
));
options
.
add
(
"d"
,
ki18n
(
"Skip dependency check"
));
options
.
add
(
"k"
,
ki18n
(
"Only remove database entries"
));
options
.
add
(
"n"
,
ki18n
(
"Also remove configuration files"
));
options
.
add
(
"s"
,
ki18n
(
"Remove dependencies as well. (-ss includes explicitely installed dependencies"
));
options
.
add
(
"u"
,
ki18n
(
"Removes not used packages"
));
options
.
add
(
"S"
,
ki18n
(
"Sync operation"
));
options
.
add
(
"asdeps"
,
ki18n
(
"Install all packages as non-explicit"
));
...
...
@@ -120,6 +126,18 @@ int main(int argc, char** argv)
list
.
append
(
APM
::
ShowLess
);
}
else
if
(
args
->
isSet
(
"R"
))
{
type
=
APM
::
RemoveOperationType
;
if
(
args
->
isSet
(
"c"
))
list
.
append
(
APM
::
Cascade
);
if
(
args
->
isSet
(
"d"
))
list
.
append
(
APM
::
SkipDependencyCheck
);
if
(
args
->
isSet
(
"k"
))
list
.
append
(
APM
::
DatabaseOnly
);
if
(
args
->
isSet
(
"n"
))
list
.
append
(
APM
::
RemoveConfig
);
if
(
args
->
isSet
(
"s"
))
list
.
append
(
APM
::
Recursive
);
if
(
args
->
isSet
(
"u"
))
list
.
append
(
APM
::
Unneeded
);
}
else
if
(
args
->
isSet
(
"S"
))
{
type
=
APM
::
SyncOperationType
;
if
(
args
->
isSet
(
"asdeps"
))
...
...
removeoperation.cpp
0 → 100644
View file @
745374b3
/* This file is part of the Chakra project
Copyright (C) 2011 Lukas Appelhans
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
*/
#include "removeoperation.h"
#include "apm.h"
#include <akabeiclientbackend.h>
#include <qtextstream.h>
#include <akabeidatabase.h>
#include <akabeiclientqueue.h>
#include <akabeiclienttransactionhandler.h>
#include <kdebug.h>
#include <kio/global.h>
RemoveOperation
::
RemoveOperation
(
QObject
*
parent
)
:
QObject
(
parent
)
{
}
RemoveOperation
::~
RemoveOperation
()
{
}
void
RemoveOperation
::
start
(
QList
<
APM
::
Operation
>
operations
,
QMultiHash
<
APM
::
Operation
,
QString
>
options
,
QStringList
args
)
{
if
(
operations
.
contains
(
APM
::
DatabaseOnly
))
{
}
else
{
QString
query
=
"SELECT * FROM packages WHERE"
;
foreach
(
const
QString
&
pkg
,
args
)
{
query
=
query
+
" Name LIKE
\"
"
+
pkg
+
"
\"
"
;
if
(
args
.
last
()
!=
pkg
)
query
=
query
+
" OR"
;
}
remove
(
Akabei
::
Backend
::
instance
()
->
localDatabase
()
->
queryPackages
(
query
));
}
}
void
RemoveOperation
::
remove
(
QList
<
Akabei
::
Package
*>
packages
)
{
QTextStream
out
(
stdout
);
foreach
(
Akabei
::
Package
*
pkg
,
packages
)
{
AkabeiClient
::
Backend
::
instance
()
->
queue
()
->
addPackage
(
pkg
,
AkabeiClient
::
Remove
);
}
connect
(
AkabeiClient
::
Backend
::
instance
()
->
transactionHandler
(),
SIGNAL
(
validationFinished
(
bool
)),
SLOT
(
validationFinished
(
bool
)));
connect
(
AkabeiClient
::
Backend
::
instance
()
->
transactionHandler
(),
SIGNAL
(
errorsOccurred
(
QList
<
Akabei
::
Error
*>&
)),
SLOT
(
errors
(
QList
<
Akabei
::
Error
*>&
)));
AkabeiClient
::
Backend
::
instance
()
->
transactionHandler
()
->
validate
();
}
void
RemoveOperation
::
errors
(
QList
<
Akabei
::
Error
*>&
errors
)
{
kDebug
()
<<
"yoyoyo"
;
QTextStream
out
(
stdout
);
out
<<
"Errors occurred: "
<<
endl
;
foreach
(
Akabei
::
Error
*
err
,
errors
)
{
out
<<
err
->
description
()
<<
endl
;
}
out
.
flush
();
}
void
RemoveOperation
::
validationFinished
(
bool
valid
)
{
QTextStream
out
(
stdout
);
if
(
!
valid
)
{
//foreach (Akabei::Operation * op, Akabei::Backend::instance()->operationRunner()->operations()) {
//kDebug() << op->fileSystemRemovals();
//}
out
<<
"Queue not valid"
<<
endl
;
out
.
flush
();
return
;
}
int
removeSize
=
0
;
out
<<
"Packages: "
;
foreach
(
AkabeiClient
::
QueueItem
*
item
,
AkabeiClient
::
Backend
::
instance
()
->
queue
()
->
items
())
{
if
(
item
!=
AkabeiClient
::
Backend
::
instance
()
->
queue
()
->
items
().
first
())
out
<<
", "
;
out
<<
item
->
package
()
->
name
();
removeSize
+=
item
->
package
()
->
installedSize
();
if
(
item
->
action
()
==
AkabeiClient
::
Remove
)
{
//FIXME: Why this?
foreach
(
Akabei
::
Package
*
dep
,
item
->
requiredByTree
())
{
out
<<
", "
<<
dep
->
name
();
removeSize
+=
dep
->
installedSize
();
}
}
}
out
<<
endl
<<
endl
;
out
<<
"Size of packages about to be removed: "
<<
KIO
::
convertSize
(
removeSize
)
<<
endl
;
out
.
flush
();
out
<<
"Continue with installation?[y/n]"
;
out
.
flush
();
//std::string input;
//getline(std::cin, input);
//if (input != "y")
// return;
kDebug
()
<<
"Let's remove"
;
connect
(
AkabeiClient
::
Backend
::
instance
()
->
transactionHandler
(),
SIGNAL
(
progressChanged
(
int
)),
SLOT
(
showProgress
(
int
)));
connect
(
AkabeiClient
::
Backend
::
instance
()
->
transactionHandler
(),
SIGNAL
(
finished
()),
SLOT
(
finished
()));
Akabei
::
ProcessingOptions
options
;
AkabeiClient
::
Backend
::
instance
()
->
transactionHandler
()
->
process
(
options
);
}
void
RemoveOperation
::
showProgress
(
int
progress
)
{
QTextStream
out
(
stdout
);
out
.
reset
();
out
<<
" ["
;
for
(
int
i
=
1
;
i
!=
11
;
i
++
)
{
if
(
progress
/
i
>=
10
)
{
out
<<
"#"
;
}
else
{
out
<<
"-"
;
}
}
out
<<
"] "
<<
progress
<<
"%"
;
//FIXME
if
(
progress
==
100
)
{
out
<<
endl
;
}
else
{
out
<<
"
\r
"
;
}
out
.
flush
();
}
void
RemoveOperation
::
finished
()
{
QTextStream
out
(
stdout
);
out
<<
"The transaction finished!"
<<
endl
;
}
removeoperation.h
0 → 100644
View file @
745374b3
/* This file is part of the Chakra project
Copyright (C) 2011 Lukas Appelhans
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
*/
#ifndef REMOVEOPERATION_H
#define REMOVEOPERATION_H
#include <QObject>
#include "apm.h"
#include <akabeierror.h>
class
RemoveOperation
:
public
QObject
{
Q_OBJECT
public:
RemoveOperation
(
QObject
*
parent
=
0
);
virtual
~
RemoveOperation
();
void
start
(
QList
<
APM
::
Operation
>
operations
,
QMultiHash
<
APM
::
Operation
,
QString
>
options
,
QStringList
args
);
public
slots
:
void
remove
(
QList
<
Akabei
::
Package
*>
);
void
validationFinished
(
bool
valid
);
void
errors
(
QList
<
Akabei
::
Error
*>&
errors
);
void
showProgress
(
int
progress
);
void
finished
();
};
#endif // REMOVEOPERATION_H
syncoperation.cpp
View file @
745374b3
...
...
@@ -14,6 +14,7 @@
#include <akabeipackage.h>
#include <akabeidatabase.h>
#include <akabeiclientbackend.h>
#include <akabeiconfig.h>
#include <klocale.h>
#include <QTextStream>
#include <QDateTime>
...
...
@@ -21,10 +22,14 @@
#include <akabeigroup.h>
#include <kdebug.h>
#include <QCoreApplication>
#include <QFile>
#include <QDir>
#include <akabeiclientqueue.h>
#include <akabeiclienttransactionhandler.h>
#include <iostream>
#include <kio/global.h>
#include <akabeioperation.h>
#include <akabeioperationrunner.h>
SyncOperation
::
SyncOperation
(
QObject
*
parent
)
:
QObject
(
parent
),
...
...
@@ -87,7 +92,7 @@ void SyncOperation::start(QList<APM::Operation> operations, QMultiHash<APM::Oper
void
SyncOperation
::
install
(
QUuid
,
QList
<
Akabei
::
Package
*
>
packages
)
{
QTextStream
out
(
stdout
);
Q
List
<
Akabei
::
Package
*>
toBeInstalled
;
Q
Map
<
QString
,
Akabei
::
Package
*>
toBeInstalled
;
QMap
<
QString
,
Akabei
::
Package
*>
local
;
foreach
(
Akabei
::
Package
*
pkg
,
packages
)
{
if
(
pkg
->
database
()
==
Akabei
::
Backend
::
instance
()
->
localDatabase
())
...
...
@@ -95,10 +100,11 @@ void SyncOperation::install(QUuid , QList< Akabei::Package* > packages)
}
foreach
(
Akabei
::
Package
*
pkg
,
packages
)
{
if
(
pkg
->
database
()
!=
Akabei
::
Backend
::
instance
()
->
localDatabase
())
{
if
(
local
[
pkg
->
name
()])
toBeInstalled
<<
local
[
pkg
->
name
()];
else
toBeInstalled
<<
pkg
;
//if (local[pkg->name()])
// toBeInstalled << local[pkg->name()];
//else
if
(
!
toBeInstalled
[
pkg
->
name
()]
||
toBeInstalled
[
pkg
->
name
()]
->
version
()
<
pkg
->
version
())
toBeInstalled
[
pkg
->
name
()]
=
pkg
;
}
}
if
(
!
toBeInstalled
.
count
())
...
...
@@ -127,7 +133,7 @@ void SyncOperation::install(QUuid , QList< Akabei::Package* > packages)
}
kDebug
()
<<
"Let's do this"
;
foreach
(
Akabei
::
Package
*
pkg
,
toBeInstalled
)
{
foreach
(
Akabei
::
Package
*
pkg
,
toBeInstalled
.
values
()
)
{
AkabeiClient
::
Backend
::
instance
()
->
queue
()
->
addPackage
(
pkg
,
AkabeiClient
::
Install
);
}
connect
(
AkabeiClient
::
Backend
::
instance
()
->
transactionHandler
(),
SIGNAL
(
validationFinished
(
bool
)),
SLOT
(
validationFinished
(
bool
)));
...
...
@@ -139,6 +145,9 @@ void SyncOperation::validationFinished(bool valid)
{
QTextStream
out
(
stdout
);
if
(
!
valid
)
{
foreach
(
Akabei
::
Operation
*
op
,
Akabei
::
Backend
::
instance
()
->
operationRunner
()
->
operations
())
{
//kDebug() << op->fileSystemRemovals();
}
out
<<
"Queue not valid"
<<
endl
;
out
.
flush
();
return
;
...
...
@@ -150,13 +159,13 @@ void SyncOperation::validationFinished(bool valid)
if
(
item
!=
AkabeiClient
::
Backend
::
instance
()
->
queue
()
->
items
().
first
())
out
<<
", "
;
out
<<
item
->
package
()
->
name
();
if
(
item
->
package
()
->
database
()
!=
Akabei
::
Backend
::
instance
()
->
localDatabase
())
if
(
item
->
package
()
->
database
()
!=
Akabei
::
Backend
::
instance
()
->
localDatabase
()
&&
!
QFile
::
exists
(
Akabei
::
Config
::
instance
()
->
cacheDir
().
absoluteFilePath
(
item
->
package
()
->
filename
()))
)
downloadSize
+=
item
->
package
()
->
size
();
installSize
+=
item
->
package
()
->
installedSize
();
if
(
item
->
action
()
==
AkabeiClient
::
Install
)
{
if
(
item
->
action
()
==
AkabeiClient
::
Install
)
{
//FIXME: Why this?
foreach
(
Akabei
::
Package
*
dep
,
item
->
dependencyTree
())
{
out
<<
", "
<<
dep
->
name
();
if
(
dep
->
database
()
!=
Akabei
::
Backend
::
instance
()
->
localDatabase
())
if
(
dep
->
database
()
!=
Akabei
::
Backend
::
instance
()
->
localDatabase
()
&&
!
QFile
::
exists
(
Akabei
::
Config
::
instance
()
->
cacheDir
().
absoluteFilePath
(
dep
->
filename
()))
)
downloadSize
+=
dep
->
size
();
installSize
+=
dep
->
installedSize
();
}
...
...
@@ -175,13 +184,37 @@ void SyncOperation::validationFinished(bool valid)
// return;
kDebug
()
<<
"Let's install"
;
connect
(
AkabeiClient
::
Backend
::
instance
()
->
transactionHandler
(),
SIGNAL
(
progressChanged
(
int
)),
SLOT
(
showProgress
(
int
)));
connect
(
AkabeiClient
::
Backend
::
instance
()
->
transactionHandler
(),
SIGNAL
(
finished
()),
SLOT
(
finished
()));
Akabei
::
ProcessingOptions
options
;
AkabeiClient
::
Backend
::
instance
()
->
transactionHandler
()
->
process
(
options
);
}
void
SyncOperation
::
showProgress
(
int
progress
)
{
kDebug
()
<<
progress
;
QTextStream
out
(
stdout
);
out
.
reset
();
out
<<
qSetFieldWidth
(
maxDbNameLenght
)
<<
static_cast
<
AkabeiClient
::
DatabaseHandler
*>
(
QObject
::
sender
())
->
name
()
<<
qSetFieldWidth
(
0
);
out
<<
" ["
;
for
(
int
i
=
1
;
i
!=
11
;
i
++
)
{
if
(
progress
/
i
>=
10
)
{
out
<<
"#"
;
}
else
{
out
<<
"-"
;
}
}
out
<<
"] "
<<
progress
<<
"%"
;
//FIXME
if
(
progress
==
100
)
{
out
<<
endl
;
}
else
{
out
<<
"
\r
"
;
}
out
.
flush
();
}
void
SyncOperation
::
finished
()
{
QTextStream
out
(
stdout
);
out
<<
"The transaction finished!"
<<
endl
;
}
void
SyncOperation
::
errors
(
QList
<
Akabei
::
Error
*>&
errors
)
...
...
syncoperation.h
View file @
745374b3
...
...
@@ -38,6 +38,7 @@ private slots:
void
validationFinished
(
bool
valid
);
void
showProgress
(
int
);
void
errors
(
QList
<
Akabei
::
Error
*>&
errors
);
void
finished
();
private:
int
currentDatabasePos
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment