Commit Graph

37 Commits

Author SHA1 Message Date
Gábor Stefanik c73d8c9dc1 Add extension mechanism to execute .sh files dropped in /steps/after
These are executed at the end of the bootstrap, if /steps/after exists.
In interactive mode, they run before the interactive prompt is displayed.
2024-04-16 20:53:52 +02:00
Gábor Stefanik ee3ab501da Add rootwait to grub command line to fix USB boot failures
Without this, one of my boards fails to reboot from USB drive due to
slow USB enumeration. Rootwait is not needed during the Fiwix -> Linux
jump, because we use an initramfs there, and the init scripts already
wait for USB drives to show up. Linux->Linux kexec, used with a custom
early kernel, might need it, so add it there as well to be safe.
2024-02-18 17:52:33 +01:00
Gábor Stefanik 11d3605b08 Upgrade Linux kernel to 4.14.336
This is the last LTS version buildable using GCC 4.0.x. The next one,
version 4.19, requires at least GCC 4.6.

Fortunately, this is also the first version of the Linux kernel
without firmware blobs being included in /firmware, so the FSFLA
deblob scripts aren't needed anymore to ensure a fully auditable
kernel - the 3 remaining drivers that do include blobs masquerading
as source code are removed via a patch, avoiding all the other side
effects of the deblob scripts.
This doesn't compromise the trustworthiness of the bootstrapped
environment, since all the other drivers deblob would remove use
the firmware loader mechanism, which does nothing when the actual
firmware blobs aren't installed on the system separately. Features
dependent on firmware still won't work, but many drivers that load
firmware do so only optionally. This includes r8169, the driver for
the Realtek gigabit NICs found on many x86 motherboards.

This kernel is considerably larger than 4.9.10, and we build more
of it (including drivers that would previously get stripped away by
the deblob script, such as r8169), so to accommodate that, Fiwix
initrd size is increased by 64MiB, while lowering kexec space by
the same amount to ensure enough userspace memory available in Fiwix.
Fiwix's maximum open file count is also bumped from 1.5K to 2.5K.

The Documentation folder is deleted before build, to further save
space in the ramdisk.
2024-02-17 15:37:33 +01:00
Gábor Stefanik 32138d13b9 Clean pre-Bash build artifacts before building the Linux kernel
All of these are archived, in a compressed form, in base.tar.bz2.
2024-02-17 15:32:02 +01:00
Gábor Stefanik 4e0a0f03dd Capture everything built before the repo system in a base tarball
Parts built before bash and the repo system are available aren't
stored in a clean repository tarball, so if any early file is
overwritten, it's lost. Fix this by creating a base.tar.bz2 right
after the repo is set up, to hold reference copies of early files.
This tarball isn't checksummed, since it varies considerably with
bootstrap options, but the binaries inside are protected by their
own checksums.
2024-02-17 15:32:02 +01:00
fosslinux 9c1ae45bb8
Merge pull request #436 from Googulator/xz
Support early xz/lzma decompression, and use it wherever possible
2024-02-15 07:51:13 +00:00
Gábor Stefanik 4bc54d83cb Allow grub to autodetect screen resolution
With this, systems without a supported non-vesa FB driver in Linux
(such as Intel integrated graphics) get full resolution after reboot.
2024-02-14 16:02:28 +01:00
Gábor Stefanik 65953732a0 Support early xz/lzma decompression, and use it wherever possible 2024-02-14 14:34:16 +01:00
Gábor Stefanik 009ec57835 Fix typo in make_bootable.sh causing failure to reboot 2024-02-06 19:22:35 +01:00
Gábor Stefanik d50ecd58e8 Improve pseudo-interactive prompts using the early bash
By wrapping $(cat) in an eval, redirections and other advanced
syntax can now work in the early prompts.
Also, since "set -E" is broken is the early bash, fall back to
using "set -e" and an EXIT trap, until we can upgrade to a bash
version that already has working "set -E", or perhaps backport
it to 2.05b.
2024-02-05 10:02:34 +01:00
Gábor Stefanik 6d26855dc6 Support reboot in non-chroot modes using grub and an init script
We use grub-2.06 as 2.12 has some packaging issues, and can't be
built in live-bootstrap for now.
2024-02-04 16:54:13 +01:00
fosslinux 3dee6eab1c
Merge pull request #424 from fosslinux/shadow
Shadow/Users
2024-02-04 03:50:36 +00:00
fosslinux 6c377de2f0 Add basic users and groups 2024-02-01 21:23:16 +11:00
Gábor Stefanik 221f2d0f8e Open shells on virtual terminals for monitoring in interactive mode
We spawn a shell:
- When Bash is first built, on tty2. This shell uses the old Bash,
  so interactive mode needs to be emulated using redirection. Thus,
  entering commands needs to be done using Enter followed by Ctrl+D,
  and certain redirection features are unavailable.
