[Rpm-maint] [PATCH] Moved code to check possibility of freshen operation to checkFreshenStatus.

Rakesh Pandit rakesh.pandit at gmail.com
Wed Mar 11 06:54:44 UTC 2009


Is checkFreshenStatus apt enough ?

- Moved code to check possibility of freshen operation to checkFreshenStatus.

Patch: http://rakesh.fedorapeople.org/rpm/0002--Moved-code-to-check-possibility-of-freshen-operati.patch

-- 
Regards,
Rakesh Pandit

>From 3cab3dac76e2dfffbc6749b991e64032c8042fd4 Mon Sep 17 00:00:00 2001
From: Rakesh Pandit <rakesh at fedoraproject.org>
Date: Wed, 11 Mar 2009 12:12:59 +0530
Subject: [PATCH] - Moved code to check possibility of freshen
operation to checkFreshenStatus.

---
 lib/rpminstall.c |   57 +++++++++++++++++++++++++++++++----------------------
 1 files changed, 33 insertions(+), 24 deletions(-)

diff --git a/lib/rpminstall.c b/lib/rpminstall.c
index b1f558c..0afb98e 100644
--- a/lib/rpminstall.c
+++ b/lib/rpminstall.c
@@ -360,6 +360,36 @@ static int tryReadHeader(rpmts ts, struct rpmEIU
* eiu, rpmVSFlags vsflags)
    return RPMRC_OK;
 }

+
+/* On --freshen, verify package is installed and newer */
+static int checkFreshenStatus(rpmts ts, struct rpmEIU * eiu)
+{
+    int xx;
+    rpmdbMatchIterator mi;
+    const char * name;
+    Header oldH;
+    int count;
+
+    xx = headerNVR(eiu->h, &name, NULL, NULL);
+    mi = rpmtsInitIterator(ts, RPMTAG_NAME, name, 0);
+    count = rpmdbGetIteratorCount(mi);
+    while ((oldH = rpmdbNextIterator(mi)) != NULL) {
+        if (rpmVersionCompare(oldH, eiu->h) < 0)
+	    continue;
+	/* same or newer package already installed */
+	count = 0;
+	break;
+    }
+    mi = rpmdbFreeIterator(mi);
+    if (count == 0) {
+        eiu->h = headerFree(eiu->h);
+	return -1;
+    }
+    /* Package is newer than those currently installed. */
+
+   return 1;
+}
+
 /** @todo Generalize --freshen policies. */
 int rpmInstall(rpmts ts, struct rpmInstallArguments_s * ia, ARGV_t fileArgv)
 {
@@ -527,30 +557,9 @@ restart:
 	    }
 	}

-	/* On --freshen, verify package is installed and newer */
-	if (ia->installInterfaceFlags & INSTALL_FRESHEN) {
-	    rpmdbMatchIterator mi;
-	    const char * name;
-	    Header oldH;
-	    int count;
-
-	    xx = headerNVR(eiu->h, &name, NULL, NULL);
-	    mi = rpmtsInitIterator(ts, RPMTAG_NAME, name, 0);
-	    count = rpmdbGetIteratorCount(mi);
-	    while ((oldH = rpmdbNextIterator(mi)) != NULL) {
-		if (rpmVersionCompare(oldH, eiu->h) < 0)
-		    continue;
-		/* same or newer package already installed */
-		count = 0;
-		break;
-	    }
-	    mi = rpmdbFreeIterator(mi);
-	    if (count == 0) {
-		eiu->h = headerFree(eiu->h);
-		continue;
-	    }
-	    /* Package is newer than those currently installed. */
-	}
+	if (ia->installInterfaceFlags & INSTALL_FRESHEN)
+	    if (checkFreshenStatus(ts, eiu) != 1)
+	        continue;

 	rc = rpmtsAddInstallElement(ts, eiu->h, (fnpyKey)fileName,
 			(ia->installInterfaceFlags & INSTALL_UPGRADE) != 0,
-- 
1.6.0.6


More information about the Rpm-maint mailing list