The following commit has been merged in the master branch:
commit 86823d5792af8328107c3d86e486d2cf373da128
Author: Ian Jackson <[email protected]>
Date:   Sat Aug 15 12:42:03 2009 +0200

    dpkg: change behaviour of --merge-avail
    
    With this change, dpkg --merge-avail does not update a package's
    information if the version provided is older than the one already listed
    in the available file.

diff --git a/debian/changelog b/debian/changelog
index 1563df5..05b7af8 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -57,6 +57,10 @@ dpkg (1.15.4) UNRELEASED; urgency=low
     package and need no conflicts/breaks as the code does nothing if
     the current status file is already backupped. Thanks to Leo 'costela'
     Antunes <[email protected]> for the patch. Closes: #541412
+  * Change behaviour of dpkg --merge-avail to not update a package's
+    information if the version provided is older than the one already listed
+    in the available file. Thanks to Ian Jackson
+    <[email protected]> for the patch. Closes: #496114
 
   [ Modestas Vainius ]
   * Provide a meaningful label for dpkg-gensymbols diff.
diff --git a/lib/dpkg/dpkg-db.h b/lib/dpkg/dpkg-db.h
index 34943f7..39b6e16 100644
--- a/lib/dpkg/dpkg-db.h
+++ b/lib/dpkg/dpkg-db.h
@@ -338,7 +338,8 @@ enum parsedbflags {
   pdb_recordavailable   =001, /* Store in `available' in-core structures, not 
`status' */
   pdb_rejectstatus      =002, /* Throw up an error if `Status' encountered     
        */
   pdb_weakclassification=004, /* Ignore priority/section info if we already 
have any   */
-  pdb_ignorefiles       =010  /* Ignore files info if we already have them     
        */
+  pdb_ignorefiles       =010, /* Ignore files info if we already have them     
        */
+  pdb_ignoreolder       =020  /* Ignore packages with older versions already 
read      */
 };
 
 const char *illegal_packagename(const char *p, const char **ep);
diff --git a/lib/dpkg/parse.c b/lib/dpkg/parse.c
index c91eb6b..84ac195 100644
--- a/lib/dpkg/parse.c
+++ b/lib/dpkg/parse.c
@@ -328,6 +328,11 @@ int parsedb(const char *filename, enum parsedbflags flags,
 
     pigp= findpackage(newpig.name);
     pifp= (flags & pdb_recordavailable) ? &pigp->available : &pigp->installed;
+
+    if ((flags & pdb_ignoreolder) &&
+       versioncompare(&newpifp->version, &pifp->version) < 0)
+      continue;
+
     if (!pifp->valid) blankpackageperfile(pifp);
 
     /* Copy the priority and section across, but don't overwrite existing
diff --git a/src/update.c b/src/update.c
index 0e85b02..4a97a8c 100644
--- a/src/update.c
+++ b/src/update.c
@@ -84,7 +84,8 @@ void updateavailable(const char *const *argv) {
     parsedb(vb.buf, pdb_recordavailable | pdb_rejectstatus, NULL, NULL, NULL);
 
   if (cipaction->arg != act_avclear)
-    count += parsedb(sourcefile, pdb_recordavailable | pdb_rejectstatus,
+    count += parsedb(sourcefile,
+                    pdb_recordavailable | pdb_rejectstatus | pdb_ignoreolder,
                      NULL, NULL, NULL);
 
   if (!f_noact) {

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]

Reply via email to