Opened 4 years ago

Closed 19 months ago

Last modified 19 months ago

#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:
Has a Patch: no 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 hrily, 19 months ago

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...

comment:2 by korli, 19 months 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 hrily, 19 months 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 korli, 19 months 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".

comment:5 by hrily, 19 months 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.

in reply to:  5 comment:6 by korli, 19 months 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 hrily, 19 months 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 korli, 19 months 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 hrily, 19 months 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:10 by korli, 19 months ago

The same logic could be applied to the uninstall action.

comment:11 by hrily, 19 months 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.

comment:12 by korli, 19 months ago

Resolution: fixed
Status: newclosed

Patch applied in hrev51813

comment:13 by diver, 19 months 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.

in reply to:  13 comment:14 by hrily, 19 months 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:15 by diver, 19 months ago

I'm talking about repository "system".

in reply to:  15 comment:16 by hrily, 19 months ago

Replying to diver:

I'm talking about repository "system".

Oops! Sorry...

comment:17 by diver, 19 months ago

BTW, I think that "Nothing to do." is superfluous now.

in reply to:  17 comment:18 by korli, 19 months ago

Replying to diver:

BTW, I think that "Nothing to do." is superfluous now.

I don't think so, it is still relevant.

comment:19 by diver, 19 months ago

pkgmain install mc
pkgmain install --home mc

The latter one will simply prints "Nothing to do."

in reply to:  19 comment:20 by hrily, 19 months ago

Replying to diver:

pkgmain install mc
pkgmain install --home mc

The 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.

Note: See TracTickets for help on using tickets.