From 350566818c15706569bae25817862ce453b46b58 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Sun, 9 Aug 2009 23:34:07 +0200 Subject: [PATCH] xbps_find_new_pkg: always set pkg state. --HG-- extra : convert_revision : e259f424344c9aa618e9ba515a4d39a8b9a11655 --- lib/findpkg.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/lib/findpkg.c b/lib/findpkg.c index f9598233e2..f10756e1ca 100644 --- a/lib/findpkg.c +++ b/lib/findpkg.c @@ -205,6 +205,7 @@ xbps_find_new_pkg(const char *pkgname, prop_dictionary_t instpkg) struct repository_data *rdata; const char *repoloc, *repover, *instver; int rv = 0; + pkg_state_t state = 0; assert(pkgname != NULL); assert(instpkg != NULL); @@ -266,6 +267,24 @@ xbps_find_new_pkg(const char *pkgname, prop_dictionary_t instpkg) goto out; } + /* + * Always set "not-installed" package state. Will be overwritten + * to its correct state later. + */ + rv = xbps_set_pkg_state_dictionary(pkgrd, XBPS_PKG_STATE_NOT_INSTALLED); + if (rv != 0) + goto out; + + /* + * Overwrite package state in dictionary if it was unpacked + * previously. + */ + rv = xbps_get_pkg_state_installed(pkgname, &state); + if (rv == 0) { + if ((rv = xbps_set_pkg_state_dictionary(pkgrd, state)) != 0) + goto out; + } + if (!prop_array_add(unsorted, pkgrd)) rv = errno;