[PackageKit-commit] packagekit: Branch 'master' - 5 commits

Richard Hughes hughsient at kemper.freedesktop.org
Wed Dec 2 04:42:19 PST 2009


 backends/aptcc/acqprogress.cpp      |  296 ++++++++++++----------------------
 backends/aptcc/acqprogress.h        |    2 
 backends/aptcc/apt.cpp              |  313 ++++++++++++++++++------------------
 backends/aptcc/pk-backend-aptcc.cpp |    4 
 backends/yum/yumBackend.py          |   12 +
 lib/packagekit-qt/src/client.cpp    |   36 +++-
 lib/packagekit-qt/src/client.h      |   49 ++++-
 lib/packagekit-qt/src/transaction.h |   20 +-
 src/pk-transaction-db.c             |   56 +++---
 9 files changed, 408 insertions(+), 380 deletions(-)

New commits:
commit 5e2d1ffb9876589989b620f0cacacfaacf7c7301
Author: Richard Hughes <richard at hughsie.com>
Date:   Wed Dec 2 12:24:34 2009 +0000

    yum: Only check certain transaction elements, not all of them. Fixes rh#541645

diff --git a/backends/yum/yumBackend.py b/backends/yum/yumBackend.py
index dcdafac..1c53b98 100755
--- a/backends/yum/yumBackend.py
+++ b/backends/yum/yumBackend.py
@@ -254,6 +254,9 @@ class PackageKitYumBackend(PackageKitBaseBackend, PackagekitPackage):
             sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
             sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_CONGESTION, "lp")
 
+        # we only check these types
+        self.transaction_sig_check_map = [TS_UPDATE, TS_INSTALL, TS_TRUEINSTALL, TS_OBSOLETING]
+
         # this is global so we can catch sigquit and closedown
         yumbase = self.yumbase
         try:
@@ -1500,6 +1503,9 @@ class PackageKitYumBackend(PackageKitBaseBackend, PackagekitPackage):
                 # check all the packages in the transaction if only-trusted
                 if only_trusted:
                     for t in txmbr:
+                        # ignore transactions that do not have to be checked, e.g. obsoleted
+                        if t.output_state not in self.transaction_sig_check_map:
+                            continue
                         pkg = t.po
                         try:
                             signed = self._is_package_repo_signed(pkg)
@@ -1683,6 +1689,9 @@ class PackageKitYumBackend(PackageKitBaseBackend, PackagekitPackage):
             if only_trusted:
                 for t in txmbrs:
                     pkg = t.po
+                    # ignore transactions that do not have to be checked, e.g. obsoleted
+                    if t.output_state not in self.transaction_sig_check_map:
+                        continue
                     try:
                         signed = self._is_package_repo_signed(pkg)
                     except PkError, e:
@@ -1990,6 +1999,9 @@ class PackageKitYumBackend(PackageKitBaseBackend, PackagekitPackage):
             if txmbrs:
                 if only_trusted:
                     for t in txmbrs:
+                        # ignore transactions that do not have to be checked, e.g. obsoleted
+                        if t.output_state not in self.transaction_sig_check_map:
+                            continue
                         pkg = t.po
                         try:
                             signed = self._is_package_repo_signed(pkg)
commit 5233d0d3af0e0505ca7ab5b7909ec8afe555835c
Author: Richard Hughes <richard at hughsie.com>
Date:   Wed Dec 2 12:20:13 2009 +0000

    Ensure we return a very big number if we ask for the time since a role completed, and the role has never completed

diff --git a/src/pk-transaction-db.c b/src/pk-transaction-db.c
index fc69337..a6a8fba 100644
--- a/src/pk-transaction-db.c
+++ b/src/pk-transaction-db.c
@@ -246,11 +246,11 @@ pk_transaction_db_action_time_since (PkTransactionDb *tdb, PkRoleEnum role)
 	if (rc != SQLITE_OK) {
 		egg_warning ("SQL error: %s\n", error_msg);
 		sqlite3_free (error_msg);
-		return 0;
+		return G_MAXUINT;
 	}
 	if (timespec == NULL) {
-		egg_warning ("no response, assume zero");
-		return 0;
+		egg_warning ("no response, assume maximum value");
+		return G_MAXUINT;
 	}
 
 	/* work out the difference */
@@ -270,29 +270,41 @@ pk_transaction_db_action_time_reset (PkTransactionDb *tdb, PkRoleEnum role)
 	gchar *error_msg = NULL;
 	gint rc;
 	const gchar *role_text;
+	gboolean ret = TRUE;
 	gchar *statement;
 	gchar *timespec;
+	guint since;
 
 	g_return_val_if_fail (PK_IS_TRANSACTION_DB (tdb), FALSE);
 	g_return_val_if_fail (tdb->priv->db != NULL, FALSE);
 
 	timespec = pk_iso8601_present ();
 	role_text = pk_role_enum_to_text (role);
-	egg_debug ("reset action time=%s to %s", role_text, timespec);
 
-	statement = g_strdup_printf ("UPDATE last_action SET timespec = '%s' WHERE role = '%s'", timespec, role_text);
+	/* get the previous entry */
+	since = pk_transaction_db_action_time_since (tdb, role);
+	if (since == G_MAXUINT) {
+		egg_debug ("set action time=%s to %s", role_text, timespec);
+		statement = g_strdup_printf ("INSERT INTO last_action (role, timespec) VALUES ('%s', '%s')", role_text, timespec);
+	} else {
+		egg_debug ("reset action time=%s to %s", role_text, timespec);
+		statement = g_strdup_printf ("UPDATE last_action SET timespec = '%s' WHERE role = '%s'", timespec, role_text);
+	}
+
+	/* update or insert the entry */
 	rc = sqlite3_exec (tdb->priv->db, statement, NULL, NULL, &error_msg);
-	g_free (timespec);
-	g_free (statement);
 
 	/* did we fail? */
 	if (rc != SQLITE_OK) {
 		egg_warning ("SQL error: %s\n", error_msg);
 		sqlite3_free (error_msg);
-		return FALSE;
+		ret = FALSE;
+		goto out;
 	}
-
-	return TRUE;
+out:
+	g_free (timespec);
+	g_free (statement);
+	return ret;
 }
 
 /**
@@ -771,11 +783,8 @@ pk_transaction_db_init (PkTransactionDb *tdb)
 	const gchar *statement;
 	gint rc;
 	gchar *error_msg = NULL;
-	const gchar *role_text;
 	gchar *text;
-	gchar *timespec;
 	gboolean ret;
-	guint i;
 
 	g_return_if_fail (PK_IS_TRANSACTION_DB (tdb));
 
@@ -829,17 +838,6 @@ pk_transaction_db_init (PkTransactionDb *tdb)
 		egg_debug ("adding last action details: %s", error_msg);
 		statement = "CREATE TABLE last_action (role TEXT PRIMARY KEY, timespec TEXT);";
 		sqlite3_exec (tdb->priv->db, statement, NULL, NULL, NULL);
-
-		/* create values for now */
-		timespec = pk_iso8601_present ();
-		for (i=0; i<PK_ROLE_ENUM_LAST; i++) {
-			role_text = pk_role_enum_to_text (i);
-			/* reset to now if the role does not exist */
-			text = g_strdup_printf ("INSERT INTO last_action (role, timespec) VALUES ('%s', '%s')", role_text, timespec);
-			sqlite3_exec (tdb->priv->db, text, NULL, NULL, NULL);
-			g_free (text);
-		}
-		g_free (timespec);
 	}
 
 	/* check config (since 0.4.6) */
@@ -973,6 +971,14 @@ pk_transaction_db_test (EggTest *test)
 	else
 		egg_test_failed (test, "took a long time: %ims", ms);
 
+	/************************************************************/
+	egg_test_title (test, "do we get the correct time on a blank database");
+	value = pk_transaction_db_action_time_since (db, PK_ROLE_ENUM_REFRESH_CACHE);
+	if (value == G_MAXUINT)
+		egg_test_success (test, NULL);
+	else
+		egg_test_failed (test, "failed to get correct time, got %i", value);
+
 	/************************************************************
 	 ****************          IDENT           ******************
 	 ************************************************************/
@@ -1021,7 +1027,7 @@ pk_transaction_db_test (EggTest *test)
 	if (value > 1 && value <= 4)
 		egg_test_success (test, NULL);
 	else
-		egg_test_failed (test, "failed to get correct time, %i", value);
+		egg_test_failed (test, "failed to get correct time, %u", value);
 
 	/************************************************************
 	 ****************          PROXIES         ******************
commit 1dd15d74211fbca32c612b286909e156f2c2d25e
Author: Daniel Nicoletti <dantti85-pk at yahoo.com.br>
Date:   Tue Dec 1 14:46:44 2009 -0200

    packagekit-qt: Forgot to deprecate setLocale

diff --git a/lib/packagekit-qt/src/client.h b/lib/packagekit-qt/src/client.h
index f7c9981..28d3781 100644
--- a/lib/packagekit-qt/src/client.h
+++ b/lib/packagekit-qt/src/client.h
@@ -326,7 +326,7 @@ public:
 	 * \warning THIS FUNCTION IS DEPRECATED. It will be removed in a future release.
 	 * Use SetHints("locale=$code") instead.
 	 */
-	void setLocale(const QString& locale);
+	void Q_DECL_DEPRECATED setLocale(const QString& locale);
 
 	/**
 	 * \brief Sets a global hints for all the transactions to be created
commit 4dc16a9e47ec14b5723437a2ff11361641541522
Author: Daniel Nicoletti <dantti85-pk at yahoo.com.br>
Date:   Tue Dec 1 13:39:43 2009 -0200

    packagekit-qt: Fixed emmition of updatesChanged(), and added DEPRECATED macro to warn users of the lib

diff --git a/lib/packagekit-qt/src/client.cpp b/lib/packagekit-qt/src/client.cpp
index e3577be..dc0b028 100644
--- a/lib/packagekit-qt/src/client.cpp
+++ b/lib/packagekit-qt/src/client.cpp
@@ -82,6 +82,7 @@ Client::Client(QObject* parent) : QObject(parent)
 	connect(d->daemon, SIGNAL(RepoListChanged()), this, SIGNAL(repoListChanged()));
 	connect(d->daemon, SIGNAL(RestartSchedule()), this, SIGNAL(restartScheduled()));
 	connect(d->daemon, SIGNAL(TransactionListChanged(const QStringList&)), d, SLOT(transactionListChanged(const QStringList&)));
+	connect(d->daemon, SIGNAL(UpdatesChanged()), this, SIGNAL(updatesChanged()));
 
 	// Set up database for desktop files
 	QSqlDatabase db;
@@ -97,7 +98,7 @@ Client::~Client()
 	delete d;
 }
 
-Client::Actions Client::getActions() const
+Client::Actions Client::actions() const
 {
 	QStringList actions = d->daemon->roles().split(";");
 
@@ -108,6 +109,11 @@ Client::Actions Client::getActions() const
 	return flags;
 }
 
+Client::Actions Client::getActions() const
+{
+	return actions();
+}
+
 Client::BackendDetail Client::getBackendDetail() const
 {
 	BackendDetail detail;
@@ -131,7 +137,7 @@ QString Client::backendAuthor() const
 	return d->daemon->backendAuthor();
 }
 
-Client::Filters Client::getFilters() const
+Client::Filters Client::filters() const
 {
 	QStringList filters = d->daemon->filters().split(";");
 
@@ -147,7 +153,12 @@ Client::Filters Client::getFilters() const
 	return flags;
 }
 
-Client::Groups Client::getGroups() const
+Client::Filters Client::getFilters() const
+{
+	return filters();
+}
+
+Client::Groups Client::groups() const
 {
 	QStringList groups = d->daemon->groups().split(";");
 
@@ -158,22 +169,37 @@ Client::Groups Client::getGroups() const
 	return flags;
 }
 
+Client::Groups Client::getGroups() const
+{
+	return groups();
+}
+
 bool Client::locked() const
 {
 	return d->daemon->locked();
 }
 
-QStringList Client::getMimeTypes() const
+QStringList Client::mimeTypes() const
 {
 	return d->daemon->mimeTypes().split(";");
 }
 
-Client::NetworkState Client::getNetworkState() const
+QStringList Client::getMimeTypes() const
+{
+	return mimeTypes();
+}
+
+Client::NetworkState Client::networkState() const
 {
 	QString state = d->daemon->networkState();
 	return (NetworkState) Util::enumFromString<Client>(state, "NetworkState", "Network");
 }
 
+Client::NetworkState Client::getNetworkState() const
+{
+	return networkState();
+}
+
 QString Client::distroId() const
 {
 	return d->daemon->distroId();
diff --git a/lib/packagekit-qt/src/client.h b/lib/packagekit-qt/src/client.h
index 377fcfe..f7c9981 100644
--- a/lib/packagekit-qt/src/client.h
+++ b/lib/packagekit-qt/src/client.h
@@ -124,8 +124,15 @@ public:
 
 	/**
 	 * Returns all the actions supported by the current backend
+	 * This function is DEPRECATED and will be removed in a
+	 * future release, use \sa actions() instead.
 	 */
-	Actions getActions() const;
+	Actions Q_DECL_DEPRECATED getActions() const;
+
+	/**
+	 * Returns all the actions supported by the current backend
+	 */
+	Actions actions() const;
 
 	/**
 	 * Holds a backend's detail
@@ -140,8 +147,10 @@ public:
 	/**
 	 * Gets the current backend's details
 	 * \return a BackendDetail struct holding the backend's details. You have to free this structure.
+	 * This method is DEPRECATED use backendAuthor(), backendName()
+	 * and backendDescription() instead.
 	 */
-	BackendDetail getBackendDetail() const;
+	BackendDetail Q_DECL_DEPRECATED getBackendDetail() const;
 
 	/**
 	 * The backend name, e.g. "yum".
@@ -194,8 +203,14 @@ public:
 
 	/**
 	 * Returns the filters supported by the current backend
+	 * This method is DEPRECATED use \sa filters() instead.
+	 */
+	Filters Q_DECL_DEPRECATED getFilters() const;
+
+	/**
+	 * Returns the filters supported by the current backend
 	 */
-	Filters getFilters() const;
+	Filters filters() const;
 
 	/**
 	 * Describes the different groups
@@ -241,8 +256,14 @@ public:
 
 	/**
 	 * Returns the groups supported by the current backend
+	 * This method is DEPRECATED use \sa groups() instead.
+	 */
+	Groups Q_DECL_DEPRECATED getGroups() const;
+
+	/**
+	 * Returns the groups supported by the current backend
 	 */
-	Groups getGroups() const;
+	Groups groups() const;
 
 	/**
 	 * Set when the backend is locked and native tools would fail.
@@ -251,8 +272,14 @@ public:
 
 	/**
 	 * Returns a list containing the MIME types supported by the current backend
+	 * This method is DEPRECATED use \sa mimeTypes() instead.
+	 */
+	QStringList Q_DECL_DEPRECATED getMimeTypes() const;
+
+	/**
+	 * Returns a list containing the MIME types supported by the current backend
 	 */
-	QStringList getMimeTypes() const;
+	QStringList mimeTypes() const;
 
 	/**
 	 * Describes the current network state
@@ -268,8 +295,14 @@ public:
 
 	/**
 	 * Returns the current network state
+	 * This method is DEPRECATED use \sa networkState() instead.
+	 */
+	NetworkState Q_DECL_DEPRECATED getNetworkState() const;
+
+	/**
+	 * Returns the current network state
 	 */
-	NetworkState getNetworkState() const;
+	NetworkState networkState() const;
 
 	/**
 	 * The distribution identifier in the
@@ -853,11 +886,13 @@ Q_SIGNALS:
 
 	/**
 	 * Emitted when the daemon's locked state changes
+	 * This signal is DEPRECATED use \sa changed() and \sa locked() instead.
 	 */
 	void locked(bool locked);
 
 	/**
 	 * Emitted when the network state changes
+	 * This signal is DEPRECATED use \sa changed() and \sa networkState() instead.
 	 */
 	void networkStateChanged(PackageKit::Client::NetworkState state);
 
diff --git a/lib/packagekit-qt/src/transaction.h b/lib/packagekit-qt/src/transaction.h
index 7f0c76b..e31c7ed 100644
--- a/lib/packagekit-qt/src/transaction.h
+++ b/lib/packagekit-qt/src/transaction.h
@@ -119,12 +119,16 @@ public:
 		uint remaining;
 	} ProgressInfo;
 	/**
-	 * TODO this function should be deprecated since any changes to the above
-	 * struct breaks our API
 	 * Returns the current transaction's progress
 	 * \return a ProgressInfo struct describing the transaction's progress
+	 *
+	 * \warning THIS FUNCTION IS DEPRECATED. It will be removed in a future release.
+	 * Use \sa percentage(), \sa subpercentage(), \sa elapsedTime(),
+	 * \sa remainingTime() and \sa speed() instead.
+	 *
+	 * \sa Client::setLocale
 	 */
-	ProgressInfo progress() const;
+	ProgressInfo Q_DECL_DEPRECATED progress() const;
 
 	/**
 	 * The percentage complete of the whole transaction.
@@ -172,7 +176,7 @@ public:
 	 *
 	 * \sa Client::setLocale
 	 */
