summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backends/aptcc/Makefile.am1
-rw-r--r--backends/aptcc/apt-intf.cpp105
-rw-r--r--backends/aptcc/apt-intf.h3
-rw-r--r--backends/aptcc/pk-backend-aptcc.cpp4
-rw-r--r--backends/aptcc/pkg_dpkgpm.cpp37
-rw-r--r--backends/aptcc/pkg_dpkgpm.h36
6 files changed, 56 insertions, 130 deletions
diff --git a/backends/aptcc/Makefile.am b/backends/aptcc/Makefile.am
index 052bdf21e..0a4f5cd43 100644
--- a/backends/aptcc/Makefile.am
+++ b/backends/aptcc/Makefile.am
@@ -5,7 +5,6 @@ INCLUDES = \
plugindir = $(PK_PLUGIN_DIR)
plugin_LTLIBRARIES = libpk_backend_aptcc.la
libpk_backend_aptcc_la_SOURCES = pkg_acqfile.cpp \
- pkg_dpkgpm.cpp \
acqpkitstatus.cpp \
deb-file.cpp \
matcher.cpp \
diff --git a/backends/aptcc/apt-intf.cpp b/backends/aptcc/apt-intf.cpp
index 164d58c1b..2ec789127 100644
--- a/backends/aptcc/apt-intf.cpp
+++ b/backends/aptcc/apt-intf.cpp
@@ -49,7 +49,6 @@
#include "apt-messages.h"
#include "acqpkitstatus.h"
#include "pkg_acqfile.h"
-#include "pkg_dpkgpm.h"
#include "deb-file.h"
#define RAMFS_MAGIC 0x858458f6
@@ -1645,7 +1644,12 @@ void AptIntf::updateInterface(int fd, int writeFd)
/* Remove unused automatic packages */
bool AptIntf::DoAutomaticRemove(pkgCacheFile &Cache)
{
- bool doAutoRemove = _config->FindB("APT::Get::AutomaticRemove", false);
+ bool doAutoRemove;
+ if (pk_backend_get_bool(m_backend, "autoremove")) {
+ doAutoRemove = true;
+ } else {
+ doAutoRemove = _config->FindB("APT::Get::AutomaticRemove", false);
+ }
pkgDepCache::ActionGroup group(*Cache);
if (_config->FindB("APT::Get::Remove",true) == false &&
@@ -1655,27 +1659,30 @@ bool AptIntf::DoAutomaticRemove(pkgCacheFile &Cache)
doAutoRemove = false;
}
- // look over the cache to see what can be removed
- for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); ! Pkg.end(); ++Pkg) {
- if (Cache[Pkg].Garbage && doAutoRemove)
- {
- if (Pkg.CurrentVer() != 0 &&
- Pkg->CurrentState != pkgCache::State::ConfigFiles) {
- Cache->MarkDelete(Pkg, _config->FindB("APT::Get::Purge", false));
- } else {
- Cache->MarkKeep(Pkg, false, false);
+ if (doAutoRemove) {
+ bool purge = _config->FindB("APT::Get::Purge", false);
+ // look over the cache to see what can be removed
+ for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); ! Pkg.end(); ++Pkg) {
+ if (Cache[Pkg].Garbage) {
+ if (Pkg.CurrentVer() != 0 &&
+ Pkg->CurrentState != pkgCache::State::ConfigFiles) {
+ Cache->MarkDelete(Pkg, purge);
+ } else {
+ Cache->MarkKeep(Pkg, false, false);
+ }
}
}
- }
- // Now see if we destroyed anything
- if (Cache->BrokenCount() != 0) {
- cout << "Hmm, seems like the AutoRemover destroyed something which really\n"
- "shouldn't happen. Please file a bug report against apt." << endl;
- // TODO call show_broken
- // ShowBroken(c1out,Cache,false);
- return _error->Error("Internal Error, AutoRemover broke stuff");
+ // Now see if we destroyed anything
+ if (Cache->BrokenCount() != 0) {
+ cout << "Hmm, seems like the AutoRemover destroyed something which really\n"
+ "shouldn't happen. Please file a bug report against apt." << endl;
+ // TODO call show_broken
+ // ShowBroken(c1out,Cache,false);
+ return _error->Error("Internal Error, AutoRemover broke stuff");
+ }
}
+
return true;
}
@@ -2052,35 +2059,23 @@ bool AptIntf::runTransaction(PkgList &install, PkgList &remove, bool simulate, b
}
}
- // Try to auto-remove packages
- if (!DoAutomaticRemove(Cache)) {
- // TODO
- return false;
- }
-
- // check for essential packages!!!
- if (removingEssentialPackages(Cache)) {
- return false;
- }
-
- if (simulate) {
- // Print out a list of packages that are going to be installed extra
- emitChangedPackages(Cache);
- return true;
- } else {
- // Store the packages that are going to change
- // so we can emit them as we process it.
- populateInternalPackages(Cache);
- return installPackages(Cache);
- }
+ // If we are simulating the install packages
+ // will just calculate the trusted packages
+ return installPackages(Cache, simulate);
}
// InstallPackages - Download and install the packages
// ---------------------------------------------------------------------
/* This displays the informative messages describing what is going to
happen and then calls the download routines */
-bool AptIntf::installPackages(pkgCacheFile &Cache)
+bool AptIntf::installPackages(pkgCacheFile &Cache, bool simulate)
{
+ // Try to auto-remove packages
+ if (!DoAutomaticRemove(Cache)) {
+ // TODO
+ return false;
+ }
+
//cout << "installPackages() called" << endl;
if (_config->FindB("APT::Get::Purge",false) == true) {
pkgCache::PkgIterator I = Cache->PkgBegin();
@@ -2140,8 +2135,7 @@ bool AptIntf::installPackages(pkgCacheFile &Cache)
fetcher.Setup(&Stat);
// Create the package manager and prepare to download
- // SPtr<pkgPackageManager> PM= _system->CreatePM(Cache);
- SPtr<pkgPackageManager> PM = new pkgDebDPkgPM(Cache);
+ SPtr<pkgPackageManager> PM = _system->CreatePM(Cache);
if (PM->GetArchives(&fetcher, packageSourceList, &Recs) == false ||
_error->PendingError() == true) {
return false;
@@ -2229,6 +2223,14 @@ bool AptIntf::installPackages(pkgCacheFile &Cache)
return false;
}
+ if (simulate) {
+ // Print out a list of packages that are going to be installed extra
+ emitChangedPackages(Cache);
+ return true;
+ } else {
+
+ }
+
pk_backend_set_status (m_backend, PK_STATUS_ENUM_DOWNLOAD);
pk_backend_set_simultaneous_mode(m_backend, true);
// Download and check if we can continue
@@ -2245,30 +2247,27 @@ bool AptIntf::installPackages(pkgCacheFile &Cache)
return false;
}
- // Right now it's not safe to cancel
- pk_backend_set_allow_cancel (m_backend, false);
+ // Store the packages that are going to change
+ // so we can emit them as we process it.
+ populateInternalPackages(Cache);
- // TODO true or false?
+ // Check if the user canceled
if (_cancel) {
return true;
}
+ // Right now it's not safe to cancel
+ pk_backend_set_allow_cancel (m_backend, false);
+
// Download should be finished by now, changing it's status
pk_backend_set_status (m_backend, PK_STATUS_ENUM_RUNNING);
pk_backend_set_percentage(m_backend, PK_BACKEND_PERCENTAGE_INVALID);
pk_backend_set_sub_percentage(m_backend, PK_BACKEND_PERCENTAGE_INVALID);
- // TODO DBus activated does not have all vars
// we could try to see if this is the case
setenv("PATH", "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", 1);
_system->UnLock();
- if (!m_localDebFile.empty()) {
- // add the local file name to be proccessed by the PM queue
- pkgDebDPkgPM *pm = static_cast<pkgDebDPkgPM*>(&*PM);
- pm->addDebFile(m_localDebFile);
- }
-
pkgPackageManager::OrderResult res;
res = PM->DoInstallPreFork();
if (res == pkgPackageManager::Failed) {
diff --git a/backends/aptcc/apt-intf.h b/backends/aptcc/apt-intf.h
index c6c8c5635..b22d66766 100644
--- a/backends/aptcc/apt-intf.h
+++ b/backends/aptcc/apt-intf.h
@@ -28,7 +28,6 @@
#include <apt-pkg/cachefile.h>
#include <apt-pkg/policy.h>
-#include <set>
#include <pk-backend.h>
#define PREUPGRADE_BINARY "/usr/bin/do-release-upgrade"
@@ -133,7 +132,7 @@ public:
/**
* Download and install packages
*/
- bool installPackages(pkgCacheFile &Cache);
+ bool installPackages(pkgCacheFile &Cache, bool simulate);
/**
* Install a DEB file
diff --git a/backends/aptcc/pk-backend-aptcc.cpp b/backends/aptcc/pk-backend-aptcc.cpp
index 87f3b34ea..27113d4e7 100644
--- a/backends/aptcc/pk-backend-aptcc.cpp
+++ b/backends/aptcc/pk-backend-aptcc.cpp
@@ -426,7 +426,9 @@ static gboolean backend_get_or_update_system_thread (PkBackend *backend)
m_apt->emitUpdates(update, filters);
m_apt->emit_packages(kept, filters, PK_INFO_ENUM_BLOCKED);
} else {
- res = m_apt->installPackages(Cache);
+ // TODO there should be a simulate upgrade system,
+ // tho afaik Apper and GPK don't use this
+ res = m_apt->installPackages(Cache, false);
}
delete m_apt;
diff --git a/backends/aptcc/pkg_dpkgpm.cpp b/backends/aptcc/pkg_dpkgpm.cpp
deleted file mode 100644
index 4a495bd73..000000000
--- a/backends/aptcc/pkg_dpkgpm.cpp
+++ /dev/null
@@ -1,37 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2011 Daniel Nicoletti <dantti85-pk@yahoo.com.br>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * 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.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include "pkg_dpkgpm.h"
-
-#include <iostream>
-
-pkgDebDPkgPM::pkgDebDPkgPM(pkgDepCache *cache) :
- pkgDPkgPM(cache)
-{
-}
-
-void pkgDebDPkgPM::addDebFile(const std::string &filename)
-{
- PkgIterator pkg;
- std::cout << "PkgIterator " << pkg.end() << std::endl;
- Item item(Item::Install, pkg, filename);
- List.push_back(item);
-}
diff --git a/backends/aptcc/pkg_dpkgpm.h b/backends/aptcc/pkg_dpkgpm.h
deleted file mode 100644
index 320ae6126..000000000
--- a/backends/aptcc/pkg_dpkgpm.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2011 Daniel Nicoletti <dantti85-pk@yahoo.com.br>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * 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.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#ifndef DEB_DPKG_PM_H
-#define DEB_DPKG_PM_H
-
-#include <string>
-#include <apt-pkg/dpkgpm.h>
-
-class pkgDebDPkgPM : public pkgDPkgPM
-{
-public:
- pkgDebDPkgPM(pkgDepCache *cache);
-
- void addDebFile(const std::string &filename);
-};
-
-#endif