canonical / charmcraft

Collaborate, build and publish charmed operators for Kubernetes, Linux and Windows.
Apache License 2.0
65 stars 69 forks source link

Can't build charm targeted at the current development release: `Skipping 'bases[8].build-on[0]': channel 'devel' does not match host '23.10'.` #1267

Closed fnordahl closed 1 month ago

fnordahl commented 1 year ago

Bug Description

Slightly, but not quite, related to #1104 and #1203.

As proponents and developers of model driven operations, trying to release machine charms for new versions of, ehh, machines, it would be great to be able to know ahead of time whether your charmed machine operator would work with the next Ubuntu release.

The references above and this bug report serves as proof that this is not currently possible.

To Reproduce

Attempt to pack a charm with a bases config like:

  - build-on:
      - name: ubuntu
        channel: devel
        architectures: [amd64]
    run-on:
      - name: ubuntu
        channel: "23.10"
        architectures: [amd64]

Environment

N/A

charmcraft.yaml

N/A

Relevant log output

See above.
fnordahl commented 1 year ago

This simple patch appears to fix it, but I'm sure we would be able to get the version information hiding behind devel to perform proper validation:

diff --git a/charmcraft/bases.py b/charmcraft/bases.py
index c5b362e..297a8ac 100644
--- a/charmcraft/bases.py
+++ b/charmcraft/bases.py
@@ -58,7 +58,7 @@ def check_if_base_matches_host(base: Base) -> Tuple[bool, Union[str, None]]:
         host_channel = host_base.channel
     else:
         host_channel = host_base.channel.split(".")[0]
-    if host_channel != base.channel:
+    if base.channel != "devel" and host_channel != base.channel:
         return (
             False,
             f"channel {base.channel!r} does not match host {host_base.channel!r}",
lengau commented 1 month ago

I believe this is fixed in Charmcraft 3. If not, please reopen :-)