Page 1 of 1
The function get_unrelevant_host_packages() returns an empty list
Published: March 25, 2024 - 10:28
by brice73
Hello,
I wanted to use the `get_unrelevant_host_packages()` function within a package. When I apply it to a package installed on the machine but no longer assigned to it (no longer present in the list of packages assigned to the machine in the console), the function returns an empty list, whereas it should return at least that package in the list.
What could be the reason for this?
Re: The get_unrelevant_host_packages() function returns an empty list
Published: March 28, 2024 - 09:51
by brice73
The `get_unrelevant_host_packages()` function works correctly, and it's normal that it returns an empty list.
I misunderstood which packages it was returning (host, unit, etc.). I initially thought it returned packages installed on the machine but no longer assigned to it.
You can close or delete the thread.
Regards
Re: The get_unrelevant_host_packages() function returns an empty list
Published: March 28, 2024 - 7:34 PM
by dcardon
Hello Brice,
Indeed, it is a common function which is used by the WAPT engine but which does not really make sense to be called in a WAPT package.
It seems to me that the function you want is similar to the autoremove function in Debian apt-get. Currently, we don't store the installation origin, which can be implicit (unit package / or group package, profile package) or explicit (command line wapt-get install or self-service). Therefore, we can't implement autoremove at the moment, otherwise we risk removing unnecessary packages.
If you have a specific package to clean up across your entire domain, you can use a cleanup package with a function like the following:
Code: Select all
def install():
WAPT.uninstall('mon-paquet-que-je-ne-veux-plus')
Sincerely,
Denis
Re: The get_unrelevant_host_packages() function returns an empty list
Published: March 31, 2024 - 11:01
by brice73
Hello Denis,
Thank you for your advice. My goal was to completely uninstall a package while installing another package. Therefore, I used the `remove('package')` function instead of `uninstall('package')`, but I wanted to make the uninstallation conditional on two factors: firstly, a subsequent WAPT version of the package to be uninstalled (because uninstalling the existing package failed, and I first needed to update it using the `upgrades()` function), and secondly, that the package was no longer assigned to the machine. I thought I could retrieve this information using the `get_unrelevant_host_packages()` function to avoid reinstalling the package if it was still assigned to the machine. Since
the `get_unrelevant_host_packages()` function didn't return the information I was expecting, I didn't include this second condition for the package uninstallation. But it wasn't absolutely necessary; I made sure via the console that the package to be uninstalled was removed from all machines, and everything worked.
Regards