Skip to content

Commit

Permalink
experiment: adding pre-built snapd to classic images
Browse files Browse the repository at this point in the history
  • Loading branch information
ernestl committed Jul 24, 2024
1 parent 4d79b09 commit 0612244
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
5 changes: 4 additions & 1 deletion snapdtool/tool_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,11 @@ func ExecInSnapdOrCoreSnap() {

// Is this executable in the core snap too?
coreOrSnapdPath := snapdSnap
origin := "snapd from snap"
full := filepath.Join(snapdSnap, exe)
if !osutil.FileExists(full) {
coreOrSnapdPath = coreSnap
origin = "snapd from core"
full = filepath.Join(coreSnap, exe)
if !osutil.FileExists(full) {
return
Expand All @@ -222,9 +224,10 @@ func ExecInSnapdOrCoreSnap() {

// If the core snap doesn't support re-exec or run-from-core then don't do it.
if !systemSnapSupportsReExec(coreOrSnapdPath) {
logger.Noticef(">>>>>> %s does not support re-exec", origin)
return
}

logger.Noticef(">>>>>>> restarting into %s (%q)", origin, full)
logger.Debugf("restarting into %q", full)
panic(syscallExec(full, os.Args, os.Environ()))
}
Expand Down
23 changes: 23 additions & 0 deletions tests/lib/prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,29 @@ prepare_classic() {
cache_snaps core20
fi

# Install snapd either build by CI or by snapcraft depending on
# TESTS_USE_PREBUILT_SNAPD_SNAP. This makes the default behaviour
# to re-exec to snapd snap instead of snapd in core. Furthermore,
# it prevents snapd from automatically installing snapd snap as
# prerequisite for installing any non-base snap
if snap list snapd ; then
snap snap info snapd
echo "Error: not expecting snapd be be installed"
exit 1
else
echo ">>>>>> Snapd is not installed"
echo ">>>>>> Building snapd"
build_dir="$WORK_DIR/snapd_snap_for_classic"
rm -rf "$build_dir"
mkdir -p "$build_dir"
build_snapd_snap "$build_dir"
echo ">>>>>> Installing snapd"
snap install --dangerous "$build_dir/"snapd_*.snap
fi
snap list | grep snapd

#exit 1

# now use parameterized core channel (defaults to edge) instead
# of a fixed one and close to stable in order to detect defects
# earlier
Expand Down

0 comments on commit 0612244

Please sign in to comment.