snapcraft icon indicating copy to clipboard operation
snapcraft copied to clipboard

snapcraft 7.x fails to replace new variables

Open dilyn-corner opened this issue 1 year ago • 4 comments

Bug Description

Snapcraft will fail to replace the new variable syntax and will only replace the old variable syntax.

To Reproduce

Install snapcraft 7.x (only tested 7.5.4+), use the provided snapcraft.yaml. Compare the error message just in case you remove the { } around the variable.

Environment

Ubuntu 23.04, building with --use-lxd

snapcraft.yaml

name: my-snap-name # you probably want to 'snapcraft register <name>'
base: core22 # the base snap is the execution environment for this snap
version: '0.1' # just for humans, typically '1.2+git' or '1.3.2'
summary: Single-line elevator pitch for your amazing snap # 79 char long summary
description: |
  This is my-snap's description. You have a paragraph or two to tell the
  most important story about your snap. Keep it under 100 words though,
  we live in tweetspace and your description wants to look good in the snap
  store.

grade: devel # must be 'stable' to release into candidate/stable channels
confinement: devmode # use 'strict' once you have the right plugs and slots

architectures:
  - build-on: amd64
    build-for: riscv64

parts:
  my-part:
    # See 'snapcraft plugins'
    plugin: nil
    build-packages:
      - gcc-${CRAFT_ARCH_TRIPLET_BUILD_FOR}

Relevant log output

2024-03-18 20:52:34.621 :: 2024-03-18 20:52:28.857 part build packages: ['gcc-${CRAFT_ARCH_TRIPLET_BUILD_FOR}']
2024-03-18 20:52:34.621 :: 2024-03-18 20:52:28.857 Requested build-packages: ['gcc-${CRAFT_ARCH_TRIPLET_BUILD_FOR}']
2024-03-18 20:52:34.621 :: 2024-03-18 20:52:30.183 Marking gcc-${CRAFT_ARCH_TRIPLET_BUILD_FOR} (and its dependencies) to be fetched
2024-03-18 20:52:34.621 :: 2024-03-18 20:52:34.160 Cannot find package listed in 'build-packages': gcc-${CRAFT_ARCH_TRIPLET_BUILD_FOR}

Additional context

No response

dilyn-corner avatar Mar 19 '24 00:03 dilyn-corner

Thank you for reporting us your feedback!

The internal ticket has been created: https://warthogs.atlassian.net/browse/CRAFT-2623.

This message was autogenerated

The problem here is that CRAFT_ARCH_TRIPLET_BUILD_FOR was introduced in craft-parts 1.24.0, but Snapcraft 7.5.x uses craft-parts 1.19.7. For that particular case you can fallback to CRAFT_ARCH_TRIPLET instead

tigarmo avatar Mar 19 '24 11:03 tigarmo

so the env did not get replaced, leaving the _ after the : triggering the slice check. The slice check probably needs to check things before the architecture check. I am not even sure we support slices with architecture tags, so : might also not be allowed for slices specifically

sergiusens avatar Mar 19 '24 12:03 sergiusens

I wonder how useful it is to fix this on the slice-verification side, because if a variable didn't get expanded then basically all bets are off: the build would fail later when trying to install gcc-${CRAFT_ARCH_TRIPLET_BUILD_FOR} from apt

tigarmo avatar Mar 19 '24 12:03 tigarmo