@@ -309,3 +309,106 @@ spec:
309309``` 
310310
311311Then ` oc rsh pods/cosa `  and you should be able to ` ls -al /dev/kvm `  - and ` cosa build `  etc!
312+ 
313+ ## I'm a contributor investigating a CoreOS bug. How can I test my fixes?  
314+ 
315+ If you're a contributor unfamiliar with how CoreOS is built or provisioned and
316+ you're looking at fixing a bug in an RPM component (thank you!), here's the
317+ minimum you need to know to get started debugging and iterating on CoreOS. This
318+ requires access to podman and /dev/kvm.
319+ 
320+ 1 .  First, download the latest QEMU CoreOS image. If you're handling a bug
321+    report from someone on the CoreOS team, they may have asked you to download a
322+    specific image. Otherwise, for Fedora, you can get the latest from
323+    https://fedoraproject.org/coreos/download  or by using coreos-installer:
324+ 
325+    ``` bash 
326+    #  as privileged
327+    podman run --privileged --rm -v .:/srv -w /srv quay.io/coreos/coreos-installer:release \
328+        download --decompress -p qemu -f qcow2.xz
329+    #  as unprivileged, but relabeling the working directory
330+    podman run --rm -v .:/srv:z -w /srv quay.io/coreos/coreos-installer:release \
331+        download --decompress -p qemu -f qcow2.xz
332+    ``` 
333+ 
334+    For RHCOS, you can get an image from the OpenShift mirrors at
335+    https://mirror.openshift.com/pub/openshift-v4/x86_64/dependencies/rhcos/ .
336+    If you are a Red Hat employee, you can also access development builds not yet
337+    available on the mirrors from the RHCOS release browser.
338+ 
339+ 2 .  Run the VM:
340+ 
341+    ``` bash 
342+    #  as privileged
343+    podman run --privileged --rm -ti -v .:/srv quay.io/coreos-assembler/coreos-assembler \
344+        run --bind-ro /srv,/var/srv fedora-coreos-40.20240519.3.0-qemu.x86_64.qcow2
345+    #  as unprivileged, but relabeling the working directory and passing /dev/kvm
346+    podman run --rm -ti -v .:/srv:z --device /dev/kvm quay.io/coreos-assembler/coreos-assembler \
347+        run --bind-ro /srv,/var/srv fedora-coreos-40.20240519.3.0-qemu.x86_64.qcow2
348+    ``` 
349+ 
350+    This will mount the working directory at /srv as read-only in the VM so that you
351+    can more easily pass data into it.
352+ 
353+ 3 .  Modifying the OS:
354+ 
355+    Once you're in the VM, you can test your changes multiple ways.
356+ 
357+    (1) One universal way is to build a custom RPM, and put it in the mounted
358+    directory, then use ` rpm-ostree override replace /srv/path/to/my.rpm ` . You
359+    can then either reboot, or ` rpm-ostree apply-live `  to have the change apply
360+    immediately.
361+ 
362+    (2) Alternatively, you can do ` rpm-ostree usroverlay `  to make the rootfs writable. Then
363+    you can do e.g. ` rpm -Uvh /srv/my.rpm `  for example as you would on a traditional system.
364+    Or at this point, you can directly rsync over the output from your local
365+    project build. E.g. assuming your build system uses a Makefile and it
366+    supports ` DESTDIR= ` , on your host, you can do
367+    ` make install DESTDIR=/path/to/mounted/dir/subdir ` , and in the VM, ` rsync -av /srv/subdir/ / ` .
368+ 
369+    (3) Another [ newer approach] ( https://containers.github.io/bootable/ )  is to build
370+    a derived container image with your changes. For example, to customize the rawhide image,
371+    you can build a Containerfile like:
372+ 
373+    ``` Dockerfile 
374+    FROM  quay.io/fedora/fedora-coreos:rawhide
375+    #  using a locally built RPM
376+    COPY  my.rpm /
377+    RUN  dnf install /my.rpm && dnf clean all
378+    #  or using project output directly from a `make install DESTDIR=installtree/
379+    COPY  installtree/ /tmp
380+    RUN  rsync /tmp/ / && rm -rf /tmp
381+    ``` 
382+ 
383+    You can build this image, then copy it to the VM as an OCI archive:
384+ 
385+    ``` 
386+    podman build -t localhost/my-image . 
387+    skopeo copy containers-storage:localhost/my-image oci-archive:/path/to/mounted/dir/my.ociarchive 
388+ ``` 
389+ 
390+    And then on the VM:
391+ 
392+    ``` 
393+    rpm-ostree rebase ostree-unverified-image:oci-archive:/srv/my.ociarchive 
394+ ``` 
395+ 
396+    (4) That said, sometimes you just have to build FCOS/RHCOS from scratch. In that case, follow
397+    the steps in https://coreos.github.io/coreos-assembler/building-fcos/  and see
398+    the other sections on this page for ways to modify inputs (e.g. custom RPMs or rootfs content).
399+    But roughly, the flow looks something like this:
400+ 
401+    ``` bash 
402+    cosa init https://github.com/coreos/fedora-coreos-config
403+    #  copy any modifications in e.g. the overrides/rpm directory
404+    cp /path/to/my.rpm overrides/rpm/
405+    #  or overrides/rootfs directory
406+    (cd /path/to/my/project &&  make install DESTDIR=/path/to/overrides/rootfs)
407+    cosa fetch &&  cosa build
408+    #  to run the freshly built image
409+    cosa run
410+    #  to build the live ISO
411+    cosa buildextend-metal &&  cosa buildextend-live --fast
412+    #  to run the live ISO
413+    cosa run -p qemu-iso
414+    ``` 
0 commit comments