Merge ~sylvain-pineau/checkbox-ng:fix-respawn-cmd-snappy into checkbox-ng:master

Proposed by Sylvain Pineau
Status: Merged
Approved by: Sylvain Pineau
Approved revision: 6292bf7012559134ff3be8e003b468652cee5b6e
Merged at revision: 7fc11c56ee567354f4ed17ec8fa232bd4827603d
Proposed branch: ~sylvain-pineau/checkbox-ng:fix-respawn-cmd-snappy
Merge into: checkbox-ng:master
Diff against target: 36 lines (+16/-2)
1 file modified
checkbox_ng/launcher/subcommands.py (+16/-2)
Reviewer Review Type Date Requested Status
Sylvain Pineau (community) Approve
Review via email: mp+338552@code.launchpad.net

Description of the change

Fix the respawn commands when running from a snap to call the checkbox-cli app.

To post a comment you must log in.
Revision history for this message
Sylvain Pineau (sylvain-pineau) wrote :

Tested with checkbox-oem-qa and the suspend with reboots job. no crash when resuming, checkbox-cli entry point correctly loads the snap modules.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/checkbox_ng/launcher/subcommands.py b/checkbox_ng/launcher/subcommands.py
2index 9c50b45..ae2b9b8 100644
3--- a/checkbox_ng/launcher/subcommands.py
4+++ b/checkbox_ng/launcher/subcommands.py
5@@ -285,7 +285,14 @@ class Launcher(Command, MainLoopStage):
6 if strategy:
7 # gluing the command with pluses b/c the middle part
8 # (launcher path) is optional
9- respawn_cmd = sys.argv[0] # entry-point to checkbox
10+ snap_name = os.getenv('SNAP_NAME')
11+ if snap_name:
12+ # NOTE: This implies that any snap wishing to include a
13+ # Checkbox snap to be autostarted creates a snapcraft
14+ # app called "checkbox-cli"
15+ respawn_cmd = '/snap/bin/{}.checkbox-cli'.format(snap_name)
16+ else:
17+ respawn_cmd = sys.argv[0] # entry-point to checkbox
18 respawn_cmd += " launcher "
19 if ctx.args.launcher:
20 respawn_cmd += os.path.abspath(ctx.args.launcher) + ' '
21@@ -945,7 +952,14 @@ class Run(Command, MainLoopStage):
22
23 def _configure_restart(self):
24 strategy = detect_restart_strategy()
25- respawn_cmd = sys.argv[0] # entry-point to checkbox
26+ snap_name = os.getenv('SNAP_NAME')
27+ if snap_name:
28+ # NOTE: This implies that any snap wishing to include a
29+ # Checkbox snap to be autostarted creates a snapcraft
30+ # app called "checkbox-cli"
31+ respawn_cmd = '/snap/bin/{}.checkbox-cli'.format(snap_name)
32+ else:
33+ respawn_cmd = sys.argv[0] # entry-point to checkbox
34 respawn_cmd += ' --resume {}' # interpolate with session_id
35 self.sa.configure_application_restart(
36 lambda session_id: [ respawn_cmd.format(session_id)])

Subscribers

People subscribed via source and target branches