Skip to content

Instantly share code, notes, and snippets.

@fgimenez
Created July 10, 2017 07:42
Show Gist options
  • Save fgimenez/6f02f5c1d86fe96c46fb17e8e8d086ca to your computer and use it in GitHub Desktop.
Save fgimenez/6f02f5c1d86fe96c46fb17e8e8d086ca to your computer and use it in GitHub Desktop.
snappy image for staging store
set -ex
tmp=$(mktemp -d)
cd "$tmp"
export GOPATH=$(pwd)
export PATH=$GOPATH/bin:$PATH
# get snapd source
git clone -b release/2.26 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 --stable core
sudo unsquashfs core_*.snap
rm core_*.snap core_*.assert
# 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'
# repack
sudo snapcraft snap ./squashfs-root
sudo rm -rf ./squashfs-root
sudo chown $USER:$USER core_*.snap
# get model
snap known --remote model series=16 model=pc-amd64 brand-id=canonical > pc-amd64.model
# build image using modified core snap (requires recent ubuntu-image)
sudo /snap/bin/ubuntu-image --image-size 3G -O . --extra-snaps ./core_*.snap pc-amd64.model
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment