rpm-software-management / mock

Mock is a tool for a reproducible build of RPM packages.
GNU General Public License v2.0
376 stars 219 forks source link

A new option `--buildroot-image=` similar to `bootstrap_image` #1159

Open praiskup opened 11 months ago

praiskup commented 11 months ago

As the --use-bootstrap-image feature is now stabilized, and enabled by default (mock v5.0+), we can start thinking about a similar feature for the build chroot (buildroot) itself.

Buildroot preparation is relatively expensive and time consuming task because installing the (dynamic) build dependencies generates many DNF transactions, and downloads huge pile of DNF/RPM (meta)data.

I'd propose to have two new options (this is to replicate the naming option from bootstrap_image, bootstrap_image_ready and use_bootstrap_image).

The problem with the buildroot_image option (contrary to bootstrap_image) is that we can not simply have a reasonable default for everyone and every package out there; each package - on each distribution - has a different build dependency set. Therefore this would be completely up to the end user to provide such an image, and eventually use it via --buildroot-image=my-mock-specific-buildroot. This new commandline option should set:

So, with the new --buildroot-image option, mock would just extract the buildroot image into a directory, do necessary (but very fast) directory modifications, and directly start rpmbuild.

Things to do:

praiskup commented 11 months ago

@ericcurtin @odra CC

What do you folk think about this proposal, especially WRT to the pkgbox? Would you be able to cooperate on the feature here?

With https://github.com/kubernetes/kubernetes/pull/116377 in OpenShift, we can run Mock "rootless" easily (root in a separate user namespace). Therefore, Mock is going to be a normal thing in OpenShift soon. This feature seems like a low-hanging fruit and has the potential to minimize the buildroot preparation time to almost zero.

Conan-Kudo commented 11 months ago

What about being able to take rootfs images in disk image or plain tarball formats?

praiskup commented 11 months ago

That would make sense as well, I think we have to start with something (we already have the Podman image download support in Mock, so it is the easy starter). But downloading root_cache tarballs, rootfs images, disk images or whatever else seems like a trivial alternative. Would that affect the proposed option/cmdline API?

voxik commented 5 months ago

I am not huge fan of this RFE, mainly due to the additional complexity.

BTW this RFE reminds me this discussion:

https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/message/TA3KCIYA7UDZYCP6IRH6LLMCBKUTJAUN/ https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/message/OCKSM7B7VKUK4QBC6UNRXJ4CAWO6WG63/

praiskup commented 5 months ago

I am not huge fan of this RFE, mainly due to the additional complexity.

This will bring some new opt-in if-else branches, yes. But nothing exceptional? I replied dozens of times to questions related to this. People typically start with

  1. Containerfile: FROM fedora:XYZ
  2. Containerfile: RUN dnf install -y x y z
  3. Containerfile: USER abc
  4. podman run ... rpmbuild... srpm/spec

To a random observer, appears to be as easy as that, making the 1-3 steps super fast for repeated runs (and easily shareable). Except that this is a re-implementation of Mock. Is it good for Koji? Probably not.

Tojaj commented 4 months ago

Disclaimer: This is very unlikely to happen

IMHO, this would be awesome if it works in tandem with Koji itself - i.e. Koji generates these buildroot container images from the buildroot content.

Something like this:

This way this would work out-of-box for mock and users regardless if it's a user who runs mock locally or Koji itself who runs it as part of RPM build. Mock would just auto-detect that Koji has a buildroot container available for the buildroot and download it - instead of bootstraping the whole chroot structure from scratch by downloading the packages and installing them.