Skip to content
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

Fix 349 #368

Merged
merged 2 commits into from Oct 8, 2019
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 0 additions & 2 deletions mock/py/mock.py
Expand Up @@ -752,11 +752,9 @@ def main():
try:
result = run_command(options, args, config_opts, commands, buildroot, state)
finally:
buildroot.uid_manager.becomeUser(0, 0)
buildroot.finalize()
if bootstrap_buildroot is not None:
bootstrap_buildroot.finalize()
buildroot.uid_manager.restorePrivs()
return result


Expand Down
11 changes: 6 additions & 5 deletions mock/py/mockbuild/backend.py
Expand Up @@ -297,13 +297,17 @@ def build(self, srpm, timeout, check=True, spec=None):
buildsetup_finished = True

rpmbuildstate = "rpmbuild %s" % baserpm
self.state.start(rpmbuildstate)

# tell caching we are building
self.plugins.call_hooks('prebuild')
# intentionally we do not call bootstrap hook here - it does not have sense

results = self.rebuild_package(spec_path, timeout, check, dynamic_buildreqs)
try:
self.state.start(rpmbuildstate)
results = self.rebuild_package(spec_path, timeout, check, dynamic_buildreqs)
finally:
self.state.finish(rpmbuildstate)

# In the nspawn case, we retained root until here, but we
# need to ensure our output files are owned by the caller's uid.
# So drop them now.
Expand All @@ -318,7 +322,6 @@ def build(self, srpm, timeout, check=True, spec=None):
raise PkgError('No build results found')
self.state.result = 'success'

self.state.finish(rpmbuildstate)
finally:
if not buildsetup_finished:
self.state.finish(buildsetup)
Expand Down Expand Up @@ -486,11 +489,9 @@ def chain(self, args, options, buildroot):
except Error:
build_ret_code = 1
finally:
buildroot.uid_manager.becomeUser(0, 0)
buildroot.finalize()
if buildroot.bootstrap_buildroot is not None:
buildroot.bootstrap_buildroot.finalize()
buildroot.uid_manager.restorePrivs()
except (RootError,) as e:
log.warning(e.msg)
failed.append(pkg)
Expand Down