-
-
Save maxiberta/f4df3a92007bb6aa13d9e5edcd33fbc2 to your computer and use it in GitHub Desktop.
Ubuntu Core image for the staging Snap Store
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create an Ubuntu core image with a custom snapd that talks to the staging Snap Store. | |
# | |
# LXD-based alternative: | |
# https://gist.github.com/maxiberta/5fb47645b0d32137e13f5046ff330eb6 | |
set -ex | |
tmp=$(mktemp -d) | |
cd "$tmp" | |
export GOPATH=$(pwd) | |
export PATH=$GOPATH/bin:$PATH | |
# get snapd source | |
git clone -b release/2.39 https://github.com/snapcore/snapd src/github.com/snapcore/snapd | |
go get -u github.com/kardianos/govendor | |
cd src/github.com/snapcore/snapd | |
govendor sync | |
cd - | |
# build binaries with staging keys | |
go build -tags withstagingkeys -o snap-stg github.com/snapcore/snapd/cmd/snap | |
go build -tags withstagingkeys -o snapd-stg github.com/snapcore/snapd/cmd/snapd | |
# download and unpack core snap | |
snap download core | |
sudo unsquashfs core_*.snap | |
# put binaries in place | |
sudo ls -l squashfs-root/usr/bin/snap squashfs-root/usr/lib/snapd/snapd | |
sudo cp snap-stg squashfs-root/usr/bin/snap | |
sudo cp snapd-stg squashfs-root/usr/lib/snapd/snapd | |
# customize environment | |
sudo su -c 'echo "SNAPPY_USE_STAGING_STORE=1" >> squashfs-root/etc/environment' | |
sudo su -c 'echo "SNAPD_DEBUG_HTTP=7" >> squashfs-root/etc/environment' | |
sudo su -c 'echo "SNAPPY_TESTING=1" >> squashfs-root/etc/environment' | |
# repack | |
sudo snapcraft pack ./squashfs-root | |
# get staging model | |
SNAPPY_USE_STAGING_STORE=1 ./snap-stg known --remote model series=16 model=pc-amd64 brand-id=canonical > pc-amd64.model | |
# build image using modified core snap and just built snap command (requires recent ubuntu-image) | |
SNAPPY_USE_STAGING_STORE=1 UBUNTU_IMAGE_SNAP_CMD=$PWD/snap-stg /usr/bin/ubuntu-image snap -O . --snap core_16-*.snap pc-amd64.model | |
# run image | |
echo DONE! Run with: | |
echo " kvm -m 512 -netdev user,id=mynet0,hostfwd=tcp::3322-:22 -device virtio-net-pci,netdev=mynet0 -drive file=$tmp/pc.img,format=raw --snapshot" | |
# After initial configuration, SSH to the instance | |
# ssh -p 3322 -o "StrictHostKeyChecking no" -o "UserKnownHostsFile /dev/null" <sso-user-name>@localhost |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment