Commit graph

83 commits

Author SHA1 Message Date
vxtls
c742563d3b fix(payload): switch raw payload metadata fields from u32 to u64 2026-03-15 13:31:19 -04:00
vxtls
35a570bc4e fix(mirror): bind file mirror server to 0.0.0.0 for qemu guest access via 10.0.2.2 2026-03-03 19:03:02 -05:00
vxtls
d1b466c047 fix(generator): enforce stage-bounded distfile sets before curl/import and stage repo minimally 2026-03-03 09:01:13 -05:00
vxtls
b1642d63bc refactor(generator): enforce manifest-only distfile copy in kernel-bootstrap modes 2026-03-03 08:48:34 -05:00
vxtls
95b25afdcd fix(kernel-bootstrap): place pre-network distfiles back into init image paths 2026-03-03 08:40:58 -05:00
vxtls
85c389044d fix(kernel-bootstrap): unify external raw container flow and remove default second disk 2026-03-03 08:33:19 -05:00
vxtls
beb9fb12f9 refactor+docs(payload.img, payload.img discovery): split offline distfiles at improve: import_payload so main image is minimal and payload.img is primary carrier, detect payload.img automaticly using magic number 2026-03-01 21:05:29 -05:00
vxtls
f30c20b7be fix(kernel-bootstrap): restore kexec-fiwix baseline and move post-fiwix distfiles into raw payload import path
The instability was not caused by kexec-fiwix logic itself but by oversized early-stage payload pressure in kernel-bootstrap mode.
When too many distfiles are injected before the Fiwix handoff, the early memory/file-table assumptions become fragile and KVM can fail during transition.
This change restores kexec-fiwix.c to the known baseline (matching commit 984b8322...) and fixes the actual failure mode by moving non-early distfiles out of the initial image.

What changed:
- Keep only bootstrap-required distfiles in early init image.
- Generate a separate raw payload image (LBPAYLD1 format) for the remaining distfiles.
- Attach payload image as an extra disk in QEMU/bare-metal kernel-bootstrap flow.
- Add a dedicated C89/tcc-compatible importer (payload-import) that scans payload disks and copies files into /external/distfiles after jump: fiwix.
- Insert improve: import_payload immediately after jump: fiwix so the full distfile set is restored before heavy build steps continue.
- Add PAYLOAD_REQUIRED config gating so this behavior is active only in kernel-bootstrap paths that need it.

