1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
|
summary: Check that prepare-image works when we have components
details: |
The `snap prepare-image` command performs some of the steps necessary for
creating device images.
This test verifies that in classic and Ubuntu Core systems, the
prepare-image command prepares properly an image with components. It is
checked that the fundamental snaps are present and the snap assertions are
retrieved.
backends: [-autopkgtest]
systems: [ubuntu-18*, ubuntu-2*]
execute: |
TARGET_D=target
# Checks for container files and assertions.
# $1: number of expected components
check_files_and_assertions() {
SNAPS_D=$TARGET_D/system-seed/snaps
LABEL_D=$(find $TARGET_D/system-seed/systems/ -maxdepth 1 -mindepth 1)
for f in snapd pc pc-kernel core24 test-snap-with-components; do
stat "$SNAPS_D"/"$f"_*.snap
done
for comp in "$@"; do
stat "$SNAPS_D"/test-snap-with-components+"$comp"_*.comp
MATCH "resource-name: $comp" < "$LABEL_D"/assertions/snaps
done
MATCH "type: snap-resource-revision" < "$LABEL_D"/assertions/snaps
MATCH "type: snap-resource-pair" < "$LABEL_D"/assertions/snaps
}
check_comps_local_to_system() {
LABEL_D=$(find $TARGET_D/system-seed/systems/ -maxdepth 1 -mindepth 1)
SYSTEM_SNAPS_D=$LABEL_D/snaps
for comp in "$@"; do
stat "$SYSTEM_SNAPS_D"/test-snap-with-components+"$comp"_*.comp
MATCH "resource-name: $comp" < "$LABEL_D"/assertions/snaps
done
}
## dangerous model
# component one is mandatory in model
snap prepare-image "$TESTSLIB"/assertions/pc24-with-comps-dangerous.model "$TARGET_D"
check_files_and_assertions one
# component one is optional in model
rm -rf "$TARGET_D"
snap prepare-image "$TESTSLIB"/assertions/pc24-with-comps-dangerous.model \
--comp test-snap-with-components+two "$TARGET_D"
check_files_and_assertions one two
# component three is not in model
rm -rf "$TARGET_D"
snap prepare-image "$TESTSLIB"/assertions/pc24-with-comps-dangerous.model \
--comp test-snap-with-components+two --comp test-snap-with-components+three "$TARGET_D"
check_files_and_assertions one two
check_comps_local_to_system three
## signed model
# component one is mandatory in model
rm -rf "$TARGET_D"
snap prepare-image "$TESTSLIB"/assertions/pc24-with-comps-signed.model "$TARGET_D"
check_files_and_assertions one
# component one is optional in model
rm -rf "$TARGET_D"
snap prepare-image "$TESTSLIB"/assertions/pc24-with-comps-signed.model \
--comp test-snap-with-components+two "$TARGET_D"
check_files_and_assertions one two
# component three is not in model, must fail
rm -rf "$TARGET_D"
not snap prepare-image "$TESTSLIB"/assertions/pc24-with-comps-signed.model \
--comp test-snap-with-components+two --comp test-snap-with-components+three "$TARGET_D"
|