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

Snapcraft unable to compile ARM64 kernel #5219

Open
RuhanSA079 opened this issue Jan 28, 2025 · 1 comment
Open

Snapcraft unable to compile ARM64 kernel #5219

RuhanSA079 opened this issue Jan 28, 2025 · 1 comment

Comments

@RuhanSA079
Copy link

RuhanSA079 commented Jan 28, 2025

Bug Description

I am trying to cross-compile a kernel for a ARM64 device, and it seems on both 7.x/stable and 8.x/stable channels that the snapcraft application fails to download the snapd:arm64 package, with the error: E: Can't select candidate version from package snapd:arm64 as it has no candidate
Failed to build 'kernel'.

This build-process happens on a Ubuntu Focal Multipass instance running on a AMD64 machine.
Snapcraft versions: 7.x/stable (7.5.8) and 8.x/stable (8.5.1)

This has worked last time I tried to compile a kernel, a few months back.

To Reproduce

Not sure how to replicate, try to cross-compile a kernel?
Multipass instance compile options: (Manual compile commands)
snapcraft --target-arch=arm64 --destructive-mode --enable-experimental-target-arch --enable-experimental-plugins

Environment

Running Multipass snap, version 1.15.0 on Ubuntu Bionic machine
Mutipass container version: Ubuntu 20.04.6 LTS

snapcraft.yaml

name: my-kernel
version: "20-8"
adopt-info: kernel
summary: Generic Linux kernel description: |
  Kernel for testing

grade: stable
confinement: strict
type: kernel

architectures:
  - build-on: amd64
    run-on: arm64
build-base: core20