Why this design:
- Preserves minimal early environment assumptions (no dependency on full shell utilities for the copy operation itself).
- Avoids adding filesystem-construction toolchain dependencies for the payload container by using a simple length-prefixed raw format.
- Keeps bare-metal and QEMU behavior aligned: both can carry full build artifacts without overloading the early handoff stage.
- Leaves kexec-fiwix behavior deterministic and auditable by reverting to a known-good baseline implementation.
2026-03-01 13:45:16 -05:00
vxtls
21ddab36c3 script-generator: support explicit manifest/config roots and wire all callers 2026-02-18 10:14:17 -05:00
Karl Pettersson
e013715f43 Removed trailing whitespace. 2026-01-28 17:31:13 +01:00
Karl Pettersson
3bca91e71e Check image size and pad after closing first with statement. 2026-01-28 17:21:10 +01:00
Samuel Tyler
bbccded731
Use a "real" copyright line 2025-10-17 18:53:10 +11:00
Samuel Tyler
851aa5ed5b Add distfile source type to sources files 2025-10-03 21:32:59 +10:00
fosslinux
ba89224641 Modify GH actions to support mirror 2025-02-02 10:02:32 +11:00
fosslinux
7d50a224c6 Support file:// mirrors
Spawns a simple HTTP server to host the mirror.
Useful for testing mirror support or CI in chroot or bwrap modes.
2025-02-02 10:02:32 +11:00
fosslinux
df1c9e9aba Support mirrors within 2025-02-02 10:02:32 +11:00
Andrius Štikonas
9950b07204 Silence pylint errors. 2024-10-25 18:15:58 +01:00
Googulator
8884d79802
Allow use of base.tar.bz2 from previous build as early preseed
base.tar.bz2 will contain the "steps" and "external" subdirectories, which we later try to create - ensure that they are deleted when restoring an early preseed; this way base.tar.bz2 works without any modification as a preseed tarball
2024-05-22 00:51:07 +02:00
Gábor Stefanik
89a4d18ff0 Support multiple mirrors for each source file
If multiple URLs are entered in a sources listing for the same file,
each will be tried in turn, until either one succeeds, or we fail
having run out of mirrors.
2024-04-14 00:17:41 +02:00
fosslinux
b80e1f6a57 Ensure that substituted files are equivalent to upstream 2024-02-24 20:36:12 +11:00
Gábor Stefanik
6ecd0a79ef Exclude bootstrap-seeds from kernel bootstrap images
In kernel bootstrap mode, the kernel (builder-hex0) includes the
ability to assemble hex0 source code, and to execute basic commands,
obviating the need for the bootstrap-seeds subdirectory.
With the bootstrap-seeds directory excluded, the image consists of
purely source code, with the exception of the boot sector, which is
assembled from hex0 code by rootfs.py, and delivered ready for BIOS
to boot.
2024-02-13 18:31:36 +01:00
Gábor Stefanik
5945bdc1e8 Replace Fiwix filelist with parsing builder-hex0's FS structures
And while we're at it, use a more sustainable way of getting the
address of the next file to be written to.

Since builder-hex0 doesn't distinguish directories from zero-length
files, this has a limitation that it won't copy any zero-length
files or empty directories. Only one such file is important for the
bootstrap process (mes/config.h), which is recreated using an
improve step.
2024-02-06 12:30:24 +01:00
rick-masters
5aa58e34e0 Add -F flag to mkfs to avoid prompt to proceed. 2024-01-29 23:51:52 +00:00
fosslinux
34e4bf9bcc
Merge pull request #381 from eduardosm/disk-images-without-root
Create disk images without root
2024-01-24 01:40:13 +00:00
Gábor Stefanik
2023432c5e Use builder-hex0 stages from submodule
This ends the reliance on the precompiled stage1 image in ootstrap-seeds,
and the locally committed copy of the stage2 hex0 code. Instead, both
stages are taken from the new builder-hex0 submodule, with stage1 compiled
by generator.py on the fly. The local copy of stage2 is dropped.

This way, updating to a newer builder-hex0 becomes much easier: just update
the submodule.
2024-01-21 19:18:21 +01:00
Eduardo Sánchez Muñoz
3f41cab6f7 Only copy no-network distfiles to "init" when --external-source is passed (with kernel bootstrap)
All distfiles are still copied to "external"
2024-01-12 22:39:21 +01:00
Eduardo Sánchez Muñoz
5dbaeaf19b Create disk images without root
`mke2fs` has a `-d` option that allows to populate the newly created filesystem without needing to temporarily mount it. That allows to use `parted` and `mkfs.ext3` on regular files without needing root access.
2024-01-12 22:39:20 +01:00
Andrius Štikonas
754d967b29
Merge pull request #406 from rick-masters/fix-qemu-linux-str-concat
Account for int and NoneType in string concatenations.
2024-01-10 22:39:55 +00:00
Andrius Štikonas
969f42155b
Merge pull request #404 from rick-masters/add-curl-header-for-download
Add curl header to bypass suspected savannah throttling.
2024-01-10 22:36:48 +00:00
rick-masters
82235e5bd0 Account for int and NoneType in string concatenations. 2024-01-10 18:03:50 +00:00
rick-masters
7a0f03678c Add curl header to bypass suspected savannah throttling. 2024-01-10 17:46:15 +00:00
rick-masters
468aeb07a7 Convert status_code to string for error message. 2024-01-10 17:32:06 +00:00
Gábor Stefanik
81e3123262 Rename tmpdir to target and always preserve it, dropping --preserve
There is nothing temporary about our "tmpdir" - its sole purpose is to
contain the final product of the bootstrap process. Thus, removing it
at the end of bootstrap amounts to doing the entire process for nothing.

