rpm-software-management / mock

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

[Feature] Allow to trust rpm repositories from bootstrap image #1500

Open Romain-Geissler-1A opened 1 week ago

Romain-Geissler-1A commented 1 week ago

This is issue a feature request for allowing to fully trust the rpm repositories already configured inside the bootstrap image. The use case for this would be people building package inside organization using their own rpm repositories (either because they don't have internet access for some reason, either because they have some extra repositories purely internal to that organization).

Let me describe what we do now inside Amadeus:

Ideally, I would like to be able to provide my images, with rpm repositories correctly configured already, and my users would just need to call mock with an option to disable the mock logic rewritting the rpm repositories, while keeping all the other logic wrt dnf configuration override.

Right now, what we do is no great (according to me):

ALL_RPM_REPOSITORIES=($(podman run --rm "${BOOTSTRAP_IMAGE}" dnf repoinfo --quiet --enabled | grep -E -i '[^:]*base.?url[^:]*:' | sed -e 's/[^:]*:\s*//'))

MOCKBUILD_REPOSITORIES_ARGUMENTS=()

for RPM_REPOSITORY in "${ALL_RPM_REPOSITORIES[@]}"; do
    MOCKBUILD_REPOSITORIES_ARGUMENTS+=("--addrepo" "${RPM_REPOSITORY}")
done

# Actually build the packages.
fedpkg --release "${RELEASEVER}" mockbuild --mock-config "${MOCK_CONFIG_NAME}" -- --config-opts "bootstrap_image=${BOOTSTRAP_IMAGE}" "${MOCKBUILD_REPOSITORIES_ARGUMENTS[@]}"

Ideally I would like to have some new hypothetical boolean config option use_boostrap_image_rpm_repositories so that we would only do:

# Actually build the packages.
fedpkg --release "${RELEASEVER}" mockbuild --mock-config "${MOCK_CONFIG_NAME}" -- --config-opts "bootstrap_image=${BOOTSTRAP_IMAGE}" --config-opts use_boostrap_image_rpm_repositories=True

So this feature if accepted would mean more or less:

Would that make sense ?

Thanks, Romain

praiskup commented 5 days ago

Thank you for the question/RFE. This is a hard one :) though.

Where do you / your users execute Mock? In Podman containers or on host? If you run mock-in-podman then you can easily ship mock configuration there (sets of configuration files, whatever you need). If "on host", it is a matter of shipping one config file per build target/chroot (whatever way you prefer) - it isn't that bad, you can use Copr to build your mock-cofiguration set, complementary to mock-core-configs.

The thing is that Mock is designed to have the configuration in /etc/mock + $HOME, there's no tooling (yet) to extract the config from the bootstrap image. Such a potential implementation would look like

a) parse configuration on host, b) take a look how bootstrap image is named, c) get the configuration options from that image, d) combine the newly extracted configuration with the on-host configuration e) start the build ... this seems pretty convoluted.

Can't you ship the mock config in container? Then you can do

podman run <your bootstrap image> cat /mock.cfg > /tmp/mock.cfg
mock - /tmp/mock.cfg <your.src.rpm>

What is inside "${MOCK_CONFIG_NAME}"?