fix: don't add duplicate packages to package lists
In some uncommon cases where multiple packages suggest the same packages (and possibly in other circumstances) Nala may show the same packages repeatedly in the "Suggested, Will Not Be Installed" section. An example on Ubuntu 24.04:
❱ sudo nala install -n qemu-system
==========================================================================================================================================================
Installing
==========================================================================================================================================================
Package: Version: Size:
qemu-efi-aarch64 2024.02-2ubuntu0.4 4.1 MB
qemu-efi-arm 2024.02-2ubuntu0.4 774 KB
qemu-system 1:8.2.2+ds-0ubuntu1.9 57 KB
qemu-system-arm 1:8.2.2+ds-0ubuntu1.9 10.9 MB
qemu-system-mips 1:8.2.2+ds-0ubuntu1.9 16.3 MB
qemu-system-misc 1:8.2.2+ds-0ubuntu1.9 57.7 MB
qemu-system-ppc 1:8.2.2+ds-0ubuntu1.9 9.1 MB
qemu-system-s390x 1:8.2.2+ds-0ubuntu1.9 3.4 MB
qemu-system-sparc 1:8.2.2+ds-0ubuntu1.9 6.3 MB
==========================================================================================================================================================
Suggested, Will Not Be Installed
==========================================================================================================================================================
Package: Version: Size:
samba 2:4.19.5+dfsg-4ubuntu9.3 1.0 MB
vde2 2.3.2+r586-10 131 KB
samba 2:4.19.5+dfsg-4ubuntu9.3 1.0 MB
vde2 2.3.2+r586-10 131 KB
samba 2:4.19.5+dfsg-4ubuntu9.3 1.0 MB
vde2 2.3.2+r586-10 131 KB
samba 2:4.19.5+dfsg-4ubuntu9.3 1.0 MB
vde2 2.3.2+r586-10 131 KB
samba 2:4.19.5+dfsg-4ubuntu9.3 1.0 MB
vde2 2.3.2+r586-10 131 KB
==========================================================================================================================================================
Summary
==========================================================================================================================================================
Install 9 Packages
Total download size 108.8 MB
Disk space required 893.0 MB
Abort.
This small change checks to see if a package is in a given list before potentially adding it again. The method done here is algorithmically inefficient, but in realistic use cases the performance hit is going to be effectively zero, and it solves the issue:
❱ sudo ./nala-cli.py install -n qemu-system
==========================================================================================================================================================
Installing
==========================================================================================================================================================
Package: Version: Size:
qemu-efi-aarch64 2024.02-2ubuntu0.4 4.1 MB
qemu-efi-arm 2024.02-2ubuntu0.4 774 KB
qemu-system 1:8.2.2+ds-0ubuntu1.9 57 KB
qemu-system-arm 1:8.2.2+ds-0ubuntu1.9 10.9 MB
qemu-system-mips 1:8.2.2+ds-0ubuntu1.9 16.3 MB
qemu-system-misc 1:8.2.2+ds-0ubuntu1.9 57.7 MB
qemu-system-ppc 1:8.2.2+ds-0ubuntu1.9 9.1 MB
qemu-system-s390x 1:8.2.2+ds-0ubuntu1.9 3.4 MB
qemu-system-sparc 1:8.2.2+ds-0ubuntu1.9 6.3 MB
==========================================================================================================================================================
Suggested, Will Not Be Installed
==========================================================================================================================================================
Package: Version: Size:
samba 2:4.19.5+dfsg-4ubuntu9.3 1.0 MB
vde2 2.3.2+r586-10 131 KB
==========================================================================================================================================================
Summary
==========================================================================================================================================================
Install 9 Packages
Total download size 108.8 MB
Disk space required 893.0 MB
Abort.