Commit graph

62 commits

Author SHA1 Message Date
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
Andrius Štikonas
26552a928f Increase disk size to 16G. 2023-05-20 12:46:22 +01:00
Eduardo Sánchez Muñoz
c143e65154 Pass --unshare-net to bwrap when building with --external-sources
Ensures that when `--external-sources` is used, the build does not require a working internet connection.

`--unshare-net` is always passed for the sysa phase.
2023-04-13 18:52:37 +02:00
Andrius Štikonas
d83f810773 Pylint fixes. 2023-02-01 22:17:57 +00:00
fosslinux
51b0bf8405 Rework tmpdir & associated a bit.
- Split out tmpdir logic into a separate entity & add the appropriate
  arguments and checks.
- sysb can be removed since there is now no associated logic.
- Move disk/etc logic into tmpdir.py.
2023-01-28 16:51:00 +11:00
Andrius Štikonas
77b64a0585 parts.rst: add more verbose description of stage0-posix. 2023-01-21 01:26:36 +00:00
Dor Askayo
a1c8c0312c Download source files using a source manifest 2023-01-13 23:38:18 +02:00
Dor Askayo
425beee8dd Always pass file name to download_file()
Move the file name decision to get_packages() when a file name is not
specified in the package source file.
2023-01-13 19:41:32 +02:00
Dor Askayo
38e5dfe35b Pass destination directory to download_file() 2023-01-13 16:21:56 +02:00
fosslinux
10a55522a2 Change sources getting method.
- Rather than defining the urls where they are gotten (python sysa,
  python sysc, inside sysc), a spec file is now used that is easily
  interpretable and tool-independent.
- This is interpreted by rootfs.py and inside sysc.
- This is also used to make sources available and extract sources.
- Manual dirname selection is no longer required as is tarball renaming
  upon download - all of this is handled automatically.

Fixes #188
2022-10-02 09:48:20 +11:00
Dor Askayo
43a8cc6b50 Add a timeout in requests.get() 2022-09-07 22:35:43 +03:00
fosslinux
25f37ba926 Various fixes from rebase
This took a while so a bunch of stuff got broken in rebase.
2022-06-18 09:10:11 +10:00
fosslinux
0ce50a6393 Add options for;
- disk to be created (blank disk given to live-bootstrap) (default)
- disk to already exist but sources downloaded within live-bootstrap
- sources to be downloaded outside live-bootstrap (non-blank disk given
  to live-bootstrap)

Also migrate sysb to use sys_transfer in QEMU mode also.

Note that this means copy_sysc is now irrelevant. sysc is *always*
sourced from sysa.
2022-06-10 13:33:16 +10:00
fosslinux
6ea1b8e295 Add e2fsprogs 1.45.7
Additionally, fix downloading in chunks for some files.
2022-06-10 13:30:58 +10:00
Andrius Štikonas
625c844779 Fix pylint. 2022-06-03 21:43:49 +01:00
Dor Askayo
8330ab4504 Add an option to avoid creating a tmpfs in prepare()
Root access is required for creating tmpfs mounts in the context of
the current mount namespace, and creating a tmpfs in the context of a
new mount namespace is less useful because a process in the parent
namespace can't easily access it.

So add an option to avoid creating tmpfs mounts, which will be used by
the rootless bootstrap mode for now.

In addition, when tmp directories aren't mounted as tmpfs, their
contents can't be removed using os.umount(). So instead remove them
recursively using shutil.rmtree().
2022-05-27 11:45:09 +03:00
Andrius Štikonas
9d15314ebc Checksum source tarballs during bootstrap. 2022-05-21 23:49:37 +01:00
Dor Askayo
c9868f4312 Add -P to the losetup command
It seems to be required for partitions to be recognized.
2022-05-10 22:37:52 +03:00
fosslinux
f1600467a7 Variety of improvements
- Rename sources to distfiles for clarity.
- Per sys(a/c) distfiles to reduce rootfs.py processing and reduce RAM
  usage in sysa.
- Canonicalise early kaem mes/tcc files to kaem script conventions.
- Cleanup unused setup in python.
2022-05-05 17:44:47 +10:00
Andrius Štikonas
5b032cb46c rootfs.py refactoring.
Switch to bzip2 packages
Move most of the preprocessing done by rootfs.py
into kaem and bash scripts inside live-bootstrap.
2022-04-21 00:49:56 +01:00
fosslinux
9543a47f1b Fix up checksums + other fixes 2022-03-12 16:23:24 +11:00
fosslinux
4fb8efafe2 Use sudo for losetup -f.
This is required in some environments.
2022-03-07 19:02:12 +11:00