-	void setLocale(const QString& locale);
+	void Q_DECL_DEPRECATED setLocale(const QString& locale);
 
 	/**
 	 * \brief Tells the underlying package manager to use the given \p hints
@@ -325,11 +329,15 @@ Q_SIGNALS:
 
 	/**
 	 * The transaction has changed it's "cancellability"
+	* \warning THIS signal IS DEPRECATED and will be removed in a future release,
+	 * use \sa changed() and \sa allowCancel() property.
 	 */
 	void allowCancelChanged(bool allow);
 
 	/**
 	 * The transaction's caller activity changed
+	 * \warning THIS signal IS DEPRECATED and will be removed in a future release,
+	 * use \sa changed() and \sa callerActive() property.
 	 */
 	void callerActiveChanged(bool isActive);
 
@@ -409,6 +417,8 @@ Q_SIGNALS:
 
 	/**
 	 * Emitted when the progress of the transaction has changed
+	 * \warning THIS signal IS DEPRECATED and will be removed in a future release,
+	 * use \sa changed() and progress properties.
 	 */
 	void progressChanged(PackageKit::Transaction::ProgressInfo info);
 
@@ -431,6 +441,8 @@ Q_SIGNALS:
 
 	/**
 	 * Emitted when the transaction's status has changed
+	 * \warning THIS signal IS DEPRECATED and will be removed in a future release,
+	 * use \sa changed() and \sa status() property.
 	 */
 	void statusChanged(PackageKit::Transaction::Status s);
 
commit 06399388253ed5b1bf166f3941c85a30c54f1930
Author: Daniel Nicoletti <dantti85-pk at yahoo.com.br>
Date:   Mon Nov 30 17:53:18 2009 -0200

    aptcc: Better error handling in instalation

diff --git a/backends/aptcc/acqprogress.cpp b/backends/aptcc/acqprogress.cpp
index cf997f7..f624966 100644
--- a/backends/aptcc/acqprogress.cpp
+++ b/backends/aptcc/acqprogress.cpp
@@ -24,11 +24,10 @@ using namespace std;
 // AcqPackageKitStatus::AcqPackageKitStatus - Constructor				/*{{{*/
 // ---------------------------------------------------------------------
 /* */
-AcqPackageKitStatus::AcqPackageKitStatus(aptcc *apt, PkBackend *backend, bool &cancelled, unsigned int Quiet) :
+AcqPackageKitStatus::AcqPackageKitStatus(aptcc *apt, PkBackend *backend, bool &cancelled) :
 	m_apt(apt),
 	m_backend(backend),
 	_cancelled(cancelled),
-	Quiet(Quiet),
 	last_percent(0),
 	last_sub_percent(0)
 {
@@ -49,16 +48,13 @@ void AcqPackageKitStatus::Start()
 /* */
 void AcqPackageKitStatus::IMSHit(pkgAcquire::ItemDesc &Itm)
 {
-   if (Quiet > 1)
-      return;
-
-   if (Quiet <= 0)
-      cout << '\r' << BlankLine << '\r';
-
-   cout << /*_*/("Hit ") << Itm.Description;
-   if (Itm.Owner->FileSize != 0)
-      cout << " [" << SizeToStr(Itm.Owner->FileSize) << "B]";
-   cout << endl;
+//    if (Quiet <= 0)
+//       cout << '\r' << BlankLine << '\r';
+// 
+//    cout << /*_*/("Hit ") << Itm.Description;
+//    if (Itm.Owner->FileSize != 0)
+//       cout << " [" << SizeToStr(Itm.Owner->FileSize) << "B]";
+//    cout << endl;
    Update = true;
 };
 									/*}}}*/
@@ -73,16 +69,16 @@ void AcqPackageKitStatus::Fetch(pkgAcquire::ItemDesc &Itm)
 
    Itm.Owner->ID = ID++;
 
-   if (Quiet > 1)
-      return;
-
-   if (Quiet <= 0)
-      cout << '\r' << BlankLine << '\r';
-
-   cout << /*_*/("Get:") << Itm.Owner->ID << ' ' << Itm.Description;
-   if (Itm.Owner->FileSize != 0)
-      cout << " [" << SizeToStr(Itm.Owner->FileSize) << "B]";
-   cout << endl;
+//    if (Quiet > 1)
+//       return;
+// 
+//    if (Quiet <= 0)
+//       cout << '\r' << BlankLine << '\r';
+// 
+//    cout << /*_*/("Get:") << Itm.Owner->ID << ' ' << Itm.Description;
+//    if (Itm.Owner->FileSize != 0)
+//       cout << " [" << SizeToStr(Itm.Owner->FileSize) << "B]";
+//    cout << endl;
 };
 									/*}}}*/
 // AcqPackageKitStatus::Done - Completed a download				/*{{{*/
@@ -98,27 +94,24 @@ void AcqPackageKitStatus::Done(pkgAcquire::ItemDesc &Itm)
 /* We print out the error text  */
 void AcqPackageKitStatus::Fail(pkgAcquire::ItemDesc &Itm)
 {
-   if (Quiet > 1)
-      return;
-
-   // Ignore certain kinds of transient failures (bad code)
-   if (Itm.Owner->Status == pkgAcquire::Item::StatIdle)
-      return;
-
-   if (Quiet <= 0)
-      cout << '\r' << BlankLine << '\r';
+	// Ignore certain kinds of transient failures (bad code)
+	if (Itm.Owner->Status == pkgAcquire::Item::StatIdle) {
+		return;
+	}
 
-   if (Itm.Owner->Status == pkgAcquire::Item::StatDone)
-   {
-      cout << /*_*/("Ign ") << Itm.Description << endl;
-   }
-   else
-   {
-      cout << /*_*/("Err ") << Itm.Description << endl;
-      cout << "  " << Itm.Owner->ErrorText << endl;
-   }
+	if (Itm.Owner->Status == pkgAcquire::Item::StatDone)
+	{
+		// TODO add a PK message
+		cout << /*_*/("Ign ") << Itm.Description << endl;
+	} else {
+		// an error was found (maybe 404, 403...)
+		// the item that got the error and the error text
+		_error->Error("Error %s\n  %s",
+			      Itm.Description.c_str(),
+			      Itm.Owner->ErrorText.c_str());
+	}
 
-   Update = true;
+	Update = true;
 };
 									/*}}}*/
 // AcqPackageKitStatus::Stop - Finished downloading				/*{{{*/
