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

Support for isolated builds #1393

Merged

Conversation

praiskup
Copy link
Member

@praiskup praiskup commented Jun 26, 2024

  • Don't misuse the package_state plugin for this purpose
  • Standardize the output JSON format format fixed for now, this will take time
  • add a feature documentation page
  • manual pages
  • add unit-tests && behave test
  • assert the bootstrap image sha1

@praiskup praiskup marked this pull request as draft June 26, 2024 06:43
@praiskup praiskup force-pushed the praiskup-separate-build-deps-mode branch from 5e78af2 to 611c60c Compare June 26, 2024 08:36
@praiskup
Copy link
Member Author

One of the experiments might look like:

1. prepare `f41-bootstrap` image that has dnf5-plugins available
2. download RPMs (cache): mock --calculate-build-dependencies -r fedora-rawhide-x86_64 /tmp/tito/python-copr-1.132-1.git.0.787a685.fc40.src.rpm
3. copy cached RPMs aside: cp -r /var/cache/mock/fedora-rawhide-x86_64/dnf_cache/fedora-2d95c80a1fa0a67d/packages/ /tmp/rawhide
4. create repo: createrepo_c /tmp/rawhide
5. isolated build: mock -r fedora-isolated /tmp/tito/python-copr-1.132-1.git.0.787a685.fc40.src.rpm --config-opts local_directory=/tmp/rawhide --config-opts=bootstrap_image=localhost/f41-bootstrap:latest --config-opts=bootstrap_image_skip_pull=True

Alternative way to 5 might look like:

5. install build deps: mock -r fedora-isolated --installdeps /var/lib/mock/fedora-rawhide-x86_64/result/python-copr-1.132-1.git.0.787a685.fc41.buildreqs.nosrc.rpm  --config-opts local_directory=/tmp/rawhide --config-opts=bootstrap_image=localhost/f41-bootstrap:latest --config-opts=bootstrap_image_skip_pull=True
6. run the final build (no clean): mock -r fedora-isolated --no-clean /tmp/tito/python-copr-1.132-1.git.0.787a685.fc40.src.rpm --config-opts local_directory=/tmp/rawhide --config-opts=bootstrap_image=localhost/f41-bootstrap:latest --config-opts=bootstrap_image_skip_pull=True

@pep8speaks
Copy link

pep8speaks commented Jun 28, 2024

Hello @praiskup! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2024-09-10 15:23:51 UTC

Copy link
Member

@xsuchy xsuchy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This "skip pull" commit is weird. I do not understand it.

@praiskup
Copy link
Member Author

praiskup commented Jul 1, 2024

This "skip pull" commit is weird. I do not understand it.

The purpose is to not "podman pull" the image (and fail) if the image is not pushed into any registry. I'm going to document it (or drop the commit), sorry for the confusion.

@praiskup praiskup force-pushed the praiskup-separate-build-deps-mode branch from 37564a9 to bb24b44 Compare July 1, 2024 08:51
@praiskup
Copy link
Member Author

praiskup commented Jul 1, 2024

Updated with a bit more convenient use-case, see below.

First we calculate the build-deps:

$ mock -r fedora-rawhide-x86_64 --calculate-build-dependencies /tmp/tito/python-copr-1.132-1.git.0.787a685.fc40.src.rpm

Then, using the JSON file in result directory, we download the RPMs and prepare
the local repository:

$ repo-from-json --json /var/lib/mock/fedora-rawhide-x86_64/result/mock-build-environment.json --output-repo /tmp/repo

Then, with the local-repo prepared, we can run the isolated build:

$ mock -r fedora-isolated --isolated-build-config /tmp/prepared/mock-build-environment.json /tmp/repo/ /tmp/tito/python-copr-1.132-1.git.0.787a685.fc40.src.rpm

@praiskup
Copy link
Member Author

praiskup commented Jul 2, 2024

The last part is now simplified, one just needs to

$ mock --isolated-build-config /tmp/prepared/mock-build-environment.json /tmp/repo/ /tmp/tito/python-copr-1.132-1.git.0.787a685.fc40.src.rpm

Warning: this whole PoC only works with bootstrap_image_ready = True.

