Repository: canonical/cloud-init

Issue:
package-update-upgrade-install does not work on Gentoo
This bug was originally filed in Launchpad as [LP: #1799544](https://bugs.launchpad.net/cloud-init/+bug/1799544)
<details>
<summary>Launchpad details</summary>
<pre>
affected_projects = []
assignee = holmanb
assignee_name = Brett Holman
date_closed = 2022-07-21T15:16:56.010973+00:00
date_created = 2018-10-23T17:34:36.633424+00:00
date_fix_committed = 2022-07-21T15:16:56.010973+00:00
date_fix_released = 2022-07-21T15:16:56.010973+00:00
id = 1799544
importance = medium
is_complete = True
lp_url = https://bugs.launchpad.net/cloud-init/+bug/1799544
milestone = 22.2
owner = gilles-dartiguelongue
owner_name = Gilles Dartiguelongue
private = False
status = fix_released
submitter = gilles-dartiguelongue
submitter_name = Gilles Dartiguelongue
tags = ['gentoo']
duplicates = []
</pre>
</details>

_Launchpad user **Gilles Dartiguelongue(gilles-dartiguelongue)** wrote on 2018-10-23T17:34:36.633424+00:00_

I'm testing cloud-init in a nocloud setup. I'm trying to perform installation of packages using the appropriate module and after fixing some issues in Gentoo packaging, I hit an error in execution due to cmd = list('emerge') being interpreted as ['e', 'm', 'e', ...] while it was meant as ['emerge'].


Discussion:
_Launchpad user **Gilles Dartiguelongue(gilles-dartiguelongue)** wrote on 2018-10-23T17:34:36.633424+00:00_


_Launchpad attachments_: [0001-Fix-Gentoo-package-installation-command.patch](https://api.launchpad.net/devel/cloud-init/+bug/1799544/+attachment/5204611/data)
_Launchpad user **Scott Moser(smoser)** wrote on 2018-10-25T17:42:30.851433+00:00_

Hi,
Thank you for contributing to cloud-init.

To contribute, you must sign the Canonical Contributor License Agreement
(CLA) [1].

If you have already signed it as an individual, your Launchpad user will
be listed in the contributor-agreement-canonical launchpad group [2].
Unfortunately there is no easy way to check if an organization or company
you are doing work for has signed. If you are unsure or have questions,
email scott.moser@canonical.com or ping smoser in #cloud-init channel
via freenode.

For information on how to sign, please see the HACKING document [3].

Thanks again, and please feel free to reach out with any questions.

–
[1] http://www.canonical.com/contributors
[2] https://launchpad.net/~contributor-agreement-canonical/+members
[3] http://cloudinit.readthedocs.io/en/latest/topics/hacking.html

_Launchpad user **Brett Holman(holmanb)** wrote on 2022-04-12T15:12:02.771851+00:00_

This should be fixed in the upcoming 22.2 release.
I'm surprised to see the issue is not fixed.
https://github.com/canonical/cloud-init/blame/main/cloudinit/distros/gentoo.py#L221

The patch should still apply.

Resolving patch:
diff --git a/cloudinit/distros/gentoo.py b/cloudinit/distros/gentoo.py
--- a/cloudinit/distros/gentoo.py
+++ b/cloudinit/distros/gentoo.py
@@ -218,7 +218,7 @@ def set_timezone(self, tz):
         distros.set_etc_timezone(tz=tz, tz_file=self._find_tz_file(tz))
 
     def package_command(self, command, args=None, pkgs=None):
-        cmd = list("emerge")
+        cmd = ["emerge"]
         # Redirect output
         cmd.append("--quiet")
 


Test patch: