Skip to content

Commit ecfd5d4

Browse files
committed
Prefetch RPM: use partials in examples
Allow to replace examples in downstream Signed-off-by: Martin Basti <[email protected]>
1 parent 81b4543 commit ecfd5d4

6 files changed

+55
-18
lines changed

modules/ROOT/pages/building/prefetching-dependencies.adoc

+17-18
Original file line numberDiff line numberDiff line change
@@ -257,41 +257,40 @@ Cachi2 has a dev-preview package manager capable of fetching `rpm` dependencies.
257257

258258
To prefetch dependencies for a component build, complete the following steps:
259259

260+
. Have a Containerfile, for example:
261+
+
262+
include::ROOT:partial$building/{context}-example-prefetch-rpm-containerfile.adoc[]
263+
260264
. Create a `rpms.in.yaml` file in your git repository, with the following contents:
261265

262266
+
263-
[source,yaml]
264-
----
265-
packages: [nethack] <1>
266-
contentOrigin:
267-
repofiles: ["./fedora.repo"] <2>
268-
arches: [x86_64, aarch64] <3>
269-
----
267+
include::ROOT:partial$building/{context}-example-prefetch-rpm-rpms_in_yaml.adoc[]
270268
<1> The `*packages*` list is the list of packages you want to install in your Container. You don't have to declare transitive dependencies here. The rpm-lockfile-prototype tool will resolve them for you.
271269
<2> This should be a reference to a repo file, like those found in `/etc/yum.repos.d/`. This tells the tooling where to find your rpm and its dependencies.
272270
<3> The `arches` array allows you to specify which architectures the dependencies should be downloaded for. If you're building a multi-arch container this array is mandatory, otherwise the build task will fail.
271+
+
272+
NOTE: The description of all options available for `rpms.in.yaml` can be found
273+
https://github.com/konflux-ci/rpm-lockfile-prototype?tab=readme-ov-file#whats-the-input_file[here].
273274

274-
. Copy any necessary yum/dnf repo files into your git repository. If you are using a fedora rawhide base image, that looks like:
275+
. Copy any necessary yum/dnf repo files into your git repository. For example:
275276

276277
+
277-
[source,console]
278-
----
279-
$ BASE_IMAGE=quay.io/fedora/fedora:rawhide
280-
$ podman run -it $BASE_IMAGE cat /etc/yum.repos.d/fedora.repo > fedora.repo
281-
----
278+
include::ROOT:partial$building/{context}-example-prefetch-rpm-copy-repo.adoc[]
282279

283280
+
284281
NOTE: For every repository defined in your set of repo files, make sure to add the corresponding sources repo (or make sure to enable them, if they’re already present). Otherwise, the lockfile generator will not include any SRPMs in your lockfile, cachi2 won’t download any SRPMs and the source container for your build will be incomplete.
285282

286283
. Run the following command to resolve your `rpms.in.yaml` file and produce a `rpms.lock.yaml` file.
287284

288285
+
289-
[source,console]
290-
----
291-
$ BASE_IMAGE=quay.io/fedora/fedora:rawhide
292-
$ rpm-lockfile-prototype --image $BASE_IMAGE rpms.in.yaml <1>
293-
----
286+
include::ROOT:partial$building/{context}-example-prefetch-rpm-execute.adoc[]
294287
<1> The produced `rpms.lock.yaml` file will include only your requested dependency plus its transitive dependencies, minus any rpms that are already installed in the provided base image.
288+
+
289+
Example of generated lockfile:
290+
+
291+
include::ROOT:partial$building/{context}-example-prefetch-rpm-lockfile.adoc[]
292+
+
293+
NOTE: The list of `arches.packages` is omitted for brevity.
295294

296295
. Additionally, pass an extra parameter to the `prefetch-dependencies` task in the `.spec.pipelineSpec.tasks` section to indicate that "dev package managers" should be enabled.
297296

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[source,Dockerfile]
2+
----
3+
FROM quay.io/fedora/fedora:rawhide
4+
RUN dnf -y install cargo
5+
WORKDIR /workdir
6+
ENTRYPOINT ["cargo", "--version"]
7+
----
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[source,console]
2+
----
3+
$ BASE_IMAGE=quay.io/fedora/fedora:rawhide
4+
$ podman run -it $BASE_IMAGE cat /etc/yum.repos.d/fedora.repo > fedora.repo
5+
----
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[source,console]
2+
----
3+
$ BASE_IMAGE=quay.io/fedora/fedora:rawhide
4+
$ rpm-lockfile-prototype --image $BASE_IMAGE rpms.in.yaml <1>
5+
----
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[source,yaml]
2+
----
3+
lockfileVersion: 1
4+
lockfileVendor: fedora
5+
arches:
6+
- arch: aarch64
7+
packages:
8+
- ...
9+
module_metadata: []
10+
- arch: x86_64
11+
packages:
12+
- ...
13+
module_metadata: []
14+
----
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[source,yaml]
2+
----
3+
packages: [cargo] <1>
4+
contentOrigin:
5+
repofiles: ["./fedora.repo"] <2>
6+
arches: [x86_64, aarch64] <3>
7+
----

0 commit comments

Comments
 (0)