Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

validate architecture scalars #4340

Open
mr-cal opened this issue Aug 30, 2023 · 0 comments
Open

validate architecture scalars #4340

mr-cal opened this issue Aug 30, 2023 · 0 comments
Labels
Enhancement New features or optimizations

Comments

@mr-cal
Copy link
Collaborator

mr-cal commented Aug 30, 2023

What needs to get done

Validate that architectures only contain alphanumeric characters and recommend using brackets for multiple architectures.

archictectures: 
  - build-on: amd64
    build-for: bad, value
> snapcraft
Error: Architecture 'bad, value' must only contain alphanumeric characters. Use brackets to list multiple architectures: '[arch1, arch2]'.
For more information, check out: https://snapcraft.io/docs/architectures

This validation can be done during yaml validation and should be similar for the core20 and core22 implementations.

This issue is referenced in the documentation and should be updated when completed. (both readthedocs and snapcraft.io/docs)

Breaking changes

This can break previously working core20 snap builds. However the snap themselves are useless; snap install "my-snap_1.0_amd64, arm64.snap" always fails.

Why it needs to get done

Consider the following snapcraft.yaml:

base: core20
architectures:
  - build-on: amd64
    run-on: amd64, arm64  # problematic: this is a scalar, not a list

This scenario happens during iterative development. A user starts with a single scalar architecture amd64 and later adds another architecture without adding brackets. So amd64, arm64 is still treated as a scalar. The correct syntax is a yaml list: [amd64, arm64].

In core20, this is allowed. It would produce a snap named my-snap_1.0_amd64, arm64.snap.

In core22, this is not allowed but the error could be improved. It may not be obvious that the square brackets are missing.

source: https://bugs.launchpad.net/snapcraft/+bug/2009520

@mr-cal mr-cal added the Enhancement New features or optimizations label Aug 30, 2023
@mr-cal mr-cal changed the title architectures: validate architecture scalars validate architecture scalars Sep 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New features or optimizations
Projects
None yet
Development

No branches or pull requests

1 participant