* improve apt progress reporting, display trigger actions
authorMichael Vogt <michael.vogt@ubuntu.com>
Fri, 23 May 2008 07:19:41 +0000 (09:19 +0200)
committerMichael Vogt <michael.vogt@ubuntu.com>
Fri, 23 May 2008 07:19:41 +0000 (09:19 +0200)
apt-pkg/deb/dpkgpm.cc
apt-pkg/deb/dpkgpm.h
debian/changelog
po/apt-all.pot

index bc15b88..8222be7 100644 (file)
@@ -333,6 +333,12 @@ void pkgDPkgPM::ProcessDpkgStatusLine(int OutStatusFd, char *line)
       'status: /var/cache/apt/archives/krecipes_0.8.1-0ubuntu1_i386.deb : error : trying to overwrite `/usr/share/doc/kde/HTML/en/krecipes/krectip.png', which is also in package krecipes-data 
       and conffile-prompt like this
       'status: conffile-prompt: conffile : 'current-conffile' 'new-conffile' useredited distedited
+      
+      Newer versions of dpkg sent also:
+      'processing: install: pkg'
+      'processing: configure: pkg'
+      'processing: remove: pkg'
+      'processing: trigproc: trigger'
            
    */
    char* list[5];
@@ -351,6 +357,34 @@ void pkgDPkgPM::ProcessDpkgStatusLine(int OutStatusFd, char *line)
    char *pkg = list[1];
    char *action = _strstrip(list[2]);
 
+   // 'processing' from dpkg looks like
+   // 'processing: action: pkg'
+   if(strncmp(list[0], "processing", strlen("processing")) == 0)
+   {
+      char s[200];
+      map<string,string>::iterator iter;
+      char *pkg_or_trigger = _strstrip(list[2]);
+      action =_strstrip( list[1]);
+      iter = PackageProcessingOps.find(action);
+      if(iter == PackageProcessingOps.end())
+      {
+        if (_config->FindB("Debug::pkgDPkgProgressReporting",false) == true)
+           std::clog << "ignoring unknwon action: " << action << std::endl;
+        return;
+      }
+      snprintf(s, sizeof(s), _(iter->second.c_str()), pkg_or_trigger);
+
+      status << "pmstatus:" << pkg_or_trigger
+            << ":"  << (PackagesDone/float(PackagesTotal)*100.0) 
+            << ":" << s
+            << endl;
+      if(OutStatusFd > 0)
+        write(OutStatusFd, status.str().c_str(), status.str().size());
+      if (_config->FindB("Debug::pkgDPkgProgressReporting",false) == true)
+        std::clog << "send: '" << status.str() << "'" << endl;
+      return;
+   }
+
    if(strncmp(action,"error",strlen("error")) == 0)
    {
       status << "pmerror:" << list[1]
@@ -526,7 +560,7 @@ bool pkgDPkgPM::Go(int OutStatusFd)
 
    if (RunScriptsWithPkgs("DPkg::Pre-Install-Pkgs") == false)
       return false;
-   
+
    // map the dpkg states to the operations that are performed
    // (this is sorted in the same way as Item::Ops)
    static const struct DpkgState DpkgStatesOpMap[][7] = {
@@ -566,6 +600,12 @@ bool pkgDPkgPM::Go(int OutStatusFd)
       },
    };
 
+   // populate the "processing" map
+   PackageProcessingOps.insert( make_pair("install",N_("Installing %s")) );
+   PackageProcessingOps.insert( make_pair("configure",N_("Configuring %s")) );
+   PackageProcessingOps.insert( make_pair("remove",N_("Removing %s")) );
+   PackageProcessingOps.insert( make_pair("trigproc",N_("Triggering %s")) );
+   
    // init the PackageOps map, go over the list of packages that
    // that will be [installed|configured|removed|purged] and add
    // them to the PackageOps map (the dpkg states it goes through)
index ebc7e32..4494691 100644 (file)
@@ -47,6 +47,8 @@ class pkgDPkgPM : public pkgPackageManager
    // the int is the state that is already done (e.g. a package that is
    // going to be install is already in state "half-installed")
    map<string,unsigned int> PackageOpsDone;
+   // map the dpkg "processing" info to human readable names
+   map<string,string> PackageProcessingOps;
    // progress reporting
    unsigned int PackagesDone;
    unsigned int PackagesTotal;