To remedy this, --tmpdir is renamed --target, keeping the -t short form,
and defaulting to "target" instead of "tmp" to make its purpose clearer.
The --preserve option is removed, as the target is now always preserved.
2023-12-26 16:34:04 +01:00
Gábor Stefanik
f67c7d1144 Tolerate externals/distfiles already existing (needed for CI) 2023-12-26 13:01:24 +11:00
Gábor Stefanik
896c618bd1 Re-copy distfiles on generator.reuse() 2023-12-26 13:01:24 +11:00
Gábor Stefanik
9ed4ae9a59 Support reusing existing directory for multipass bootstrapping 2023-12-26 13:01:24 +11:00
Gábor Stefanik
ab9455f918 Fix warnings in existing code revealed by newer pylint 2023-12-22 13:08:23 +01:00
Gábor Stefanik
be1333ee8b Make tmpdir a method parameter of prepare()
Fixes pylint errors.
2023-12-22 13:08:20 +01:00
Gábor Stefanik
b45e1f81ae Fix failure with --external-sources 2023-12-22 13:07:45 +01:00
Gábor Stefanik
32dc4c702b More verbose error message on HTTP errors 2023-12-22 13:07:45 +01:00
Gábor Stefanik
55d3c36e09 Move kernel-bootstrap source image out of the directory it's generated from
This way, an incomplete version of the image itself won't get included
in srcfs anymore.
2023-12-22 13:07:45 +01:00
Gábor Stefanik
3305f2a41b Use manifest to deduce pre-network sources list
No need to maintain a separate pre-network-sources file anymore,
the list is instead derived from the bootstrap manifest via the
source manifest.
2023-12-22 13:07:04 +01:00
Gábor Stefanik
a68ae62f9e Download distfiles only when needed, based on manifest
Unless --external-sources is given, only download distfiles that
need to be included in srcfs. The rest will be downloaded anyway
by the bootstrap system once it gets network access.

To accomplish this, instead of searching steps for sources files,
we now parse steps/manifest. As a side effect, source_manifest.py
now outputs source files in the order they appear in the manifest.
2023-12-22 13:07:04 +01:00
Gábor Stefanik
b4d9c5e7cb Disk creation improvements
* Support specifying the size of the target disk image for qemu
* For bare metal, only pad the image to the next megabyte
* Use truncate() to extend images, instead of writing zeros (faster)
* Return None from get_disk() with nonexistent name
* Leave 1MiB on non-boot disks, or 1GiB on boot disks, unpartitioned
  (for proper 4K alignment and to help preserve the srcfs or boot
  partition creation)
* Fix qemu invocation when an external.img is not used
* Make -qr work with kernel bootstrap (will need kexec-fiwix fix)
2023-12-22 13:06:19 +01:00
Gábor Stefanik
dc62d8242c Create external.img only when needed 2023-12-22 12:10:09 +01:00
fosslinux
ab47483a51 Linters & CI updates 2023-12-15 21:44:43 +11:00
fosslinux
05c13dd64e Modify rootfs.py infrastructure to support the new layout 2023-12-15 21:43:21 +11:00
rick-masters
4cf2b860ef Fix lint warning for unnecessary else block. 2023-11-27 14:10:37 +00:00
rick-masters
4d20284f85 Return process from run_as_root. 2023-11-27 13:55:05 +00:00
Seppo Yli-Olli
f893df52fe Add a wrapper for commmands needing sudo that checks if you are euid 0 2023-11-08 17:34:56 +02:00