From dfc1370d50322e2e9d225a7a63b44993fc01a727 Mon Sep 17 00:00:00 2001
From: Roy Li <rongqing.li@windriver.com>
Date: Fri, 22 May 2015 08:05:15 +0800
Subject: [PATCH] Revert "always run 'dpkg --configure -a' at the end of our
 dpkg callings"

Upstream-Status: Inappropriate [embedded specific]

This reverts commit a2a75ff4516f7609f4c55b42270abb8d08943c60, which
always run 'dpkg --configure -a' at the end of our dpkg callings,
but it does not work for cross-compile, since the rootfs dir can not
be passed into dpkg, and lead to the below similar error:
   -------
   |mkdir: cannot create directory '/usr/lib/opkg': Permission denied
   -------

Signed-off-by: Roy Li <rongqing.li@windriver.com>
---
 apt-pkg/deb/dpkgpm.cc                                     |  9 ++-------
 test/integration/test-apt-progress-fd-deb822              | 14 +++++++-------
 test/integration/test-no-fds-leaked-to-maintainer-scripts |  6 ++----
 3 files changed, 11 insertions(+), 18 deletions(-)

diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc
index 533d9b367..6ce81bbd9 100644
--- a/apt-pkg/deb/dpkgpm.cc
+++ b/apt-pkg/deb/dpkgpm.cc
@@ -1041,12 +1041,6 @@ void pkgDPkgPM::BuildPackagesProgressMap()
 	 PackagesTotal++;
       }
    }
-   /* one extra: We don't want the progress bar to reach 100%, especially not
-      if we call dpkg --configure --pending and process a bunch of triggers
-      while showing 100%. Also, spindown takes a while, so never reaching 100%
-      is way more correct than reaching 100% while still doing stuff even if
-      doing it this way is slightly bending the rules */
-   ++PackagesTotal;
 }
                                                                         /*}}}*/
 bool pkgDPkgPM::Go(int StatusFd)
@@ -1268,8 +1262,9 @@ bool pkgDPkgPM::Go(APT::Progress::PackageManager *progress)
 
    // support subpressing of triggers processing for special
    // cases like d-i that runs the triggers handling manually
+   bool const SmartConf = (_config->Find("PackageManager::Configure", "all") != "all");
    bool const TriggersPending = _config->FindB("DPkg::TriggersPending", false);
-   if (_config->FindB("DPkg::ConfigurePending", true) == true)
+   if (_config->FindB("DPkg::ConfigurePending", SmartConf) == true)
       List.push_back(Item(Item::ConfigurePending, PkgIterator()));
 
    // for the progress
diff --git a/test/integration/test-apt-progress-fd-deb822 b/test/integration/test-apt-progress-fd-deb822
index a8d59608d..0c6a9bbbf 100755
--- a/test/integration/test-apt-progress-fd-deb822
+++ b/test/integration/test-apt-progress-fd-deb822
@@ -27,36 +27,36 @@ Message: Installing testing (amd64)
 
 Status: progress
 Package: testing:amd64
-Percent: 16.6667
+Percent: 20
 Message: Preparing testing (amd64)
 
 Status: progress
 Package: testing:amd64
-Percent: 33.3333
+Percent: 40
 Message: Unpacking testing (amd64)
 
 Status: progress
 Package: testing:amd64
-Percent: 50.0000
+Percent: 60.0000
 Message: Preparing to configure testing (amd64)
 
 Status: progress
-Percent: 50.0000
+Percent: 60.0000
 Message: Running dpkg
 
 Status: progress
 Package: testing:amd64
-Percent: 50.0000
+Percent: 60.0000
 Message: Configuring testing (amd64)
 
 Status: progress
 Package: testing:amd64
-Percent: 66.6667
+Percent: 80
 Message: Configuring testing (amd64)
 
 Status: progress
 Package: testing:amd64
-Percent: 83.3333
+Percent: 100
 Message: Installed testing (amd64)
 
 Status: progress
diff --git a/test/integration/test-no-fds-leaked-to-maintainer-scripts b/test/integration/test-no-fds-leaked-to-maintainer-scripts
index d86e638cd..ef6d23be2 100755
--- a/test/integration/test-no-fds-leaked-to-maintainer-scripts
+++ b/test/integration/test-no-fds-leaked-to-maintainer-scripts
@@ -59,8 +59,7 @@ startup packages configure
 configure $PKGNAME 1.0 <none>
 status unpacked $PKGNAME 1.0
 status half-configured $PKGNAME 1.0
-status installed $PKGNAME 1.0
-startup packages configure" cut -f 3- -d' ' rootdir/var/log/dpkg.log
+status installed $PKGNAME 1.0" cut -f 3- -d' ' rootdir/var/log/dpkg.log
 }
 checkinstall
 
@@ -85,8 +84,7 @@ status config-files $PKGNAME 1.0
 status config-files $PKGNAME 1.0
 status config-files $PKGNAME 1.0
 status config-files $PKGNAME 1.0
-status not-installed $PKGNAME <none>
-startup packages configure" cut -f 3- -d' ' rootdir/var/log/dpkg.log
+status not-installed $PKGNAME <none>" cut -f 3- -d' ' rootdir/var/log/dpkg.log
 }
 checkpurge
 
-- 
2.11.0

