summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Nicoletti <dantti12@gmail.com>2012-04-22 12:15:22 -0300
committerDaniel Nicoletti <dantti12@gmail.com>2012-04-22 12:15:22 -0300
commit311255d4a62678bd35b21304b3793ff8e4bbe8bc (patch)
treee3333e74eb41f548a08db5a3a0f431d0f92b82fd
parent4b529d627b1d133b81f766296fe8ad6ce78ab380 (diff)
aptcc: Cleanup includes
-rw-r--r--backends/aptcc/AptCacheFile.cpp5
-rw-r--r--backends/aptcc/AptCacheFile.h5
-rw-r--r--backends/aptcc/acqpkitstatus.cpp12
-rw-r--r--backends/aptcc/acqpkitstatus.h2
-rw-r--r--backends/aptcc/apt-intf.cpp109
-rw-r--r--backends/aptcc/apt-intf.h14
-rw-r--r--backends/aptcc/apt-messages.cpp4
-rw-r--r--backends/aptcc/apt-messages.h3
-rw-r--r--backends/aptcc/apt-utils.cpp6
-rw-r--r--backends/aptcc/apt-utils.h10
-rw-r--r--backends/aptcc/deb-file.cpp28
-rw-r--r--backends/aptcc/deb-file.h29
-rwxr-xr-xbackends/aptcc/get-distro-upgrade.py2
-rw-r--r--backends/aptcc/gstMatcher.cpp3
-rw-r--r--backends/aptcc/gstMatcher.h2
-rw-r--r--backends/aptcc/matcher.cpp2
-rw-r--r--backends/aptcc/matcher.h4
-rw-r--r--backends/aptcc/pk-backend-aptcc.cpp36
-rw-r--r--backends/aptcc/pkg_acqfile.cpp12
-rw-r--r--backends/aptcc/pkg_acqfile.h2
20 files changed, 135 insertions, 155 deletions
diff --git a/backends/aptcc/AptCacheFile.cpp b/backends/aptcc/AptCacheFile.cpp
index 7753a99ad..9ce31e4b5 100644
--- a/backends/aptcc/AptCacheFile.cpp
+++ b/backends/aptcc/AptCacheFile.cpp
@@ -98,6 +98,11 @@ bool AptCacheFile::CheckDeps(bool FixBroken)
return true;
}
+bool AptCacheFile::DistUpgrade()
+{
+ return pkgDistUpgrade(*this);
+}
+
void AptCacheFile::ShowBroken(bool Now, PkErrorEnum error)
{
std::stringstream out;
diff --git a/backends/aptcc/AptCacheFile.h b/backends/aptcc/AptCacheFile.h
index 49a5e31ee..b8fe04d29 100644
--- a/backends/aptcc/AptCacheFile.h
+++ b/backends/aptcc/AptCacheFile.h
@@ -53,6 +53,11 @@ public:
*/
bool CheckDeps(bool FixBroken = false);
+ /**
+ * Mark Cache for dist-upgrade
+ */
+ bool DistUpgrade();
+
/** Shows a list of all broken packages together with their
* dependencies. Similar to and based on the equivalent routine in
* apt-get.
diff --git a/backends/aptcc/acqpkitstatus.cpp b/backends/aptcc/acqpkitstatus.cpp
index 3e3068712..e95b8acf9 100644
--- a/backends/aptcc/acqpkitstatus.cpp
+++ b/backends/aptcc/acqpkitstatus.cpp
@@ -1,6 +1,6 @@
/* acqpkitstatus.cpp
*
- * Copyright (c) 2009 Daniel Nicoletti <dantti85-pk@yahoo.com.br>
+ * Copyright (c) 2009 Daniel Nicoletti <dantti@gmail.com>
*
* 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
@@ -20,18 +20,8 @@
#include "acqpkitstatus.h"
-#include "pkg_acqfile.h"
-
#include <apt-pkg/acquire-item.h>
#include <apt-pkg/acquire-worker.h>
-#include <apt-pkg/strutl.h>
-#include <apt-pkg/error.h>
-
-#include <stdio.h>
-#include <signal.h>
-#include <iostream>
-
-using namespace std;
// AcqPackageKitStatus::AcqPackageKitStatus - Constructor
// ---------------------------------------------------------------------
diff --git a/backends/aptcc/acqpkitstatus.h b/backends/aptcc/acqpkitstatus.h
index b33880909..7d09a1a1f 100644
--- a/backends/aptcc/acqpkitstatus.h
+++ b/backends/aptcc/acqpkitstatus.h
@@ -1,6 +1,6 @@
/* acqpkitstatus.h
*
- * Copyright (c) 2009 Daniel Nicoletti <dantti85-pk@yahoo.com.br>
+ * Copyright (c) 2009 Daniel Nicoletti <dantti12@gmail.com>
*
* 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
diff --git a/backends/aptcc/apt-intf.cpp b/backends/aptcc/apt-intf.cpp
index 2b26cb952..60aa4889b 100644
--- a/backends/aptcc/apt-intf.cpp
+++ b/backends/aptcc/apt-intf.cpp
@@ -2,7 +2,7 @@
*
* Copyright (c) 1999-2008 Daniel Burrows
* Copyright (c) 2004 Michael Vogt <mvo@debian.org>
- * 2009 Daniel Nicoletti <dantti85-pk@yahoo.com.br>
+ * 2009 Daniel Nicoletti <dantti12@gmail.com>
* 2012 Matthias Klumpp <matthias@tenstral.net>
*
* This program is free software; you can redistribute it and/or modify
@@ -24,13 +24,10 @@
#include "apt-intf.h"
#include <apt-pkg/error.h>
-#include <apt-pkg/tagfile.h>
#include <apt-pkg/algorithms.h>
-#include <apt-pkg/init.h>
-#include <apt-pkg/sptr.h>
#include <apt-pkg/pkgsystem.h>
+#include <apt-pkg/sptr.h>
#include <apt-pkg/version.h>
-#include <apt-pkg/aptconfiguration.h>
#include <sys/statvfs.h>
#include <sys/statfs.h>
@@ -40,9 +37,8 @@
#include <fstream>
#include <dirent.h>
-#include <assert.h>
-#include <regex.h>
+#include "AptCacheFile.h"
#include "apt-utils.h"
#include "matcher.h"
#include "gstMatcher.h"
@@ -54,7 +50,6 @@
#define RAMFS_MAGIC 0x858458f6
AptIntf::AptIntf(PkBackend *backend, bool &cancel) :
- m_cache(backend),
m_backend(backend),
m_cancel(cancel),
m_terminalTimeout(120),
@@ -64,6 +59,8 @@ AptIntf::AptIntf(PkBackend *backend, bool &cancel) :
// Make sure initial m_time is 0
m_restartStat.st_mtime = 0;
+
+ m_cache = new AptCacheFile(backend);
}
bool AptIntf::init()
@@ -98,7 +95,7 @@ bool AptIntf::init()
// Tries to open the cache
bool ret;
- ret = m_cache.Open();
+ ret = m_cache->Open();
// Prepare for the restart thing
if (g_file_test(REBOOT_REQUIRED, G_FILE_TEST_EXISTS)) {
@@ -129,6 +126,8 @@ AptIntf::~AptIntf()
}
}
+ delete m_cache;
+
pk_backend_finished(m_backend);
}
@@ -150,7 +149,7 @@ pkgCache::VerIterator AptIntf::findPackageId(const gchar *packageId)
pkgCache::PkgIterator pkg;
parts = pk_package_id_split(packageId);
- pkg = m_cache->FindPkg(parts[PK_PACKAGE_ID_NAME], parts[PK_PACKAGE_ID_ARCH]);
+ pkg = (*m_cache)->FindPkg(parts[PK_PACKAGE_ID_NAME], parts[PK_PACKAGE_ID_ARCH]);
// Ignore packages that could not be found or that exist only due to dependencies.
if (pkg.end() || (pkg.VersionList().end() && pkg.ProvidesList().end())) {
@@ -166,7 +165,7 @@ pkgCache::VerIterator AptIntf::findPackageId(const gchar *packageId)
return ver;
}
- const pkgCache::VerIterator &candidateVer = m_cache.findCandidateVer(pkg);
+ const pkgCache::VerIterator &candidateVer = m_cache->findCandidateVer(pkg);
// check to see if the provided package isn't virtual too
if (candidateVer.end() == false &&
strcmp(candidateVer.VerStr(), parts[PK_PACKAGE_ID_VERSION]) == 0) {
@@ -187,7 +186,7 @@ pkgCache::VerIterator AptIntf::findVer(const pkgCache::PkgIterator &pkg)
}
// Else get the candidate version iterator
- const pkgCache::VerIterator &candidateVer = m_cache.findCandidateVer(pkg);
+ const pkgCache::VerIterator &candidateVer = m_cache->findCandidateVer(pkg);
if (!candidateVer.end()) {
return candidateVer;
}
@@ -343,7 +342,7 @@ void AptIntf::emitPackage(const pkgCache::VerIterator &ver, PkInfoEnum state)
pk_backend_package(m_backend,
state,
package_id,
- m_cache.getShortDescription(ver).c_str());
+ m_cache->getShortDescription(ver).c_str());
g_free(package_id);
}
@@ -443,7 +442,7 @@ void AptIntf::providesCodec(PkgList &output, gchar **values)
return;
}
- for (pkgCache::PkgIterator pkg = m_cache.GetPkgCache()->PkgBegin(); !pkg.end(); ++pkg) {
+ for (pkgCache::PkgIterator pkg = m_cache->GetPkgCache()->PkgBegin(); !pkg.end(); ++pkg) {
if (m_cancel) {
delete matcher;
break;
@@ -458,14 +457,14 @@ void AptIntf::providesCodec(PkgList &output, gchar **values)
// Ignore virtual packages
pkgCache::VerIterator ver = findVer(pkg);
if (ver.end() == true) {
- ver = m_cache.findCandidateVer(pkg);
+ ver = m_cache->findCandidateVer(pkg);
if (ver.end() == true) {
continue;
}
}
pkgCache::VerFileIterator vf = ver.FileList();
- pkgRecords::Parser &rec = m_cache.GetPkgRecords()->Lookup(vf);
+ pkgRecords::Parser &rec = m_cache->GetPkgRecords()->Lookup(vf);
const char *start, *stop;
rec.GetRec(start, stop);
string record(start, stop - start);
@@ -521,7 +520,7 @@ void AptIntf::providesLibrary(PkgList &output, gchar **values)
g_debug ("pkg-name: %s", libPkgName.c_str ());
- for (pkgCache::PkgIterator pkg = m_cache.GetPkgCache()->PkgBegin(); !pkg.end(); ++pkg) {
+ for (pkgCache::PkgIterator pkg = m_cache->GetPkgCache()->PkgBegin(); !pkg.end(); ++pkg) {
// Ignore packages that exist only due to dependencies.
if (pkg.VersionList().end() && pkg.ProvidesList().end()) {
continue;
@@ -530,7 +529,7 @@ void AptIntf::providesLibrary(PkgList &output, gchar **values)
// TODO: Ignore virtual packages
pkgCache::VerIterator ver = findVer (pkg);
if (ver.end()) {
- ver = m_cache.findCandidateVer(pkg);
+ ver = m_cache->findCandidateVer(pkg);
if (ver.end()) {
continue;
}
@@ -577,7 +576,7 @@ bool AptIntf::getArchive(pkgAcquire *Owner,
// Does not really matter here.. we are going to fail out below
if (Vf.end() != true) {
// If this fails to get a file name we will bomb out below.
- pkgRecords::Parser &Parse = m_cache.GetPkgRecords()->Lookup(Vf);
+ pkgRecords::Parser &Parse = m_cache->GetPkgRecords()->Lookup(Vf);
if (_error->PendingError() == true) {
return false;
}
@@ -597,12 +596,12 @@ bool AptIntf::getArchive(pkgAcquire *Owner,
// Try to cross match against the source list
pkgIndexFile *Index;
- if (m_cache.GetSourceList()->FindIndex(Vf.File(),Index) == false) {
+ if (m_cache->GetSourceList()->FindIndex(Vf.File(),Index) == false) {
continue;
}
// Grab the text package record
- pkgRecords::Parser &Parse = m_cache.GetPkgRecords()->Lookup(Vf);
+ pkgRecords::Parser &Parse = m_cache->GetPkgRecords()->Lookup(Vf);
if (_error->PendingError() == true) {
return false;
}
@@ -648,7 +647,7 @@ void AptIntf::emitPackageDetail(const pkgCache::VerIterator &ver)
section = section.substr(found + 1);
pkgCache::VerFileIterator vf = ver.FileList();
- pkgRecords::Parser &rec = m_cache.GetPkgRecords()->Lookup(vf);
+ pkgRecords::Parser &rec = m_cache->GetPkgRecords()->Lookup(vf);
long size;
if (pkg->CurrentState == pkgCache::State::Installed && pkg.CurrentVer() == ver) {
@@ -664,7 +663,7 @@ void AptIntf::emitPackageDetail(const pkgCache::VerIterator &ver)
package_id,
"unknown",
get_enum_group(section),
- m_cache.getLongDescriptionParsed(ver).c_str(),
+ m_cache->getLongDescriptionParsed(ver).c_str(),
rec.Homepage().c_str(),
size);
@@ -708,7 +707,7 @@ void AptIntf::emitUpdateDetail(const pkgCache::VerIterator &candver)
pkgCache::VerFileIterator vf = candver.FileList();
string origin = vf.File().Origin() == NULL ? "" : vf.File().Origin();
- pkgRecords::Parser &rec = m_cache.GetPkgRecords()->Lookup(candver.FileList());
+ pkgRecords::Parser &rec = m_cache->GetPkgRecords()->Lookup(candver.FileList());
// Build the changelogURI
char uri[512];
@@ -963,7 +962,7 @@ void AptIntf::getRequires(PkgList &output,
const pkgCache::VerIterator &ver,
bool recursive)
{
- for (pkgCache::PkgIterator parentPkg = m_cache.GetPkgCache()->PkgBegin(); !parentPkg.end(); ++parentPkg) {
+ for (pkgCache::PkgIterator parentPkg = m_cache->GetPkgCache()->PkgBegin(); !parentPkg.end(); ++parentPkg) {
if (m_cancel) {
break;
}
@@ -998,8 +997,8 @@ void AptIntf::getRequires(PkgList &output,
PkgList AptIntf::getPackages()
{
PkgList output;
- output.reserve(m_cache.GetPkgCache()->HeaderP->PackageCount);
- for (pkgCache::PkgIterator pkg = m_cache.GetPkgCache()->PkgBegin(); !pkg.end(); ++pkg) {
+ output.reserve(m_cache->GetPkgCache()->HeaderP->PackageCount);
+ for (pkgCache::PkgIterator pkg = m_cache->GetPkgCache()->PkgBegin(); !pkg.end(); ++pkg) {
if (m_cancel) {
break;
}
@@ -1038,7 +1037,7 @@ PkgList AptIntf::getPackagesFromGroup(gchar **values)
pk_backend_set_allow_cancel(m_backend, true);
- for (pkgCache::PkgIterator pkg = m_cache.GetPkgCache()->PkgBegin(); !pkg.end(); ++pkg) {
+ for (pkgCache::PkgIterator pkg = m_cache->GetPkgCache()->PkgBegin(); !pkg.end(); ++pkg) {
if (m_cancel) {
break;
}
@@ -1070,10 +1069,18 @@ PkgList AptIntf::getPackagesFromGroup(gchar **values)
return output;
}
-PkgList AptIntf::searchPackageName(Matcher *matcher)
+PkgList AptIntf::searchPackageName(gchar *search)
{
PkgList output;
- for (pkgCache::PkgIterator pkg = m_cache.GetPkgCache()->PkgBegin(); !pkg.end(); ++pkg) {
+
+ Matcher *matcher = new Matcher(search);
+ if (matcher->hasError()) {
+ g_debug("Regex compilation error");
+ delete matcher;
+ return output;
+ }
+
+ for (pkgCache::PkgIterator pkg = m_cache->GetPkgCache()->PkgBegin(); !pkg.end(); ++pkg) {
if (m_cancel) {
break;
}
@@ -1105,10 +1112,18 @@ PkgList AptIntf::searchPackageName(Matcher *matcher)
return output;
}
-PkgList AptIntf::searchPackageDetails(Matcher *matcher)
+PkgList AptIntf::searchPackageDetails(gchar *search)
{
PkgList output;
- for (pkgCache::PkgIterator pkg = m_cache.GetPkgCache()->PkgBegin(); !pkg.end(); ++pkg) {
+
+ Matcher *matcher = new Matcher(search);
+ if (matcher->hasError()) {
+ g_debug("Regex compilation error");
+ delete matcher;
+ return output;
+ }
+
+ for (pkgCache::PkgIterator pkg = m_cache->GetPkgCache()->PkgBegin(); !pkg.end(); ++pkg) {
if (m_cancel) {
break;
}
@@ -1120,7 +1135,7 @@ PkgList AptIntf::searchPackageDetails(Matcher *matcher)
const pkgCache::VerIterator &ver = findVer(pkg);
if (ver.end() == false) {
if (matcher->matches(pkg.Name()) ||
- matcher->matches(m_cache.getLongDescription(ver))) {
+ matcher->matches((*m_cache).getLongDescription(ver))) {
// The package matched
output.push_back(ver);
}
@@ -1202,7 +1217,7 @@ PkgList AptIntf::searchPackageFiles(gchar **values)
if (m_cancel) {
break;
}
- const pkgCache::PkgIterator &pkg = m_cache->FindPkg(*it);
+ const pkgCache::PkgIterator &pkg = (*m_cache)->FindPkg(*it);
if (pkg.end() == true) {
continue;
}
@@ -1283,7 +1298,7 @@ void AptIntf::providesMimeType(PkgList &output, gchar **values)
if (m_cancel) {
break;
}
- const pkgCache::PkgIterator &pkg = m_cache->FindPkg(*it);
+ const pkgCache::PkgIterator &pkg = (*m_cache)->FindPkg(*it);
if (pkg.end() == true) {
continue;
}
@@ -1298,7 +1313,7 @@ void AptIntf::providesMimeType(PkgList &output, gchar **values)
if (output.empty()) {
// check if app-install-data is installed
pkgCache::PkgIterator pkg;
- pkg = m_cache->FindPkg("app-install-data");
+ pkg = (*m_cache)->FindPkg("app-install-data");
if (pkg->CurrentState != pkgCache::State::Installed) {
pk_backend_error_code(m_backend,
PK_ERROR_ENUM_INTERNAL_ERROR,
@@ -1574,7 +1589,7 @@ PkgList AptIntf::checkChangedPackages(AptCacheFile &cache, bool emitChanged)
for (pkgCache::PkgIterator pkg = cache->PkgBegin(); ! pkg.end(); ++pkg) {
if (cache[pkg].NewInstall() == true) {
// installing;
- const pkgCache::VerIterator &ver = m_cache.findCandidateVer(pkg);
+ const pkgCache::VerIterator &ver = m_cache->findCandidateVer(pkg);
if (!ver.end()) {
ret.push_back(ver);
installing.push_back(ver);
@@ -1598,7 +1613,7 @@ PkgList AptIntf::checkChangedPackages(AptCacheFile &cache, bool emitChanged)
}
} else if (cache[pkg].Upgrade() == true) {
// updating
- const pkgCache::VerIterator &ver = m_cache.findCandidateVer(pkg);
+ const pkgCache::VerIterator &ver = m_cache->findCandidateVer(pkg);
if (!ver.end()) {
ret.push_back(ver);
updating.push_back(ver);
@@ -1643,7 +1658,7 @@ void AptIntf::emitTransactionPackage(string name, PkInfoEnum state)
}
}
- const pkgCache::PkgIterator &pkg = m_cache->FindPkg(name);
+ const pkgCache::PkgIterator &pkg = (*m_cache)->FindPkg(name);
// Ignore packages that could not be found or that exist only due to dependencies.
if (pkg.end() == true ||
(pkg.VersionList().end() && pkg.ProvidesList().end())) {
@@ -1656,7 +1671,7 @@ void AptIntf::emitTransactionPackage(string name, PkInfoEnum state)
emitPackage(ver, state);
}
- const pkgCache::VerIterator &candidateVer = m_cache.findCandidateVer(pkg);
+ const pkgCache::VerIterator &candidateVer = m_cache->findCandidateVer(pkg);
// check to see if we found the package
if (candidateVer.end() == false) {
emitPackage(candidateVer, state);
@@ -2005,7 +2020,7 @@ PkgList AptIntf::resolvePackageIds(gchar **package_ids, PkBitfield filters)
// it can only return one package in this case we need to
// search the whole package cache and match the package
// name manually
- for (pkgCache::PkgIterator pkg = m_cache.GetPkgCache()->PkgBegin(); !pkg.end(); ++pkg) {
+ for (pkgCache::PkgIterator pkg = m_cache->GetPkgCache()->PkgBegin(); !pkg.end(); ++pkg) {
if (m_cancel) {
break;
}
@@ -2026,14 +2041,14 @@ PkgList AptIntf::resolvePackageIds(gchar **package_ids, PkBitfield filters)
ret.push_back(ver);
}
- const pkgCache::VerIterator &candidateVer = m_cache.findCandidateVer(pkg);
+ const pkgCache::VerIterator &candidateVer = m_cache->findCandidateVer(pkg);
// check to see if the provided package isn't virtual too
if (candidateVer.end() == false) {
ret.push_back(candidateVer);
}
}
} else {
- const pkgCache::PkgIterator &pkg = m_cache->FindPkg(pi);
+ const pkgCache::PkgIterator &pkg = (*m_cache)->FindPkg(pi);
// Ignore packages that could not be found or that exist only due to dependencies.
if (pkg.end() == true || (pkg.VersionList().end() && pkg.ProvidesList().end())) {
continue;
@@ -2045,7 +2060,7 @@ PkgList AptIntf::resolvePackageIds(gchar **package_ids, PkBitfield filters)
ret.push_back(ver);
}
- const pkgCache::VerIterator &candidateVer = m_cache.findCandidateVer(pkg);
+ const pkgCache::VerIterator &candidateVer = m_cache->findCandidateVer(pkg);
// check to see if the provided package isn't virtual too
if (candidateVer.end() == false) {
ret.push_back(candidateVer);
@@ -2069,7 +2084,7 @@ void AptIntf::refreshCache()
AcqPackageKitStatus Stat(this, m_backend, m_cancel);
// do the work
- ListUpdate(Stat, *m_cache.GetSourceList());
+ ListUpdate(Stat, *m_cache->GetSourceList());
}
void AptIntf::markAutoInstalled(AptCacheFile &cache, const PkgList &pkgs)
@@ -2414,7 +2429,7 @@ bool AptIntf::installPackages(AptCacheFile &cache, bool simulating)
// Create the package manager and prepare to download
SPtr<pkgPackageManager> PM = _system->CreatePM(cache);
- if (PM->GetArchives(&fetcher, m_cache.GetSourceList(), &Recs) == false ||
+ if (PM->GetArchives(&fetcher, m_cache->GetSourceList(), &Recs) == false ||
_error->PendingError() == true) {
return false;
}
@@ -2437,7 +2452,7 @@ bool AptIntf::installPackages(AptCacheFile &cache, bool simulating)
}
pkgCache::VerIterator ver = cache[pkg].InstVerIter(cache);
- if (ver.end() && (ver = m_cache.findCandidateVer(pkg))) {
+ if (ver.end() && (ver = m_cache->findCandidateVer(pkg))) {
// Ignore invalid versions
continue;
}
diff --git a/backends/aptcc/apt-intf.h b/backends/aptcc/apt-intf.h
index bbebbfd4d..1d80b06cc 100644
--- a/backends/aptcc/apt-intf.h
+++ b/backends/aptcc/apt-intf.h
@@ -1,7 +1,7 @@
/* apt-intf.h - Interface to APT
*
* Copyright (c) 1999-2002, 2004-2005, 2007-2008 Daniel Burrows
- * Copyright (c) 2009 Daniel Nicoletti <dantti85-pk@yahoo.com.br>
+ * Copyright (c) 2009 Daniel Nicoletti <dantti12@gmail.com>
* 2012 Matthias Klumpp <matthias@tenstral.net>
*
* This program is free software; you can redistribute it and/or modify
@@ -26,9 +26,10 @@
#include <glib.h>
#include <glib/gstdio.h>
-#include <pk-backend.h>
+#include <apt-pkg/depcache.h>
+#include <apt-pkg/acquire.h>
-#include "AptCacheFile.h"
+#include <pk-backend.h>
#define PREUPGRADE_BINARY "/usr/bin/do-release-upgrade"
#define GDEBI_BINARY "/usr/bin/gdebi"
@@ -40,6 +41,7 @@ typedef vector<pkgCache::VerIterator> PkgList;
class pkgProblemResolver;
class Matcher;
+class AptCacheFile;
class AptIntf
{
public:
@@ -128,12 +130,12 @@ public:
/**
* Returns a list of all packages that matched their names with matcher
*/
- PkgList searchPackageName(Matcher *matcher);
+ PkgList searchPackageName(gchar *search);
/**
* Returns a list of all packages that matched their description with matcher
*/
- PkgList searchPackageDetails(Matcher *matcher);
+ PkgList searchPackageDetails(gchar *search);
/**
* Returns a list of all packages that matched contains the given files
@@ -251,7 +253,7 @@ private:
PkgList checkChangedPackages(AptCacheFile &cache, bool emitChanged);
void emitTransactionPackage(string name, PkInfoEnum state);
- AptCacheFile m_cache;
+ AptCacheFile *m_cache;
PkBackend *m_backend;
bool &m_cancel;
struct stat m_restartStat;
diff --git a/backends/aptcc/apt-messages.cpp b/backends/aptcc/apt-messages.cpp
index b95c0dee1..4c38d062b 100644
--- a/backends/aptcc/apt-messages.cpp
+++ b/backends/aptcc/apt-messages.cpp
@@ -1,7 +1,7 @@
/* apt-messages.cpp
*
* Copyright (c) 2004 Daniel Burrows
- * Copyright (c) 2009-2011 Daniel Nicoletti <dantti85-pk@yahoo.com.br>
+ * Copyright (c) 2009-2011 Daniel Nicoletti <dantti12@gmail.com>
* 2011-2012 Matthias Klumpp <matthias@tenstral.net>
*
* This program is free software; you can redistribute it and/or modify
@@ -24,9 +24,7 @@
#include "apt-utils.h"
-#include <string>
#include <sstream>
-#include <cstdio>
using namespace std;
diff --git a/backends/aptcc/apt-messages.h b/backends/aptcc/apt-messages.h
index bdd04d0bf..5cdf69b1b 100644
--- a/backends/aptcc/apt-messages.h
+++ b/backends/aptcc/apt-messages.h
@@ -1,7 +1,7 @@
/* apt-messages.h
*
* Copyright (c) 2004 Daniel Burrows
- * Copyright (c) 2009-2011 Daniel Nicoletti <dantti85-pk@yahoo.com.br>
+ * Copyright (c) 2009-2011 Daniel Nicoletti <dantti12@gmail.com>
* 2011-2012 Matthias Klumpp <matthias@tenstral.net>
*
* This program is free software; you can redistribute it and/or modify
@@ -24,7 +24,6 @@
#define APT_MESSAGES_H
#include <pk-backend.h>
-#include <apt-pkg/cachefile.h>
/** \file apt-messages.h
*/
diff --git a/backends/aptcc/apt-utils.cpp b/backends/aptcc/apt-utils.cpp
index 65f699c9d..6fea1ac49 100644
--- a/backends/aptcc/apt-utils.cpp
+++ b/backends/aptcc/apt-utils.cpp
@@ -1,6 +1,6 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
- * Copyright (c) 2009 Daniel Nicoletti <dantti85-pk@yahoo.com.br>
+ * Copyright (c) 2009 Daniel Nicoletti <dantti12@gmail.com>
*
* 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
@@ -20,9 +20,9 @@
#include "apt-utils.h"
-#include <iostream>
+#include "pkg_acqfile.h"
+
#include <fstream>
-#include <sys/stat.h>
PkGroupEnum get_enum_group(string group)
{
diff --git a/backends/aptcc/apt-utils.h b/backends/aptcc/apt-utils.h
index 514737456..3297e16db 100644
--- a/backends/aptcc/apt-utils.h
+++ b/backends/aptcc/apt-utils.h
@@ -1,7 +1,7 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
* Copyright (c) 2001, 2005 Daniel Burrows (aptitude)
- * Copyright (c) 2009 Daniel Nicoletti <dantti85-pk@yahoo.com.br>
+ * Copyright (c) 2009 Daniel Nicoletti <dantti12@gmail.com>
*
* 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
@@ -23,15 +23,9 @@
#define APT_UTILS_H
#include <apt-pkg/pkgrecords.h>
-
-#include <string.h>
-#include <set>
-#include <pk-backend.h>
+#include <apt-pkg/acquire.h>
#include "apt-intf.h"
-#include "pkg_acqfile.h"
-
-using namespace std;
// compare...uses the candidate version of each package.
class compare
diff --git a/backends/aptcc/deb-file.cpp b/backends/aptcc/deb-file.cpp
index aebe97465..a7d3452fe 100644
--- a/backends/aptcc/deb-file.cpp
+++ b/backends/aptcc/deb-file.cpp
@@ -1,6 +1,6 @@
/* deb-file.cpp
*
- * Copyright (c) 2011 Daniel Nicoletti <dantti85-pk@yahoo.com.br>
+ * Copyright (c) 2011 Daniel Nicoletti <dantti12@gmail.com>
* 2012 Matthias Klumpp <matthias@tenstral.net>
*
* Licensed under the GNU General Public License Version 2
@@ -22,13 +22,9 @@
#include "deb-file.h"
-#include <apt-pkg/fileutl.h>
-#include <apt-pkg/tagfile.h>
#include <apt-pkg/init.h>
-#include <iostream>
-
-DebFile::DebFile(const std::string &filename) :
+DebFile::DebFile(const string &filename) :
m_filePath(filename)
{
FileFd in(filename, FileFd::ReadOnly);
@@ -51,45 +47,45 @@ bool DebFile::isValid() const
return m_isValid;
}
-std::string DebFile::filePath() const
+string DebFile::filePath() const
{
return m_filePath;
}
-std::string DebFile::packageName() const
+string DebFile::packageName() const
{
return m_controlData.FindS("Package");
}
-std::string DebFile::sourcePackage() const
+string DebFile::sourcePackage() const
{
return m_controlData.FindS("Source");
}
-std::string DebFile::version() const
+string DebFile::version() const
{
return m_controlData.FindS("Version");
}
-std::string DebFile::architecture() const
+string DebFile::architecture() const
{
return m_controlData.FindS("Architecture");
}
-std::string DebFile::conflicts() const
+string DebFile::conflicts() const
{
return m_controlData.FindS("Conflicts");
}
-std::string DebFile::summary() const
+string DebFile::summary() const
{
- std::string longDesc = description ();
+ string longDesc = description ();
longDesc.resize (longDesc.find_first_of ("\n"));
return longDesc;
}
-std::string DebFile::description() const
+string DebFile::description() const
{
return m_controlData.FindS("Description");
}
@@ -156,7 +152,7 @@ bool DebFile::check()
return true;
}
-std::string DebFile::errorMsg() const
+string DebFile::errorMsg() const
{
return m_errorMsg;
}
diff --git a/backends/aptcc/deb-file.h b/backends/aptcc/deb-file.h
index 187c4b680..6c81b90e2 100644
--- a/backends/aptcc/deb-file.h
+++ b/backends/aptcc/deb-file.h
@@ -1,6 +1,6 @@
/* deb-file.h
*
- * Copyright (c) 2011 Daniel Nicoletti <dantti85-pk@yahoo.com.br>
+ * Copyright (c) 2011 Daniel Nicoletti <dantti12@gmail.com>
* 2012 Matthias Klumpp <matthias@tenstral.net>
*
* Licensed under the GNU General Public License Version 2
@@ -23,34 +23,35 @@
#ifndef DEB_FILE_H
#define DEB_FILE_H
-#include <string>
#include <apt-pkg/debfile.h>
+using std::string;
+
class DebFile
{
// typedef int user_tag_reference;
public:
- DebFile(const std::string &filename);
+ DebFile(const string &filename);
bool isValid() const;
- std::string filePath() const;
- std::string packageName() const;
- std::string sourcePackage() const;
- std::string version() const;
- std::string architecture() const;
- std::string summary() const;
- std::string description() const;
- std::string conflicts() const;
+ string filePath() const;
+ string packageName() const;
+ string sourcePackage() const;
+ string version() const;
+ string architecture() const;
+ string summary() const;
+ string description() const;
+ string conflicts() const;
// THIS should be moved to AptIntf class
bool check();
- std::string errorMsg() const;
+ string errorMsg() const;
private:
- std::string m_filePath;
+ string m_filePath;
debDebFile::MemControlExtract *m_extractor;
pkgTagSection m_controlData;
- std::string m_errorMsg;
+ string m_errorMsg;
bool m_isValid;
};
diff --git a/backends/aptcc/get-distro-upgrade.py b/backends/aptcc/get-distro-upgrade.py
index 8c9636842..d4b27c263 100755
--- a/backends/aptcc/get-distro-upgrade.py
+++ b/backends/aptcc/get-distro-upgrade.py
@@ -6,7 +6,7 @@ Provides an apt backend to PackageKit
Copyright (C) 2007 Ali Sabil <ali.sabil@gmail.com>
Copyright (C) 2007 Tom Parker <palfrey@tevp.net>
Copyright (C) 2008-2009 Sebastian Heinlein <glatzor@ubuntu.com>
-Copyright (C) 2010 Daniel Nicoletti <dantti85-pk@yahoo.com.br>
+Copyright (C) 2010 Daniel Nicoletti <dantti12@gmail.com>
Licensed under the GNU General Public License Version 2
diff --git a/backends/aptcc/gstMatcher.cpp b/backends/aptcc/gstMatcher.cpp
index 43a42d628..7819b74af 100644
--- a/backends/aptcc/gstMatcher.cpp
+++ b/backends/aptcc/gstMatcher.cpp
@@ -1,6 +1,6 @@
/* gstMatcher.cpp - Match GStreamer packages
*
- * Copyright (c) 2010 Daniel Nicoletti <dantti85-pk@yahoo.com.br>
+ * Copyright (c) 2010 Daniel Nicoletti <dantti12@gmail.com>
*
* 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
@@ -22,7 +22,6 @@
#include <regex.h>
#include <gst/gst.h>
-#include <iostream>
GstMatcher::GstMatcher(gchar **values)
{
diff --git a/backends/aptcc/gstMatcher.h b/backends/aptcc/gstMatcher.h
index d6e18d7c2..a8894e167 100644
--- a/backends/aptcc/gstMatcher.h
+++ b/backends/aptcc/gstMatcher.h
@@ -1,6 +1,6 @@
/* gstMatcher.h - Match GStreamer package names
*
- * Copyright (c) 2010 Daniel Nicoletti <dantti85-pk@yahoo.com.br>
+ * Copyright (c) 2010 Daniel Nicoletti <dantti12@gmail.com>
*
* 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
diff --git a/backends/aptcc/matcher.cpp b/backends/aptcc/matcher.cpp
index de4c27a93..d0b70effb 100644
--- a/backends/aptcc/matcher.cpp
+++ b/backends/aptcc/matcher.cpp
@@ -1,7 +1,7 @@
/* matcher.cpp
*
* Copyright (c) 1999-2008 Daniel Burrows
- * Copyright (c) 2009 Daniel Nicoletti <dantti85-pk@yahoo.com.br>
+ * Copyright (c) 2009 Daniel Nicoletti <dantti12@gmail.com>
* 2012 Matthias Klumpp <matthias@tenstral.net>
*
* This program is free software; you can redistribute it and/or modify
diff --git a/backends/aptcc/matcher.h b/backends/aptcc/matcher.h
index 23c97ab06..33e871ed2 100644
--- a/backends/aptcc/matcher.h
+++ b/backends/aptcc/matcher.h
@@ -1,7 +1,7 @@
/* matcher.h
*
* Copyright (c) 1999-2008 Daniel Burrows
- * Copyright (c) 2009 Daniel Nicoletti <dantti85-pk@yahoo.com.br>
+ * Copyright (c) 2009 Daniel Nicoletti <dantti12@gmail.com>
*
* 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
@@ -44,7 +44,7 @@ private:
bool m_hasError;
string m_error;
bool parse_pattern(string::const_iterator &start,
- const std::string::const_iterator &end);
+ const string::const_iterator &end);
string parse_substr(string::const_iterator &start,
const string::const_iterator &end);
string parse_literal_string_tail(string::const_iterator &start,
diff --git a/backends/aptcc/pk-backend-aptcc.cpp b/backends/aptcc/pk-backend-aptcc.cpp
index 1a8b208d7..932b82a34 100644
--- a/backends/aptcc/pk-backend-aptcc.cpp
+++ b/backends/aptcc/pk-backend-aptcc.cpp
@@ -1,7 +1,6 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
+/*
* Copyright (C) 2007-2008 Richard Hughes <richard@hughsie.com>
- * Copyright (C) 2009 Daniel Nicoletti <dantti85-pk@yahoo.com.br>
+ * Copyright (C) 2009-2012 Daniel Nicoletti <dantti12@gmail.com>
*
* Licensed under the GNU General Public License Version 2
*
@@ -22,8 +21,6 @@
#include <stdio.h>
#include <apt-pkg/init.h>
-#include <apt-pkg/algorithms.h>
-#include <apt-pkg/aptconfiguration.h>
#include <config.h>
#include <pk-backend.h>
@@ -31,8 +28,6 @@
#include "apt-intf.h"
#include "AptCacheFile.h"
-#include "apt-utils.h"
-#include "matcher.h"
#include "apt-messages.h"
#include "acqpkitstatus.h"
#include "pkg_acqfile.h"
@@ -394,7 +389,7 @@ static gboolean backend_get_or_update_system_thread(PkBackend *backend)
}
pk_backend_set_status(backend, PK_STATUS_ENUM_RUNNING);
- if (pkgDistUpgrade(*cache) == false) {
+ if (cache.DistUpgrade() == false) {
cache.ShowBroken(false);
g_debug("Internal error, DistUpgrade broke stuff");
delete apt;
@@ -822,45 +817,36 @@ static gboolean backend_search_package_thread(PkBackend *backend)
search = g_strjoinv("|", values);
filters = (PkBitfield) pk_backend_get_uint(backend, "filters");
- pk_backend_set_percentage(backend, PK_BACKEND_PERCENTAGE_INVALID);
- pk_backend_set_allow_cancel(backend, true);
-
- Matcher *matcher = new Matcher(search);
- g_free(search);
- if (matcher->hasError()) {
- g_debug("Regex compilation error");
- delete matcher;
- pk_backend_finished(backend);
- return false;
- }
-
AptIntf *apt = new AptIntf(backend, _cancel);
pk_backend_set_pointer(backend, "aptcc_obj", apt);
if (apt->init()) {
g_debug("Failed to create apt cache");
- delete matcher;
+ g_free(search);
delete apt;
return false;
}
if (_error->PendingError() == true) {
- delete matcher;
+ g_free(search);
delete apt;
return false;
}
pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY);
+ pk_backend_set_percentage(backend, PK_BACKEND_PERCENTAGE_INVALID);
+ pk_backend_set_allow_cancel(backend, true);
+
PkgList output;
if (pk_backend_get_bool(backend, "search_details")) {
- output = apt->searchPackageDetails(matcher);
+ output = apt->searchPackageDetails(search);
} else {
- output = apt->searchPackageName(matcher);
+ output = apt->searchPackageName(search);
}
+ g_free(search);
// It's faster to emmit the packages here than in the matching part
apt->emitPackages(output, filters);
- delete matcher;
pk_backend_set_percentage(backend, 100);
delete apt;
return true;
diff --git a/backends/aptcc/pkg_acqfile.cpp b/backends/aptcc/pkg_acqfile.cpp
index b8f24e128..c30d38014 100644
--- a/backends/aptcc/pkg_acqfile.cpp
+++ b/backends/aptcc/pkg_acqfile.cpp
@@ -1,7 +1,7 @@
/* pkg_acqfile.cpp
*
* Copyright (c) 2002, 2005 Daniel Burrows
- * Copyright (c) 2009 Daniel Nicoletti <dantti85-pk@yahoo.com.br>
+ * Copyright (c) 2009 Daniel Nicoletti <dantti12@gmail.com>
* 2012 Matthias Klumpp <matthias@tenstral.net>
*
* This program is free software; you can redistribute it and/or modify
@@ -28,17 +28,7 @@
#include <config.h>
#endif
-#include <stdio.h>
-#include <errno.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <sys/stat.h>
-
-#include <apt-pkg/error.h>
#include <apt-pkg/configuration.h>
-#include <apt-pkg/acquire-item.h>
-#include <apt-pkg/sourcelist.h>
-#include <apt-pkg/strutl.h>
// Let's all sing a song about apt-pkg's brokenness..
diff --git a/backends/aptcc/pkg_acqfile.h b/backends/aptcc/pkg_acqfile.h
index 3c48a9a5f..cb3cbb748 100644
--- a/backends/aptcc/pkg_acqfile.h
+++ b/backends/aptcc/pkg_acqfile.h
@@ -1,7 +1,7 @@
/* pkg_acqfile.h
*
* Copyright (c) 2002, 2005 Daniel Burrows
- * Copyright (c) 2009 Daniel Nicoletti <dantti85-pk@yahoo.com.br>
+ * Copyright (c) 2009 Daniel Nicoletti <dantti@gmail.com>
* 2012 Matthias Klumpp <matthias@tenstral.net>
*
* This program is free software; you can redistribute it and/or modify