- After moving the system to disk, on tty2. Old Bash, same limitations.
- After 2nd Bash is built, on tty3. This is a fully functional shell.

This is disabled in chroot-like bootstrap modes, or when -i is not set.
2024-01-30 02:50:36 +01:00
Gábor Stefanik 8fca0973ab Fix "no job control in this shell" in final Bash prompt 2024-01-30 02:50:36 +01:00
fosslinux 76217c6b0d Ensure sources are always cleaned the same
Otherwise, in --repo mode, sources are not cleaned identically to how
they are in non --repo mode
2024-01-26 10:29:57 +11:00
fosslinux 7f967fe2dc Cleanup the filesystem at end of bootstrap 2024-01-26 10:29:57 +11:00
fosslinux 3669db9125 Use merged usr throughout the entire bootstrap 2024-01-26 10:29:18 +11:00
fosslinux f71445362e
Merge pull request #408 from Googulator/checksum-fix
Fix Python 3 checksum regression from 8341c4e
2024-01-13 01:06:31 +00:00
Gábor Stefanik 7e73fd25cb Fix Python 3 checksum regression from 8341c4e
The Linux kernel won't autocreate /dev/shm inside devtmpfs.
Without it, semaphores won't work properly in Python.

Previously, /dev/shm was set up in populate_device_nodes, but we
no longer run that after booting into Linux.
2024-01-12 19:58:40 +01:00
Gábor Stefanik 36c1925742 Fix panic due to after.sh prematurely quitting on shutdown
The sysrq shutdown trigger takes some time to fully shut down the system,
during which init is expected to continue running. Since after.sh is the
last step in our init, if it quits before shutdown is complete, Linux will
panic with "Attempted to kill init".

Add an infinite loop after shutdown is issued via sysrq to prevent this.
2024-01-12 19:55:10 +01:00
fosslinux 01a4f90378
Merge pull request #388 from Googulator/kernel-bootstrap-jobs
Restore multicore build support with kernel-bootstrap
2024-01-10 07:16:10 +00:00
Andrius Štikonas 959ea69742
Merge pull request #398 from Googulator/after-fix
Fix spelling of sysrq-trigger in after.sh
2024-01-09 22:45:54 +00:00
Gábor Stefanik 50d1d68f99 Restore multicore build support with kernel-bootstrap
This was removed as part of the simplify refactor, severely slowing
down qemu and bare-metal builds. Restoring it brings us back to the
same build times that we saw before the refactor.
2024-01-08 12:56:15 +01:00
Gábor Stefanik a76fac4fa7 Allow update_env to incorporate runtime changes to bootstrap.cfg
Perform variable substitution at runtime, rather than at generation
time. This way, if bootstrap.cfg changes after update_env, the new
values there take effect immediately.
2024-01-08 12:55:19 +01:00
Gábor Stefanik 82062143a4 Fix spelling of sysrq-trigger in after.sh 2024-01-08 12:43:31 +01:00
fosslinux 9ec45654cf
Merge pull request #390 from Googulator/devtmpfs
Use devtmpfs, and improve finalize_fhs.sh
2024-01-08 10:55:57 +00:00
fosslinux 4a822e231c
Merge pull request #389 from Googulator/after
After bootstrap, drop to a shell if needed, then shut down cleanly
2024-01-08 10:55:21 +00:00
Gábor Stefanik 2a095a3301 After bootstrap, drop to a shell if needed, then shut down cleanly 2024-01-08 05:19:19 +01:00
Gábor Stefanik d5008f93a5 Support swap files in qemu or bare-metal mode
This can help alleviate memory pressure when bootstrapping
with high core counts.
2024-01-02 04:32:08 +01:00
Gábor Stefanik 8341c4e089 Use devtmpfs, and improve finalize_fhs.sh
With this, finalize_fhs.sh can be rerun as needed, e.g. when rebooting.
Also, the preferred nameserver will persist after DHCP.

