The function get_unrelevant_host_packages() returns an empty list

Questions about WAPT Packaging / Requests and help regarding Wapt packages.
Forum Rules
Community Forum Rules
* English support on www.reddit.com/r/wapt
* French community support is available on this forum
* Please prefix the topic title with [RESOLVED] if it is resolved.
* Please do not edit a topic that is tagged [RESOLVED]. Open a new topic referencing the old one.
* Specify the installed WAPT version, full version, and build number (2.2.1.11957 / 2.2.2.12337 / etc.) as well as the Enterprise/Discovery edition.
* Versions 1.8.2 and earlier are no longer supported. The only questions accepted regarding version 1.8.2 are related to upgrading to a supported version (2.1, 2.2, etc.).
* Specify the server OS (Linux/Windows) and version (Debian Buster/Bullseye - CentOS 7 - Windows Server 2012/2016/2019).
* Specify the OS of the administration/package creation machine and the machine with the problematic agent, if applicable (Windows 7/10/11/Debian 11/etc.).
* Avoid asking multiple questions when opening a topic, otherwise it may be ignored. If there are multiple topics, open separate topics, preferably one after the other and not all at the same time (i.e., do not spam the forum).
* Include code snippets, screenshots, and other images directly in the post. Links to Pastebin, Bitly, and other third-party sites will be systematically removed.
* As with any community forum, support is provided voluntarily by members. If you require commercial support, you can contact Tranquil IT's sales department at 02.40.97.57.55
Answer
brice73
Messages: 42
Registration: February 13, 2023 - 8:05 AM

March 25, 2024 - 10:28

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?
WAPT Enterprise 2.6.1.17765
WAPT server under Debian 13
Administration/package creation under Windows 11/10
brice73
Messages: 42
Registration: February 13, 2023 - 8:05 AM

March 28, 2024 - 09:51

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
WAPT Enterprise 2.6.1.17765
WAPT server under Debian 13
Administration/package creation under Windows 11/10
User avatar
dcardon
WAPT Expert
Messages: 1932
Registration: June 18, 2014 - 09:58
Location: Saint Sébastien sur Loire
Contact :

March 28, 2024 - 7:34 PM

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
Denis Cardon - Tranquil IT
Share your experiences on WAPT! Send us your blog and article URLs in the "Your Opinion of the forum, and we'll feature them on the WAPT
brice73
Messages: 42
Registration: February 13, 2023 - 8:05 AM

March 31, 2024 - 11:01

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
WAPT Enterprise 2.6.1.17765
WAPT server under Debian 13
Administration/package creation under Windows 11/10
Answer