socsvn commit: r254487 - soc2013/mattbw/backend
mattbw at FreeBSD.org
mattbw at FreeBSD.org
Tue Jul 9 10:00:21 UTC 2013
Author: mattbw
Date: Tue Jul 9 10:00:21 2013
New Revision: 254487
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254487
Log:
report packages already installed as installed when searching
Modified:
soc2013/mattbw/backend/pkgutils.c
soc2013/mattbw/backend/pkgutils.h
Modified: soc2013/mattbw/backend/pkgutils.c
==============================================================================
--- soc2013/mattbw/backend/pkgutils.c Tue Jul 9 09:59:46 2013 (r254486)
+++ soc2013/mattbw/backend/pkgutils.c Tue Jul 9 10:00:21 2013 (r254487)
@@ -18,6 +18,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
+#include <assert.h>
#include <string.h>
#include <glib.h>
#include "pk-backend.h"
@@ -33,9 +34,19 @@
PkInfoEnum
pkgutils_pkg_current_state(struct pkg *pkg)
{
+ PkInfoEnum info;
+
+ /* If the package is local, then it's installed. If it is remote, then
+ * it is installed if it is the same version as an installed package,
+ * and available if it is not.
+ */
+ if ((pkg_type(pkg) == PKG_INSTALLED) ||
+ pkgutils_pkg_install_state(pkg) == PK_INFO_ENUM_REINSTALLING)
+ info = PK_INFO_ENUM_INSTALLED;
+ else
+ info = PK_INFO_ENUM_AVAILABLE;
- return (pkg_type(pkg) == PKG_INSTALLED ?
- PK_INFO_ENUM_INSTALLED : PK_INFO_ENUM_AVAILABLE);
+ return info;
}
/*
@@ -146,6 +157,31 @@
}
/*
+ * Adds any old version of the given package to itself as PKG_OLD_VERSION.
+ */
+void
+pkgutils_add_old_version(struct pkgdb *db, struct pkg *pkg)
+{
+ const char *origin;
+ struct pkg *pkg2;
+
+ origin = NULL;
+ pkg_get(pkg, PKG_ORIGIN, &origin);
+
+ pkg2 = NULL;
+ if (pkg_try_installed(db, origin, &pkg2, PKG_LOAD_BASIC) == EPKG_OK) {
+ const char *version;
+
+ assert(pkg2 != NULL);
+
+ pkg_get(pkg2, PKG_VERSION, &version);
+ pkg_set(pkg, PKG_OLD_VERSION, version);
+
+ pkg_free(pkg2);
+ }
+}
+
+/*
* Emits a package through the backend with the given info enum.
*/
void
@@ -173,7 +209,7 @@
should_emit = TRUE;
- if (pkg_type(pkg) == PKG_INSTALLED)
+ if (pkgutils_pkg_current_state(pkg) == PK_INFO_ENUM_INSTALLED)
should_emit = pk_bitfield_contain(filters,
PK_FILTER_ENUM_NOT_INSTALLED) ? FALSE : should_emit;
else
Modified: soc2013/mattbw/backend/pkgutils.h
==============================================================================
--- soc2013/mattbw/backend/pkgutils.h Tue Jul 9 09:59:46 2013 (r254486)
+++ soc2013/mattbw/backend/pkgutils.h Tue Jul 9 10:00:21 2013 (r254487)
@@ -30,6 +30,7 @@
const char *pkgutils_pk_repo_of(struct pkg *pkg);
gchar *pkgutils_pkg_to_id(struct pkg *pkg);
gchar *pkgutils_pkg_to_id_through(struct pkg *pkg, const gchar **strv);
+void pkgutils_add_old_version(struct pkgdb *db, struct pkg *pkg);
void pkgutils_emit(struct pkg *pkg, PkBackend *backend, PkInfoEnum info);
void pkgutils_emit_filtered(struct pkg *pkg, PkBackend *backend, PkBitfield filters, PkInfoEnum info);
More information about the svn-soc-all
mailing list