logo

live-bootstrap

Mirror of <https://github.com/fosslinux/live-bootstrap>

README.rst (6217B)


  1. .. SPDX-FileCopyrightText: 2021 Andrius Štikonas <andrius@stikonas.eu>
  2. .. SPDX-FileCopyrightText: 2021 Paul Dersey <pdersey@gmail.com>
  3. .. SPDX-FileCopyrightText: 2021 fosslinux <fosslinux@aussies.space>
  4. .. SPDX-License-Identifier: CC-BY-SA-4.0
  5. live-bootstrap
  6. ==============
  7. An attempt to provide a reproducible, automatic, complete end-to-end
  8. bootstrap from a minimal number of binary seeds to a supported fully
  9. functioning operating system.
  10. How do I use this?
  11. ------------------
  12. Quick start:
  13. See ``./rootfs.py --help`` and follow the instructions given there.
  14. This uses a variety of userland tools to prepare the bootstrap.
  15. (*Currently, there is no way to perform the bootstrap without external
  16. preparations! This is a currently unsolved problem.*)
  17. Without using Python:
  18. 1. ``git clone https://github.com/fosslinux/live-bootstrap``
  19. 2. ``git submodule update --init --recursive``
  20. 3. Consider whether you are going to run this in a chroot, in QEMU, or on bare
  21. metal. (All of this *can* be automated, but not in a trustable way. See
  22. further below.)
  23. a. **chroot:** Create a directory where the chroot will reside, run
  24. ``./download-distfiles.sh``, and copy:
  25. * The entire contents of ``seed/stage0-posix`` into that directory.
  26. * All other files in ``seed`` into that directory.
  27. * ``steps/`` and ``distfiles/`` into that directory.
  28. * At least all files listed in ``steps/pre-network-sources`` must be
  29. copied in. All other files will be obtained from the network.
  30. * Run ``/bootstrap-seeds/POSIX/x86/kaem-optional-seed`` in the chroot.
  31. (Eg, ``chroot rootfs /bootstrap-seeds/POSIX/x86/kaem-optional-seed``).
  32. b. **QEMU:** Create two blank disk images.
  33. * Generate ``builder-hex0-x86-stage1.img`` from hex0 source:
  34. ``sed 's/[;#].*$//g' builder-hex0/builder-hex0-x86-stage1-hex0 | xxd -r -p``
  35. * On the first image, write ``builder-hex0-x86-stage1.img`` to it, followed
  36. by ``kernel-bootstrap/builder-hex0-x86-stage2.hex0``, followed by zeros
  37. padding the disk to the next sector.
  38. * distfiles can be obtained using ``./download-distfiles.sh``.
  39. * See the list in part a. For every file within that list, write a line to
  40. the disk ``src <size-of-file> <path-to-file>``, followed by the contents
  41. of the file.
  42. * *Only* copy distfiles listed in ``sources`` files for ``build:`` steps
  43. manifested before ``improve: get_network`` into this disk.
  44. * Optionally (if you don't do this, distfiles will be network downloaded):
  45. * On the second image, create an MSDOS partition table and one ext3
  46. partition.
  47. * Copy ``distfiles/`` into this disk.
  48. * Run QEMU, with 4+G RAM, optionally SMP (multicore), both drives (in the
  49. order introduced above), a NIC with model E1000
  50. (``-nic user,model=e1000``), and ``-machine kernel-irqchip=split``.
  51. c. **Bare metal:** Follow the same steps as QEMU, but the disks need to be
  52. two different *physical* disks, and boot from the first disk.
  53. Background
  54. ----------
  55. Problem statement
  56. =================
  57. live-bootstrap's overarching problem statement is;
  58. > How can a usable Linux system be created with only human-auditable, and
  59. wherever possible, human-written, source code?
  60. Clarifications:
  61. * "usable" means a modern toolchain, with appropriate utilities, that can be
  62. used to expand the amount of software on the system, interactively, or
  63. non-interactively.
  64. * "human-auditable" is discretionary, but is usually fairly strict. See
  65. "Specific things to be bootstrapped" below.
  66. Why is this difficult?
  67. ======================
  68. The core of a modern Linux system is primarily written in C and C++. C and C++
  69. are **self-hosting**, ie, nearly every single C compiler is written in C.
  70. Every single version of GCC was written in C. To avoid using an existing
  71. toolchain, we need some way to be able to compile a GCC version without C. We
  72. can use a less well-featured compiler, TCC, to do this. And so forth, until we
  73. get to a fairly primitive C compiler written in assembly, ``cc_x86``.
  74. Going up through this process requires a bunch of other utilities as well; the
  75. autotools suite, guile and autogen, etc. These also have to be matched
  76. appropriately to the toolchain available.
  77. Why should I care?
  78. ------------------
  79. That is outside of the scope of this README. Here’s a few things you can
  80. look at:
  81. - https://bootstrappable.org
  82. - Trusting Trust Attack (as described by Ken Thompson)
  83. - https://guix.gnu.org/manual/en/html_node/Bootstrapping.html
  84. - Collapse of the Internet (eg CollapseOS)
  85. Specific things to be bootstrapped
  86. ----------------------------------
  87. GNU Guix is currently the furthest along project to automate
  88. bootstrapping. However, there are a number of non-auditable files used
  89. in many of their packages. Here is a list of file types that we deem
  90. unsuitable for bootstrapping.
  91. 1. Binaries (apart from seed hex0, kaem, builder-hex0).
  92. 2. Any pre-generated configure scripts, or Makefile.in’s from autotools.
  93. 3. Pre-generated bison/flex parsers (identifiable through a ``.y``
  94. file).
  95. 4. Any source code/binaries downloaded within a software’s build system
  96. that is outside of our control to verify before use in the build
  97. system.
  98. 5. Any non-free software. (Must be FSF-approved license).
  99. How does this work?
  100. -------------------
  101. **For a more in-depth discussion, see parts.rst.**
  102. Firstly, ``builder-hex0`` is launched. ``builder-hex0`` is a minimal kernel that is
  103. written in ``hex0``, existing in 3 self-bootstrapping stages.
  104. This is capable of executing the entirety of ``stage0-posix``, (see
  105. ``seed/stage0-posix``), which produces a variety of useful utilities and a basic
  106. C language, ``M2-Planet``.
  107. ``stage0-posix`` runs a file called ``after.kaem``. This is a shell script that
  108. builds and runs a small program called ``script-generator``. This program reads
  109. ``steps/manifest`` and converts it into a series of shell scripts that can be
  110. executed in sequence to complete the bootstrap.
  111. From this point forward, ``steps/manifest`` is effectively self documenting.
  112. Each package built exists in ``steps/<pkg>``, and the build scripts can be seen
  113. there.