]> git.saurik.com Git - apt.git/commitdiff
* apt-pkg/contrib/configuration.cc:
authorDavid Kalnischkies <kalnischkies@gmail.com>
Sat, 28 Aug 2010 20:26:32 +0000 (22:26 +0200)
committerDavid Kalnischkies <kalnischkies@gmail.com>
Sat, 28 Aug 2010 20:26:32 +0000 (22:26 +0200)
  - fix autoremove by using correct config-option name and
    don't make faulty assumptions in error handling (Closes: #594689)

apt-pkg/contrib/configuration.cc
apt-pkg/contrib/configuration.h
apt-pkg/depcache.h
debian/changelog
test/integration/test-autoremove [new file with mode: 0755]

index 81cc87d15e93b434e1a0003c65bdcc96b6ec7866..cc7093fe2cf4146c1574dcd38f03fead67ed2dc6 100644 (file)
@@ -857,19 +857,27 @@ Configuration::MatchAgainstConfig::MatchAgainstConfig(char const * Config)
       {
         regfree(p);
         delete p;
       {
         regfree(p);
         delete p;
+        clearPatterns();
         _error->Warning("Regex compilation error for '%s' in configuration option '%s'",
                                s->c_str(), Config);
         _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()
 }
                                                                        /*}}}*/
 // MatchAgainstConfig Destructor                                       /*{{{*/
 Configuration::MatchAgainstConfig::~MatchAgainstConfig()
+{
+   clearPatterns();
+}
+void Configuration::MatchAgainstConfig::clearPatterns()
 {
    for(std::vector<regex_t *>::const_iterator p = patterns.begin();
        p != patterns.end(); ++p)
    {
 {
    for(std::vector<regex_t *>::const_iterator p = patterns.begin();
        p != patterns.end(); ++p)
    {
+      if (*p == NULL) continue;
       regfree(*p);
       delete *p;
    }
       regfree(*p);
       delete *p;
    }
@@ -880,7 +888,7 @@ bool Configuration::MatchAgainstConfig::Match(char const * str) const
 {
    for(std::vector<regex_t *>::const_iterator p = patterns.begin();
        p != patterns.end(); ++p)
 {
    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;
         return true;
 
    return false;
index cbe18e4e56e6e7fa24f03f286c3582ee538405b3..175c1bef3b91540cf8f63e982eb7a932f8153b10 100644 (file)
@@ -109,6 +109,7 @@ class Configuration
    class MatchAgainstConfig
    {
      std::vector<regex_t *> patterns;
    class MatchAgainstConfig
    {
      std::vector<regex_t *> patterns;
+     void clearPatterns();
 
    public:
      MatchAgainstConfig(char const * Config);
 
    public:
      MatchAgainstConfig(char const * Config);
index 45276dc954803685df2c44c7d5a4f72283d530fb..08e68355814d1ebd66d03bc7257a531dc82d34c1 100644 (file)
@@ -186,7 +186,7 @@ class pkgDepCache : protected pkgCache::Namespace
    class DefaultRootSetFunc : public InRootSetFunc, public Configuration::MatchAgainstConfig
    {
    public:
    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()); };
      virtual ~DefaultRootSetFunc() {};
 
      bool InRootSet(const pkgCache::PkgIterator &pkg) { return pkg.end() == true && Match(pkg.Name()); };
index 4ec71cbb655c9449f20d0dba0dbd5d19af5c1c1a..072c00398e2519a36474e6a2442ffb356a8c2720 100644 (file)
@@ -26,8 +26,11 @@ apt (0.8.1) UNRELEASED; urgency=low
       pass this purge forward to the non-pseudo package for pseudos
   * apt-pkg/contrib/fileutl.cc:
     - apply SilentlyIgnore also on files without an extension
       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 config-option name and
+      don't make faulty assumptions in error handling (Closes: #594689)
 
 
- -- David Kalnischkies <kalnischkies@gmail.com>  Sat, 28 Aug 2010 17:53:00 +0200
+ -- David Kalnischkies <kalnischkies@gmail.com>  Sat, 28 Aug 2010 22:23:20 +0200
 
 apt (0.8.0) unstable; urgency=low
 
 
 apt (0.8.0) unstable; urgency=low
 
diff --git a/test/integration/test-autoremove b/test/integration/test-autoremove
new file mode 100755 (executable)
index 0000000..fb39e97
--- /dev/null
@@ -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)'