History log of /haiku/src/bin/pkgman/PackageManager.cpp
Revision Date Author Comments
# bc6674c8 05-Mar-2024 Emir SARI <bitigchi@me.com>

pkgman: Use BNumberFormat for i18n

Change-Id: I2441f1d37bfccd5f5dbc9b763aeb87d017e628bc
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7508
Haiku-Format: Haiku-format Bot <no-reply+haikuformatbot@haiku-os.org>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>


# 63ba21d5 01-Jun-2019 Augustin Cavalier <waddlesplash@gmail.com>

pkgman: Inform the user when a reboot is required to complete installation.

Fixes #14783 following on hrev53005.


# 45c3eb3a 13-May-2019 Augustin Cavalier <waddlesplash@gmail.com>

pkgman: Split "interactive" and "show progress" logic.

Previously we didn't show progress in non-interactive mode. Now
we do, so long as stdout is a TTY.

Fixes #14603.


# 21e99b47 10-Sep-2018 Augustin Cavalier <waddlesplash@gmail.com>

pkgman: Suppress the erroneous "aborted: No Error" messages on no internet.

Here's what happens:
* BPackageManager created a BRefreshRepositoryRequest with a BContext
of an empty DecisionProvider and itself.
* Since there is no internet access, the FetchFileJobs that the refresh
class queued fail. Specifically, the first one does, but then as the
subsequent ones depend on it, they are all aborted.
* As some jobs were aborted, the StateListener is notified.
* The state listener of course has the BPackageManager class as one of
the listeners, and so calls it, because even though the handler methods
of BRefreshRepositoryRequest, they are powerless to stop event propagation.
* The BPackageManager's highest subclass' implementation gets called, which is
of course pkgman's.
* pkgman decides to DIE() upon receiving word that a job was aborted.

There are thus four potential solutions to this issue:
* Rewrite the package kit's event & job handling systems to not be so
screwed up in terms of propagation. Seriously, there is way too much
stuff that we send to the "user" in here, and as you can see, it can
get *extremely* convoluted even for supposedly "simple" tasks. This
is probably the best "long-term" solution; but obviously is far too
involved for the present.
* Only partially rework event handling; specifically in the SupportKit to
allow JobStateListeners to stop further propagation. This is probably
the best "medium-term" solution.
* Do not pass the package manager as the JobStateListener to the
RefreshRepositoryRequest. This would have the downside that the
regular notifications about download state, etc. would not be returned
at all, which we don't want. We could make a shim ... but that would be
a lot of code for little benefit. The prior solution makes more sense.
* Completely ignore "JobAborted" notices in pkgman. In fact, this is the
solution that virtually all other consumers of this API take (although
some of them seem to have TODOs about it), including package_daemon,
HaikuDepot, etc., and so it's the one I've taken here. If a "job aborted"
error is actually fatal, then it's the Package Kit's problem.

Fixes #13075.


# 6663167b 21-Nov-2017 Adrien Destugues <pulkomandy@pulkomandy.tk>

pkgman: improve progress bar

- Do not update more than twice a second
- Do not use tabs, so we can reliably compute the string width
- Cleanup and tweak other parts of the code

There is still a glitch when resizing Terminal, but it isn't as bad as
before. Ideally, using the SIGWINCH signal would solve that, but it is
sent to the app only when you release the mouse after a release
operation, so in our case, it is already too late.


# 67379bfb 04-Nov-2017 Augustin Cavalier <waddlesplash@gmail.com>

pkgman: Fixes to the new download progress meter.

* Make string-splitting UTF8-aware
* If the window size is too small for the full string, mid-truncate it
* Ensure the string is long enough if the window size is large.
* Rework flushing strategy slightly.

Fixes #13750, as well as taos' unrelated issue he reported there.


# a9c1157a 30-Oct-2017 Augustin Cavalier <waddlesplash@gmail.com>

pkgman: Completely rework download progress indicator.

* Remove the Unicode progress characters, instead change terminal
background color
* Include downloaded/total size in the displayed information
* Include transfer rate (over the last 1s)

Here's a quick screenshot of what it looks like now:
https://i.imgur.com/x4II3Fu.png

"Inspired" by a very old patch by Axel, but almost all of this is my own work.

Fixes #13424.


# a055d42d 29-Jul-2016 Augustin Cavalier <waddlesplash@gmail.com>

pkgman: Change the update prompt to be "yes/no" instead of "y/n".

Matches the text used elsewhere on the system (and that of the "add-repo"
command.) You can still type a single character to confirm/deny.

Fixes #11260.


# 43c29278 13-Nov-2015 Adrien Destugues <pulkomandy@pulkomandy.tk>

pkgman: show old version when updating packages.


# e711e6e4 18-May-2015 Axel Dörfler <axeld@pinc-software.de>

Moved BJob, and JobQueue into the support kit.

* Put it in the BSupportKit namespace, following the style introduced
with the package kit for now.
* The BSupportKit::BJob class no longer knows about the package kit's
Context class. However, the BPackageKit::BJob class does.
* Due to the namespace juggling, a lot of files had to be touched.
* The JobQueue class remains private.
* Due to the way Haiku is built on itself, you cannot build this change
under Haiku with an older release.


# 1aaa0c21 24-Jan-2015 Axel Dörfler <axeld@pinc-software.de>

Package Kit: FetchFileJob now contains package size.

* So that you know how much already was, and still has to be downloaded.
* Automatic whitespace cleanup.
* The link in FetchFileJob.h did not fetch the correct header under
Haiku anymore (since the addition of the private headers to the
image).


# 1f35b018 27-Mar-2015 Augustin Cavalier <waddlesplash@gmail.com>

pkgman: fix build.


# 74de7435 27-Mar-2015 Augustin Cavalier <waddlesplash@gmail.com>

pkgman: fix problems pointed out by Jerome & Axel.


# c771066b 27-Mar-2015 Augustin Cavalier <waddlesplash@gmail.com>

pkgman: cleanup output.

This makes the progressbars disappear after the download is complete,
as well as reducing the number of lines for most actions to 1 instead
of 3-4.


# 8667d6c7 04-Feb-2015 Jessica Hamilton <jessica.l.hamilton@gmail.com>

pkgman: replace install/uninstall pairs with upgrade text.

Signed-off-by: Augustin Cavalier <waddlesplash@gmail.com>
I fixed some bugs and removed some code duplication.


# e22040ef 27-Mar-2015 Augustin Cavalier <waddlesplash@gmail.com>

pkgman: make progressbar work properly when the width is < 70.


# 47db8ac7 31-Oct-2014 Jessica Hamilton <jessica.l.hamilton@gmail.com>

pkgman: add missing padding for percentage display


# 87d0590f 30-Oct-2014 Adrien Destugues <pulkomandy@gmail.com>

pkgman: better download progress bar

* Use Unicode block drawing characters to provide sub-character accuracy
* Also display the download progress percentage as a number

When downloading big packages this helps seeing that the bar continues
moving and that the download is not stalled.


# f9f8a8f5 15-Jun-2014 Ingo Weinhold <ingo_weinhold@gmx.de>

pkgman: Update some user messages


# ea761a10 14-Jun-2014 Ingo Weinhold <ingo_weinhold@gmx.de>

pkgman: Print issues from committing the transaction


# eee42275 14-Jun-2014 Ingo Weinhold <ingo_weinhold@gmx.de>

BPackageManager: Make BCommitTransactionResult available

* BFatalErrorException: Add commitTransactionResult property and
respective constructor. In case committing the transaction failed,
BPackageManager throws a BFatalErrorException with the result.
* BFatalErrorException::UserInteractionHandler: Pass
BCommitTransactionResult to ProgressTransactionCommitted().


# 83f63a21 22-Nov-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

pkgman [un]install/update: Add non-interactive mode (-y)


# 6722e1ae 20-Nov-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

BPackageManager: Add mandatory constructor parameters

Require the installation interface and the user interaction handle to
be passed to the constructor. Formerly, derived classes set them
manually in their constructors. This makes using the class without
having to subclass it possible.


# d3f4a865 02-Oct-2013 Rene Gollent <rene@gollent.com>

Implement #10051.

- Add a simple download progress meter to pkgman that prints a hash mark
for every 2% of the download completed. Improvements welcome.


# 9345049a 28-Sep-2013 Rene Gollent <anevilyak@gmail.com>

Package Kit: Implement progress notifications.

- BJobStateListener: Add progress state and corresponding hook.
- FetchFileJob: Notify job progress hook on libcurl notifications.
- UserInteractionHandler: Add hooks for download progress and checksum
validation progress.
- PackageManager: inherit from JobStateListener and watch for job
notifications for internally generated jobs. Forward to corresponding
UserInteractionHandler hooks as needed.
- Adapt pkgman, HaikuDepot and package_daemon to above changes.
Neither HaikuDepot nor package_daemon's progress hooks are wired up to
do anything yet though.


# fe39d2eb 27-Sep-2013 Rene Gollent <anevilyak@gmail.com>

BPackageManager: Eliminate RequestHandler.

- Pull functionality back into package manager itself since the extra
indirection doesn't really buy us anything in this case, as neither
request that it handles requires a decision provider.
- Adjust pkgman and HaikuDepot accordingly.


# cf3bb0d7 31-Aug-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

BPackageManager: Abstract installed repository initialization

* Rename TransactionHandler -> InstallationInterface and
DaemonClientTransactionHandler -> ClientInstallationInterface.
* Add InstallationInterface::InitInstalledRepository(). Use in
_AddInstalledRepository() to get the repository packages instead of
using the package roster. The ClientInstallationInterface
implementation does it that way.


# 83462cc2 31-Aug-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

Refactor reusable pkgman code into libpackage

* Move RepositoryBuilder class to libpackage and add B* prefix to name.
* Pull BPackageManager class out of PackageManager and move to
libpackage. The base class is customizable via three handler objects
responsible for transaction handling, request execution, respectively
user interaction.
* Reorganize _ApplyPackageChanges(): Now we first prepare the
transactions for all affected installation locations (downloading
files etc.) and then commit them.


# a0cb235c 29-Aug-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

pkgman: Use BPackageInfo::FileName() instead of Canonical*()


# 08fb013f 29-Aug-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

pkgman uninstall: Verify more specific locations

... after having determined the packages to remove from the selected
installation location. This uninstalls packages from the more specific
locations when their dependencies have been removed.


# a54a50b4 28-Aug-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

pkgman: add support for [un]installing/updating in system


# 3381a1bf 28-Aug-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

pkgman uninstall: improve correctness

... with respect to inter-installation-location dependencies. E.g.
uninstalling a package from common should only uninstall packages
depending on it, when system doesn't still provide those dependencies.

We don't consider uninstalling packages from more specific installation
locations when dependencies are uninstalled from a more general one yet.


# 90f9f139 27-Aug-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

pkgman install: Add base package support

If any of the packages to install has requires a base package, that is
installed in a more general installation location, we copy the package
to the target installation location. Ideally we'd hard-link, but BFS
doesn't support that. Symlinks would be a small nightmare to maintain.

We might want to choose the installation location intelligently
depending on the base package requirement -- e.g. install curl_devel in
system rather than common, since curl is installed in system -- so we
can avoid duplicating packages.


# ce4f3676 26-Aug-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

pkgman: auto-refresh repositories only for update/install


# 8b26ef67 25-Aug-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

pkgman: PackageManager: Use flags instead of bools in ctor


# 8f9efca9 25-Aug-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

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.


# 014eed80 06-Jul-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

Change repository directory layout

* Under the base URL there are supposed to be the repository files and a
subdirectory "packages".
* Fix the repository URL related confusion introduced earlier. The URL
in
the repository info (and thus in the repository file) is supposed to
be the base URL for the repository. It is not a (potentially)
different base URL for the package files. Package and repository
files were supposed to live in the same directory. Now, by requiring
the package files to live in a subdirectory -- which can also be a
symlink -- we gain some flexibility.
The URL in the repository config is usually the same as the in the
repository info, unless it refers to a mirror site. This allows for
mirrors to copy the original repository verbatim.
* Remove the PackageURL rule and introduce a DownloadPackage rule
instead. The URL for a package file cannot be computed in the jam
parsing phase anymore, as it contains the hash value of the package
list.
* BRepositoryConfig: Add PackagesURL() for convenience.


# a5999f6f 21-Apr-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

pkgman: Add "update" command


# df2685d8 20-Apr-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

pkgman: Add "uninstall" command


# 3ac0de3b 20-Apr-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

pkgman: Refactoring -> PackageManager

Move common and reusable functionality from "search" and "install" to
new PackageManager class.


# e711e6e42fd7ec3111ba9dc2324fa8efedd6674b 18-May-2015 Axel Dörfler <axeld@pinc-software.de>

Moved BJob, and JobQueue into the support kit.

* Put it in the BSupportKit namespace, following the style introduced
with the package kit for now.
* The BSupportKit::BJob class no longer knows about the package kit's
Context class. However, the BPackageKit::BJob class does.
* Due to the namespace juggling, a lot of files had to be touched.
* The JobQueue class remains private.
* Due to the way Haiku is built on itself, you cannot build this change
under Haiku with an older release.


# 1aaa0c2142c6c843e93bd1ee8edd4c7ea6256559 24-Jan-2015 Axel Dörfler <axeld@pinc-software.de>

