Commit 9d6832a1 authored by Dario Freddi's avatar Dario Freddi

Now start the real fun

Signed-off-by: default avatarDario Freddi <drf@kde.org>
parent d1c02a14
......@@ -18,6 +18,7 @@ set(QT_MIN_VERSION "4.4.0")
find_package(Qt4 REQUIRED)
find_package(Sqlite REQUIRED)
find_package(LibArchive REQUIRED)
include_directories(
${QT_INCLUDES}
......
# - Try to find libarchive
# Once done this will define
#
# LIBARCHIVE_FOUND - system has libarchive
# LIBARCHIVE_INCLUDE_DIR - the libarchive include directory
# LIBARCHIVE_LIBRARY - Link this to use libarchive
#
# Copyright (c) 2006, Pino Toscano, <toscano.pino@tiscali.it>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
include(CheckLibraryExists)
if (LIBARCHIVE_LIBRARY AND LIBARCHIVE_INCLUDE_DIR)
# in cache already
set(LIBARCHIVE_FOUND TRUE)
else (LIBARCHIVE_LIBRARY AND LIBARCHIVE_INCLUDE_DIR)
find_path(LIBARCHIVE_INCLUDE_DIR archive.h
${GNUWIN32_DIR}/include
)
find_library(LIBARCHIVE_LIBRARY NAMES archive libarchive archive2 libarchive2
PATHS
${GNUWIN32_DIR}/lib
)
if (LIBARCHIVE_LIBRARY)
CHECK_LIBRARY_EXISTS(${LIBARCHIVE_LIBRARY} archive_write_set_compression_gzip "" HAVE_LIBARCHIVE_GZIP_SUPPORT)
endif (LIBARCHIVE_LIBRARY)
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibArchive DEFAULT_MSG LIBARCHIVE_INCLUDE_DIR LIBARCHIVE_LIBRARY HAVE_LIBARCHIVE_GZIP_SUPPORT)
# ensure that they are cached
set(LIBARCHIVE_INCLUDE_DIR ${LIBARCHIVE_INCLUDE_DIR} CACHE INTERNAL "The libarchive include path")
set(LIBARCHIVE_LIBRARY ${LIBARCHIVE_LIBRARY} CACHE INTERNAL "The libraries needed to use libarchive")
endif (LIBARCHIVE_LIBRARY AND LIBARCHIVE_INCLUDE_DIR)
......@@ -29,6 +29,7 @@ set_target_properties(akabeicore PROPERTIES VERSION ${MAJOR_AKABEI_VERSION}.${MI
target_link_libraries(akabeicore
${QT_QTCORE_LIBRARY}
${SQLITE_LIBRARIES}
${LIBARCHIVE_LIBRARY}
)
add_subdirectory(benchmarks)
\ No newline at end of file
......@@ -136,4 +136,19 @@ void Operation::setSubOperations(const List &operations)
d->children = operations;
}
void Operation::setProgress(int percentage)
{
}
void Operation::setFinished(bool result)
{
}
void Operation::setValidationFinished(bool result)
{
}
}
......@@ -78,13 +78,14 @@ protected:
void setFileSystemRemovals(const QStringList &targets);
void setConflictingTargets(const QStringList &targets);
void setError(Error *error);
void setSubOperations(const List &operations);
void setProgress(int percentage);
void setValidationFinished(bool result);
void setFinished(bool result);
private:
OperationPrivate * const d_ptr;
......
......@@ -121,7 +121,7 @@ QString Package::pathToArchive() const
}
QStringList Package::providers() const
QStringList Package::provides() const
{
}
......
......@@ -61,7 +61,10 @@ public:
List computeDependsOn();
List computeRequiredBy();
QList<Group*> groups() const;
QStringList providers() const;
QStringList provides() const;
QStringList conflictsWith() const;
Database *database();
bool isValid() const;
......
......@@ -12,17 +12,29 @@
#include "akabeipackage.h"
#include <QFile>
#include <archive.h>
#include <archive_entry.h>
namespace Akabei {
class PlainInstallOperation::Private
{
public:
Private(Package *p) : package(p) {}
~Private() {}
Package *package;
};
PlainInstallOperation::PlainInstallOperation(Package *package)
: Operation(package->name())
, d(new Private)
, d(new Private(package))
{
setPhase(Phase3); // Installation happens in phase 3.
setPriority(50); // Installation has a low priority.
setCanBeConcurrent(false); // And of course, it can not be concurrent.
}
PlainInstallOperation::~PlainInstallOperation()
......@@ -37,7 +49,45 @@ void PlainInstallOperation::run()
void PlainInstallOperation::validate()
{
// Validate the operation. First, let's check if the archive actually exists and it's valid
if (!QFile::exists(d->package->pathToArchive())) {
// Utter fail.
setValidationFinished(false);
return;
}
// Ok, now let's check that we are actually able to load the archive.
struct archive *a;
struct archive_entry *entry;
int r;
a = archive_read_new();
archive_read_support_compression_all(a);
archive_read_support_format_all(a);
r = archive_read_open_filename(a, d->package->pathToArchive().toUtf8().data(), 10240); // Note 1
if (r != ARCHIVE_OK) {
// Utter fail.
setValidationFinished(false);
return;
}
bool found = false;
while (archive_read_next_header(a, &entry) == ARCHIVE_OK) {
if (archive_entry_pathname(entry) == ".PKGINFO") {
}
archive_read_data_skip(a); // Note 2
}
r = archive_read_finish(a); // Note 3
if (!found) {
// Utter fail.
setValidationFinished(false);
return;
}
// 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());
}
}
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