Skip to content

Commit

Permalink
tests/nested/manual/remodel-offline: use the fakestore
Browse files Browse the repository at this point in the history
  • Loading branch information
valentindavid committed Jan 16, 2025
1 parent 39dc92b commit f874793
Show file tree
Hide file tree
Showing 6 changed files with 311 additions and 28 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"type": "validation-set",
"series": "16",
"account-id": "developer1",
"authority-id": "developer1",
"name": "test-snapd-core22-required-vset",
"sequence": "1",
"timestamp": "2023-10-24T19:55:00+00:00",
"snaps": [
{
"id": "buPKUD3TKqCOgLEjjHx5kSiCpIs5cMuQ",
"name": "hello-world",
"revision": "28",
"presence": "required"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"type": "model",
"series": "16",
"authority-id": "developer1",
"brand-id": "developer1",
"model": "test-snapd-remodel-pc",
"serial-authority": ["generic"],
"system-user-authority": "*",
"architecture": "amd64",
"timestamp": "2023-10-30T11:01:45+00:00",
"grade": "dangerous",
"base": "core20",
"snaps": [
{
"default-channel": "20/edge",
"id": "UqFziVZDHLSyO3TqSWgNBoAdHbLI4dAH",
"name": "pc",
"type": "gadget"
},
{
"default-channel": "20/edge",
"id": "pYVQrBcKmBa0mZ4CCN7ExT6jH8rY1hza",
"name": "pc-kernel",
"type": "kernel"
},
{
"default-channel": "latest/edge",
"id": "DLqre5XGLbDqg9jPtiAhRRjDuPVa5X1q",
"name": "core20",
"type": "base"
},
{
"default-channel": "latest/edge",
"id": "PMrrV4ml8uWuEUDBT8dSGnKUYbevVhc4",
"name": "snapd",
"type": "snapd"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"type": "model",
"series": "16",
"revision": "1",
"authority-id": "developer1",
"brand-id": "developer1",
"model": "test-snapd-remodel-pc",
"serial-authority": ["generic"],
"system-user-authority": "*",
"architecture": "amd64",
"timestamp": "2023-10-30T11:01:45+00:00",
"grade": "dangerous",
"base": "core22",
"validation-sets": [
{
"name": "test-snapd-core22-required-vset",
"mode": "enforce"
}
],
"snaps": [
{
"default-channel": "22/edge",
"id": "UqFziVZDHLSyO3TqSWgNBoAdHbLI4dAH",
"name": "pc",
"type": "gadget"
},
{
"default-channel": "22/edge",
"id": "pYVQrBcKmBa0mZ4CCN7ExT6jH8rY1hza",
"name": "pc-kernel",
"type": "kernel"
},
{
"default-channel": "latest/edge",
"id": "amcUKQILKXHHTlmSa7NMdnXSx02dNeeT",
"name": "core22",
"type": "base"
},
{
"default-channel": "latest/stable",
"id": "buPKUD3TKqCOgLEjjHx5kSiCpIs5cMuQ",
"name": "hello-world",
"type": "app"
},
{
"default-channel": "latest/stable",
"id": "99T7MUlRhtI3U0QFgl5mXXESAiSwt776",
"name": "core",
"type": "core"
},
{
"default-channel": "latest/edge",
"id": "PMrrV4ml8uWuEUDBT8dSGnKUYbevVhc4",
"name": "snapd",
"type": "snapd"
}
]
}
3 changes: 3 additions & 0 deletions tests/nested/manual/remodel-offline/prepare-device
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
# 10.0.2.2 is the host from a nested VM
snapctl set device-service.url=http://10.0.2.2:11029
59 changes: 59 additions & 0 deletions tests/nested/manual/remodel-offline/repack-kernel.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/bin/bash

set -eu

version=$1
branch=$2

tmpd=$(mktemp -d)
cleanup() {
rm -rf "${tmpd}"
}
trap cleanup EXIT

waited=0
while ! resolvectl query api.launchpad.net; do
waited=$((waited+1))
if [ "${waited}" -gt 120 ]; then
break
fi
sleep 1
done

add-apt-repository ppa:snappy-dev/image -y
apt-get install -y golang ubuntu-core-initramfs

snap download pc-kernel --channel="${version}/${branch}" --basename=pc-kernel --target-directory="${tmpd}"
unsquashfs -d "${tmpd}/pc-kernel" "${tmpd}/pc-kernel.snap"

objcopy -O binary -j .initrd "${tmpd}/pc-kernel/kernel.efi" "${tmpd}/initrd"
objcopy -O binary -j .linux "${tmpd}/pc-kernel/kernel.efi" "${tmpd}/linux"
objcopy -O binary -j .uname "${tmpd}/pc-kernel/kernel.efi" "${tmpd}/kver"

mkdir "${tmpd}/early"
mkdir "${tmpd}/main"
( (cd "${tmpd}/early"; cpio -id) ; (cd "${tmpd}/main"; zstdcat | cpio -id) ) <"${tmpd}/initrd"

if [ "${BUILD_FDE_HOOK-}" = 1 ]; then
go build -o "${tmpd}/main/usr/bin/fde-reveal-key" /project/tests/lib/fde-setup-hook
fi

go build -tags 'nomanagers withtestkeys faultinject' -o "${tmpd}/main/usr/lib/snapd/snap-bootstrap" /project/cmd/snap-bootstrap

(cd "${tmpd}/early"; find . | cpio --create --quiet --format=newc --owner=0:0) >"${tmpd}/new-initrd"
(cd "${tmpd}/main"; find . | cpio --create --quiet --format=newc --owner=0:0 | zstd -1 -T0) >>"${tmpd}/new-initrd"

ubuntu-core-initramfs create-efi \
--kernelver "" \
--initrd "${tmpd}/new-initrd" \
--kernel "${tmpd}/linux" \
--key "${SNAKEOIL_KEY}" \
--cert "${SNAKEOIL_CERT}" \
--output "${tmpd}/pc-kernel/kernel.efi"


if [ "${BUILD_FDE_HOOK-}" = 1 ]; then
go build -o "${tmpd}/pc-kernel/meta/hooks/fde-setup" /project/tests/lib/fde-setup-hook
fi

snap pack "${tmpd}/pc-kernel" --filename="pc-kernel-modified.snap"
Loading

0 comments on commit f874793

Please sign in to comment.