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

Bug#594689: apt 0.8.0 breaks autoremove



package apt
tag 594689 + patch
thanks

Hi Andreas Metzler,

first of all: Thanks for your excellent report!

2010/8/28 Andreas Metzler <ametzler@downhill.at.eu.org>:
> since todays upgrade (apt 0.7.25.3 -> 0.8.0) autoremove is broken.

You are right, its broken and that even two times - and you can
blame me - who is going bright red with shame now - for both…
(and no, i don't know what i have smoked while introducing
those bugs, so i can't share with interested peers…)

The problem for you is fixed by:

=== modified file 'apt-pkg/depcache.h'
--- apt-pkg/depcache.h  2010-07-04 12:23:20 +0000
+++ apt-pkg/depcache.h  2010-08-28 16:54:58 +0000
@@ -186,7 +186,7 @@
    class DefaultRootSetFunc : public InRootSetFunc, public
Configuration::MatchAgainstConfig
    {
    public:
-     DefaultRootSetFunc() :
Configuration::MatchAgainstConfig("APT::NeverRemove") {};
+     DefaultRootSetFunc() :
Configuration::MatchAgainstConfig("APT::NeverAutoRemove") {};
      virtual ~DefaultRootSetFunc() {};

      bool InRootSet(const pkgCache::PkgIterator &pkg) { return
pkg.end() == true && Match(pkg.Name()); };


The rest is the not always true assumption that if this config setting has no
entries something is wrong… (its just unlikely as APT ships a default list).
(Complete patch attached for reference)

Looks like a binary compatible change at first glance, but i will test
later a bit. Otherwise i will do a bit of trickery in MatchAgainstConfig
to fix the misspelling…

No data is lost and in the case someone is in a hurry for autoremove:
Workaround it by providing a APT::NeverRemove list int the configs.
So at least we don't need to break the transition now…


Best regards

David Kalnischkies
=== modified file 'apt-pkg/contrib/configuration.cc'
--- apt-pkg/contrib/configuration.cc	2010-06-26 11:29:24 +0000
+++ apt-pkg/contrib/configuration.cc	2010-08-28 19:44:07 +0000
@@ -857,19 +857,27 @@
       {
 	 regfree(p);
 	 delete p;
+	 clearPatterns();
 	 _error->Warning("Regex compilation error for '%s' in configuration option '%s'",
 				s->c_str(), Config);
+	 return;
       }
-    }
-
+   }
+   if (strings.size() == 0)
+      patterns.push_back(NULL);
 }
 									/*}}}*/
 // MatchAgainstConfig Destructor					/*{{{*/
 Configuration::MatchAgainstConfig::~MatchAgainstConfig()
 {
+   clearPatterns();
+}
+void Configuration::MatchAgainstConfig::clearPatterns()
+{
    for(std::vector<regex_t *>::const_iterator p = patterns.begin();
 	p != patterns.end(); ++p)
    {
+      if (*p == NULL) continue;
       regfree(*p);
       delete *p;
    }
@@ -880,7 +888,7 @@
 {
    for(std::vector<regex_t *>::const_iterator p = patterns.begin();
 	p != patterns.end(); ++p)
-      if (regexec(*p, str, 0, 0, 0) == 0)
+      if (*p != NULL && regexec(*p, str, 0, 0, 0) == 0)
 	 return true;
 
    return false;

=== modified file 'apt-pkg/contrib/configuration.h'
--- apt-pkg/contrib/configuration.h	2010-06-26 11:29:24 +0000
+++ apt-pkg/contrib/configuration.h	2010-08-28 19:44:07 +0000
@@ -109,6 +109,7 @@
    class MatchAgainstConfig
    {
      std::vector<regex_t *> patterns;
+     void clearPatterns();
 
    public:
      MatchAgainstConfig(char const * Config);

=== modified file 'apt-pkg/depcache.h'
--- apt-pkg/depcache.h	2010-07-04 12:23:20 +0000
+++ apt-pkg/depcache.h	2010-08-28 19:44:07 +0000
@@ -186,7 +186,7 @@
    class DefaultRootSetFunc : public InRootSetFunc, public Configuration::MatchAgainstConfig
    {
    public:
-     DefaultRootSetFunc() : Configuration::MatchAgainstConfig("APT::NeverRemove") {};
+     DefaultRootSetFunc() : Configuration::MatchAgainstConfig("APT::NeverAutoRemove") {};
      virtual ~DefaultRootSetFunc() {};
 
      bool InRootSet(const pkgCache::PkgIterator &pkg) { return pkg.end() == true && Match(pkg.Name()); };

=== modified file 'debian/changelog'
--- debian/changelog	2010-08-28 15:54:29 +0000
+++ debian/changelog	2010-08-28 19:44:07 +0000
@@ -26,8 +26,10 @@
       pass this purge forward to the non-pseudo package for pseudos
   * apt-pkg/contrib/fileutl.cc:
     - apply SilentlyIgnore also on files without an extension
+  * apt-pkg/contrib/configuration.cc:
+    - fix autoremove by using correct configname and error handling
 
- -- David Kalnischkies <kalnischkies@gmail.com>  Sat, 28 Aug 2010 17:53:00 +0200
+ -- David Kalnischkies <kalnischkies@gmail.com>  Sat, 28 Aug 2010 21:42:48 +0200
 
 apt (0.8.0) unstable; urgency=low
 

=== added file 'test/integration/test-autoremove'
--- test/integration/test-autoremove	1970-01-01 00:00:00 +0000
+++ test/integration/test-autoremove	2010-08-28 19:44:07 +0000
@@ -0,0 +1,31 @@
+#!/bin/sh
+set -e
+
+local TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+setupenvironment
+configarchitecture "i386"
+
+buildsimplenativepackage "unrelated" "all" "1" "unstable"
+buildsimplenativepackage "po-debconf" "all" "1.0.16" "unstable"
+buildsimplenativepackage "debhelper" "all" "8.0.0" "unstable" "Depends: po-debconf"
+setupaptarchive
+
+aptget install unrelated debhelper -qq 2>&1 > /dev/null
+
+testfileequal "rootdir/var/lib/apt/extended_states" "Package: po-debconf
+Architecture: i386
+Auto-Installed: 1
+"
+aptget remove debhelper -y -qq 2>&1 > /dev/null
+aptget autoremove -y -qq 2>&1 > /dev/null
+
+testfileequal "rootdir/var/lib/apt/extended_states" ""
+
+sed -i rootdir/var/log/apt/history.log -e '/^Commandline: / d' -e '/^Start-Date: / d' -e '/^End-Date: / d'
+testfileequal "rootdir/var/log/apt/history.log" '
+Install: unrelated:i386 (1), debhelper:i386 (8.0.0), po-debconf:i386 (1.0.16, automatic)
+
+Remove: debhelper:i386 (8.0.0)
+
+Remove: po-debconf:i386 (1.0.16)'


Reply to: