Jump to content

User:Nmariusp/Snap

From KDE Community Wiki

How to run locally in a similar way to KDE GitLab CI

As per https://invent.kde.org/sysadmin/ci-images/-/blob/master/README.md

kde-builder ci-images
# https://invent.kde.org/sysadmin/ci-images/-/blob/master/README.md#setting-up-vm-runner-locally

cd ~/kde/src/sysadmin-ci-images/vm-runner
mkdir -p ~/temp
./vm-runner pull storage.kde.org/vm-images/snap-builder
./vm-runner run --cpu 8 --ram 8G --disk 50G --image storage.kde.org/vm-images/snap-builder --mount ~/temp/ --ssh-keys ~/.ssh/id_ed25519.pub myfirstsnapvm
#Machine provisioned successfully
#Name:      myfirstsnapvm                                                                                       
#IP:        192.168.122.154
ssh [email protected]
#user@myfirstsnapvm:~$ 
# /mnt in the VM is ~/temp on the host computer

The KDE git repository for an app that should be published to the snap store (e.g. kcalc). In the file .gitlab-ci.yml (e.g. https://invent.kde.org/utilities/kcalc/-/blob/master/.gitlab-ci.yml) should contain the line:

- /gitlab-templates/snap-snapcraft-lxd.yml

As per https://documentation.ubuntu.com/snapcraft/stable/tutorials/craft-a-snap .

On the host computer.

kde-builder kontrast
cp -r ~/kde/src/kontrast ~/temp

In the VM.

ls -la /mnt
cd /mnt/kontrast
snapcraft pack
# Packed kontrast_25.08.3_amd64.snap

On the host computer.

sudo snap install ~/temp/kontrast/kontrast_*_amd64.snap --devmode --dangerous
which kontrast
kontrast

How to run locally again

I am on the Debian family of Linux operating systems.

#python3 -m venv --system-site-packages ~/myvenv/
source ~/myvenv/bin/activate

cd ~/kde/src/sysadmin-ci-images/vm-runner

# ./vm-runner run --cpu 8 --ram 8G --disk 50G --image storage.kde.org/vm-images/snap-builder --mount ~/temp/ --ssh-keys ~/.ssh/id_ed25519.pub myfirstsnapvm
# Says:
# Requested VM already exists - unable to continue

./vm-runner images
# Says:
#| Image URL                              | Image ID                              | Disk Size | In Use | Created on       |
#| storage.kde.org/vm-images/snap-builder | 50f8c95c0eacded1da28e87cd246ed76-1148 | 30.0G     | 5.6G   | 2025-08-03 07:56 |

./vm-runner ps
# Says:
#| VM Name       | Status             | CPU Count     | RAM           |
#| myfirstsnapvm | Powered Off        | 8             | 8.0G          |

./vm-runner start myfirstsnapvm
ssh [email protected]

Building blocks

See https://documentation.ubuntu.com/snapcraft/stable/reference/extensions/kde-neon-extensions

These are valid snap packages, e.g. https://snapcraft.io/kde-qt6-core24-sdk :

Snap base: core24

Snap extension: kde-neon-6. Is not a snap package.

Snap SDK: kde-qt6-core24-sdk

Build snaps: core24, kf6-core24 .

Platform snap: kf6-core24

Build snap: kf6-core24-sdk

How to package as snap a KDE app

This is for developing on your computer, without using the KDE GitLab CI virtual machines.

# The operating system should probably be the newest version of (non LTS) Kubuntu.

# Install lxd. See https://canonical.com/lxd/install
sudo su
snap install lxd
lxd init
# Accept the defaults.
exit
sudo usermod -a -G lxd $USER
sudo reboot
groups $USER 
# Check that your user is member of the user group "lxd".

# Install the snap package snapcraft. https://documentation.ubuntu.com/snapcraft/stable/tutorials/craft-a-snap
sudo snap install snapcraft --classic

kde-builder kolorfill
cd ~/kde/src/kolorfill
snapcraft init
# Will create a very simple file ~/kde/src/kolorfill/snap/snapcraft.yaml
# Make a backup of this file.
cp ~/kde/src/kontrast/snapcraft.yaml ~/kde/src/kolorfill/snap/snapcraft.yaml
# Edit the file. Replace "kontrast" with "kolorfill" etc.

Development loop

# Use gigabit ethernet otherwise the step "Installing build-snaps" can take tens of minutes. Or maybe use snap-store-proxy.
# If building fails, please also run "snapcraft clean". If building succeeds maybe the
# build is correct even if you do not run "snapcraft clean".
snapcraft clean
snapcraft pack -v
sudo snap install  klickety_2.1.25120_amd64.snap --devmode --dangerous
which klickety
klickety
sudo snap remove --purge klickety

See

https://community.kde.org/Guidelines_and_HOWTOs/Snap