Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions mock/py/mockbuild/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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:
Copy link
Member Author

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 ...

Copy link
Member

Choose a reason for hiding this comment

The 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.

Copy link
Member Author

Choose a reason for hiding this comment

The 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
Expand All @@ -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")

config_opts['nspawn_args'] += ['--bind={0}:/etc/resolv.conf'.format(resolv_path)]

Expand Down
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.
Loading