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

regresion: Can't build pc-amd64-gadget-desktop (neither 22 nor 24 versions) with snapcraft 8.x #4818

Closed
sergio-costas opened this issue May 22, 2024 · 5 comments · Fixed by #4850
Labels

Comments

@sergio-costas
Copy link
Contributor

Bug Description

I tried to build the pc-amd64-gadget-desktop snap (version 22) for core desktop, but snapcraft 8.2.x, but it crashes with an error. Also tried with version 24 and it fails too, but doesn't crash. Instead, snapcraft 7.5.5 works like a charm.

To Reproduce

  • Download the repository from https://github.com/canonical/pc-amd64-gadget-desktop.git
  • Change to branch 22 (or 24; it fails in both.
  • Run snapcraft

Environment

I'm using LXD under Ubuntu 24.04 LTS.

snapcraft.yaml

name: pc-desktop
version: '22-0.4'
type: gadget
build-base: core22
base: core22-desktop
summary: PC gadget for generic devices
description: |
    This gadget enables generic pc devices to work with Ubuntu Core Desktop
confinement: strict
grade: stable
architectures:
  - build-on: amd64
    build-for: amd64
icon: icon.png

package-repositories:
 - type: apt
   ppa: ucdev/uc-staging-ppa

hooks:
  prepare-device:
    environment:
      # If you are forking and building your own gadget:
      # define your model's API key here
      # See https://ubuntu.com/core/services/guide/serial-vault-overview
      # for instructions on how to generate an API key
      # DO NOT check this API key into a publicly accessible VCS
      MODEL_APIKEY: ""


# Min version to support shim 15.7
# Using passthrough until LP#2019931 is fixed
passthrough:
  assumes:
    - snapd2.59.3

parts:
  # Temporary workaround until pinning is supported by snapcraft
  pin-ucdev:
    plugin: nil
    override-pull: |
      # This is run before the pull step of grub part, so we make sure
      # we get the packages from the PPA.
      set -x
      cat <<'EOF' > /etc/apt/preferences.d/ucdev
      Package: *
      Pin: release LP-PPA-ucdev-uc-staging-ppa,a=jammy,n=jammy
      Pin: origin ppa.launchpad.net
      Pin-Priority: 1000
      EOF
  mbr:
    source: .
    build-packages:
      - ubuntu-dev-tools
    plugin: make
  grub:
    after: [ pin-ucdev ]
    plugin: nil
    source: .
    build-packages:
      - ubuntu-dev-tools
      - grub-pc-bin
      - grub-common
      - sbsigntool
    stage-packages:
      - grub-efi-amd64-signed
      - shim-signed
    override-build: |
      set -x
      # Make sure we have signatures from the UC certificates
      sbverify --list "$CRAFT_PART_INSTALL"/usr/lib/shim/shimx64.efi.dualsigned |
          grep -E 'Canonical Ltd. Secure Boot Signing \(Ubuntu Core'
      sbverify --list "$CRAFT_PART_INSTALL"/usr/lib/grub/x86_64-efi-signed/grubx64.efi.signed |
          grep -E 'Canonical Ltd. Secure Boot Signing \(Ubuntu Core'
      # grub.conf lets snapd identify grub as the bootloader on boot
      install -m 644 /dev/null "$CRAFT_PART_INSTALL"/grub.conf
    organize:
      usr/lib/shim/shimx64.efi.dualsigned: shim.efi.signed
      usr/lib/grub/x86_64-efi-signed/grubx64.efi.signed: grubx64.efi
    prime:
      - shim.efi.signed
      - grubx64.efi
      - grub.conf

  extra:
    source: ./extra
    plugin: dump

Relevant log output

With branch 24 it shows:

`Unknown base 'core24-desktop'`

With branch 22 it crashes with:


Traceback (most recent call last):
  File "/snap/snapcraft/11722/lib/python3.10/site-packages/snapcraft/application.py", line 361, in main
    return app.run()
  File "/snap/snapcraft/11722/lib/python3.10/site-packages/craft_application/application.py", line 488, in run
    dispatcher = self._get_dispatcher()
  File "/snap/snapcraft/11722/lib/python3.10/site-packages/snapcraft/application.py", line 220, in _get_dispatcher
    raise errors.ClassicFallback()
snapcraft.errors.ClassicFallback

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/snap/snapcraft/11722/lib/python3.10/site-packages/snapcraft/models/project.py", line 651, in _providers_base
    return SNAPCRAFT_BASE_TO_PROVIDER_BASE[base]
KeyError: 'core22-desktop'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/snap/snapcraft/11722/bin/snapcraft", line 8, in <module>
    sys.exit(main())
  File "/snap/snapcraft/11722/lib/python3.10/site-packages/snapcraft/application.py", line 364, in main
    return cli.run()
  File "/snap/snapcraft/11722/lib/python3.10/site-packages/snapcraft/cli.py", line 222, in run
    _run_dispatcher(dispatcher, global_args)
  File "/snap/snapcraft/11722/lib/python3.10/site-packages/snapcraft/cli.py", line 194, in _run_dispatcher
    dispatcher.run()
  File "/snap/snapcraft/11722/lib/python3.10/site-packages/craft_cli/dispatcher.py", line 487, in run
    return self._loaded_command.run(self._parsed_command_args)
  File "/snap/snapcraft/11722/lib/python3.10/site-packages/snapcraft/commands/core22/lifecycle.py", line 265, in run
    super().run(parsed_args)
  File "/snap/snapcraft/11722/lib/python3.10/site-packages/snapcraft/commands/core22/lifecycle.py", line 138, in run
    parts_lifecycle.run(self.name, parsed_args)
  File "/snap/snapcraft/11722/lib/python3.10/site-packages/snapcraft/parts/lifecycle.py", line 104, in run
    project = models.Project.unmarshal(yaml_data_for_arch)
  File "/snap/snapcraft/11722/lib/python3.10/site-packages/snapcraft/models/project.py", line 876, in unmarshal
    project = Project(**data)
  File "pydantic/main.py", line 339, in pydantic.main.BaseModel.__init__
  File "pydantic/main.py", line 1100, in pydantic.main.validate_model
  File "/snap/snapcraft/11722/lib/python3.10/site-packages/craft_application/models/project.py", line 178, in _validate_devel
    base_alias = cls._providers_base(base)
  File "/snap/snapcraft/11722/lib/python3.10/site-packages/snapcraft/models/project.py", line 653, in _providers_base
    raise CraftValidationError(f"Unknown base {base!r}") from err
craft_application.errors.CraftValidationError: Unknown base 'core22-desktop'


### Additional context

_No response_
@sergio-costas sergio-costas changed the title Can't build pc-amd64-gadget-desktop (neither 22 nor 24 versions) with snapcraft 8.x regresion: Can't build pc-amd64-gadget-desktop (neither 22 nor 24 versions) with snapcraft 8.x May 22, 2024
@mr-cal mr-cal added the triaged label Jun 5, 2024
Copy link

Thank you for reporting us your feedback!

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

This message was autogenerated

@mr-cal
Copy link
Collaborator

mr-cal commented Jun 5, 2024

Looks like Snapcraft needs to make the base validation handle core22-desktop and core24-desktop. Are there any other uncommon bases that you use?

lengau added a commit that referenced this issue Jun 11, 2024
@sergio-costas
Copy link
Contributor Author

@mr-cal Sorry, didn't receive a mail with your question. No, there aren't other uncommon bases, for me at least.

@jhenstridge
Copy link
Contributor

@mr-cal: looking at the fix you applied, I'm kind of surprised you needed to special case coreXX-desktop. The snapcraft project in question reads:

build-base: core22
base: core22-desktop

If the aim is to choose a build environment to build the snap in, it should be using build-base in preference to base if it is available. The build-base should be an exact match for one of your build environments.

@mr-cal
Copy link
Collaborator

mr-cal commented Jun 25, 2024

@jhenstridge - are you talking about #4850? If so, that PR is about expanding the accepted values of base and doesn't affect the build-base or build environment used in this project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants