Commit 4deee045 authored by Dario Freddi's avatar Dario Freddi

Move on by creating a libarchive helper class, which has been taken from pacman

Signed-off-by: default avatarDario Freddi <drf@kde.org>
parent 9d6832a1
......@@ -6,8 +6,10 @@ include_directories(
set(AKABEI_CORE_SRCS
akabeibackend.cpp
akabeiconfig.cpp
akabeidatabase.cpp
akabeigroup.cpp
akabeilibarchivehelper.cpp
akabeioperation.cpp
akabeioperationrunner.cpp
akabeipackage.cpp
......
/* This file is part of the Chakra project
Copyright (C) 2010 Dario Freddi <drf@chakra-project.org>
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 "akabeiconfig.h"
#include <qglobal.h>
namespace Akabei
{
class Config::Private
{
public:
Private() : root('/') {}
~Private() {}
QString root;
};
class ConfigHelper
{
public:
ConfigHelper() : q(0) {}
~ConfigHelper() {
delete q;
}
Config *q;
};
Q_GLOBAL_STATIC(ConfigHelper, s_globalConfig)
Config *Config::instance()
{
if (!s_globalConfig()->q) {
new Config;
}
return s_globalConfig()->q;
}
Config::Config()
: d(new Private())
{
Q_ASSERT(!s_globalConfig()->q);
s_globalConfig()->q = this;
}
Config::~Config()
{
delete d;
}
QString Config::root() const
{
return d->root;
}
void Config::setRoot(const QString& root)
{
d->root = root;
}
}
/* This file is part of the Chakra project
Copyright (C) 2010 Dario Freddi <drf@chakra-project.org>
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 AKABEI_AKABEICONFIG_H
#define AKABEI_AKABEICONFIG_H
#include <QtCore/QString>
namespace Akabei {
class Config
{
public:
static Config *instance();
~Config();
QString root() const;
void setRoot(const QString &root);
private:
Config();
class Private;
Private * const d;
};
}
#endif // AKABEI_AKABEICONFIG_H
This diff is collapsed.
/* This file is part of the Chakra project
Copyright (C) 2010 Dario Freddi <drf@chakra-project.org>
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 AKABEI_AKABEILIBARCHIVEHELPER_H
#define AKABEI_AKABEILIBARCHIVEHELPER_H
namespace Akabei {
namespace LibArchiveHelper
{
static int extract_single_file(struct archive *archive, struct archive_entry *entry);
};
}
#endif // AKABEI_AKABEILIBARCHIVEHELPER_H
......@@ -64,6 +64,16 @@ Operation::Status Operation::status() const
return d->status;
}
QStringList Operation::targetAdditions() const
{
}
QStringList Operation::targetRemovals() const
{
}
QStringList Operation::fileSystemAdditions() const
{
Q_D(const Operation);
......@@ -124,6 +134,21 @@ void Operation::setConflictingTargets(const QStringList &targets)
d->conflictingTargets = targets;
}
void Operation::setTargetDependencies(const QStringList& targets)
{
}
void Operation::setTargetAdditions(const QStringList& targets)
{
}
void Operation::setTargetRemovals(const QStringList& targets)
{
}
void Operation::setError(Error *error)
{
Q_D(Operation);
......
......@@ -61,8 +61,13 @@ public:
QStringList fileSystemAdditions() const;
QStringList fileSystemRemovals() const;
QStringList targetAdditions() const;
QStringList targetRemovals() const;
List subOperations() const;
//OperationRunner *runner();
protected:
explicit Operation(const QString &targetName);
......@@ -77,6 +82,11 @@ protected:
void setFileSystemAdditions(const QStringList &targets);
void setFileSystemRemovals(const QStringList &targets);
void setTargetAdditions(const QStringList &targets);
void setTargetRemovals(const QStringList &targets);
void setTargetDependencies(const QStringList &targets);
void setConflictingTargets(const QStringList &targets);
void setError(Error *error);
......
......@@ -24,10 +24,17 @@ public:
QUuid uuid;
bool canBeConcurrent;
QStringList conflictingTargets;
QStringList deps;
Operation::Phase phase;
int priority;
QStringList fileSystemAdditions;
QStringList fileSystemRemovals;
QStringList targetAdditions;
QStringList targetRemovals;
Operation::Status status;
Error *error;
Operation::List children;
......
......@@ -40,7 +40,27 @@ QDateTime Package::buildDate() const
return d->buildDate;
}
Package::List Package::computeDependsOn()
QString Package::retrieveChangelog() const
{
}
QString Package::retrieveLoggedActions() const
{
}
QStringList Package::conflictsWith() const
{
}
QStringList Package::computeUnresolvedDependencies()
{
}
Package::List Package::computeDependencies()
{
}
......
......@@ -58,7 +58,9 @@ public:
QStringList files() const;
QStringList hooks() const;
List computeDependsOn();
QStringList computeUnresolvedDependencies();
List computeDependencies();
List computeRequiredBy();
QList<Group*> groups() const;
......
......@@ -44,7 +44,7 @@ PlainInstallOperation::~PlainInstallOperation()
void PlainInstallOperation::run()
{
// Run it.
}
void PlainInstallOperation::validate()
......@@ -88,6 +88,37 @@ void PlainInstallOperation::validate()
// Ok, the archive is valid. Now let's set the conflicting targets & stuff.
// Since this is an installation, we're adding stuff to the filesystem
setFileSystemAdditions(d->package->files());
// Add conflicts
setConflictingTargets(d->package->conflictsWith());
// Add addition targets
QStringList targets = QStringList() << d->package->name() << d->package->provides();
targets.removeDuplicates();
setTargetAdditions(targets);
// If it has a scriptlet, we need a new suboperation
if (d->package->hasScriptlet()) {
//TODO: add scriptlet
}
// Compute dependencies and stuff
// Any unresolved dependencies?
if (!d->package->computeUnresolvedDependencies().isEmpty()) {
// Utter fail.
setValidationFinished(false);
return;
}
Package::List depends = d->package->computeDependencies();
QStringList stringDeps;
foreach (Package *p, depends) {
stringDeps << p->name();
}
setTargetDependencies(stringDeps);
// Ok, validated!
setValidationFinished(true);
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment