[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#534920: patch to fix issue



Here's a patch to fix this problem. It works by removing the package name from the list of packages each time it successfully updates an entry. If there are any left over after processing the complete file, it adds the entries to the end of the file.

There isn't a constructor for TagSection classes in apt_pkg (from python-apt) so I just emit the lines by hand.

-gc

--
Gene Cash       Oracle Support Services (Orlando, FL USA)
--- /usr/bin/apt-mark	2009-12-15 03:29:39.000000000 -0500
+++ apt-mark	2010-01-14 10:34:30.000000000 -0500
@@ -44,14 +44,19 @@
             if pkgname in pkgs:
                 if options.verbose:
                     print "changing %s to %s" % (pkgname,action)
                 newsec = apt_pkg.RewriteSection(tagfile.Section,
                                        [],
-                                       [ ("Auto-Installed",str(action)) ]
-                                       )
+                                       [ ("Auto-Installed",str(action)) ])
+                pkgs.remove(pkgname)
                 outfile.write(newsec+"\n")
             else:
                 outfile.write(str(tagfile.Section)+"\n")
+        if action == 1:
+            for pkgname in pkgs:
+                if options.verbose:
+                    print "changing %s to %s" % (pkgname,action)
+                outfile.write("Package: %s\nAuto-Installed: %d\n\n" % (pkgname, action))
         # all done, rename the tmpfile
         os.chmod(outfile.name, 0644)
         os.rename(outfile.name, STATE_FILE)
         os.chmod(STATE_FILE, 0644)


Reply to: