added 4 changesets to branch 'refs/remotes/HaikuPM-github/package-management' old head: f5821a1aee77d3b9a979b42c68a79e50b5ebaefe new head: 8f9efca9a673d62f43e4ae26a153337a25b22ce3 overview: https://github.com/haiku/HaikuPM/compare/f5821a1...8f9efca ---------------------------------------------------------------------------- ab9a117: package kit: JobQueue::Pop() fix invalid iterator access c33daf2: package kit: fix JobQueue::_RemoveDependantJobsOf() * Delete the right job (the removed dependant job). * Sever the depencency link between the jobs or the next iteration of the loop would process the same job again. 03191ec: pkgman: make JobStateListener a bit more flexible Flags can be passed to the constructor to specify whether to exit() when a job failed/was aborted. 8f9efca: pkgman: PackageManager: no longer auto-exit() when a job fails This way search and uninstall no longer fail when there's no connection to the internet. [ Ingo Weinhold <ingo_weinhold@xxxxxx> ] ---------------------------------------------------------------------------- 4 files changed, 36 insertions(+), 10 deletions(-) src/bin/pkgman/JobStateListener.cpp | 13 +++++++++++-- src/bin/pkgman/JobStateListener.h | 25 ++++++++++++++++++++----- src/bin/pkgman/PackageManager.cpp | 2 +- src/kits/package/JobQueue.cpp | 6 ++++-- ############################################################################ Commit: ab9a1179187625603394b817a104471ef6d3aa14 Author: Ingo Weinhold <ingo_weinhold@xxxxxx> Date: Sun Aug 25 15:02:05 2013 UTC package kit: JobQueue::Pop() fix invalid iterator access ---------------------------------------------------------------------------- diff --git a/src/kits/package/JobQueue.cpp b/src/kits/package/JobQueue.cpp index 182856a..bd5bceb 100644 --- a/src/kits/package/JobQueue.cpp +++ b/src/kits/package/JobQueue.cpp @@ -159,8 +159,9 @@ JobQueue::Pop() if (head == fQueuedJobs->end()) return NULL; } + BJob* job = *head; fQueuedJobs->erase(head); - return *head; + return job; } return NULL; ############################################################################ Commit: c33daf26ea9f29d5b9e980c8c04322e88c7bbc98 Author: Ingo Weinhold <ingo_weinhold@xxxxxx> Date: Sun Aug 25 15:05:00 2013 UTC package kit: fix JobQueue::_RemoveDependantJobsOf() * Delete the right job (the removed dependant job). * Sever the depencency link between the jobs or the next iteration of the loop would process the same job again. ---------------------------------------------------------------------------- diff --git a/src/kits/package/JobQueue.cpp b/src/kits/package/JobQueue.cpp index bd5bceb..4726e88 100644 --- a/src/kits/package/JobQueue.cpp +++ b/src/kits/package/JobQueue.cpp @@ -236,7 +236,8 @@ JobQueue::_RemoveDependantJobsOf(BJob* job) } catch (...) { } _RemoveDependantJobsOf(dependantJob); - delete job; + dependantJob->RemoveDependency(job); + delete dependantJob; } } ############################################################################ Commit: 03191ec5afc690881b227d4dd8d2d0f191a354c4 Author: Ingo Weinhold <ingo_weinhold@xxxxxx> Date: Sun Aug 25 15:06:30 2013 UTC pkgman: make JobStateListener a bit more flexible Flags can be passed to the constructor to specify whether to exit() when a job failed/was aborted. ---------------------------------------------------------------------------- diff --git a/src/bin/pkgman/JobStateListener.cpp b/src/bin/pkgman/JobStateListener.cpp index f410703..1f27001 100644 --- a/src/bin/pkgman/JobStateListener.cpp +++ b/src/bin/pkgman/JobStateListener.cpp @@ -13,6 +13,13 @@ using BPackageKit::BJob; +JobStateListener::JobStateListener(uint32 flags) + : + fFlags(flags) +{ +} + + void JobStateListener::JobStarted(BJob* job) { @@ -34,12 +41,14 @@ JobStateListener::JobFailed(BJob* job) error.ReplaceAll("\n", "\n*** "); fprintf(stderr, "%s", error.String()); } - DIE(job->Result(), "failed!"); + if ((fFlags & EXIT_ON_ERROR) != 0) + DIE(job->Result(), "failed!"); } void JobStateListener::JobAborted(BJob* job) { - DIE(job->Result(), "aborted"); + if ((fFlags & EXIT_ON_ABORT) != 0) + DIE(job->Result(), "aborted"); } diff --git a/src/bin/pkgman/JobStateListener.h b/src/bin/pkgman/JobStateListener.h index f765301..9ff8c53 100644 --- a/src/bin/pkgman/JobStateListener.h +++ b/src/bin/pkgman/JobStateListener.h @@ -9,11 +9,26 @@ #include <package/Job.h> -struct JobStateListener : public BPackageKit::BJobStateListener { - virtual void JobStarted(BPackageKit::BJob* job); - virtual void JobSucceeded(BPackageKit::BJob* job); - virtual void JobFailed(BPackageKit::BJob* job); - virtual void JobAborted(BPackageKit::BJob* job); +class JobStateListener : public BPackageKit::BJobStateListener { +public: + enum { + EXIT_ON_ERROR = 0x01, + EXIT_ON_ABORT = 0x02, + }; + + +public: + JobStateListener( + uint32 flags = EXIT_ON_ERROR + | EXIT_ON_ABORT); + + virtual void JobStarted(BPackageKit::BJob* job); + virtual void JobSucceeded(BPackageKit::BJob* job); + virtual void JobFailed(BPackageKit::BJob* job); + virtual void JobAborted(BPackageKit::BJob* job); + +private: + uint32 fFlags; }; ############################################################################ Commit: 8f9efca9a673d62f43e4ae26a153337a25b22ce3 Author: Ingo Weinhold <ingo_weinhold@xxxxxx> Date: Sun Aug 25 15:09:41 2013 UTC pkgman: PackageManager: no longer auto-exit() when a job fails This way search and uninstall no longer fail when there's no connection to the internet. ---------------------------------------------------------------------------- diff --git a/src/bin/pkgman/PackageManager.cpp b/src/bin/pkgman/PackageManager.cpp index f7c4df9..3e71c42 100644 --- a/src/bin/pkgman/PackageManager.cpp +++ b/src/bin/pkgman/PackageManager.cpp @@ -83,7 +83,7 @@ PackageManager::PackageManager(BPackageInstallationLocation location, fInstalledRepositories(10), fOtherRepositories(10, true), fDecisionProvider(), - fJobStateListener(), + fJobStateListener(JobStateListener::EXIT_ON_ABORT), fContext(fDecisionProvider, fJobStateListener) { // create the solver