← Back to issue list

component does not take snap version when no version provided

View original Github issue

Metadata

Project
snapcraft
Number
#5115
Type
issue
State
open
Author
stephensp
Labels
Status: Triaged Type: Enhancement
Created
2024-10-14 00:50:52+00:00
Updated
2025-04-25 20:09:36+00:00
Closed

Current evaluation

No evaluation has been recorded for this issue yet.

Issue body

### Bug Description component does not take snap version when no version provided as is defined by the spec "A component might have an optionally set version. Snapcraft will have mechanisms to set this." ### To Reproduce 1. Build a snap + component when no component version is provided. Component version can be deleted from: https://git.launchpad.net/~portias/+git/kernel-snaps-u24.04/tree/snapcraft.yaml?h=portias/pc-components 2. The version of the component is <comp_name>_.comp instead of <comp_name>_.comp ### Environment This reproduces on any environment. ### snapcraft.yaml ```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: test summary: nvidia 550 kernel objects description: nvidia 550 kernel objects nouveau: type: test 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: ./component-hooks plugin: nil override-build: | craftctl default cp install.sh remove.sh $CRAFT_PART_INSTALL #duplicate install.sh as a post refres hook cp install.sh $CRAFT_PART_INSTALL/post-refresh.sh organize: install.sh: (component/nouveau)/snap/hooks/install post-refresh.sh: (component/nouveau)/snap/hooks/post-refresh remove.sh: (component/nouveau)/snap/hooks/remove files: plugin: dump source: files nvidia-550-ko-comp: source: ./component-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 link-and-install.sh $CRAFT_PART_INSTALL/post-refresh.sh cp link-and-install.sh $CRAFT_PART_INSTALL/install.sh cp remove.sh $CRAFT_PART_INSTALL/remove.sh organize: bits/: (component/nvidia-550-ko)/bits usr/bin: (component/nvidia-550-ko)/bin usr/lib: (component/nvidia-550-ko)/lib install.sh: (component/nvidia-550-ko)/snap/hooks/install post-refresh.sh: (component/nvidia-550-ko)/snap/hooks/post-refresh remove.sh: (component/nvidia-550-ko)/snap/hooks/remove ``` ### Relevant log output ```shell None. ``` ### Additional context _No response_

Evaluation history

No evaluation history available.