Package Kit: FetchFileJob now contains package size.

* So that you know how much already was, and still has to be downloaded.
* Automatic whitespace cleanup.
* The link in FetchFileJob.h did not fetch the correct header under
Haiku anymore (since the addition of the private headers to the
image).


# 1f35b0186b43dc10737ad9895bfe8342a09af2d7 27-Mar-2015 Augustin Cavalier <waddlesplash@gmail.com>

pkgman: fix build.


# 74de74358aeb10d5833adb6cd4b216ce41e8e385 27-Mar-2015 Augustin Cavalier <waddlesplash@gmail.com>

pkgman: fix problems pointed out by Jerome & Axel.


# c771066bd2216500496b5e5ca360e06db74bf819 27-Mar-2015 Augustin Cavalier <waddlesplash@gmail.com>

pkgman: cleanup output.

This makes the progressbars disappear after the download is complete,
as well as reducing the number of lines for most actions to 1 instead
of 3-4.


# 8667d6c75862803e19ccc88b36abd2b4e87fe38f 04-Feb-2015 Jessica Hamilton <jessica.l.hamilton@gmail.com>

pkgman: replace install/uninstall pairs with upgrade text.

Signed-off-by: Augustin Cavalier <waddlesplash@gmail.com>
I fixed some bugs and removed some code duplication.


# e22040efac37667c67da13b304ec3c80d1db497e 27-Mar-2015 Augustin Cavalier <waddlesplash@gmail.com>

pkgman: make progressbar work properly when the width is < 70.


# 47db8ac7d6fe6f8861f8b709a366d7467122311e 31-Oct-2014 Jessica Hamilton <jessica.l.hamilton@gmail.com>

pkgman: add missing padding for percentage display


# 87d0590f6091f16a32dfa672888f050de2e0266b 30-Oct-2014 Adrien Destugues <pulkomandy@gmail.com>

pkgman: better download progress bar

* Use Unicode block drawing characters to provide sub-character accuracy
* Also display the download progress percentage as a number

When downloading big packages this helps seeing that the bar continues
moving and that the download is not stalled.


# f9f8a8f56ecde660fe4455efae7535619212d0da 15-Jun-2014 Ingo Weinhold <ingo_weinhold@gmx.de>

pkgman: Update some user messages


# ea761a10d403ede93209c1dcbf0089ecd849f115 14-Jun-2014 Ingo Weinhold <ingo_weinhold@gmx.de>

pkgman: Print issues from committing the transaction


# eee422752c6de8ab971937a81225008d254ad785 14-Jun-2014 Ingo Weinhold <ingo_weinhold@gmx.de>

BPackageManager: Make BCommitTransactionResult available

* BFatalErrorException: Add commitTransactionResult property and
respective constructor. In case committing the transaction failed,
BPackageManager throws a BFatalErrorException with the result.
* BFatalErrorException::UserInteractionHandler: Pass
BCommitTransactionResult to ProgressTransactionCommitted().


# 83f63a216ee17213be3e9125c17f611bdb26e1b5 22-Nov-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

pkgman [un]install/update: Add non-interactive mode (-y)


# 6722e1ae43d51bb855e472045e84bb45592751cd 20-Nov-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

BPackageManager: Add mandatory constructor parameters

Require the installation interface and the user interaction handle to
be passed to the constructor. Formerly, derived classes set them
manually in their constructors. This makes using the class without
having to subclass it possible.


# d3f4a86549823f80504a10118e7fc41f51f06a24 02-Oct-2013 Rene Gollent <rene@gollent.com>

Implement #10051.

- Add a simple download progress meter to pkgman that prints a hash mark
for every 2% of the download completed. Improvements welcome.


# 9345049af828506bd2b20408e3612655a0153db1 28-Sep-2013 Rene Gollent <anevilyak@gmail.com>

Package Kit: Implement progress notifications.

- BJobStateListener: Add progress state and corresponding hook.
- FetchFileJob: Notify job progress hook on libcurl notifications.
- UserInteractionHandler: Add hooks for download progress and checksum
validation progress.
- PackageManager: inherit from JobStateListener and watch for job
notifications for internally generated jobs. Forward to corresponding
UserInteractionHandler hooks as needed.
- Adapt pkgman, HaikuDepot and package_daemon to above changes.
Neither HaikuDepot nor package_daemon's progress hooks are wired up to
do anything yet though.


# fe39d2eb8d03c1e71d835bab5d939c9b75440316 27-Sep-2013 Rene Gollent <anevilyak@gmail.com>

BPackageManager: Eliminate RequestHandler.

- Pull functionality back into package manager itself since the extra
indirection doesn't really buy us anything in this case, as neither
request that it handles requires a decision provider.
- Adjust pkgman and HaikuDepot accordingly.


# cf3bb0d753b4cf0a90db533152c58af2a568fc9e 31-Aug-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

BPackageManager: Abstract installed repository initialization

* Rename TransactionHandler -> InstallationInterface and
DaemonClientTransactionHandler -> ClientInstallationInterface.
* Add InstallationInterface::InitInstalledRepository(). Use in
_AddInstalledRepository() to get the repository packages instead of
using the package roster. The ClientInstallationInterface
implementation does it that way.


# 83462cc28d356d564a818c1d34605ed2ec83f274 31-Aug-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

Refactor reusable pkgman code into libpackage

* Move RepositoryBuilder class to libpackage and add B* prefix to name.
* Pull BPackageManager class out of PackageManager and move to
libpackage. The base class is customizable via three handler objects
responsible for transaction handling, request execution, respectively
user interaction.
* Reorganize _ApplyPackageChanges(): Now we first prepare the
transactions for all affected installation locations (downloading
files etc.) and then commit them.


# a0cb235c0ebfe6f62a975a884b6eb9a0f3708970 29-Aug-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

pkgman: Use BPackageInfo::FileName() instead of Canonical*()


# 08fb013f56bf7119a68ea7c06cac8f947dc4661e 29-Aug-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

pkgman uninstall: Verify more specific locations

... after having determined the packages to remove from the selected
installation location. This uninstalls packages from the more specific
locations when their dependencies have been removed.


# a54a50b48e316421f2735e9c46219164e16dd8cd 28-Aug-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

pkgman: add support for [un]installing/updating in system


# 3381a1bf81eb9d0c21e37cb031ab4b436294cbdf 28-Aug-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

pkgman uninstall: improve correctness

... with respect to inter-installation-location dependencies. E.g.
uninstalling a package from common should only uninstall packages
depending on it, when system doesn't still provide those dependencies.

We don't consider uninstalling packages from more specific installation
locations when dependencies are uninstalled from a more general one yet.


# 90f9f1392b5bac87c6333ec9627eda462035617d 27-Aug-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

pkgman install: Add base package support

If any of the packages to install has requires a base package, that is
installed in a more general installation location, we copy the package
to the target installation location. Ideally we'd hard-link, but BFS
doesn't support that. Symlinks would be a small nightmare to maintain.

We might want to choose the installation location intelligently
depending on the base package requirement -- e.g. install curl_devel in
system rather than common, since curl is installed in system -- so we
can avoid duplicating packages.


# ce4f36769285c1c491491dac6a909c76b7d761ad 26-Aug-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

pkgman: auto-refresh repositories only for update/install


# 8b26ef6779119ba64f5de3ce47ea4cac154ab4e8 25-Aug-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

pkgman: PackageManager: Use flags instead of bools in ctor


# 8f9efca9a673d62f43e4ae26a153337a25b22ce3 25-Aug-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

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.


# 014eed80e289c2bbc187ac91bb7b3a35560a971f 06-Jul-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

Change repository directory layout

* Under the base URL there are supposed to be the repository files and a
subdirectory "packages".
* Fix the repository URL related confusion introduced earlier. The URL
in
the repository info (and thus in the repository file) is supposed to
be the base URL for the repository. It is not a (potentially)
different base URL for the package files. Package and repository
files were supposed to live in the same directory. Now, by requiring
the package files to live in a subdirectory -- which can also be a
symlink -- we gain some flexibility.
The URL in the repository config is usually the same as the in the
repository info, unless it refers to a mirror site. This allows for
mirrors to copy the original repository verbatim.
* Remove the PackageURL rule and introduce a DownloadPackage rule
instead. The URL for a package file cannot be computed in the jam
parsing phase anymore, as it contains the hash value of the package
list.
* BRepositoryConfig: Add PackagesURL() for convenience.


# a5999f6ff7fbadb4f8cc94f5e4283dacbf231a59 21-Apr-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

pkgman: Add "update" command


# df2685d885f3b940bc04b1cf5f39511ce6750ddf 20-Apr-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

pkgman: Add "uninstall" command


# 3ac0de3b1fac18912d6cb7758b502468e3802ee9 20-Apr-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

pkgman: Refactoring -> PackageManager

Move common and reusable functionality from "search" and "install" to
new PackageManager class.