parts:
  kernel:
    plugin: kernel
    source: github-link-removed
    source-type: git
    source-branch: lf-5.10.y
    source-depth: 1
    kernel-kdefconfig: [imx8_var_defconfig, snappy/generic.config, snappy/security.config, snappy/systemd.config, snappy/snappy.config, snappy/containers.config ]
    kernel-kconfigs:
      - CONFIG_LOCALVERSION="-v0.8"
      - CONFIG_SYSFS=y
      - CONFIG_GPIO_SYSFS=y
      - CONFIG_GPIO_GENERIC=y
      - CONFIG_HW_RANDOM_TPM=m
      - CONFIG_TCG_TPM=m
      - CONFIG_TCG_TIS_CORE=m
      - CONFIG_TCG_TIS_SPI=m
      - CONFIG_SECURITYFS=y
      - CONFIG_LSM="yama,integrity,apparmor"
      - CONFIG_SECURITY_APPARMOR=y
      - CONFIG_AUDIT=y
      - CONFIG_SECURITY_APPARMOR_BOOTPARAM_VALUE=1
      - CONFIG_DEFAULT_SECURITY_APPARMOR=y
      - CONFIG_SYN_COOKIES=y
      - CONFIG_STRICT_DEVMEM=y
      - CONFIG_DEBUG_RODATA=y
      - CONFIG_CC_STACKPROTECTOR=y
      - CONFIG_CC_STACKPROTECTOR_STRONG=y
      - CONFIG_DEBUG_SET_MODULE_RONX=n
      - CONFIG_ENCRYPTED_KEYS=y
      - CONFIG_SQUASHFS_XATTR=y
      - CONFIG_SQUASHFS_XZ=y
      - CONFIG_DEVPTS_MULTIPLE_INSTANCES=y
      - CONFIG_TMPFS_XATTR=y
      - CONFIG_TMPFS_POSIX_ACL=y
    override-pull: |
      snapcraftctl pull
      set -e
      echo "Applying Ubuntu Core AppArmor patches to the kernel..."
      git apply -v ../../../patches/apparmor-patch-510.patch
      git apply -v ../../../patches/configs-patch-510.patch
      snapcraftctl set-version "20-8"
    kernel-initrd-compression: lz4
    kernel-initrd-firmware:
      - firmware/imx/sdma/sdma-imx7d.bin

    kernel-device-trees: [ freescale/imx8mp-device-tree-for-kernel ]
    kernel-image-target: Image
    kernel-with-firmware: false
    kernel-add-ppa: true
    kernel-initrd-stage-firmware: true
    organize:
      kernel.img: Image
    after: [ firmware ]
    build-packages:
      - cpio
      - libc6-dev
      - bison
      - flex
      - lzop
      - libssl-dev
      - on amd64 to arm64:
        - gcc-aarch64-linux-gnu:amd64

  #TODO Strip most firmwares out to make kernel smaller.
  firmware:
    plugin: nil
    source: linux-firmware
    override-build: |
      mkdir -p $SNAPCRAFT_PART_INSTALL/firmware
      cp -av ../../../linux-firmware/* $SNAPCRAFT_PART_INSTALL/firmware/

build-packages:
    - zstd
    - bison
    - device-tree-compiler
    - dpkg-dev
    - flex
    - initramfs-tools-core
    - libfdt-dev
    - libssl-dev
    - lzop
    - python3-crypto
    - python3-pycryptodome
    - python3-pyelftools
    - python3-serial
    - u-boot-tools
    - wget
    - libjson-c-dev
    - binutils-${SNAPCRAFT_ARCH_TRIPLET}
    - gcc-${SNAPCRAFT_ARCH_TRIPLET}

Relevant log output

+ '[' -d /home/ubuntu/kernel/parts/kernel/src/kernel ']'
+ KERNEL_SRC=/home/ubuntu/kernel/parts/kernel/src
+ echo PATH=/snap/snapcraft/13058/libexec/snapcraft:/snap/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PATH=/snap/snapcraft/13058/libexec/snapcraft:/snap/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
+ echo KERNEL_SRC=/home/ubuntu/kernel/parts/kernel/src
KERNEL_SRC=/home/ubuntu/kernel/parts/kernel/src
+ initrd_installed_kernel_modules=
+ initrd_configured_kernel_modules=
+ echo 'Getting ubuntu-core-initrd....'
Getting ubuntu-core-initrd....
+ '[' '!' -e /home/ubuntu/kernel/parts/kernel/build/ubuntu-core-initramfs ']'
+ download_core_initrd arm64 /home/ubuntu/kernel/parts/kernel/build/ubuntu-core-initramfs
+ apt-get download ubuntu-core-initramfs:arm64
Get:1 http://ppa.launchpad.net/snappy-dev/image/ubuntu focal/main arm64 ubuntu-core-initramfs arm64 51.15 [18.2 MB]
Fetched 18.2 MB in 48s (381 kB/s)
W: Download is performed unsandboxed as root as file '/home/ubuntu/kernel/parts/kernel/build/ubuntu-core-initramfs_51.15_arm64.deb' couldn't be accessed by user '_apt'. - pkgAcquire::Run (13: Permission denied)
+ dpkg -x ubuntu-core-initramfs_51.15_arm64.deb /home/ubuntu/kernel/parts/kernel/build/ubuntu-core-initramfs
+ echo 'Getting snapd deb for snap bootstrap...'
Getting snapd deb for snap bootstrap...
+ '[' '!' -e /home/ubuntu/kernel/parts/kernel/build/ubuntu-core-initramfs/usr/lib/snapd ']'
+ download_snap_bootstrap arm64 /home/ubuntu/kernel/parts/kernel/build/ubuntu-core-initramfs
+ apt-get download snapd:arm64
E: Can't select candidate version from package snapd:arm64 as it has no candidate
Failed to build 'kernel'.

Recommended resolution:
Check the build logs and ensure the part's configuration and sources are correct.

Additional context

No response

@RuhanSA079
Copy link
Author

RuhanSA079 commented Jan 29, 2025

It appears to be an aptitude repository problem, where it does not allow you to download the snapd deb file, seperately.
Reproduce with: apt-get download snapd or apt-get download snapd:arm64, and it will return an error -> E: Can't select candidate version from package snapd:<arch> as it has no candidate

I could reproduce this on my Ubuntu 20 and Ubuntu 22 Multipass instances.

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

No branches or pull requests

1 participant