]> git.saurik.com Git - apt.git/commitdiff
Merge remote-tracking branch 'donkult/debian/sid' into debian/sid
authorMichael Vogt <mvo@debian.org>
Fri, 14 Feb 2014 21:28:34 +0000 (22:28 +0100)
committerMichael Vogt <mvo@debian.org>
Fri, 14 Feb 2014 21:28:34 +0000 (22:28 +0100)
Conflicts:
apt-private/acqprogress.cc

apt-pkg/cacheset.cc
apt-pkg/cacheset.h
apt-private/private-cacheset.h
test/integration/test-kernel-helper-autoremove [new file with mode: 0755]
test/integration/test-kernel-helper-autoremove.fake-dpkg [new file with mode: 0644]

index 29281aab93569636a66cfb9d77f3e2058544cc1f..eab1e09f86d23284a3b19fce1feecb0156e75798 100644 (file)
@@ -204,12 +204,20 @@ PackageContainerInterface::FromFnmatch(PackageContainerInterface * const pci,
                }
 
                pci->insert(Pkg);
+#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13)
+               helper.showFnmatchSelection(Pkg, pattern);
+#else
                helper.showRegExSelection(Pkg, pattern);
+#endif
                found = true;
        }
 
        if (found == false) {
-               helper.canNotFindRegEx(pci, Cache, pattern);
+#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13)
+               helper.canNotFindFnmatch(pci, Cache, pattern);
+#else
+                helper.canNotFindRegEx(pci, Cache, pattern);
+#endif
                pci->setConstructor(UNKNOWN);
                return false;
        }
