Ubuntu-Image 2.0 snap does not inject required environment variables

Bug #1951576 reported by Ruhan van der berg
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Ubuntu Image
Incomplete
Undecided
William Wilson

Bug Description

Current setup:
#snap info ubuntu-image
installed: 1.11+snap1 (214) 12MB classic
(latest/stable channel)

#snap version
snap 2.52.1
snapd 2.52.1
series 16
ubuntu 18.04
kernel 5.4.0-90-generic

#snapcraft --version (For supporting legacy Core16, moving soon over to latest snapcraft)
snapcraft, version 4.8

#snap info snapcraft
installed: 4.8 (6512) 74MB classic
(4.x/stable channel)

###Building a image:
ubuntu-image snap -c stable --snap mygadget-gadget_16-1_arm64.snap --snap kernel/mykernel-kernel_r2.4_arm64.snap -O image/ models/devboard-imx8.model
Fetching core
WARNING: "mykernel-kernel", "mygadget-gadget" installed from local snaps disconnected from a store cannot be refreshed subsequently!
Copying "kernel/mykernel-kernel_r2.4_arm64.snap" (mykernel-kernel)
Copying "mygadget-gadget_16-1_arm64.snap" (mygadget-gadget)

#mount built image
sudo losetup -Pf image/myimage.img

*mount the boot partition*
sudo mkdir -p /media/ruhan/boot
mount /dev/loop8p1 /media/ruhan/boot/

#cat /media/ruhan/boot/uboot.env (Removed the garbage data, only readable data)
e▒e▒snap_core=core_11996.snapsnap_kernel=iotgateimx8-kernel_x1.snapsnap_menuentry=Ubuntu Core 16 (arm64)snappy=1▒▒▒▒

*unmount the image/boot partitions*

#########################################################################################################

refresh ubuntu-image to 2.0+
# snap refresh ubuntu-image --edge
ubuntu-image (edge) 2.0+snap2 from Canonical✓ refreshed

Repeat the same command as above:
#ubuntu-image snap -c stable --snap mygadget-gadget_16-1_arm64.snap --snap kernel/mykernel-kernel_r2.4_arm64.snap -O image/ models/devboard-imx8.model
Fetching core
WARNING: "mykernel-kernel", "mygadget-gadget" installed from local snaps disconnected from a store cannot be refreshed subsequently!
Copying "kernel/mykernel-kernel_r2.4_arm64.snap" (mykernel-kernel)
Copying "mygadget-gadget_16-1_arm64.snap" (mygadget-gadget)
WARNING: volumes:myimage:structure:0:filesystem_label used for defining partition roles; use role instead

#mount built image
sudo losetup -Pf image/myimage.img

*mount the boot partition*
mount /dev/loop8p1 /media/ruhan/boot/

#cat /media/ruhan/boot/uboot.env (Removed the garbage data, only readable data)
▒▒▒snappy=1▒▒▒▒▒

Changed in ubuntu-image:
assignee: nobody → William Wilson (jawn-smith)
status: New → In Progress
Revision history for this message
William Wilson (jawn-smith) wrote :

I'm having trouble recreating this. I don't have your exact model assertion and snaps, but have been experimenting with the dragonboard:

```
jawn-smith@desktop:~$ ubuntu-image --version
ubuntu-image 2.0+22.04ubuntu3
jawn-smith@desktop:~$ ubuntu-image snap -O ubuntu-image/ ubuntu-image/dragonboard-model.assertion
Fetching core
Fetching dragonboard-kernel
Fetching dragonboard
WARNING: volumes:dragonboard:structure:7:filesystem_label used for defining partition roles; use role instead
jawn-smith@desktop:~$ sudo losetup -Pf ubuntu-image/dragonboard.img
jawn-smith@desktop:~$ sudo mount /dev/loop35p8 /mnt
jawn-smith@desktop:~$ cat /mnt/uboot.env

(removed lots of garbage)
snap_core=core_11996.snapsnap_kernel=dragonboard-kernel_180.snapsnap_menuentry=dragonboard

Revision history for this message
William Wilson (jawn-smith) wrote :

For more information, the population of the uboot.env environment variables actually happens in snapd when we call image.Prepare().

Revision history for this message
Ruhan van der berg (ruhanvanderberg) wrote (last edit ):

My gadget snap is created with this script:
`#!/bin/sh

echo "Preparing uboot..."
mkdir -p gadget/boot-assets
mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n "boot script" -d gadget/bootscript.txt gadget/boot-assets/boot.scr
mkenvimage -r -s 8192 -o gadget/uboot.env gadget/uboot.env.in
if [ ! -f gadget/uboot.conf ]; then ln -s uboot.env gadget/uboot.conf; fi
cp gadget/uboot.env gadget/boot-assets/
cd gadget/boot-assets/
ln -s uboot.env gadget/boot-assets/uboot.conf

cd ../..

echo "Building gadget..."
snapcraft snap gadget`

Maybe this is the problem? It certainly works on ubuntu-image 1.11.

Revision history for this message
William Wilson (jawn-smith) wrote (last edit ):

Could you check which version of snapd you have installed in the system you're using? I'm wondering if this is a bug in a newer version of snapd, since the ubuntu-image 2.0 code compiles a very recent version of snapd while ubuntu-image 1.11 calls the snap binary installed on the system.

The command `snap --version` should get the information I need

Revision history for this message
Ruhan van der berg (ruhanvanderberg) wrote :

Hello, since we last spoke, my snapd version has jumped from:
#snap version
snap 2.52.1
snapd 2.52.1
series 16
ubuntu 18.04
kernel 5.4.0-90-generic

to:
#snap version
snap 2.53.2
snapd 2.53.2
series 16
ubuntu 18.04
kernel 5.4.0-90-generic

Revision history for this message
William Wilson (jawn-smith) wrote :

And does the python version of ubuntu-image (1.11) still work with the newer version of snapd?

Revision history for this message
Ruhan van der berg (ruhanvanderberg) wrote (last edit ):

Yes, I just built a new image with ubuntu-image (1.11) and snapd version 2.53.2, and the environment variables is injected, as it has been.

Revision history for this message
William Wilson (jawn-smith) wrote :

Can you please try again with the ubuntu-image snap in the latest/edge channel? It pulls in a much newer version of snapd. If that doesn't work it will at least rule out an incompatibility with the snapd version.

Revision history for this message
Łukasz Zemczak (sil2100) wrote :

Marking as incomplete for now. Ruhan, can you try checking the latest snap? We can then determine if this is now fixed or not.

Changed in ubuntu-image:
status: In Progress → Incomplete
Revision history for this message
Paul Mars (upils) wrote (last edit ):

Hey Ruhan,

Any news on this? Can you try with ubuntu-image 3.X?

Revision history for this message
Ruhan van der berg (ruhanvanderberg) wrote :

Hello. I have since then moved on to Ubuntu Image 3.x, and Ubuntu Core 20 for my image builds.
However, it appears to break the image build currently, so some dependency is broken somewhere.

# Snap version
snap 2.61.1
snapd 2.61.1
series 16
ubuntu 18.04
kernel 4.15.0-213-generic

#ubuntu-image version:
name: ubuntu-image
summary: Create Ubuntu images
publisher: Canonical✓
store-url: https://snapcraft.io/ubuntu-image
contact: <email address hidden>
license: unset
description: |
  ubuntu-image is a tool used for creation of various Ubuntu preinstalled images, both classic and
  snap-based.

  A basic documentation can be found at
  https://github.com/canonical/ubuntu-image/blob/main/ubuntu-image.rst .
commands:
  - ubuntu-image
snap-id: 4RW78vIax8JW5S8HkYsa8lNbv68uPaYX
tracking: latest/edge
refresh-date: yesterday at 01:07 UTC
channels:
  latest/stable: 3.2 2024-01-22 (702) 82MB classic
  latest/candidate: 3.2 2024-01-22 (702) 82MB classic
  latest/beta: 3.2 2024-01-22 (702) 82MB classic
  latest/edge: 3.2+snap7 2024-02-27 (747) 83MB classic
  2/stable: 2.2+snap10 2023-04-06 (321) 9MB classic
  2/candidate: 2.2+snap10 2023-04-06 (321) 9MB classic
  2/beta: 2.2+snap10 2023-04-06 (321) 9MB classic
  2/edge: 2.2+snap10 2023-04-06 (321) 9MB classic
installed: 3.2+snap7 (747) 83MB classic

#Ubuntu image buildlog:

ubuntu-image snap -c stable --snap gadget_16-2_arm64.snap --snap kernel_0.1_arm64.snap --snap core18=latest/stable --snap network-manager=1.10/stable --snap modem-manager=1.10/stable -O image/ models/uc16.model --validation=ignore -O testImg/
[0] make_temporary_directories
[1] determine_output_directory
[2] prepare_image
WARNING: "my-kernel", "my-gadget" installed from local snaps disconnected from a store cannot be refreshed subsequently!
[3] load_gadget_yaml
WARNING: volumes:mygateway:structure:0:filesystem_label used for defining partition roles; use role instead
[4] set_artifact_names
[5] populate_rootfs_contents
[6] generate_disk_info
[7] calculate_rootfs_size
[8] populate_bootfs_contents
[9] populate_prepare_partitions
Error: Error running mkfs with content: mkfs.ext4: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by /snap/ubuntu-image/747/usr/lib/lib-arch/libfakeroot/libfakeroot-tcp.so)

Revision history for this message
Paul Mars (upils) wrote :

I think you may facing something similar to LP: 2024387. Are you able to run a successful build on a more recent/supported series?

ubuntu-image should still run on bionic. We might have missed something, but we are testing every new release in CI on ubuntu 18 and onward (see https://github.com/canonical/ubuntu-image/blob/main/spread.yaml#L26).

You may also be facing LP: 2028564 because ubuntu-image is currently using the mkfs.ext4 of the host. We have a PR (see https://github.com/canonical/ubuntu-image/pull/170) in review to fix this.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.