Explorar o código

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.
Ian Jackson %!s(int64=17) %!d(string=hai) anos
pai
achega
86823d5792
Modificáronse 4 ficheiros con 13 adicións e 2 borrados
  1. 4 0
      debian/changelog
  2. 2 1
      lib/dpkg/dpkg-db.h
  3. 5 0
      lib/dpkg/parse.c
  4. 2 1
      src/update.c

+ 4 - 0
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
     package and need no conflicts/breaks as the code does nothing if
     the current status file is already backupped. Thanks to Leo 'costela'
     the current status file is already backupped. Thanks to Leo 'costela'
     Antunes <costela@debian.org> for the patch. Closes: #541412
     Antunes <costela@debian.org> 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
+    <ian@davenant.greenend.org.uk> for the patch. Closes: #496114
 
 
   [ Modestas Vainius ]
   [ Modestas Vainius ]
   * Provide a meaningful label for dpkg-gensymbols diff.
   * Provide a meaningful label for dpkg-gensymbols diff.

+ 2 - 1
lib/dpkg/dpkg-db.h

@@ -338,7 +338,8 @@ enum parsedbflags {
   pdb_recordavailable   =001, /* Store in `available' in-core structures, not `status' */
   pdb_recordavailable   =001, /* Store in `available' in-core structures, not `status' */
   pdb_rejectstatus      =002, /* Throw up an error if `Status' encountered             */
   pdb_rejectstatus      =002, /* Throw up an error if `Status' encountered             */
   pdb_weakclassification=004, /* Ignore priority/section info if we already have any   */
   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);
 const char *illegal_packagename(const char *p, const char **ep);

+ 5 - 0
lib/dpkg/parse.c

@@ -328,6 +328,11 @@ int parsedb(const char *filename, enum parsedbflags flags,
 
 
     pigp= findpackage(newpig.name);
     pigp= findpackage(newpig.name);
     pifp= (flags & pdb_recordavailable) ? &pigp->available : &pigp->installed;
     pifp= (flags & pdb_recordavailable) ? &pigp->available : &pigp->installed;
+
+    if ((flags & pdb_ignoreolder) &&
+	versioncompare(&newpifp->version, &pifp->version) < 0)
+      continue;
+
     if (!pifp->valid) blankpackageperfile(pifp);
     if (!pifp->valid) blankpackageperfile(pifp);
 
 
     /* Copy the priority and section across, but don't overwrite existing
     /* Copy the priority and section across, but don't overwrite existing

+ 2 - 1
src/update.c

@@ -84,7 +84,8 @@ void updateavailable(const char *const *argv) {
     parsedb(vb.buf, pdb_recordavailable | pdb_rejectstatus, NULL, NULL, NULL);
     parsedb(vb.buf, pdb_recordavailable | pdb_rejectstatus, NULL, NULL, NULL);
 
 
   if (cipaction->arg != act_avclear)
   if (cipaction->arg != act_avclear)
-    count += parsedb(sourcefile, pdb_recordavailable | pdb_rejectstatus,
+    count += parsedb(sourcefile,
+		     pdb_recordavailable | pdb_rejectstatus | pdb_ignoreolder,
                      NULL, NULL, NULL);
                      NULL, NULL, NULL);
 
 
   if (!f_noact) {
   if (!f_noact) {