@@ -304,7 +312,6 @@ bool PackageContainerInterface::FromString(PackageContainerInterface * const pci
 
        if (FromGroup(pci, Cache, str, helper) == false &&
                 FromTask(pci, Cache, str, helper) == false &&
-                FromFnmatch(pci, Cache, str, helper) == false &&
                 FromRegEx(pci, Cache, str, helper) == false)
        {
                helper.canNotFindPackage(pci, Cache, str);
@@ -588,7 +595,13 @@ void CacheSetHelper::canNotFindRegEx(PackageContainerInterface * const pci, pkgC
        if (ShowError == true)
                _error->Insert(ErrorType, _("Couldn't find any package by regex '%s'"), pattern.c_str());
 }
-                                                                       /*}}}*/
+#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13)
+// canNotFindFnmatch - handle the case no package is found by a fnmatch        /*{{{*/
+void CacheSetHelper::canNotFindFnmatch(PackageContainerInterface * const pci, pkgCacheFile &Cache, std::string pattern) {
+       if (ShowError == true)
+               _error->Insert(ErrorType, _("Couldn't find any package by glob '%s'"), pattern.c_str());
+}
+#endif                                                                 /*}}}*/
 // canNotFindPackage - handle the case no package is found from a string/*{{{*/
 void CacheSetHelper::canNotFindPackage(PackageContainerInterface * const pci, pkgCacheFile &Cache, std::string const &str) {
 }
@@ -648,6 +661,13 @@ void CacheSetHelper::showRegExSelection(pkgCache::PkgIterator const &pkg,
                                        std::string const &pattern) {
 }
                                                                        /*}}}*/
+#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13)
+// showFnmatchSelection                                                        /*{{{*/
+void CacheSetHelper::showFnmatchSelection(pkgCache::PkgIterator const &pkg,
+                                          std::string const &pattern) {
+}
+                                                                       /*}}}*/
+#endif
 // showSelectedVersion                                                 /*{{{*/
 void CacheSetHelper::showSelectedVersion(pkgCache::PkgIterator const &Pkg,
                                         pkgCache::VerIterator const Ver,
index 29103aad9c3f4cffb5dd66c498cb20a5bb02dc57..b69d74b8eaff1506b524518209c068ce35463c24 100644 (file)
@@ -48,11 +48,17 @@ public:                                                                     /*{{{*/
 
        virtual void showTaskSelection(pkgCache::PkgIterator const &pkg, std::string const &pattern);
        virtual void showRegExSelection(pkgCache::PkgIterator const &pkg, std::string const &pattern);
+#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13)
+       virtual void showFnmatchSelection(pkgCache::PkgIterator const &pkg, std::string const &pattern);
+#endif
        virtual void showSelectedVersion(pkgCache::PkgIterator const &Pkg, pkgCache::VerIterator const Ver,
                                 std::string const &ver, bool const verIsRel);
 
        virtual void canNotFindTask(PackageContainerInterface * const pci, pkgCacheFile &Cache, std::string pattern);
        virtual void canNotFindRegEx(PackageContainerInterface * const pci, pkgCacheFile &Cache, std::string pattern);
+#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13)
+       virtual void canNotFindFnmatch(PackageContainerInterface * const pci, pkgCacheFile &Cache, std::string pattern);
+#endif
        virtual void canNotFindPackage(PackageContainerInterface * const pci, pkgCacheFile &Cache, std::string const &str);
 
        virtual void canNotFindAllVer(VersionContainerInterface * const vci, pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg);
index 15b531e9d1be476ea68544e5b039dde7972e4b01..322b3be6b95dbbb29ae1e9fa10711f577abe2283 100644 (file)
@@ -101,6 +101,11 @@ public:
                                Pkg.FullName(true).c_str(), pattern.c_str());
                explicitlyNamed = false;
        }
+        virtual void showFnmatchSelection(pkgCache::PkgIterator const &Pkg, std::string const &pattern) {
+               ioprintf(out, _("Note, selecting '%s' for glob '%s'\n"),
+                               Pkg.FullName(true).c_str(), pattern.c_str());
+               explicitlyNamed = false;
+       }
        virtual void showRegExSelection(pkgCache::PkgIterator const &Pkg, std::string const &pattern) {
                ioprintf(out, _("Note, selecting '%s' for regex '%s'\n"),
                                Pkg.FullName(true).c_str(), pattern.c_str());
diff --git a/test/integration/test-kernel-helper-autoremove b/test/integration/test-kernel-helper-autoremove
new file mode 100755 (executable)
index 0000000..2b165d1
--- /dev/null
@@ -0,0 +1,55 @@
+#!/bin/sh
+
+set -e
+
+# setup testdir
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+
+TMPDIR=$(mktemp -d)
+cd $TMPDIR
+addtrap "cd /; rm -rf $TMPDIR"
+
+# create mock environment
+mkdir apt.conf.d
+cat > aptconfig.conf <<EOF
+Dir::Etc::parts "$TMPDIR/apt.conf.d";
+Dir::bin::dpkg "$TMPDIR/fake-dpkg";
+EOF
+APT_CONFIG=aptconfig.conf
+export APT_CONFIG
+
+# install fake-dpkg into it
+install -m755 $TESTDIR/test-kernel-helper-autoremove.fake-dpkg $TMPDIR/fake-dpkg
+
+# run the helper
+sh ${TESTDIR}/../../debian/apt.auto-removal.sh
+
+msgtest 'Check that kernel autoremoval list is correctly created'
+# and ensure its there, valid and version 10.0.0-1 is there too
+test -e $TMPDIR/apt.conf.d/01autoremove-kernels && msgpass || msgfail
+
+msgtest 'Check that most recent kernel is saved from autoremoval'
+apt-config -c ${APT_CONFIG} dump|grep -q "APT::NeverAutoRemove::.*\^linux-image-10.0.0-1-generic" && msgpass || msgfail
+
+# ... and also that the running kernel is excluded
+msgtest 'Check that running kernel is saved from autoremoval'
+apt-config -c ${APT_CONFIG} dump|grep -q "APT::NeverAutoRemove::.*\^linux-image-$(uname -r)" && msgpass || msgfail
+
+# and that the old kernel is *not* excluded from autoremoval
+msgtest 'Check that older kernels are not excluded from autoremoval'
+apt-config -c ${APT_CONFIG} dump|grep -q "APT::NeverAutoRemove::.*\^linux-image-1\.0\.01-2-generic" && msgfail || msgpass
+
+msgtest "Check that the older kernel is retained when it's being installed"
+sh ${TESTDIR}/../../debian/apt.auto-removal.sh 1.0.01-2-generic
+test -e $TMPDIR/apt.conf.d/01autoremove-kernels
+if ! apt-config -c ${APT_CONFIG} dump|grep -q "APT::NeverAutoRemove::.*\^linux-image-10.0.0-1-generic" \
+   || ! apt-config -c ${APT_CONFIG} dump|grep -q "APT::NeverAutoRemove::.*\^linux-image-$(uname -r)" \
+   || ! apt-config -c ${APT_CONFIG} dump|grep -q "APT::NeverAutoRemove::.*\^linux-image-1\.0\.01-2-generic"
+then
+       msgfail
+else
+       msgpass
+fi
+
+# done
diff --git a/test/integration/test-kernel-helper-autoremove.fake-dpkg b/test/integration/test-kernel-helper-autoremove.fake-dpkg
new file mode 100644 (file)
index 0000000..a365c53
--- /dev/null
@@ -0,0 +1,13 @@
+#!/bin/sh
+set -e
+
+if [ "$1" = "-l" ]; then
+    echo "ii  linux-image-1.0.0-2-generic  1.0.01-2  amd64"
+    echo "ii  linux-image-$(uname -r)  not-used  amd64"
+    echo "ii linux-image-10.0.0-1-generic  10.0.0.1-1  amd64"
+elif [ "$1" = "--compare-versions" ]; then
+    dpkg "$1" "$2" "$3" "$4"
+else
+    dpkg $@
+fi
+