Skip to content

Commit

Permalink
Fall back to template default if we don't know anything about Docker
Browse files Browse the repository at this point in the history
  • Loading branch information
freakboy3742 committed Jul 10, 2023
1 parent 3677230 commit 38ab799
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/briefcase/platforms/linux/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -583,9 +583,13 @@ def output_format_template_context(self, app: AppConfig):

# Use the non-root user if Docker is not mapping usernames. Also use a non-root
# user if we're on macOS; user mapping doesn't alter Docker operation, but some
# packaging tools (e.g., Arch's makepkg) don't like running as root.
# packaging tools (e.g., Arch's makepkg) don't like running as root. If we're
# not using Docker, this will fall back to the template default, which should be
# enabling the root user. This might cause problems later, but it's part of a
# much bigger "does the project need to be updated in light of configuration
# changes" problem.
try:
context["use_non_root_user"] = self.use_docker and (
context["use_non_root_user"] = (
self.tools.host_os == "Darwin" or not self.tools.docker.is_user_mapped
)
except AttributeError:
Expand Down
3 changes: 3 additions & 0 deletions tests/platforms/linux/system/test_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ def test_output_format_template_context(

def test_output_format_template_context_no_docker(create_command, first_app_config):
"""If not using Docker, `use_non_root_user` default in template is used."""
# Mock the host to Linux to avoid flagging any "always use non-root user on macOS" logic.
create_command.tools.host_os = "Linux"

# Add some properties defined in config finalization
first_app_config.python_version_tag = "3.X"
first_app_config.target_image = "somevendor:surprising"
Expand Down

0 comments on commit 38ab799

Please sign in to comment.