@@ -128,11 +121,6 @@ void AcqPackageKitStatus::Fail(pkgAcquire::ItemDesc &Itm)
 void AcqPackageKitStatus::Stop()
 {
    pkgAcquireStatus::Stop();
-   if (Quiet > 1)
-      return;
-
-   if (Quiet <= 0)
-      cout << '\r' << BlankLine << '\r' << flush;
 
    if (FetchedBytes != 0 && _error->PendingError() == false)
       ioprintf(cout,/*_*/("Fetched %sB in %s (%sB/s)\n"),
@@ -148,150 +136,88 @@ void AcqPackageKitStatus::Stop()
    bandwidth and ETA indicator. */
 bool AcqPackageKitStatus::Pulse(pkgAcquire *Owner)
 {
-   if (Quiet > 0)
-      return true;
-
-   pkgAcquireStatus::Pulse(Owner);
-
-   enum {Long = 0,Medium,Short} Mode = Long;
-
-   char Buffer[sizeof(BlankLine)];
-   char *End = Buffer + sizeof(Buffer);
-   char *S = Buffer;
-//    if (ScreenWidth >= sizeof(Buffer))
-//       ScreenWidth = sizeof(Buffer)-1;
-    unsigned long percent_done;
-    percent_done = long(double((CurrentBytes + CurrentItems)*100.0)/double(TotalBytes+TotalItems));
-   // Put in the percent done
-   sprintf(S,"%ld%%", percent_done);
-//    printf("-----------------%ld\n", percent_done);
-    if (last_percent != percent_done) {
-	    if (last_percent < percent_done) {
-		    pk_backend_set_percentage(m_backend, percent_done);
-	    } else {
-		    pk_backend_set_percentage(m_backend, PK_BACKEND_PERCENTAGE_INVALID);
-		    pk_backend_set_percentage(m_backend, percent_done);
-	    }
-	    last_percent = percent_done;
-    }
-   bool Shown = false;
-   for (pkgAcquire::Worker *I = Owner->WorkersBegin(); I != 0;
-	I = Owner->WorkerStep(I))
-   {
-      S += strlen(S);
-
-      // There is no item running 
-      if (I->CurrentItem == 0)
-      {
-	 if (I->Status.empty() == false)
-	 {
-	    snprintf(S,End-S," [%s]",I->Status.c_str());
-	    Shown = true;
-	 }
-	 
-	 continue;
-      }
-
-      Shown = true;
-
-//    printf("==================%s=\n", I->CurrentItem->ShortDesc.c_str());
-   emit_package(I->CurrentItem->ShortDesc);
-      // Add in the short description
-      if (I->CurrentItem->Owner->ID != 0)
-	 snprintf(S,End-S," [%lu %s",I->CurrentItem->Owner->ID,
-		  I->CurrentItem->ShortDesc.c_str());
-      else
-	 snprintf(S,End-S," [%s",I->CurrentItem->ShortDesc.c_str());
-      S += strlen(S);
-
-      // Show the short mode string
-      if (I->CurrentItem->Owner->Mode != 0)
-      {
-	 snprintf(S,End-S," %s",I->CurrentItem->Owner->Mode);
-	 S += strlen(S);
-      }
-
-      // Add the current progress
-      if (Mode == Long)
-	 snprintf(S,End-S," %lu",I->CurrentSize);
-      else
-      {
-	 if (Mode == Medium || I->TotalSize == 0)
-	    snprintf(S,End-S," %sB",SizeToStr(I->CurrentSize).c_str());
-      }
-      S += strlen(S);
+	pkgAcquireStatus::Pulse(Owner);
+
+	enum {Long = 0,Medium,Short} Mode = Long;
+
+	char Buffer[sizeof(BlankLine)];
+	char *End = Buffer + sizeof(Buffer);
+	char *S = Buffer;
+
+	unsigned long percent_done;
+	percent_done = long(double((CurrentBytes + CurrentItems)*100.0)/double(TotalBytes+TotalItems));
+	
+	// Emit the percent done
+	if (last_percent != percent_done) {
+		if (last_percent < percent_done) {
+			pk_backend_set_percentage(m_backend, percent_done);
+		} else {
+			pk_backend_set_percentage(m_backend, PK_BACKEND_PERCENTAGE_INVALID);
+			pk_backend_set_percentage(m_backend, percent_done);
+		}
+		last_percent = percent_done;
+	}
 
-      // Add the total size and percent
-      if (I->TotalSize > 0 && I->CurrentItem->Owner->Complete == false)
-      {
-	unsigned long sub_percent;
-	sub_percent = long(double(I->CurrentSize*100.0)/double(I->TotalSize));
-	 if (Mode == Short)
-	    snprintf(S,End-S," %lu%%",
-		     sub_percent);
-	 else
-	    snprintf(S,End-S,"/%sB %lu%%",SizeToStr(I->TotalSize).c_str(),
-		     sub_percent);
+	for (pkgAcquire::Worker *I = Owner->WorkersBegin(); I != 0;
+		I = Owner->WorkerStep(I))
+	{
+		// There is no item running
+		if (I->CurrentItem == 0)
+		{
+			continue;
+		}
+		emit_package(I->CurrentItem->ShortDesc);
 
-		if (last_sub_percent != sub_percent) {
-			if (last_sub_percent < sub_percent) {
-				pk_backend_set_sub_percentage(m_backend, sub_percent);
-			} else {
-				pk_backend_set_sub_percentage(m_backend, PK_BACKEND_PERCENTAGE_INVALID);
-				pk_backend_set_sub_percentage(m_backend, sub_percent);
+		// Add the total size and percent
+		if (I->TotalSize > 0 && I->CurrentItem->Owner->Complete == false)
+		{
+			unsigned long sub_percent;
+			sub_percent = long(double(I->CurrentSize*100.0)/double(I->TotalSize));
+			if (last_sub_percent != sub_percent) {
+				if (last_sub_percent < sub_percent) {
+					pk_backend_set_sub_percentage(m_backend, sub_percent);
+				} else {
+					pk_backend_set_sub_percentage(m_backend, PK_BACKEND_PERCENTAGE_INVALID);
+					pk_backend_set_sub_percentage(m_backend, sub_percent);
+				}
+				last_sub_percent = sub_percent;
+			}
+		} else {
+			if (last_sub_percent != PK_BACKEND_PERCENTAGE_INVALID) {
+				pk_backend_set_sub_percentage(m_backend,
+							      PK_BACKEND_PERCENTAGE_INVALID);
+				last_sub_percent = PK_BACKEND_PERCENTAGE_INVALID;
 			}
-			last_sub_percent = sub_percent;
-		}
-// 		printf("====================%lu\n", sub_percent);
-      } else {
-		if (last_sub_percent != PK_BACKEND_PERCENTAGE_INVALID) {
-			pk_backend_set_sub_percentage(m_backend, PK_BACKEND_PERCENTAGE_INVALID);
-			last_sub_percent = PK_BACKEND_PERCENTAGE_INVALID;
 		}
-      }
-      S += strlen(S);
-      snprintf(S,End-S,"]");
-   }
-
-   // Show something..
-   if (Shown == false)
-      snprintf(S,End-S,/*_*/(" [Working]"));
-
-   /* Put in the ETA and cps meter, block off signals to prevent strangeness
-      during resizing */
-   sigset_t Sigs,OldSigs;
-   sigemptyset(&Sigs);
-   sigaddset(&Sigs,SIGWINCH);
-   sigprocmask(SIG_BLOCK,&Sigs,&OldSigs);
-
-   if (CurrentCPS != 0)
-   {
-      char Tmp[300];
-      unsigned long ETA = (unsigned long)((TotalBytes - CurrentBytes)/CurrentCPS);
-      sprintf(Tmp," %sB/s %s",SizeToStr(CurrentCPS).c_str(),TimeToStr(ETA).c_str());
-      unsigned int Len = strlen(Buffer);
-      unsigned int LenT = strlen(Tmp);
-//       if (Len + LenT < ScreenWidth)
-//       {	 
-// 	 memset(Buffer + Len,' ',ScreenWidth - Len);
-// 	 strcpy(Buffer + ScreenWidth - LenT,Tmp);
-//       }
-   }
-   Buffer[/*ScreenWidth*/1024] = 0;
-   BlankLine[/*ScreenWidth*/1024] = 0;
-   sigprocmask(SIG_SETMASK,&OldSigs,0);
-
-   // Draw the current status
-   if (strlen(Buffer) == strlen(BlankLine))
-      cout << '\r' << Buffer << flush;
-   else
-      cout << '\r' << BlankLine << '\r' << Buffer << flush;
-   memset(BlankLine,' ',strlen(Buffer));
-   BlankLine[strlen(Buffer)] = 0;
-
-   Update = false;
+	}
 
-   return !_cancelled;;
+	/* Put in the ETA and cps meter, block off signals to prevent strangeness
+	    during resizing */
+	sigset_t Sigs,OldSigs;
+	sigemptyset(&Sigs);
+	sigaddset(&Sigs,SIGWINCH);
+	sigprocmask(SIG_BLOCK,&Sigs,&OldSigs);
+
+// 	if (CurrentCPS != 0)
+// 	{
+// 		char Tmp[300];
+// 		unsigned long ETA = (unsigned long)((TotalBytes - CurrentBytes)/CurrentCPS);
+// 		sprintf(Tmp," %sB/s %s",SizeToStr(CurrentCPS).c_str(),TimeToStr(ETA).c_str());
+// 		unsigned int Len = strlen(Buffer);
+// 		unsigned int LenT = strlen(Tmp);
+// 	//       if (Len + LenT < ScreenWidth)
+// 	//       {
+// 	// 	 memset(Buffer + Len,' ',ScreenWidth - Len);
+// 	// 	 strcpy(Buffer + ScreenWidth - LenT,Tmp);
+// 	//       }
+// 	}
+	Buffer[/*ScreenWidth*/1024] = 0;
+	BlankLine[/*ScreenWidth*/1024] = 0;
+	sigprocmask(SIG_SETMASK,&OldSigs,0);
+
+	Update = false;
+
+	return !_cancelled;;
 }
 									/*}}}*/
 // AcqPackageKitStatus::MediaChange - Media need to be swapped		/*{{{*/
diff --git a/backends/aptcc/acqprogress.h b/backends/aptcc/acqprogress.h
index 6013d87..905a372 100644
--- a/backends/aptcc/acqprogress.h
+++ b/backends/aptcc/acqprogress.h
@@ -45,7 +45,7 @@ public:
 
 	void addPackagePair(pair<pkgCache::PkgIterator, pkgCache::VerIterator> packagePair);
 
-	AcqPackageKitStatus(aptcc *apt, PkBackend *backend, bool &cancelled, unsigned int Quiet);
+	AcqPackageKitStatus(aptcc *apt, PkBackend *backend, bool &cancelled);
 };
 
 #endif
diff --git a/backends/aptcc/apt.cpp b/backends/aptcc/apt.cpp
index e8b8f4f..f5a84b5 100644
--- a/backends/aptcc/apt.cpp
+++ b/backends/aptcc/apt.cpp
@@ -977,6 +977,152 @@ void aptcc::updateInterface(int fd, int writeFd)
 
 	usleep(5000);
 }
+
+// DoAutomaticRemove - Remove all automatic unused packages		/*{{{*/
+// ---------------------------------------------------------------------
+/* Remove unused automatic packages */
+bool aptcc::DoAutomaticRemove(pkgCacheFile &Cache)
+{
+	bool doAutoRemove = _config->FindB("APT::Get::AutomaticRemove", true);
+	pkgDepCache::ActionGroup group(*Cache);
+
+	if (_config->FindB("APT::Get::Remove",true) == false &&
+	    doAutoRemove == true)
+	{
+		cout << "We are not supposed to delete stuff, can't start "
+			"AutoRemover" << endl;
+		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);
+			}
+		}
+	}
+
+	// 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;
+}
+
+bool aptcc::runTransaction(vector<pair<pkgCache::PkgIterator, pkgCache::VerIterator> > &pkgs,
+			   bool simulate,
+			   bool remove)
+{
+	//cout << "runTransaction" << simulate << remove << endl;
+	bool WithLock = !simulate; // Check to see if we are just simulating,
+				   //since for that no lock is needed
+
+	pkgCacheFile Cache;
+	OpTextProgress Prog(*_config);
+	int timeout = 10;
+	// TODO test this
+	while (Cache.Open(Prog, WithLock) == false) {
+		// failed to open cache, try checkDeps then..
+		// || Cache.CheckDeps(CmdL.FileSize() != 1) == false
+		if (WithLock == false || (timeout <= 0)) {
+			pk_backend_error_code(m_backend,
+					      PK_ERROR_ENUM_NO_CACHE,
+					      "Could not open package cache.");
+			return false;
+		} else {
+			pk_backend_set_status (m_backend, PK_STATUS_ENUM_WAITING_FOR_LOCK);
+			sleep(1);
+			timeout--;
+		}
+	}
+	pk_backend_set_status (m_backend, PK_STATUS_ENUM_RUNNING);
+
+	// Enter the special broken fixing mode if the user specified arguments
+	bool BrokenFix = false;
+	if (Cache->BrokenCount() != 0) {
+		BrokenFix = true;
+	}
+
+	unsigned int ExpectedInst = 0;
+	pkgProblemResolver Fix(Cache);
+
+	// new scope for the ActionGroup
+	{
+		pkgDepCache::ActionGroup group(Cache);
+		for(vector<pair<pkgCache::PkgIterator, pkgCache::VerIterator> >::iterator i=pkgs.begin();
+		    i != pkgs.end();
+		    ++i)
+		{
+			pkgCache::PkgIterator Pkg = i->first;
+			if (_cancel) {
+				break;
+			}
+
+			if (TryToInstall(Pkg,
+					 Cache,
+					 Fix,
+					 remove,
+					 BrokenFix,
+					 ExpectedInst) == false) {
+				pk_backend_error_code(m_backend,
+						      PK_ERROR_ENUM_INTERNAL_ERROR,
+						      "Could not open package cache.");
+				return false;
+			}
+		}
+
+		/* If we are in the Broken fixing mode we do not attempt to fix the
+		    problems. This is if the user invoked install without -f and gave
+		    packages */
+		if (BrokenFix == true && Cache->BrokenCount() != 0)
+		{
+			_error->Error("Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).");
+			show_broken(m_backend, this);
+			return false;
+		}
+
+		// Call the scored problem resolver
+		Fix.InstallProtect();
+		if (Fix.Resolve(true) == false) {
+			_error->Discard();
+		}
+
+		// Now we check the state of the packages,
+		if (Cache->BrokenCount() != 0)
+		{
+		    show_broken(m_backend, this);
+		    return false;
+		}
+	}
+	// Try to auto-remove packages
+	if (!DoAutomaticRemove(Cache)) {
+		// TODO
+		return false;
+	}
+
+	if (simulate) {
+		// Print out a list of packages that are going to be installed extra
+		emitChangedPackages(pkgs, 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, false);
+	}
+}
+
 									/*}}}*/
 
 // InstallPackages - Actually download and install the packages		/*{{{*/
@@ -1015,8 +1161,10 @@ bool aptcc::installPackages(pkgDepCache &Cache,
 	// Sanity check
 	if (Cache.BrokenCount() != 0)
 	{
+		// TODO
 		show_broken(m_backend, this);
-		return _error->Error("Internal error, InstallPackages was called with broken packages!");
+		_error->Error("Internal error, InstallPackages was called with broken packages!");
+		return false;
 	}
 
 	if (Cache.DelCount() == 0 && Cache.InstCount() == 0 &&
@@ -1026,7 +1174,10 @@ bool aptcc::installPackages(pkgDepCache &Cache,
 
 	// No remove flag
 	if (Cache.DelCount() != 0 && _config->FindB("APT::Get::Remove",true) == false) {
-		return _error->Error("Packages need to be removed but remove is disabled.");
+		pk_backend_error_code(m_backend,
+				      PK_ERROR_ENUM_PACKAGE_FAILED_TO_REMOVE,
+				      "Packages need to be removed but remove is disabled.");
+		return false;
 	}
 
 	// Create the text record parser
@@ -1046,7 +1197,7 @@ bool aptcc::installPackages(pkgDepCache &Cache,
 	}
 
 	// Create the download object
-	AcqPackageKitStatus Stat(this, m_backend, _cancel, _config->FindI("quiet",0));
+	AcqPackageKitStatus Stat(this, m_backend, _cancel);
 
 	// get a fetcher
 	pkgAcquire fetcher(&Stat);
@@ -1109,6 +1260,7 @@ cout << "How odd.. The sizes didn't match, email apt at packages.debian.org";
 // 		    SizeToStr(-1*Cache.UsrSize()).c_str());
 
 	if (_error->PendingError() == true) {
+	    cout << "PendingError " << endl;
 		return false;
 	}
 
@@ -1168,6 +1320,11 @@ cout << "How odd.. The sizes didn't match, email apt at packages.debian.org";
 		return false;
 	}
 
+	if (_error->PendingError() == true) {
+		cout << "PendingError download" << endl;
+		return false;
+	}
+
 	// TODO true or false?
 	if (_cancel) {
 		return true;
@@ -1186,6 +1343,8 @@ cout << "How odd.. The sizes didn't match, email apt at packages.debian.org";
 	pkgPackageManager::OrderResult res;
 	res = PM->DoInstallPreFork();
 	if (res == pkgPackageManager::Failed) {
+		egg_warning ("Failed to prepare installation");
+		show_errors(m_backend, PK_ERROR_ENUM_PACKAGE_DOWNLOAD_FAILED);
 		return false;
 	}
 
@@ -1263,151 +1422,3 @@ cout << "How odd.. The sizes didn't match, email apt at packages.debian.org";
 	return true;
 }
 
-// DoAutomaticRemove - Remove all automatic unused packages		/*{{{*/
-// ---------------------------------------------------------------------
-/* Remove unused automatic packages */
-bool aptcc::DoAutomaticRemove(pkgCacheFile &Cache)
-{
-	bool doAutoRemove = _config->FindB("APT::Get::AutomaticRemove", true);
-	pkgDepCache::ActionGroup group(*Cache);
-
-	if (_config->FindB("APT::Get::Remove",true) == false &&
-	    doAutoRemove == true)
-	{
-		cout << "We are not supposed to delete stuff, can't start "
-			"AutoRemover" << endl;
-		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);
-			}
-		}
-	}
-
-	// 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;
-}
-
-bool aptcc::runTransaction(vector<pair<pkgCache::PkgIterator, pkgCache::VerIterator> > &pkgs,
-			   bool simulate,
-			   bool remove)
-{
-	//cout << "runTransaction" << simulate << remove << endl;
-	bool WithLock = !simulate; // Check to see if we are just simulating,
-				   //since for that no lock is needed
-
-	pkgCacheFile Cache;
-	OpTextProgress Prog(*_config);
-	int timeout = 10;
-	// TODO test this
-	while (Cache.Open(Prog, WithLock) == false) {
-		// failed to open cache, try checkDeps then..
-		// || Cache.CheckDeps(CmdL.FileSize() != 1) == false
-		if (WithLock == false || (timeout <= 0)) {
-			pk_backend_error_code(m_backend,
-					      PK_ERROR_ENUM_NO_CACHE,
-					      "Could not open package cache.");
-			return false;
-		} else {
-			pk_backend_set_status (m_backend, PK_STATUS_ENUM_WAITING_FOR_LOCK);
-			sleep(1);
-			timeout--;
-		}
-	}
-	pk_backend_set_status (m_backend, PK_STATUS_ENUM_RUNNING);
-
-	// Enter the special broken fixing mode if the user specified arguments
-	bool BrokenFix = false;
-	if (Cache->BrokenCount() != 0) {
-		BrokenFix = true;
-	}
-
-	unsigned int ExpectedInst = 0;
-	pkgProblemResolver Fix(Cache);
-
-	// new scope for the ActionGroup
-	{
-		pkgDepCache::ActionGroup group(Cache);
-		for(vector<pair<pkgCache::PkgIterator, pkgCache::VerIterator> >::iterator i=pkgs.begin();
-		    i != pkgs.end();
-		    ++i)
-		{
-			pkgCache::PkgIterator Pkg = i->first;
-			if (_cancel) {
-				break;
-			}
-
-			if (TryToInstall(Pkg,
-					 Cache,
-					 Fix,
-					 remove,
-					 BrokenFix,
-					 ExpectedInst) == false) {
-				pk_backend_error_code(m_backend,
-						      PK_ERROR_ENUM_INTERNAL_ERROR,
-						      "Could not open package cache.");
-				return false;
-			}
-		}
-
-		/* If we are in the Broken fixing mode we do not attempt to fix the
-		    problems. This is if the user invoked install without -f and gave
-		    packages */
-		if (BrokenFix == true && Cache->BrokenCount() != 0)
-		{
-			// TODO
-// 			ShowBroken(c1out,Cache,false);
-			cout << "Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution)." << endl;
-			return _error->Error("Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).");
-		}
-
-		// Call the scored problem resolver
-		Fix.InstallProtect();
-		if (Fix.Resolve(true) == false) {
-			_error->Discard();
-		}
-
-		// Now we check the state of the packages,
-		if (Cache->BrokenCount() != 0)
-		{
-	// 	    c1out << _("The following information may help to resolve the situation:") << endl;
-		    // TODO
-	// 	    ShowBroken(c1out,Cache,false);
-		    return _error->Error("Broken packages");
-		}
-	}
-	// Try to auto-remove packages
-	if (!DoAutomaticRemove(Cache)) {
-		return false;
-	}
-
-	if (simulate) {
-		// Print out a list of packages that are going to be installed extra
-		emitChangedPackages(pkgs, Cache);
-		return true;
-	} else {
-	    // See if we need to prompt
-	//     if (Cache->InstCount() == ExpectedInst && Cache->DelCount() == 0)
-	// 	return InstallPackages(Cache,false,false);
-		populateInternalPackages(Cache);
-	        return installPackages(Cache, false);
-	//	return true;
-	}
-}
diff --git a/backends/aptcc/pk-backend-aptcc.cpp b/backends/aptcc/pk-backend-aptcc.cpp
index 8f7b665..7b75762 100644
--- a/backends/aptcc/pk-backend-aptcc.cpp
+++ b/backends/aptcc/pk-backend-aptcc.cpp
@@ -476,7 +476,7 @@ backend_download_packages_thread (PkBackend *backend)
 
 	pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
 	// Create the progress
-	AcqPackageKitStatus Stat(m_apt, backend, _cancel, _config->FindI("quiet",0));
+	AcqPackageKitStatus Stat(m_apt, backend, _cancel);
 
 	// get a fetcher
 	pkgAcquire fetcher(&Stat);
@@ -611,7 +611,7 @@ backend_refresh_cache_thread (PkBackend *backend)
 		}
 	}
 	// Create the progress
-	AcqPackageKitStatus Stat(m_apt, backend, _cancel, _config->FindI("quiet",0));
+	AcqPackageKitStatus Stat(m_apt, backend, _cancel);
 
 	// do the work
 	if (_config->FindB("APT::Get::Download",true) == true) {


More information about the PackageKit-commit mailing list