mock/py/mock-isolated-repo.py Fixed Show fixed Hide fixed
mock/py/mock-isolated-repo.py Fixed Show fixed Hide fixed
@praiskup
Copy link
Member Author

praiskup commented Jul 3, 2024

The experimental use-case looks like this now (after the recent update):

# we use the srpm twice
srpm=/tmp/tito/python-copr-1.132-1.git.0.787a685.fc40.src.rpm

# record list of RPMs and bootstrap image we need to download
mock --calculate-build-dependencies -r fedora-rawhide-x86_64 "$srpm"

# backup the json file
cp -r /var/lib/mock/fedora-rawhide-x86_64/result/mock-build-environment.json /tmp/

# pre-fetch the files
mock-isolated-repo --json /tmp/mock-build-environment.json --output-repo /tmp/repo

# run the isolated build
mock --isolated-build-config /tmp/mock-build-environment.json /tmp/repo/ "$srpm"

@praiskup praiskup force-pushed the praiskup-separate-build-deps-mode branch from 5f9f319 to f0bf206 Compare July 3, 2024 15:01
mock/py/mock-isolated-repo.py Outdated Show resolved Hide resolved
mock/py/mock-isolated-repo.py Show resolved Hide resolved
mock/py/mock.py Outdated Show resolved Hide resolved
mock/py/mockbuild/config.py Show resolved Hide resolved
mock/py/mockbuild/plugins/package_state.py Outdated Show resolved Hide resolved
praiskup added a commit to praiskup/mock that referenced this pull request Aug 22, 2024
praiskup added a commit to praiskup/mock that referenced this pull request Aug 22, 2024
praiskup added a commit to praiskup/mock that referenced this pull request Aug 22, 2024
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
praiskup added a commit to praiskup/mock that referenced this pull request Aug 22, 2024
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
praiskup added a commit to praiskup/mock that referenced this pull request Aug 22, 2024
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
@praiskup praiskup marked this pull request as ready for review September 3, 2024 06:47
praiskup added a commit to praiskup/mock that referenced this pull request Sep 3, 2024
There are new options, --calculate-build-dependencies and
--isolated-build.  New buildroot_lock plugin added.

Fixes: rpm-software-management#1358
Merges: rpm-software-management#1393
Relates: rpm-software-management#1380
@praiskup praiskup force-pushed the praiskup-separate-build-deps-mode branch from 538c135 to 18d6b97 Compare September 3, 2024 07:00
@praiskup
Copy link
Member Author

praiskup commented Sep 3, 2024

We can not do isolated builds with centos-stream for now, reported: https://issues.redhat.com/browse/CS-2506

praiskup added a commit to praiskup/mock that referenced this pull request Sep 3, 2024
There are new options, --calculate-build-dependencies and
--isolated-build.  New buildroot_lock plugin added.

Fixes: rpm-software-management#1358
Merges: rpm-software-management#1393
Relates: rpm-software-management#1380
@praiskup praiskup force-pushed the praiskup-separate-build-deps-mode branch from 18d6b97 to 78a0e11 Compare September 3, 2024 09:42
xsuchy pushed a commit that referenced this pull request Sep 3, 2024
@tkopecek
Copy link
Contributor

tkopecek commented Sep 3, 2024

About json versioning: Should we also store in the config part which mock version created it? I'm more inclined to "no" as mock probably doesn't have enough information about itself (was it e.g. modified in the distribution?) and leave it on other tooling. OTOH, it can be easilly lost which mock should be used for the rebuild - is json version enough to have reliable reproducibility? E.g. json version needn't to change in future twenty mock versions while some other substantial process would be different meanwhile.

@tkopecek
Copy link
Contributor

tkopecek commented Sep 3, 2024

Saving whole (parsed) mock config could be valuable? E.g. what if I run the --isolated-build phase on different machine with different site-defaults.cfg? Maybe it is also up to "process above" to store/provide correct mock configs?

@praiskup
Copy link
Member Author

praiskup commented Sep 3, 2024

About json versioning: Should we also store in the config part which mock version created it? I'm more inclined to "no" as mock probably doesn't have enough information about itself (was it e.g. modified in the distribution?) and leave it on other tooling.

