summaryrefslogtreecommitdiff
path: root/python/progress.cc
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2005-04-08 11:55:14 +0000
committerMichael Vogt <michael.vogt@ubuntu.com>2005-04-08 11:55:14 +0000
commit08ea34d6a28b4b17d0146535e85d61ab7bda341d (patch)
tree468c9348b1ee62208fdc60be8ad23a769e02e2b7 /python/progress.cc
parent8f914ef267ab1bbcbda1c6694edd2e4c9b6401ec (diff)
downloadpython-apt-08ea34d6a28b4b17d0146535e85d61ab7bda341d.tar.gz
* simple InstallProgress interface added
Diffstat (limited to 'python/progress.cc')
-rw-r--r--python/progress.cc58
1 files changed, 58 insertions, 0 deletions
diff --git a/python/progress.cc b/python/progress.cc
index 673d7c0d..310d9569 100644
--- a/python/progress.cc
+++ b/python/progress.cc
@@ -7,6 +7,8 @@
##################################################################### */
#include <iostream>
+#include <sys/types.h>
+#include <sys/wait.h>
#include "progress.h"
// generic
@@ -144,3 +146,59 @@ bool PyFetchProgress::Pulse(pkgAcquire * Owner)
// this can be canceld by returning false
return true;
}
+
+
+
+// install progress
+
+void PyInstallProgress::StartUpdate()
+{
+ RunSimpleCallback("StartUpdate");
+}
+
+void PyInstallProgress::UpdateInterface()
+{
+ RunSimpleCallback("UpdateInterface");
+}
+
+void PyInstallProgress::FinishUpdate()
+{
+ RunSimpleCallback("FinishUpdate");
+}
+
+pkgPackageManager::OrderResult PyInstallProgress::Run(pkgPackageManager *pm)
+{
+ void *dummy;
+ pkgPackageManager::OrderResult res;
+ int ret;
+ pid_t _child_id;
+
+#if 0 // FIXME: this needs to be merged into apt to support medium swaping
+ res = pm->DoInstallPreFork();
+ if (res == pkgPackageManager::Failed)
+ return res;
+#endif
+
+ _child_id = fork();
+
+#if 0 // FIXME: this needs to be merged into apt to support medium swaping
+ if (_child_id == 0) {
+ res = pm->DoInstallPostFork();
+ _exit(res);
+ }
+#endif
+ if (_child_id == 0) {
+ res = pm->DoInstall();
+ _exit(res);
+ }
+
+ StartUpdate();
+ while (waitpid(_child_id, &ret, WNOHANG) == 0)
+ UpdateInterface();
+
+ res = (pkgPackageManager::OrderResult) WEXITSTATUS(ret);
+
+ FinishUpdate();
+
+ return res;
+}