Ensures snap_dir='/' if not better specified.

UDI sets the SNAP env var to '.' for development purposes.

See: https://github.com/canonical/ubuntu-desktop-installer/commit/9eb6f04

It is unlikely that under test or production that env var will
ever by just '.'. On the other hand in dry-run we want this controller
to interpret it as '/' if not properly set, thus discarding the '.'.
This commit is contained in:
Carlos Nihelton 2022-04-06 13:25:35 -03:00
parent 1b7ab29e25
commit d3e2544875
No known key found for this signature in database
GPG Key ID: 6FE346D245197E9A
1 changed files with 7 additions and 0 deletions

View File

@ -145,6 +145,13 @@ class ConfigureController(SubiquityController):
packages = []
# Running that command doesn't require root.
snap_dir = os.getenv("SNAP", default="/")
# UDI sets the SNAP env var to '.' for development purposes.
# See:
# https://github.com/canonical/ubuntu-desktop-installer/commit/9eb6f04
# It is unlikely that under test or production that env var will
# ever by just '.'. On the other hand in dry-run we want it pointing to
# '/' if not properly set.
snap_dir = snap_dir if snap_dir != '.' else '/'
data_dir = os.path.join(snap_dir, "usr/share/language-selector")
if not os.path.exists(data_dir):
log.error("Misconfigured snap environment pointed L-S-C data dir"