[pacman-dev] [PATCH] Ensure DESC infolevel is loaded before checking pkg->filename

Dan McGee dan at archlinux.org
Wed Feb 13 23:56:03 EST 2008


This is the first step of fixing FS#9547. This should not break any existing
code that may rely on this function behaving the way it did, and should be
good for inclusion in a maint release.

In addition, update pactest so it fills the FILENAME field in the DB entries
it creates so we can move forward with a real fix to this issue.

Signed-off-by: Dan McGee <dan at archlinux.org>
---

How about this for a maint release fix? Then we can further evaluate if
necessary for either 3.1.3 or 3.2.0. Of course, if we can address all of the
issues I brought up in my last email regarding your patch, then we can
try and fully fix the problem in 3.1.2. This just seems like a safer road
to take when we aren't going to be able to get a lot of testing in.

-Dan

 lib/libalpm/be_files.c |    4 ----
 lib/libalpm/package.c  |    7 ++++---
 pactest/pmdb.py        |    1 +
 3 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/lib/libalpm/be_files.c b/lib/libalpm/be_files.c
index 724e3c8..4cd0985 100644
--- a/lib/libalpm/be_files.c
+++ b/lib/libalpm/be_files.c
@@ -297,10 +297,6 @@ int _alpm_db_read(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq)
 			}
 			_alpm_strtrim(line);
 			if(!strcmp(line, "%FILENAME%")) {
-				/* filename is _new_ - it provides the real name of the package, on the
-				 * server, to allow for us to not tie the name of the actual file to the
-				 * data of the package
-				 */
 				if(fgets(info->filename, sizeof(info->filename), fp) == NULL) {
 					goto error;
 				}
diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c
index 937ee3e..363cf31 100644
--- a/lib/libalpm/package.c
+++ b/lib/libalpm/package.c
@@ -162,11 +162,12 @@ const char SYMEXPORT *alpm_pkg_get_filename(pmpkg_t *pkg)
 	ASSERT(handle != NULL, return(NULL));
 	ASSERT(pkg != NULL, return(NULL));
 
+	if(pkg->origin == PKG_FROM_CACHE && !(pkg->infolevel & INFRQ_DESC)) {
+		_alpm_db_read(pkg->origin_data.db, pkg, INFRQ_DESC);
+	}
+
 	if(!strlen(pkg->filename)) {
 		/* construct the file name, it's not in the desc file */
-		if(pkg->origin == PKG_FROM_CACHE && !(pkg->infolevel & INFRQ_DESC)) {
-			_alpm_db_read(pkg->origin_data.db, pkg, INFRQ_DESC);
-		}
 		if(pkg->arch && strlen(pkg->arch) > 0) {
 			snprintf(pkg->filename, PKG_FILENAME_LEN, "%s-%s-%s" PKGEXT,
 			         pkg->name, pkg->version, pkg->arch);
diff --git a/pactest/pmdb.py b/pactest/pmdb.py
index af39200..e0f328e 100755
--- a/pactest/pmdb.py
+++ b/pactest/pmdb.py
@@ -261,6 +261,7 @@ class pmdb:
             if pkg.reason:
                 data.append(_mksection("REASON", pkg.reason))
         else:
+            data.append(_mksection("FILENAME", pkg.filename()))
             if pkg.replaces:
                 data.append(_mksection("REPLACES", pkg.replaces))
             if pkg.force:
-- 
1.5.4.1





More information about the pacman-dev mailing list