Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions tests/lib/assertions/pc-kernel-snap-decl-extras.json
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe worth including also nvidia-video-driver-libs, they will eventually use it and it is harmless to put it now in our declaration.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did this, and made it the default when repacking a kernel.

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"format": "5",
"slots": {
"cuda-driver-libs": {
"allow-installation": "true"
},
"egl-driver-libs": {
"allow-installation": "true"
},
"gbm-driver-libs": {
"allow-installation": "true"
},
"opengl-driver-libs": {
"allow-installation": "true"
},
"opengles-driver-libs": {
"allow-installation": "true"
},
"vulkan-driver-libs": {
"allow-installation": "true"
},
"nvidia-video-driver-libs": {
"allow-installation": "true"
}
}
}
12 changes: 11 additions & 1 deletion tests/lib/nested.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
: "${NESTED_SIGN_SNAPS_FAKESTORE:=false}"
: "${NESTED_REPACK_FOR_FAKESTORE:=false}"
: "${NESTED_FAKESTORE_SNAP_DECL_PC_GADGET:=}"
: "${NESTED_FAKESTORE_SNAP_DECL_PC_KERNEL:=}"
: "${NESTED_UBUNTU_IMAGE_SNAPPY_FORCE_SAS_URL:=}"
: "${NESTED_UBUNTU_IMAGE_PRESEED_KEY:=}"
: "${NESTED_UBUNTU_SEED_SIZE:=}"
Expand Down Expand Up @@ -754,7 +755,16 @@ nested_prepare_kernel() {

# sign the pc-kernel snap with fakestore if requested
if [ "$NESTED_SIGN_SNAPS_FAKESTORE" = "true" ]; then
"$TESTSTOOLS"/store-state make-snap-installable --noack "$NESTED_FAKESTORE_BLOB_DIR" "$(nested_get_extra_snaps_path)/$output_name" "$snap_id"
local extra_decl_args=""
local kernel_decl="$NESTED_FAKESTORE_SNAP_DECL_PC_KERNEL"
if [ -z "$kernel_decl" ] ; then
Comment thread
andrewphelpsj marked this conversation as resolved.
kernel_decl="$TESTSLIB/assertions/pc-kernel-snap-decl-extras.json"
fi
if [ -n "$kernel_decl" ]; then
extra_decl_args="--extra-decl-json $kernel_decl"
fi
# shellcheck disable=SC2086
"$TESTSTOOLS"/store-state make-snap-installable --noack $extra_decl_args "$NESTED_FAKESTORE_BLOB_DIR" "$(nested_get_extra_snaps_path)/$output_name" "$snap_id"
fi
fi
}
Expand Down
20 changes: 15 additions & 5 deletions tests/lib/prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -854,23 +854,33 @@ repack_core_snap_with_tweaks() {
UNPACK_DIR="$(mktemp -d /tmp/core-unpack.XXXXXXXX)"
unsquashfs -no-progress -f -d "$UNPACK_DIR" "$CORESNAP"

mkdir -p "$UNPACK_DIR"/etc/systemd/journald.conf.d
cat <<EOF > "$UNPACK_DIR"/etc/systemd/journald.conf.d/to-console.conf
# determine destination directory for systemd configuration files
# core26+ uses /usr/share/factory/writable/system-data/etc/
# core24 and earlier use /etc/
local DEST_ETC
if [ -e "$UNPACK_DIR/usr/share/factory/writable" ]; then
DEST_ETC="$UNPACK_DIR/usr/share/factory/writable/system-data/etc"
else
DEST_ETC="$UNPACK_DIR/etc"
fi

mkdir -p "$DEST_ETC"/systemd/journald.conf.d
cat <<EOF > "$DEST_ETC"/systemd/journald.conf.d/to-console.conf
[Journal]
ForwardToConsole=yes
TTYPath=/dev/ttyS0
MaxLevelConsole=debug
EOF
mkdir -p "$UNPACK_DIR"/etc/systemd/system/snapd.service.d
cat <<EOF > "$UNPACK_DIR"/etc/systemd/system/snapd.service.d/logging.conf
mkdir -p "$DEST_ETC"/systemd/system/snapd.service.d
cat <<EOF > "$DEST_ETC"/systemd/system/snapd.service.d/logging.conf
[Service]
Environment=SNAPD_DEBUG_HTTP=7 SNAPD_DEBUG=1 SNAPPY_TESTING=1 SNAPD_CONFIGURE_HOOK_TIMEOUT=30s
StandardOutput=journal+console
StandardError=journal+console
EOF

if [ "${NESTED_REPACK_FOR_FAKESTORE-}" = "true" ]; then
cat <<EOF > "$UNPACK_DIR"/etc/systemd/system/snapd.service.d/store.conf
cat <<EOF > "$DEST_ETC"/systemd/system/snapd.service.d/store.conf
[Service]
Environment=SNAPPY_FORCE_API_URL=http://10.0.2.2:11028
EOF
Expand Down
17 changes: 10 additions & 7 deletions tests/lib/tools/build_kernel_with_comps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,19 @@ description: kernel component for testing purposes
EOF
# Replace _ or - with [_-], as it can be any of these
glob_mod_name=$(printf '%s' "$mod_name" | sed -r 's/[-_]/[-_]/g')
module_path=$(find kernel -name "${glob_mod_name}.ko*")
mapfile -t module_path <<< "$module_path"
cp --update=none "${module_path[@]}" "$comp_ko_dir"
# TODO: search only in kernel/modules to avoid duplicates (pc-kernel in
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Welcome to replace my previous workaround with this.

# 26/edge has both modules/ and lib/modules/). remove this hack once
# the kernel snap is fixed
module_path=$(find kernel/modules -name "${glob_mod_name}.ko*")
cp "$module_path" "$comp_ko_dir"
snap pack --filename="${kernel_name}+${comp_name}".comp "$comp_name"

# Create kernel without the kernel module
rm "${module_path[@]}"
# depmod wants a lib subdir
mkdir -p kernel/lib
ln -s ../modules kernel/lib/modules
rm "$module_path"
if [ ! -e kernel/lib/modules ]; then
Comment thread
andrewphelpsj marked this conversation as resolved.
Comment thread
andrewphelpsj marked this conversation as resolved.
mkdir -p kernel/lib
ln -s ../modules kernel/lib/modules
fi
depmod -b kernel/ "$kern_ver"
rm "${kernel_snap_file}"
# append component meta-information
Expand Down
2 changes: 0 additions & 2 deletions tests/nested/manual/kernel-modules-components/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ systems:
- -ubuntu-1*
- -ubuntu-20*
- -ubuntu-22*
# FIXME
- -ubuntu-26*

environment:
# Test both encrypted and unencrypted cases
Expand Down
10 changes: 8 additions & 2 deletions tests/nested/manual/remodel-with-components-offline/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ systems:
- -ubuntu-1*
- -ubuntu-20*
- -ubuntu-22*
# FIXME
- -ubuntu-26*

environment:
INITIAL_MODEL_JSON: $TESTSLIB/assertions/test-snapd-component-remodel-initial-pc-VERSION.json
Expand Down Expand Up @@ -86,9 +84,17 @@ execute: |

kernel_id='pYVQrBcKmBa0mZ4CCN7ExT6jH8rY1hza'

# include declaration extras for driver slots
extra_decl_args=""
if [ "$(tests.nested show version)" -ge 26 ]; then
extra_decl_args="--extra-decl-json $TESTSLIB/assertions/pc-kernel-snap-decl-extras.json"
fi

# bump the available kernel version in the fake store
#shellcheck disable=SC2086
Comment thread
andrewphelpsj marked this conversation as resolved.
"${TESTSTOOLS}"/store-state make-snap-installable --noack \
--revision 2 \
$extra_decl_args \
"${NESTED_FAKESTORE_BLOB_DIR}" \
./pc-kernel-with-comps.snap \
"${kernel_id}"
Expand Down
10 changes: 9 additions & 1 deletion tests/nested/manual/remodel-with-components/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ details: |
validates that the newly created system can be rebooted into.

systems:
# FIXME: make it work on 26
- ubuntu-24*
- ubuntu-26*

environment:
INITIAL_MODEL_JSON: $TESTSLIB/assertions/test-snapd-component-remodel-initial-pc-VERSION.json
Expand Down Expand Up @@ -84,9 +84,17 @@ execute: |

kernel_id='pYVQrBcKmBa0mZ4CCN7ExT6jH8rY1hza'

# include declaration extras for driver slots
extra_decl_args=""
if [ "$(tests.nested show version)" -ge 26 ]; then
extra_decl_args="--extra-decl-json $TESTSLIB/assertions/pc-kernel-snap-decl-extras.json"
fi

# bump the available kernel version in the fake store
#shellcheck disable=SC2086
Comment thread
andrewphelpsj marked this conversation as resolved.
"${TESTSTOOLS}"/store-state make-snap-installable --noack \
--revision 2 \
$extra_decl_args \
"${NESTED_FAKESTORE_BLOB_DIR}" \
./pc-kernel-with-comps.snap \
"${kernel_id}"
Expand Down
Loading