Ubuntu - cubic: Install snap applications from chroot in customized iso fails

Hello,
I try to customize a Lubuntu 18.04 iso using cubic.
Packages are installed in a chroot console:

  • Packages installed with apt are correctly installed in the iso (they can be then launched from the customized live usb), for exemple:
    apt install gimp

  • If a snap package is installed as follow from the same chroot console, it won’t be installed in the customized iso, but in the host system itself (here ubuntu 18.04), example:
    snap install darktable
    In this last case, darktable can be run from the host system and not from the live-usb.

Is it a cubic bug, or is there a right way to install the snap package in the iso with cubic?

We have done no work to integrate with cubic, nor is it clear whether we should. As it stands I’d say it’s a cubic bug — if there is integration work that needs to happen on the snapd side, cubic hasn’t told us what it is nor asked for it.

I also noticed this problem with Cubic. I customize the Ubuntu and Kubuntu ISO.
If I try to install an APP snap chroot, the APP installs in the host system.

Also: what advantage would running a snap inside cubic have?

For example: pre-install LibreOffice snap, then in chroot I remove LibreOffice “deb” to install the snap version.
Or preinstall spotify, as well as other APP snap.

As you can see from the screenshots, snap shows what I have in the host system, apt shows what I have in the chroot system, in this case the Ubuntu ISO.
In this case I can’t preinstall any APP on the ISO chroot and then find it after installation on the system.

I think that translates to “cubic does not support snaps”.

on a sidenote i dont think even in official ubuntu images the seeding of snaps involves installing them in the target system, but instead they get downloaded to the seed directory of the image, assertions are copied in the right place and the seed.yaml file is adjusted … the actual installation of the snaps happens during first boot of the installed image AFAIK.

EDIT: the ubuntu code that seeds snaps into images is at
https://git.launchpad.net/livecd-rootfs/tree/snap-tool

Suppose the target machine to install have no or poor internet connection.

From the cubic chroot console, would it possible to download the snap packages, without installation’, store them in /opt directory of the iso? The idea would be to post install the snap packages from a customized ubuntu iso.

no, you would have to use the correct directory, snapd does not look in /opt … and you will also have to modify the seed.yaml file in the correct way, similar to the livecd-rootfs code i linked above. best if you talk to the cubic guys so they implement it cleanly in their tool.

how could I install snaps during the first boot? It probably will achieve my goal. Thanks.
obs: the link you posted is down.

You’d have to build your OS/Installer image using the ubuntu-image tool (with the classic option) and define them in the model assertion …
note that this requires a gadget snap…

well, that code is moving fast … especially during releases … seems snap seeding moved to:

Thanks @ogra. however, I saw it is just for core images, and the customizations is limited to snap packages and other technical details. I’d like the flexibility of cubic to: install other packages from apt, change the file system, and so on, but also install some snap packages.

I do not need to ship the packages inside the image, like @emanuc does. the packages in my case could be installed during the first boot of recent installed customized ubuntu (20.04).

the livecd-rootfs script i pointed to is definitely not for core images (core images are simply seeded via the model assertion, they do not need any scripts). this script is not the only bit needed though, the formerly linked “snap-tool” now got properly integrated into the build process in live-build/auto/config and live-build/auto/build scripts …