#12447 closed enhancement (fixed)
[pkgman] inform if a package is already installed
Reported by: | diver | Owned by: | nobody |
---|---|---|---|
Priority: | normal | Milestone: | Unscheduled |
Component: | Applications/Command Line Tools | Version: | R1/Development |
Keywords: | Cc: | ||
Blocked By: | Blocking: | ||
Platform: | All |
Description
Currently, trying to install a package which is already installed pkgman prints Nothing to do.
which is not very informative. It would be nice if it explicitly say that it is installed along with the full path and a repo name
Change History (21)
comment:1 by , 7 years ago
comment:2 by , 7 years ago
This probably won't work as such:
- PackageManager::_ConfirmChanges is called for various cases (uninstall for instance).
- "pkgman install" can be called with several packages to install.
I would suggest to enhance the install action (command_install.cpp) to call the search action for the unique case "one package to install is already installed".
comment:3 by , 7 years ago
Changes pushed to https://review.haiku-os.org/91
Now the pkgman outputs something like this:
~> pkgman install vim curl 100% repochecksum-1 [65 bytes] Validating checksum for Haiku...done. 100% repocache-2 [88.43 KiB] Validating checksum for Haiku...done. 100% repochecksum-1 [64 bytes] Validating checksum for HaikuPorts...done. 100% repocache-2 [815.72 KiB] curl-7.54.1-2 from repository system is already installed. The following changes will be made in system: install package vim-8.0.1176-1 from repository HaikuPorts Continue? [yes/no] (yes):
I'm not able to get install path as package->Info().InstallPath()
is always empty.
And in case of BSolverPackageSpecifierList
, I tried adding all packages at once, and then searching for installed ones, but it didn't work when multiple packages are specified.
So, I had to add package names individually and find if packages related to it are installed.
comment:4 by , 7 years ago
Actually you should add a try/catch with the BNothingToDoException around the install call, display information there, and throw again BNothingToDoException which will display the standard "Nothing to do".
follow-up: 6 comment:5 by , 7 years ago
But, BNothingToDoException is only thrown when there are no packages to install.
In case I mentioned, curl is installed and vim isn't. In such scenario, BNothingToDoException is not thrown as there is one package to install.
comment:6 by , 7 years ago
Replying to Hrishikesh Hiraskar:
But, BNothingToDoException is only thrown when there are no packages to install.
In case I mentioned, curl is installed and vim isn't. In such scenario, BNothingToDoException is not thrown as there is one package to install.
Sure, but this case isn't the one described on this ticket, I mean, pkgman then doesn't print "Nothing to do".
comment:7 by , 7 years ago
I think I'm misunderstanding something.
I thought we needed to tell the user which packages are already installed.
Now the patch, when BNothingToDoException is thrown, will output something like this:
~> pkgman install curl 100% repochecksum-1 [65 bytes] Validating checksum for Haiku...done. 100% repocache-2 [88.43 KiB] Validating checksum for Haiku...done. 100% repochecksum-1 [64 bytes] Validating checksum for HaikuPorts...done. 100% repocache-2 [815.72 KiB] curl-7.54.1-2 from repository system is already installed. Nothing to do.
So, the patch handles both the cases. And to handle the previous case (where Exception isn't thrown), I didn't use try/catch.
Please point me if I'm missing something.
comment:8 by , 7 years ago
Checking each package before installing sounds unnecessary work. The user normally knows what he does anyway. Like I said, only the message "Nothing to do" is weird, and what this bug is about.
comment:9 by , 7 years ago
Okay
So, do you mean checking for packages and printing their info only in the case of Exception will suffice?
Or do we need to do something else?
comment:11 by , 7 years ago
Updated the required changes.
For Uninstall action, it looks like it's already been handled. If some package which isn't installed is specified, it says not found.
follow-up: 14 comment:13 by , 7 years ago
Thanks! I just tried it and it seems that repo name is wrong:
pkgman ins qt5 ... qt5-5.9.3-2 from repository system is already installed. Nothing to do.
comment:14 by , 7 years ago
Replying to diver:
Thanks! I just tried it and it seems that repo name is wrong:
pkgman ins qt5 ... qt5-5.9.3-2 from repository system is already installed. Nothing to do.
qt5-5.9.3-2 represents package name(qt5) along with the version(5.6.3-2) installed.
comment:16 by , 7 years ago
comment:18 by , 7 years ago
Replying to diver:
BTW, I think that "Nothing to do." is superfluous now.
I don't think so, it is still relevant.
follow-up: 20 comment:19 by , 7 years ago
pkgmain install mc pkgmain install --home mc
The latter one will simply prints "Nothing to do."
comment:20 by , 7 years ago
Replying to diver:
pkgmain install mc pkgmain install --home mcThe latter one will simply prints "Nothing to do."
This is due to pkgman only searching for packages in given location(system or home). https://git.haiku-os.org/haiku/tree/src/bin/pkgman/command_install.cpp#n109
@korli Any insights on this?
One solution to this I can see is to create PackageManager object with both the locations and then search.
comment:21 by , 7 years ago
The search command only uses the home location: https://git.haiku-os.org/haiku/tree/src/bin/pkgman/command_search.cpp#n200
I was looking at this issue.
The "Nothing to do" is due to BNothingToDoException thrown at https://git.haiku-os.org/haiku/tree/src/kits/package/manager/PackageManager.cpp#n498
Basically, Check is made at repository level for any changes, if no changes, then the BNothingToDoException is thrown.
So, we can change the "Nothing to do" message to something like "Packages already installed and up to date."
But, as the check is made at repository level, I'm not able to find a way to get package details and show it's name and the full path. Any insight will be helpful...