}
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'
{
// 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;
}
/*}}}*/
_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)
{
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)
if(stopOnError)
{
CloseLog();
- CleanupTerminal();
++ d->progress->Stop();
return false;
}
}
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"));