Thanks to devtmpfs, we no longer need to manage /dev once Linux is up.
2024-01-02 00:15:32 +01:00
Eduardo Sánchez Muñoz 45b635ef97 Do update checksums when building with `--update-checksums` 2023-12-27 12:36:46 +01:00
Eduardo Sánchez Muñoz 9042539165 Avoid deleting sources that will be needed in future builds 2023-12-27 12:36:46 +01:00
Gábor Stefanik 1481ad0d20 Do not try to create /dev nodes under chroot/bwrap 2023-12-26 13:01:24 +11:00
Gábor Stefanik 47711cfea9 Fix non-reproducible Linux kernel build due to timestamps
Linux's KBUILD doesn't follow SOURCE_DATE_EPOCH, but rather it
uses its own variable, KBUILD_BUILD_TIMESTAMP.

While we are at it, also update kexec-linux's checksum, which
didn't match either. (This one was reproducible, it was just
out of date.)
2023-12-25 10:16:17 +01:00
fosslinux ab47483a51 Linters & CI updates 2023-12-15 21:44:43 +11:00
fosslinux 6ed2e09f3a Remove the notion of "sys*"
- This idea originates from very early in the project and was, at the
  time, a very easy way to categorise things.
- Now, it doesn't really make much sense - it is fairly arbitary, often
  occuring when there is a change in kernel, but not from builder-hex0
  to fiwix, and sysb is in reality completely unnecessary.
- In short, the sys* stuff is a bit of a mess that makes the project
  more difficult to understand.
- This puts everything down into one folder and has a manifest file that
  is used to generate the build scripts on the fly rather than using
  coded scripts.
- This is created in the "seed" stage.

stage0-posix -- (calls) --> seed -- (generates) --> main steps

Alongside this change there are a variety of other smaller fixups to the
general structure of the live-bootstrap rootfs.

- Creating a rootfs has become much simpler and is defined as code in
  go.sh. The new structure, for an about-to-be booted system, is

/
-- /steps (direct copy of steps/)
-- /distfiles (direct copy of distfiles/)
-- all files from seed/*
-- all files from seed/stage0-posix/*

- There is no longer such a thing as /usr/include/musl, this didn't
  really make any sense, as musl is the final libc used. Rather, to
  separate musl and mes, we have /usr/include/mes, which is much easier
  to work with.
- This also makes mes easier to blow away later.
- A few things that weren't properly in packages have been changed;
  checksum-transcriber, simple-patch, kexec-fiwix have all been given
  fully qualified package names.
- Highly breaking change, scripts now exist in their package directory
  but NOT WITH THE packagename.sh. Rather, they use pass1.sh, pass2.sh,
  etc. This avoids manual definition of passes.
  - Ditto with patches; default directory is patches, but then any patch
    series specific to a pass are named patches-passX.
2023-12-15 21:43:19 +11:00