index 96c8ef8..beca698 100644 (file)
@@ -14,6 +14,9 @@ apt (0.7.14) UNRELEASED; urgency=low
   * Documented all cron script related configuration items in 
     configure-index.
 
+  [ Michael Vogt ]
+  * improve apt progress reporting, display trigger actions
+  
   [ Program translations ]
   * Simplified Chinese updated. Closes: #473360
   * Catalan fixes. Closes: #387141
index 6319e74..ae7cb47 100644 (file)
@@ -7,7 +7,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2008-05-04 09:50+0200\n"
+"POT-Creation-Date: 2008-05-22 16:56+0200\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -2574,68 +2574,79 @@ msgstr ""
 msgid "Wrote %i records with %i missing files and %i mismatched files\n"
 msgstr ""
 
-#: apt-pkg/deb/dpkgpm.cc:452
+#: apt-pkg/deb/dpkgpm.cc:486
 #, c-format
 msgid "Directory '%s' missing"
 msgstr ""
 
-#: apt-pkg/deb/dpkgpm.cc:535
+#: apt-pkg/deb/dpkgpm.cc:569
 #, c-format
 msgid "Preparing %s"
 msgstr ""
 
-#: apt-pkg/deb/dpkgpm.cc:536
+#: apt-pkg/deb/dpkgpm.cc:570
 #, c-format
 msgid "Unpacking %s"
 msgstr ""
 
-#: apt-pkg/deb/dpkgpm.cc:541
+#: apt-pkg/deb/dpkgpm.cc:575
 #, c-format
 msgid "Preparing to configure %s"
 msgstr ""
 
-#: apt-pkg/deb/dpkgpm.cc:542
+#: apt-pkg/deb/dpkgpm.cc:576 apt-pkg/deb/dpkgpm.cc:605
 #, c-format
 msgid "Configuring %s"
 msgstr ""
 
-#: apt-pkg/deb/dpkgpm.cc:544 apt-pkg/deb/dpkgpm.cc:545
+#: apt-pkg/deb/dpkgpm.cc:578 apt-pkg/deb/dpkgpm.cc:579
 #, c-format
 msgid "Processing triggers for %s"
 msgstr ""
 
-#: apt-pkg/deb/dpkgpm.cc:547
+#: apt-pkg/deb/dpkgpm.cc:581
 #, c-format
 msgid "Installed %s"
 msgstr ""
 
-#: apt-pkg/deb/dpkgpm.cc:552 apt-pkg/deb/dpkgpm.cc:554
-#: apt-pkg/deb/dpkgpm.cc:555
+#: apt-pkg/deb/dpkgpm.cc:586 apt-pkg/deb/dpkgpm.cc:588
+#: apt-pkg/deb/dpkgpm.cc:589
 #, c-format
 msgid "Preparing for removal of %s"
 msgstr ""
 
-#: apt-pkg/deb/dpkgpm.cc:557
+#: apt-pkg/deb/dpkgpm.cc:591 apt-pkg/deb/dpkgpm.cc:606
 #, c-format
 msgid "Removing %s"
 msgstr ""
 
-#: apt-pkg/deb/dpkgpm.cc:558
+#: apt-pkg/deb/dpkgpm.cc:592
 #, c-format
 msgid "Removed %s"
 msgstr ""
 
-#: apt-pkg/deb/dpkgpm.cc:563
+#: apt-pkg/deb/dpkgpm.cc:597
 #, c-format
 msgid "Preparing to completely remove %s"
 msgstr ""
 
-#: apt-pkg/deb/dpkgpm.cc:564
+#: apt-pkg/deb/dpkgpm.cc:598
 #, c-format
 msgid "Completely removed %s"
 msgstr ""
 
-#: apt-pkg/deb/dpkgpm.cc:716
+#. populate the "processing" map
+#: apt-pkg/deb/dpkgpm.cc:604
+#, c-format
+msgid "Installing %s"
+msgstr ""
+
+#: apt-pkg/deb/dpkgpm.cc:607
+#, c-format
+msgid "Triggering %s"
+msgstr ""
+
+#: apt-pkg/deb/dpkgpm.cc:756
 msgid "Can not write log, openpty() failed (/dev/pts not mounted?)\n"
 msgstr ""