summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apt-pkg/contrib/strutl.cc17
-rw-r--r--apt-pkg/contrib/strutl.h7
-rw-r--r--apt-pkg/deb/dpkgpm.cc7
-rw-r--r--apt-pkg/iprogress.cc8
-rw-r--r--apt-pkg/iprogress.h2
-rwxr-xr-xtest/integration/test-apt-progress-fd1
6 files changed, 36 insertions, 6 deletions
diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc
index 77e48962c..9f794927d 100644
--- a/apt-pkg/contrib/strutl.cc
+++ b/apt-pkg/contrib/strutl.cc
@@ -36,7 +36,22 @@
using namespace std;
/*}}}*/
-
+// Strip - Remove white space from the front and back of a string /*{{{*/
+// ---------------------------------------------------------------------
+namespace APT {
+ namespace String {
+std::string Strip(const std::string &s)
+{
+ size_t start = s.find_first_not_of(" \t\n");
+ // only whitespace
+ if (start == string::npos)
+ return "";
+ size_t end = s.find_last_not_of(" \t\n");
+ return s.substr(start, end-start+1);
+}
+}
+}
+ /*}}}*/
// UTF8ToCodeset - Convert some UTF-8 string for some codeset /*{{{*/
// ---------------------------------------------------------------------
/* This is handy to use before display some information for enduser */
diff --git a/apt-pkg/contrib/strutl.h b/apt-pkg/contrib/strutl.h
index b42e06491..c8fc317c0 100644
--- a/apt-pkg/contrib/strutl.h
+++ b/apt-pkg/contrib/strutl.h
@@ -33,6 +33,13 @@ using std::vector;
using std::ostream;
#endif
+namespace APT {
+ namespace String {
+ std::string Strip(const std::string &s);
+ };
+};
+
+
bool UTF8ToCodeset(const char *codeset, const std::string &orig, std::string *dest);
char *_strstrip(char *String);
char *_strrstrip(char *String); // right strip only
diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc
index b5f858022..5f1849b53 100644
--- a/apt-pkg/deb/dpkgpm.cc
+++ b/apt-pkg/deb/dpkgpm.cc
@@ -668,6 +668,10 @@ void pkgDPkgPM::ProcessDpkgStatusLine(char *line)
// check if the package moved to the next dpkg state
if(next_action && (action == next_action))
{
+ // we moved from one dpkg state to a new one, report that
+ PackageOpsDone[pkg]++;
+ PackagesDone++;
+
// only read the translation if there is actually a next
// action
const char *translation = _(states[PackageOpsDone[pkg]].str);
@@ -675,9 +679,6 @@ void pkgDPkgPM::ProcessDpkgStatusLine(char *line)
strprintf(msg, translation, i18n_pkgname.c_str());
d->progress->StatusChanged(pkgname, PackagesDone, PackagesTotal, msg);
- // we moved from one dpkg state to a new one, report that
- PackageOpsDone[pkg]++;
- PackagesDone++;
}
if (Debug == true)
std::clog << "(parsed from dpkg) pkg: " << short_pkgname
diff --git a/apt-pkg/iprogress.cc b/apt-pkg/iprogress.cc
index 318d626d4..daa7695e2 100644
--- a/apt-pkg/iprogress.cc
+++ b/apt-pkg/iprogress.cc
@@ -29,6 +29,7 @@ bool PackageManager::StatusChanged(std::string PackageName,
}
PackageManagerProgressFd::PackageManagerProgressFd(int progress_fd)
+ : StepsDone(0), StepsTotal(1)
{
OutStatusFd = progress_fd;
}
@@ -106,6 +107,13 @@ bool PackageManagerProgressFd::StatusChanged(std::string PackageName,
<< ":" << pkg_action
<< std::endl;
WriteToStatusFd(status.str());
+
+ if(_config->FindB("Debug::APT::Progress::PackageManagerFd", false) == true)
+ std::cerr << "progress: " << PackageName << " " << xStepsDone
+ << " " << xTotalSteps << " " << pkg_action
+ << std::endl;
+
+
return true;
}
diff --git a/apt-pkg/iprogress.h b/apt-pkg/iprogress.h
index ccf154279..42fa89be4 100644
--- a/apt-pkg/iprogress.h
+++ b/apt-pkg/iprogress.h
@@ -21,7 +21,7 @@ namespace Progress {
public:
PackageManager()
- : percentage(0.0), last_reported_progress(0) {};
+ : percentage(0.0), last_reported_progress(-1) {};
virtual ~PackageManager() {};
virtual void Start() {};
diff --git a/test/integration/test-apt-progress-fd b/test/integration/test-apt-progress-fd
index cdf8d4a23..97bb25848 100755
--- a/test/integration/test-apt-progress-fd
+++ b/test/integration/test-apt-progress-fd
@@ -50,7 +50,6 @@ pmstatus:testing:33.3333:Preparing for removal of testing (amd64)
pmstatus:testing:66.6667:Removing testing (amd64)
pmstatus:testing:100:Removed testing (amd64)" 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