I agree here. When it comes to full reproducibility, it's by far not just about Mock version. We probably want to reproduce on the same kernel, and run Mock-in-container, from the very same container image, with the very same version of container tooling, etc. The "feature-isolated-build" feature page discusses this a bit (the buildroot environment maintained by mock != the environment we run mock in).

OTOH, it can be easilly lost which mock should be used for the rebuild

The NVR of Mock in use is dumped into logs, and if the situation comes - we should be able to find the right version by git-bisect. Though, ... if you prefer to dump the mock version there, I will not object too much! And I really expect a heavy development here, so we may add it later - this PR is just the starting point.

Saving whole (parsed) mock config could be valuable? E.g. what if I run the --isolated-build phase on different machine with different site-defaults.cfg? Maybe it is also up to "process above" to store/provide correct mock configs?

Yes, my vote goes for "process above". If we have a mock container image ID/sha256 like this one, we know both the Mock version and the set of configuration files.

If all of this implicates we should document this more, please say what and where! 👍

praiskup added a commit to praiskup/mock that referenced this pull request Sep 3, 2024
There are new options, --calculate-build-dependencies and
--isolated-build.  New buildroot_lock plugin added.

Fixes: rpm-software-management#1358
Merges: rpm-software-management#1393
Relates: rpm-software-management#1380
@praiskup praiskup force-pushed the praiskup-separate-build-deps-mode branch from 78a0e11 to c1e47e3 Compare September 3, 2024 15:57
praiskup added a commit to praiskup/mock that referenced this pull request Sep 4, 2024
There are new options, --calculate-build-dependencies and
--isolated-build.  New buildroot_lock plugin added.

Fixes: rpm-software-management#1358
Merges: rpm-software-management#1393
Relates: rpm-software-management#1380
@praiskup praiskup force-pushed the praiskup-separate-build-deps-mode branch from c1e47e3 to 243f73a Compare September 4, 2024 03:47
praiskup added a commit to praiskup/mock that referenced this pull request Sep 4, 2024
There are new options, --calculate-build-dependencies and
--isolated-build.  New buildroot_lock plugin added.

Fixes: rpm-software-management#1358
Merges: rpm-software-management#1393
Relates: rpm-software-management#1380
@praiskup praiskup force-pushed the praiskup-separate-build-deps-mode branch from 243f73a to b3c6114 Compare September 4, 2024 11:26
@tkopecek
Copy link
Contributor

tkopecek commented Sep 6, 2024

If all of this implicates we should document this more, please say what and where! 👍

I think we should just stress it a bit more in "Limitations" section. For some it could look like it is providing reproducible builds without taking in account state of host machine software/hardware stack. Just a one sentence that there is still a big influence of external factors.

praiskup added a commit to praiskup/mock that referenced this pull request Sep 6, 2024
There are new options, --calculate-build-dependencies and
--isolated-build.  New buildroot_lock plugin added.

Fixes: rpm-software-management#1358
Merges: rpm-software-management#1393
Relates: rpm-software-management#1380
@praiskup praiskup force-pushed the praiskup-separate-build-deps-mode branch from b3c6114 to f9a8260 Compare September 6, 2024 13:38
@praiskup
Copy link
Member Author

praiskup commented Sep 6, 2024

I borrowed your wording and updated the Limitation section. Thank you!

There are new options, --calculate-build-dependencies and
--isolated-build.  New buildroot_lock plugin added.

Fixes: rpm-software-management#1358
Merges: rpm-software-management#1393
Relates: rpm-software-management#1380
@FrostyX FrostyX requested a review from xsuchy September 9, 2024 11:01
@praiskup praiskup force-pushed the praiskup-separate-build-deps-mode branch from f9a8260 to 0ef823f Compare September 10, 2024 15:23
@xsuchy xsuchy merged commit b45d784 into rpm-software-management:main Sep 10, 2024
21 checks passed
xsuchy pushed a commit that referenced this pull request Sep 10, 2024
There are new options, --calculate-build-dependencies and
--isolated-build.  New buildroot_lock plugin added.

Fixes: #1358
Merges: #1393
Relates: #1380
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants