Skip to content

Commit

Permalink
The installed_pkgs.log file now covers dynamic builddeps
Browse files Browse the repository at this point in the history
This change required us to create a new "postdeps" hook with
post-%generate_buildrequires timing.

Fixes: rpm-software-management#1429
Relates: rpm-software-management#1393
  • Loading branch information
praiskup committed Aug 22, 2024
1 parent 014b752 commit 5163a66
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/Plugin-Hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Where `HOOK_NAME` is one of:
* postbuild - This hook is called just after RPM or SRPM have been build (with or without success).
* postchroot - This hook is called just after exiting from command in `mock chroot` command. This action is currently being used by `root_cache` plugin.
* postclean - This hook is called when the content of the chroot has been deleted. It is called after `umount_root`. E.g., `lvm_root` use this to delete the LVM volume.
* postdeps - Called when the build dependencies (both static and dynamic) are installed, but the build has not started, yet.
* postinit - Chroot have been initialized and it is ready for installing SRPM dependencies. E.g., root_cache plugin now packs the chroot and put it in a cache. This action is currently being used by `bind_mount`, `lvm_root`, `mount`, `root_cache` plugins.
* postshell - This hook is called just after exiting from the shell in `mock shell` command. This action is currently being used by `root_cache` plugin.
* postupdate - Mock attempts to cache buildroot contents, but tries to automatically update the packages inside the buildroot in subsequent executions (so up2date packages are used during build). This hook is called anytime such update is successful and any package is updated inside the buildroot. Any plugin taking care of the buildroot caches can then react and update the cache to avoid re-updating in the subsequent mock runs.
Expand Down
3 changes: 3 additions & 0 deletions mock/py/mockbuild/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ def build(self, srpm, timeout, check=True, spec=None):
' See "dynamic_buildrequires" in config_opts.')

self.install_external(requires)
# install the (static) BuildRequires
self.installSrpmDeps(rebuilt_srpm)
self.state.finish(buildsetup)
buildsetup_finished = True
Expand Down Expand Up @@ -791,6 +792,8 @@ def get_command(mode, checkdeps=False):
mode = ['-ba']
mode += ['--noprep']

self.plugins.call_hooks('postdeps')

# When we used dynamic buildrequires, the rpmbuild call will
# execute the %generate_buildrequires section once again
# in order to actually add the BuildRequires to the SRPM metadata.
Expand Down
2 changes: 1 addition & 1 deletion mock/py/mockbuild/plugins/package_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def __init__(self, plugins, conf, buildroot):
self.inst_done = False
self.online = self.buildroot.config['online']
plugins.add_hook("postyum", self._availablePostYumHook)
plugins.add_hook("prebuild", self._installedPreBuildHook)
plugins.add_hook("postdeps", self._installedPreBuildHook)

@traceLog()
def _availablePostYumHook(self):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
The `installed_pkgs.log` — generated by the `package_state` plugin — was
[previously generated too early][issue#1429], after the static build
requirements were installed but **before** the dynamic build requirements were
resolved and installed. This led to incorrect chroot introspection for the end
user, as the full set of packages needed to build the given package was
incomplete. The new Mock version generates the `installed_pkgs.log` file after
the dynamic build requirements are installed.

0 comments on commit 5163a66

Please sign in to comment.