Przeglądaj źródła

Merge branch 'debian/sid' into feature/install-progress-refactor

Conflicts:
	apt-pkg/deb/dpkgpm.cc
Michael Vogt 12 lat temu
rodzic
commit
e8022b09e7

+ 36 - 10
apt-pkg/deb/dpkgpm.cc

@@ -542,8 +542,8 @@ void pkgDPkgPM::ProcessDpkgStatusLine(char *line)
    // A dpkg error message may contain additional ":" (like
    //  "failed in buffer_write(fd) (10, ret=-1): backend dpkg-deb ..."
    // so we need to ensure to not split too much
-   std::vector<std::string> list = StringSplit(line, ": ", 3);
-   if(list.size() != 3)
+   std::vector<std::string> list = StringSplit(line, ": ", 4);
+   if(list.size() < 3)
    {
       if (Debug == true)
 	 std::clog << "ignoring line: not enough ':'" << std::endl;
@@ -553,11 +553,32 @@ void pkgDPkgPM::ProcessDpkgStatusLine(char *line)
    std::string pkgname = list[1];
    if (pkgname.find(":") == std::string::npos)
    {
-      string const nativeArch = _config->Find("APT::Architecture");
-      pkgname = pkgname + ":" + nativeArch;
+      // find the package in the group that is in a touched by dpkg
+      // if there are multiple dpkg will send us a full pkgname:arch
+      pkgCache::GrpIterator Grp = Cache.FindGrp(pkgname);
+      if (Grp.end() == false) 
+      {
+          pkgCache::PkgIterator P = Grp.PackageList();
+          for (; P.end() != true; P = Grp.NextPkg(P))
+          {
+              if(Cache[P].Mode != pkgDepCache::ModeKeep)
+              {
+                  pkgname = P.FullName();
+                  break;
+              }
+          }
+      }
    }
    const char* const pkg = pkgname.c_str();
    const char* action = list[2].c_str();
+   
+   std::string short_pkgname = StringSplit(pkgname, ":")[0];
+   std::string i18n_pkgname = short_pkgname;
+   if (pkgname.find(":") != string::npos)
+   {
+      strprintf(i18n_pkgname, "%s (%s)", short_pkgname.c_str(),
+                StringSplit(pkgname, ":")[1].c_str());
+   }
 
    // 'processing' from dpkg looks like
    // 'processing: action: pkg'
@@ -609,17 +630,19 @@ void pkgDPkgPM::ProcessDpkgStatusLine(char *line)
       // only read the translation if there is actually a next
       // action
       std::string translation;
-      strprintf(translation, _(states[PackageOpsDone[pkg]].str), pkg);
+      strprintf(translation, _(states[PackageOpsDone[pkg]].str), 
+                i18n_pkgname.c_str());
 
       // we moved from one dpkg state to a new one, report that
       PackageOpsDone[pkg]++;
       PackagesDone++;
+
       // and send to the progress
-      d->progress->StatusChanged(pkg, PackagesDone, PackagesTotal,
+      d->progress->StatusChanged(pkgname, PackagesDone, PackagesTotal,
                                  translation);
    }
    if (Debug == true) 
-      std::clog << "(parsed from dpkg) pkg: " << pkg 
+      std::clog << "(parsed from dpkg) pkg: " << pkgname
 		<< " action: " << action << endl;
 }
 									/*}}}*/
@@ -1268,7 +1291,9 @@ bool pkgDPkgPM::Go(APT::Progress::PackageManager *progress)
       _config->Set("APT::Keep-Fds::",fd[1]);
 
        // Tell the progress that its starting and fork dpkg 
+      // FIXME: this is called once per dpkg run which is *too often*
       d->progress->Start();
+
       pid_t Child = ExecFork();
       // This is the child
       if (Child == 0)
@@ -1376,6 +1401,7 @@ bool pkgDPkgPM::Go(APT::Progress::PackageManager *progress)
 	    select_ret = racy_pselect(max(master, _dpkgin)+1, &rfds, NULL,
 				      NULL, &tv, &original_sigmask);
          d->progress->Pulse();
+
 	 if (select_ret == 0) 
   	    continue;
   	 else if (select_ret < 0 && errno == EINTR)
@@ -1401,9 +1427,6 @@ bool pkgDPkgPM::Go(APT::Progress::PackageManager *progress)
       
       signal(SIGHUP,old_SIGHUP);
 
-      // tell the progress
-      d->progress->Stop();
-
       if(master >= 0) 
       {
 	 tcsetattr(0, TCSAFLUSH, &tt);
@@ -1434,6 +1457,7 @@ bool pkgDPkgPM::Go(APT::Progress::PackageManager *progress)
 	 if(stopOnError) 
 	 {
 	    CloseLog();
+            d->progress->Stop();
 	    return false;
 	 }
       }      
