canonical / snapcraft

Package, distribute, and update any app for Linux and IoT.
https://snapcraft.io
GNU General Public License v3.0
1.18k stars 446 forks source link

unknown component type "standard" #5125

Closed stephensp closed 4 weeks ago

stephensp commented 4 weeks ago

Bug Description

Launchpad builds are not able to support the component type standard

To Reproduce

Create a snapcraft.yaml with components and set the component type to standard. Build in launchpad.

Example project with components: https://git.launchpad.net/~portias/+git/kernel-snaps-u24.04/tree/?h=portias/pc-components

Environment

Launchpad.

snapcraft 8.4.3 from Canonical** installed

snapcraft.yaml

name: pc-kernel
adopt-info: kernel
grade: stable
summary: Ubuntu generic kernel
description: The Ubuntu generic kernel package as a snap
source-code: https://git.launchpad.net/~canonical-kernel-snaps/canonical-kernel-snaps/+git/kernel-snaps-u24.04
issues: https://bugs.launchpad.net/canonical-kernel-snaps/+filebug?field.tags=pc-kernel
contact: https://answers.launchpad.net/canonical-kernel-snaps/+addquestion
type: kernel
confinement: strict
build-base: core24

platforms:
  amd64:
  arm64:

components:
  nvidia-550-ko:
    type: kernel-modules
    summary: nvidia 550 kernel objects
    description: nvidia 550 kernel objects
    hooks:
      install:
        plugs:
          - kernel-module-load

  nvidia-550-user:
    type: standard
    summary: nvidia 550 userspace libraries
    description: nvidia 550 userspace libraries

  nouveau:
    type: kernel-modules
    summary: nouveau kernel module
    description: nouveau kernel module

parts:
  kernel:
    source: https://git.launchpad.net/canonical-kernel-snaps
    source-type: git
    source-branch: main
    plugin: nil

    build-packages:
      - kmod

    stage-packages:
      - linux-image-uc-generic

    override-build: |
      echo BULID

      # Determine version and 'uname -r'
      unamer=$(basename "$CRAFT_PART_INSTALL"/lib/modules/*)
      version="$(apt show linux-image-uc-"$unamer" 2>/dev/null | sed -n 's/^Version: //p' | head -n1)"

      # Set the snap package version
      craftctl set version=$version

      # Update depmod
      /usr/sbin/depmod -b "$CRAFT_PART_INSTALL" "$unamer"

      craftctl default

      # Move nouveau out of the file tree
      find "$CRAFT_PART_INSTALL" -name nouveau.ko.zst -exec mv '{}' "$CRAFT_PART_INSTALL" \;

    # Move nouveau into a dedicated component
    organize:
      nouveau.ko.zst: (component/nouveau)/

    override-stage: |
      echo STAGE

      # Determine 'uname -r'
      unamer=$(basename "$CRAFT_PART_INSTALL"/lib/modules/*)

      # Move modules
      mv "$CRAFT_PART_INSTALL"/lib/modules "$CRAFT_PART_INSTALL"/

      # Copy firmware
      "$CRAFT_PART_SRC"/copy-firmware -m "$CRAFT_PART_INSTALL"/modules/"$unamer" -f "$CRAFT_PART_INSTALL"/lib/firmware \
          "$CRAFT_PART_INSTALL"/_tmp
      # Move the dtbs
      if [ -d "$CRAFT_PART_INSTALL"/lib/firmware/"$unamer" ] ; then
          mv "$CRAFT_PART_INSTALL"/lib/firmware/"$unamer" "$CRAFT_PART_INSTALL"/_tmp/lib/firmware/
      fi
      mv "$CRAFT_PART_INSTALL"/_tmp/lib/firmware "$CRAFT_PART_INSTALL"/

      # Move boot files
      mv "$CRAFT_PART_INSTALL"/boot/System.map-"$unamer" "$CRAFT_PART_INSTALL"/
      mv "$CRAFT_PART_INSTALL"/boot/config-"$unamer" "$CRAFT_PART_INSTALL"/
      mv "$CRAFT_PART_INSTALL"/boot/kernel.efi-"$unamer" "$CRAFT_PART_INSTALL"/kernel.efi

      # Move docs
      mv "$CRAFT_PART_INSTALL"/usr/share/doc "$CRAFT_PART_INSTALL"/

      # Clean up remaining stage package files
      rm -rf "$CRAFT_PART_INSTALL"/{_tmp,boot,lib,usr}

      # Create compat symlink for installing headers on classic
      ln -s /usr/src/linux-headers-"$unamer" "$CRAFT_PART_INSTALL"/modules/"$unamer"/build

      # Create a mountpoint for firmware updates (LP: #2051144)
      mkdir "$CRAFT_PART_INSTALL"/firmware/updates

      craftctl default

  #TODO temporary workaround for nouveau hooks not being in canonical-kernel-snaps repo
  nouveau-scripts:
    source: ./hooks
    plugin: nil
    override-build: |
      craftctl default
      cp install.module remove.module $CRAFT_PART_INSTALL/

      # duplicate install.module as a post refres hook
      cp install.module $CRAFT_PART_INSTALL/post-refresh.module
    organize:
      install.module: (component/nouveau)/snap/hooks/install
      post-refresh.module: (component/nouveau)/snap/hooks/post-refresh
      remove.module: (component/nouveau)/snap/hooks/remove

  files:
    plugin: dump
    source: files

  nvidia-550-ko-comp:
    source: ./hooks
    plugin: nil

    stage-packages:
      - binutils
      - make

    override-build: |
      craftctl default
      version="$(craftctl get version)"

      #clean up unnecessary libs
      rm -f -- $CRAFT_PART_INSTALL/usr/lib/$(uname -m)-linux-gnu/libc.so.6
      apt-get download linux-objects-nvidia-550-server-${version%.*}-generic \
          linux-signatures-nvidia-${version%.*}-generic
      for i in `find . -name '*.deb'` ; do dpkg-deb -x $i nvidia-objects ;  done

      mkdir -p $CRAFT_PART_INSTALL/bits
      mv nvidia-objects/lib/modules/*/kernel/nvidia-550srv/bits/* $CRAFT_PART_INSTALL/bits
      # Reuse the install hook as the post-refresh hook
      cp install.nvidia-ko remove.module $CRAFT_PART_INSTALL/
      cp install.nvidia-ko $CRAFT_PART_INSTALL/post-refresh.nvidia
      cp kernel-gpu-2404-provider-mangler $CRAFT_PART_INSTALL/kernel-gpu-2404-provider-mangler

    organize:
      bits/: (component/nvidia-550-ko)/bits
      usr/bin: (component/nvidia-550-ko)/bin
      usr/lib: (component/nvidia-550-ko)/lib
      install.nvidia-ko: (component/nvidia-550-ko)/snap/hooks/install
      post-refresh.nvidia-ko: (component/nvidia-550-ko)/snap/hooks/post-refresh
      remove.module: (component/nvidia-550-ko)/snap/hooks/remove

  nvidia-550-user-comp:
    source: ./hooks
    plugin: nil

    stage-packages:
      - libnvidia-egl-wayland1
      - libnvidia-cfg1-550-server
      - libnvidia-common-550-server
      - libnvidia-compute-550-server
      - libnvidia-decode-550-server
      - libnvidia-encode-550-server
      - libnvidia-extra-550-server
      - libnvidia-gl-550-server
      - libnvidia-fbc1-550-server
      - nvidia-utils-550-server
      - xserver-xorg-video-nvidia-550
      - libgl1
      - libegl1
      - libgles2
      - libvulkan1
      - libgbm1

    override-build: |
      craftctl default
      cp install.nvidia-user $CRAFT_PART_INSTALL/
      cp install.nvidia-user $CRAFT_PART_INSTALL/
      cp remove.nvidia-user $CRAFT_PART_INSTALL/
      cp kernel-gpu-2404-provider-mangler $CRAFT_PART_INSTALL/kernel-gpu-2404-provider-mangler

    organize:
      usr/share: (component/nvidia-550-user)/share
      usr/lib: (component/nvidia-550-user)/lib
      usr/bin/nvidia-smi: (component/nvidia-550-user)/usr/bin/nvidia-smi
      kernel-gpu-2404-provider-mangler: (component/nvidia-550-user)/bin/kernel-gpu-2404-provider-mangler
      install.nvidia-user: (component/nvidia-550-user)/snap/hooks/install
      post-refresh.nvidia-user: (component/nvidia-550-user)/snap/hooks/post-refresh
      remove.nvidia-user: (component/nvidia-550-user)/snap/hooks/remove

slots:
  kernel-gpu-2404:
    interface: content
    read:
      - $SNAP_COMMON/kernel-gpu-2404

Relevant log output

snapcraft 8.4.3 from Canonical** installed
:: + mkdir /build/pc-kernel/parts/kernel/install/firmware/updates
:: + craftctl default
Staging nouveau-scripts
Staging nvidia-550-ko-comp
Staging nvidia-550-user-comp
Priming files
Priming kernel
Priming nouveau-scripts
Priming nvidia-550-ko-comp
Priming nvidia-550-user-comp
Packing...
Reading snap metadata...
Running linters...
Running linter: classic
Running linter: library
Cannot pack snap: error: cannot parse snap.yaml: unknown component type "standard"
Full execution log: '/root/.local/state/snapcraft/log/snapcraft-20241017-000738.214358.log'
Build failed
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/lpbuildd/target/build_snap.py", line 284, in run
    self.build()
  File "/usr/lib/python3/dist-packages/lpbuildd/target/build_snap.py", line 268, in build
    self.run_build_command(["snapcraft"], cwd=output_path, env=env)
  File "/usr/lib/python3/dist-packages/lpbuildd/target/operation.py", line 62, in run_build_command
    return self.backend.run(args, cwd=cwd, env=full_env, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/lpbuildd/target/lxd.py", line 718, in run
    subprocess.check_call(cmd, **kwargs)
  File "/usr/lib/python3.12/subprocess.py", line 413, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['lxc', 'exec', 'lp-noble-amd64', '--env', 'LANG=C.UTF-8', '--env', 'SHELL=/bin/sh', '--env', 'http_proxy=http://10.10.10.1:8222/', '--env', 'https_proxy=http://10.10.10.1:8222/', '--env', 'GIT_PROXY_COMMAND=/usr/local/bin/lpbuildd-git-proxy', '--env', 'SNAPPY_STORE_NO_CDN=1', '--env', 'SNAPCRAFT_BUILD_INFO=1', '--env', 'SNAPCRAFT_IMAGE_INFO={"build-request-id": "lp-92962226", "build-request-timestamp": "2024-10-17T00:05:19Z", "build_url": "https://launchpad.net/~portias/+snap/pc-kernel/+build/2630751"}', '--env', 'SNAPCRAFT_BUILD_ENVIRONMENT=host', '--env', 'SNAPCRAFT_BUILD_FOR=amd64', '--', '/bin/sh', '-c', 'cd /build/pc-kernel && linux64 snapcraft']' returned non-zero exit status 1.
Revoking proxy token...
RUN: /usr/share/launchpad-buildd/bin/in-target scan-for-processes --backend=lxd --series=noble --arch=amd64 SNAPBUILD-2630751
Scanning for processes to kill in build SNAPBUILD-2630751

Additional context

No response

mr-cal commented 4 weeks ago

I believe this is due to the wrong version of snapd in the build environment. I can reproduce this with snapd 2.63:

> snap list snapd
Name   Version  Rev    Tracking       Publisher   Notes
snapd  2.63     21759  latest/stable  canonical✓  snapd
> snap pack --check-skeleton /root/prime
error: cannot parse snap.yaml: unknown component type "standard"
> snap refresh snapd --channel latest/candidate
2024-10-17T13:01:29Z INFO Waiting for automatic snapd restart...
snapd (candidate) 2.66 from Canonical✓ refreshed
> snap pack --check-skeleton /root/prime
>

Is it possible to set the snapd channel in your launchpad build?

stephensp commented 4 weeks ago

Yes , it builds successfully with snapd channel set to latest/edge . I guess we need to wait for a snapd update.

stephensp commented 4 weeks ago

I spoke to soon. It builds correctly but it does not upload

all: Error in components validation: type 'standard' is not one of ['test', 'kernel-modules']

This seems like a store issue though .