From: Michael Vogt Date: Thu, 17 Oct 2013 06:03:41 +0000 (+0200) Subject: Merge branch 'debian/sid' into feature/install-progress-refactor X-Git-Tag: 0.9.13.exp1~24 X-Git-Url: https://git.saurik.com/apt.git/commitdiff_plain/e8022b09e73ee89d3b748e1c8dba82abba5b37f3 Merge branch 'debian/sid' into feature/install-progress-refactor Conflicts: apt-pkg/deb/dpkgpm.cc --- e8022b09e73ee89d3b748e1c8dba82abba5b37f3 diff --cc apt-pkg/deb/dpkgpm.cc index fbb5e4c96,f870fab93..1b234c0ed --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@@ -558,6 -575,8 +571,14 @@@ void pkgDPkgPM::ProcessDpkgStatusLine(c } 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' @@@ -608,18 -647,28 +629,20 @@@ { // only read the translation if there is actually a next // action - const char *translation = _(states[PackageOpsDone[pkg]].str); - char s[200]; - snprintf(s, sizeof(s), translation, short_pkgname.c_str()); + 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++; - // build the status str - status << "pmstatus:" << short_pkgname - << ":" << (PackagesDone/float(PackagesTotal)*100.0) - << ":" << s - << endl; - if(_config->FindB("DPkgPM::Progress", false) == true) - SendTerminalProgress(PackagesDone/float(PackagesTotal)*100.0); - - if(OutStatusFd > 0) - FileFd::Write(OutStatusFd, status.str().c_str(), status.str().size()); - if (Debug == true) - std::clog << "send: '" << status.str() << "'" << endl; ++ + // 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: " << short_pkgname ++ std::clog << "(parsed from dpkg) pkg: " << pkgname << " action: " << action << endl; } /*}}}*/ @@@ -1264,12 -1394,20 +1287,14 @@@ bool pkgDPkgPM::Go(APT::Progress::Packa _error->DumpErrors(std::cerr); _error->RevertToStack(); - // Fork dpkg - pid_t Child; + // this is the dpkg status-fd, we need to keep it _config->Set("APT::Keep-Fds::",fd[1]); - // send status information that we are about to fork dpkg - if(OutStatusFd > 0) { - ostringstream status; - status << "pmstatus:dpkg-exec:" - << (PackagesDone/float(PackagesTotal)*100.0) - << ":" << _("Running dpkg") - << endl; - FileFd::Write(OutStatusFd, status.str().c_str(), status.str().size()); - } - Child = ExecFork(); + // 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) { @@@ -1375,7 -1516,6 +1400,8 @@@ if (select_ret < 0 && (errno == EINVAL || errno == ENOSYS)) 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) @@@ -1434,6 -1571,7 +1457,7 @@@ if(stopOnError) { CloseLog(); - CleanupTerminal(); ++ d->progress->Stop(); return false; } } @@@ -1441,7 -1579,10 +1465,9 @@@ CloseLog(); // dpkg is done at this point - if(_config->FindB("DPkgPM::Progress", false) == true) - SendTerminalProgress(100); + d->progress->StatusChanged("", PackagesDone, PackagesTotal, ""); ++ d->progress->Stop(); + - CleanupTerminal(); if (pkgPackageManager::SigINTStop) _error->Warning(_("Operation was interrupted before it could finish"));