@@ -1442,6 +1466,8 @@ bool pkgDPkgPM::Go(APT::Progress::PackageManager *progress)
 
    // dpkg is done at this point
    d->progress->StatusChanged("", PackagesDone, PackagesTotal, "");
+   d->progress->Stop();
+
 
    if (pkgPackageManager::SigINTStop)
        _error->Warning(_("Operation was interrupted before it could finish"));

+ 1 - 0
apt-pkg/deb/dpkgpm.h

@@ -88,6 +88,7 @@ class pkgDPkgPM : public pkgPackageManager
    // Terminal progress 
    void SetupTerminalScrollArea(int nr_scrolled_rows);
    void SendTerminalProgress(float percentage);
+   void CleanupTerminal();
 
    // apport integration
    void WriteApportReport(const char *pkgpath, const char *errormsg);

+ 16 - 2
debian/changelog

@@ -1,3 +1,17 @@
+apt (0.9.12.1) unstable; urgency=low
+
+  [ Michael Vogt ]
+  * do not send pkgname:arch over the APT::Status-Fd to not break
+    clients (closes: 726156). A new APT::Status-deb822-Fd will be
+    used to fix this.
+  * add integration tests for APT::Status-Fd
+  * add missing _() around the new "Progress" string
+
+  [ David Kalnischkies ]
+  * fix progress-segfault in case of dpkg errors/prompts (Closes: 726047)
+
+ -- Michael Vogt <mvo@debian.org>  Tue, 15 Oct 2013 18:25:51 +0200
+
 apt (0.9.12) unstable; urgency=low
 
   [ Christian Perrier ]
@@ -29,7 +43,7 @@ apt (0.9.12) unstable; urgency=low
     never remove packages
   * Rename "--dpkg-progress" to "--show-progress" and document it in 
     apt-get.8. This will show global install progress information in the
-    terminal window.
+    terminal.
   * Fix status-fd progress calculation for certain multi-arch install/upgrade
     situations
   * add new -o DpkgPM::Progress-Fancy for nicer dpkg progress output 
@@ -44,7 +58,7 @@ apt (0.9.12) unstable; urgency=low
       Acquire::PDiffs::FileLimit "0";
     in /etc/apt/apt.conf to get the old behavior back.
 
- -- Michael Vogt <mvo@debian.org>  Wed, 09 Oct 2013 20:50:03 +0200
+ -- Michael Vogt <mvo@debian.org>  Wed, 09 Oct 2013 22:39:41 +0200
 
 apt (0.9.11.4) unstable; urgency=low
 

Plik diff jest za duży
+ 0 - 3205
po/apt-all.pot


+ 5 - 1
test/integration/framework

@@ -335,6 +335,7 @@ buildsimplenativepackage() {
 
 	local SECTION="${7:-others}"
 	local PRIORITY="${8:-optional}"
+        local FILE_TREE="$9"
 	local DISTSECTION
 	if [ "$SECTION" = "$(echo "$SECTION" | cut -d'/' -f 2)" ]; then
 		DISTSECTION="main"
@@ -391,9 +392,12 @@ Package: $NAME" >> ${BUILDDIR}/debian/control
 		mkdir -p ${BUILDDIR}/debian/tmp/DEBIAN ${BUILDDIR}/debian/tmp/usr/share/doc/${NAME} ${BUILDDIR}/debian/tmp/usr/bin
 		cp ${BUILDDIR}/debian/copyright ${BUILDDIR}/debian/changelog ${BUILDDIR}/FEATURES ${BUILDDIR}/debian/tmp/usr/share/doc/${NAME}
 		cp ${BUILDDIR}/${NAME} ${BUILDDIR}/debian/tmp/usr/bin/${NAME}-${arch}
+                if [ -n "$FILE_TREE" ]; then
+                    cp -ar "$FILE_TREE" ${BUILDDIR}/debian/tmp
+                fi
+
 		(cd ${BUILDDIR}; dpkg-gencontrol -DArchitecture=$arch)
 		(cd ${BUILDDIR}/debian/tmp; md5sum $(find usr/ -type f) > DEBIAN/md5sums)
-
 		dpkg-deb --build ${BUILDDIR}/debian/tmp ${BUILDDIR}/.. 2> /dev/null > /dev/null
 		echo "pool/${NAME}_${VERSION}_${arch}.deb" >> ${BUILDDIR}/../${RELEASE}.${DISTSECTION}.pkglist
 	done

+ 71 - 0
test/integration/test-apt-progress-fd

@@ -0,0 +1,71 @@
+#!/bin/sh
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+
+setupenvironment
+configarchitecture 'amd64' 'i386'
+
+buildsimplenativepackage 'testing' 'amd64' '0.1' 'stable'
+buildsimplenativepackage 'testing' 'amd64' '0.8.15' 'stable'
+buildsimplenativepackage 'testing2' 'amd64,i386' '0.8.15' 'stable'
+setupaptarchive 
+
+# install native
+exec 3> apt-progress.log
+testsuccess aptget install testing=0.1 -y -o APT::Status-Fd=3
+testequal "dlstatus:1:0:Retrieving file 1 of 1
+dlstatus:1:0:Retrieving file 1 of 1
+pmstatus:dpkg-exec:0:Running dpkg
+pmstatus:testing:0:Installing testing
+pmstatus:testing:20:Preparing testing
+pmstatus:testing:40:Unpacking testing
+pmstatus:testing:60:Preparing to configure testing
+pmstatus:dpkg-exec:60:Running dpkg
+pmstatus:testing:60:Configuring testing
+pmstatus:testing:80:Configuring testing
+pmstatus:testing:100:Installed testing" cat apt-progress.log
+
+# upgrade
+exec 3> apt-progress.log
+testsuccess aptget install testing=0.8.15 -y -o APT::Status-Fd=3
+testequal "dlstatus:1:0:Retrieving file 1 of 1
+dlstatus:1:0:Retrieving file 1 of 1
+pmstatus:dpkg-exec:0:Running dpkg
+pmstatus:testing:20:Preparing testing
+pmstatus:testing:40:Unpacking testing
+pmstatus:testing:60:Preparing to configure testing
+pmstatus:dpkg-exec:60:Running dpkg
+pmstatus:testing:60:Configuring testing
+pmstatus:testing:80:Configuring testing
+pmstatus:testing:100:Installed testing" cat apt-progress.log
+
+# and remove
+exec 3> apt-progress.log
+testsuccess aptget remove testing -y -o APT::Status-Fd=3
+testequal "pmstatus:dpkg-exec:0:Running dpkg
+pmstatus:testing:0:Removing testing
+pmstatus:testing:33.3333:Preparing for removal of testing
+pmstatus:testing:66.6667:Removing testing
+pmstatus:testing:100:Removed testing" cat apt-progress.log
+
+
+# install non-native and ensure we get proper progress info
+exec 3> apt-progress.log
+testsuccess aptget install testing2:i386 -y -o APT::Status-Fd=3
+
+# and compare
+testequal "dlstatus:1:0:Retrieving file 1 of 1
+dlstatus:1:0:Retrieving file 1 of 1
+pmstatus:dpkg-exec:0:Running dpkg
+pmstatus:testing2:0:Installing testing2
+pmstatus:testing2:20:Preparing testing2
+pmstatus:testing2:40:Unpacking testing2
+pmstatus:testing2:60:Preparing to configure testing2
+pmstatus:dpkg-exec:60:Running dpkg
+pmstatus:testing2:60:Configuring testing2
+pmstatus:testing2:80:Configuring testing2
+pmstatus:testing2:100:Installed testing2" cat apt-progress.log
+
+rm -f apt-progress*.log

+ 22 - 0
test/integration/test-apt-progress-fd-error

@@ -0,0 +1,22 @@
+#!/bin/sh
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+
+setupenvironment
+configarchitecture 'amd64' 'i386'
+
+mkdir -p usr/bin
+touch usr/bin/file-conflict
+
+buildsimplenativepackage 'foo1' 'amd64,i386' '0.8.15' 'stable' '' 'pkg with file conflicts' '' '' 'usr/'
+buildsimplenativepackage 'foo2' 'amd64,i386' '0.8.15' 'stable' '' 'pkg with file conflicts' '' '' 'usr/'
+
+setupaptarchive 
+
+exec 3> apt-progress.log
+testfailure aptget install foo1 foo2 -y -o APT::Status-Fd=3
+msgtest "Ensure correct error message"
+grep -q "aptarchive/pool/foo2_0.8.15_amd64.deb :40:trying to overwrite '/usr/bin/file-conflict', which is also in package foo1 0.8.15" apt-progress.log && msgpass || msgfail
+

+ 22 - 0
test/integration/test-apt-progress-fd-error-postinst

@@ -0,0 +1,22 @@
+#!/bin/sh
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+
+setupenvironment
+configarchitecture 'amd64' 'i386'
+
+mkdir -p DEBIAN/
+echo "#!/bin/sh\nexit 1" > DEBIAN/postinst
+chmod 755 DEBIAN/postinst
+
+buildsimplenativepackage 'postinst-error' 'amd64,i386' '0.8.15' 'stable' '' 'pkg with posinst error' '' '' './DEBIAN' 
+
+setupaptarchive 
+
+exec 3> apt-progress.log
+testfailure aptget install postinst-error -y -o APT::Status-Fd=3
+msgtest "Ensure correct error message for postinst error"
+grep -q "pmerror:postinst-error :80:subprocess installed post-installation script returned error exit status 2" apt-progress.log && msgpass || msgfail
+