-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add workaround for missing build packages (#639)
The bare minimum of build packages may be missing following commit 2482f0f and commit 725d2cb. While the resolution may belong in charmcraft, we need a workaround. Fixes #638
- Loading branch information
Showing
1 changed file
with
16 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
import logging | ||
import os | ||
import requests | ||
import subprocess | ||
import sys | ||
import uuid | ||
import yaml | ||
|
@@ -773,6 +774,20 @@ def generate_python_modules_from_lock_file(self): | |
lines.append(line) | ||
return lines | ||
|
||
def workaround_charmcraft_maybe_ensure_build_packages(self): | ||
"""Workaround for missing build packages when in charmcraft build. | ||
The charmcraft reactive plugin ought to provide the bare minimum | ||
of build package dependencies, however until it does let's help | ||
here under the right circumstances. | ||
""" | ||
if (os.geteuid() == 0 | ||
and (os.environ.get('CRAFT_PART_NAME', None) | ||
or os.environ.get('CHARMCRAFT_PART_NAME', None))): | ||
log.warning('Probably running as root in charmcraft, proactively ' | ||
'installing the `git` and `virutalenv` packages.') | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
fnordahl
Author
Collaborator
|
||
subprocess.run(('apt', '-y', 'install', 'git', 'virtualenv'), check=True) | ||
|
||
def generate(self): | ||
layers = self.fetch() | ||
self.formulate_plan(layers) | ||
|
@@ -1219,6 +1234,7 @@ def main(args=None): | |
build.normalize_cache_dir() | ||
build.check_paths() | ||
build.maybe_read_lock_file() | ||
build.workaround_charmcraft_maybe_ensure_build_packages() | ||
|
||
build() | ||
|
||
|
Note the typo in "virutalenv"