Skip to content

Commit

Permalink
apport: set the APPORT_DATA_DIR variable in snap yaml definition
Browse files Browse the repository at this point in the history
The APPORT_DATA_DIR variable must be set before the apport Python module
is imported. This was no longer true because of this import:

  from subiquity.server.controllers.filesystem import set_user_error_reportable

Instead of trying to call setup_environment very early; make sure that
the variable is set by snapd before Subiquity actually starts.

LP: #2076233

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
  • Loading branch information
ogayot committed Aug 14, 2024
1 parent b2b6e9f commit 0c4d6fe
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
9 changes: 9 additions & 0 deletions snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ apps:
SUBIQUITY_ROOT: $SNAP
PYTHON_ORIG: $PYTHON
PYTHON: $SNAP/usr/bin/python3.10
# APPORT_DATA_DIR must be set before the `apport` python module is
# imported.
APPORT_DATA_DIR: $SNAP/share/apport
probert:
command: usr/bin/subiquity-cmd $SNAP/usr/bin/python3.10 $SNAP/bin/probert
environment:
Expand All @@ -43,6 +46,9 @@ apps:
PYTHON: $SNAP/usr/bin/python3.10
PY3OR2_PYTHON: $SNAP/usr/bin/python3.10
PATH: $PATH:$SNAP/bin:$SNAP/sbin
# APPORT_DATA_DIR must be set before the `apport` python module is
# imported.
APPORT_DATA_DIR: $SNAP/share/apport
subiquity-service:
command: usr/bin/subiquity-service
daemon: simple
Expand All @@ -58,6 +64,9 @@ apps:
SUBIQUITY_ROOT: $SNAP
PYTHON_ORIG: $PYTHON
PYTHON: $SNAP/usr/bin/python3.10
# APPORT_DATA_DIR must be set before the `apport` python module is
# imported.
APPORT_DATA_DIR: $SNAP/share/apport

parts:
curtin:
Expand Down
2 changes: 0 additions & 2 deletions subiquity/cmd/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,6 @@ def make_server_args_parser():
def main():
print("starting server")
setup_environment()
# setup_environment sets $APPORT_DATA_DIR which must be set before
# apport is imported, which is done by this import:
from subiquity.server.dryrun import DRConfig
from subiquity.server.server import SubiquityServer

Expand Down
2 changes: 0 additions & 2 deletions subiquity/cmd/tui.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,6 @@ def make_client_args_parser():

def main():
setup_environment()
# setup_environment sets $APPORT_DATA_DIR which must be set before
# apport is imported, which is done by this import:
from subiquity.client.client import SubiquityClient

parser = make_client_args_parser()
Expand Down

0 comments on commit 0c4d6fe

Please sign in to comment.