-
Notifications
You must be signed in to change notification settings - Fork 249
mock: disable networking in bootstrap for hermetic builds #1697
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -860,6 +860,7 @@ def clean_env(): | |
|
|
||
| @traceLog() | ||
| def setup_host_resolv(config_opts): | ||
| log = getLog() | ||
| if not config_opts['use_host_resolv']: | ||
| # If we don't copy host's resolv.conf, we at least want to resolve | ||
| # our own hostname. See commit 28027fc26d. | ||
|
|
@@ -869,7 +870,7 @@ def setup_host_resolv(config_opts): | |
| ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 | ||
| ''') | ||
|
|
||
| if config_opts['isolation'] == 'simple': | ||
| if not USE_NSPAWN: | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Modus operandi of this line was that USE_NSPAWN is global variable. Made in rush. With knowledge that globals are bad. And one day we can replace is with propper variable. But propagating config_opt in some function will be hard. On this place we have config_opts easily accessible.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We though don't have this specific value in config_opts (the value is result of config.py hack with globals that you described). |
||
| # Not using nspawn -> don't touch /etc/resolv.conf; we already have | ||
| # a valid file prepared by Buildroot._init() (if user requested). | ||
| return | ||
|
|
@@ -889,7 +890,10 @@ def setup_host_resolv(config_opts): | |
| os.chmod(resolv_path, 0o644) | ||
|
|
||
| if config_opts['use_host_resolv']: | ||
| shutil.copyfile('/etc/resolv.conf', resolv_path) | ||
| try: | ||
| shutil.copyfile('/etc/resolv.conf', resolv_path) | ||
| except FileNotFoundError: | ||
| log.warning("Non-existing resolv.conf on host, using an empty one") | ||
xsuchy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| config_opts['nspawn_args'] += ['--bind={0}:/etc/resolv.conf'.format(resolv_path)] | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| Mock no longer fails if `resolv.conf` is missing on the host. While builds | ||
| requiring network access (--enable-networking) will still fail later, Mock will | ||
| no longer crash with a FileNotFoundError during the initialization phase. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tkopecek This turned out to be the most important change - since we use
--isolation=auto(in container we do a fallback to 'simple'), we shouldn't even execute the rest of the method ...