Commit Graph

1156 Commits

Author SHA1 Message Date
Jeremi Piotrowski
ff6279a6b0 build_library: Don't preserve file ownership when copying sysext files
The docker and containerd copy files from the repository, which are owned by
the sdk user. This ownership leaks into the final image, which means the first
created user could edit systemd files. This is bad.

Modify the cp invocation to copy files without preserving ownership. The
sysext-mangle script is called by build_sysext, which is executed using sudo.

Signed-off-by: Jeremi Piotrowski <jpiotrowski@microsoft.com>
2024-08-30 09:16:25 +02:00
Thilo Fromm
1b7c0c2ecc build_sysext: Detect dev rebuild of release tag, fix build ID issue
build_sysext uses a base squashfs (basically a full snapshot of the
Flatcar OS image) to build custom sysexts on top. Before building it
ensures the base image actualy matches the OS version in the repository
root.

The version string includes a BUILD_ID which might be auto-generated (by
including common.sh) if it is not present in the version file - e.g.
when the version is an official release (tag). This build ID
auto-generation causes issues with the version check when image build
and sysext build scripts run independently - each will generate its own
build ID, and this will cause build_sysext's version check to fail.

build_sysext will now use the build id from the base squashfs when it is
not set in the source tree's version.txt to work around that issue. This
is a more general solution than 361eda220b
(which this patch reverts) as it directly addresses the issue in
build_sysext instead of working around it in sysext_prod_builder.

Signed-off-by: Thilo Fromm <thilofromm@microsoft.com>
2024-08-29 10:39:07 +02:00
James Le Cuirot
16563bb411
Fix the initrd option in the QEMU launcher script
It was -R, but this was already taken by the read-only pflash option, so
use -r instead.

Signed-off-by: James Le Cuirot <jlecuirot@microsoft.com>
2024-08-16 17:04:07 +01:00
James Le Cuirot
8e5b5af225
dev-lang/rust: Drop our custom package in favour of upstream Gentoo's
It is not clear why this was forked originally. One reason was to avoid
the sys-apps/lsb-release dependency, but it probably wasn't just that.
It seems likely that the upstream package did not support cross targets
at the time. Now it does.

It appears that LTO was previously enabled by us following Gentoo rather
than through an explicit decision. They now disable it by default, so we
do likewise. It previously used "fat" LTO, which makes Rust especially
slow to build and reportedly made rustc slower than with "thin" LTO!
There seems little benefit in using thin LTO given that we rebuild Rust
almost as much as the packages that use it, plus we don't enable LTO
anywhere else.

We still avoid rustdoc to keep the size down using INSTALL_MASK. This
isn't as good as not building it in the first place, but this alone
isn't worth keeping a fork.

Cross targets are now handled via the admittedly experimental
RUST_CROSS_TARGETS support. This has been in place for a while, and I
think it is fairly widely used now. If it does disappear, it would
almost certainly be for something even better.

This also updates Rust from 1.80.0 to 1.80.1.

Signed-off-by: James Le Cuirot <jlecuirot@microsoft.com>
2024-08-15 16:54:11 +01:00
Krzesimir Nowak
83c4cdcf44 build_library: Shrink the sysext-python image by removing python tests
Do the same thing we did for GCE and Azure.
2024-08-14 17:25:31 +02:00
James Le Cuirot
6d4692b159
sys-devel/sysroot-wrappers: Drop as Gentoo's gcc will handle sysroot
It will patch gcc to respect ESYSROOT when cross-compiling, effectively
adding the --sysroot flag without the use of flags or wrappers. This
hasn't been merged into Gentoo yet, but it has been given the nod. When
it does get merged, it was only be for newer gcc versions than we're
currently using, so we'll need this user patch in the meantime
regardless.

Signed-off-by: James Le Cuirot <jlecuirot@microsoft.com>
2024-08-08 16:40:50 +01:00
James Le Cuirot
5ab0ba0d21
Create user-patches symlink in the Catalyst stage 4 fsscript
Otherwise packages subsequently built by this script do not have the
patches applied.

Signed-off-by: James Le Cuirot <jlecuirot@microsoft.com>
2024-08-08 16:13:35 +01:00
James Le Cuirot
7d85ee75da
Skip Catalyst stage2 as recommended by upstream Gentoo
From https://wiki.gentoo.org/wiki/Catalyst/Stage_Creation#Build_Stage3:

> It is not necessary to build stage2 in order to build stage3. Gentoo
> release engineering does not build stage2, and you should not need to
> unless you're intentionally building a stage2 as your goal.

We can now sync portage-stable/scripts with upstream because
bootstrap.sh is only used during stage2, and the changes we had are no
longer relevant. It seems likely the changes were already redundant
anyway.

Signed-off-by: James Le Cuirot <jlecuirot@microsoft.com>
2024-08-01 13:31:56 +01:00
James Le Cuirot
389610f832
Drop Catalyst package.use.force for alternatives
These flags normally need to be temporarily forced during stage1, but we
already force them permanently in our profiles.

Removing this appears to make build_library/portage redundant, but it
will later be used to allow building under QEMU with Catalyst, and it
could have other uses too.

Signed-off-by: James Le Cuirot <jlecuirot@microsoft.com>
2024-07-22 14:08:57 +01:00
Dongsu Park
29f7c259bd
Merge pull request #2069 from flatcar/buildbot/monthly-glsa-metadata-updates-2024-07-01
Monthly GLSA metadata 2024-07-01
2024-07-22 10:13:49 +02:00
James Le Cuirot
2ba2b0236d
Move Catalyst upgrade inside catalyst_init and add --jobs option
catalyst.sh is a library file, so it shouldn't upgrade Catalyst until
actually taking action.

Signed-off-by: James Le Cuirot <jlecuirot@microsoft.com>
2024-07-17 11:24:20 +01:00
Dongsu Park
ea7ca345f0 test_image_content: add GLSA 202407-05 to allowlist
Add GLSA 202407-05 to allowlist, because ebuild of sys-auth/sssd already
has a custom patch to fix CVE-2021-3621.
2024-07-17 09:41:24 +02:00
James Le Cuirot
186f31168c
Upgrade to (at least) Catalyst 4 before trying to run Catalyst
The changes to support Catalyst 4 are not backwards compatible and we
need a seamless transition for builds in CI.

Signed-off-by: James Le Cuirot <jlecuirot@microsoft.com>
2024-07-15 14:28:05 +01:00
James Le Cuirot
872ea6d14d
Don't use repo snapshots for stage1 by updating seed the new way
This is what upstream Gentoo does. They would previously update the
entire seed, but this took a long time. Our seeds are much bigger, so we
kept repo snapshots to build stage1 against these instead. The new
method of only rebuilding packages with changed sub-slots is a good
compromise and removes the need to write stage1 hooks that selectively
catch the repository up.

This also avoids some conflicts by adding the `--ignore-world` option.
Gentoo seeds have nothing in @world. We have much more, but none of that
is needed for stage1.

This continues to exclude cross-*-cros-linux-gnu/* as that is not needed
for stage1. It now also excludes dev-lang/rust, because it is never a
DEPEND, so it would not break other packages in this way. It may fail to
run due to a sub-slot change in one of its own dependencies, but it is
also unlikely to be needed in stage1 and it is not configured to use the
system LLVM. If needs be, we could improve the behaviour of Portage's
@changed-subslot to respect `--with-bdeps`.

In my testing, it was unable to handle an SDK from 17 months ago, but
one from 7 months ago did work. In practise, we will always use a much
more recent one, which is far more likely to work.

Signed-off-by: James Le Cuirot <jlecuirot@microsoft.com>
2024-07-15 14:28:03 +01:00
James Le Cuirot
1d7d53fad9
Upgrade to Catalyst 4
Catalyst 4 has totally changed the way repositories are handled. It only
works when the name of the directory containing the repository matches
the configured name of that repository. This was not the case for us,
with the coreos repository residing in the coreos-overlay directory. We
wanted to move and rename our repositories anyway, but this is a big
change, so we'll do separately. For now, this just renames coreos to
coreos-overlay.

Catalyst 4 also ingests the main repository snapshot as a squashfs
rather than a tarball. It features a utility to generate such a
snapshot, but it doesn't fit Flatcar well, particularly because it
expects each ebuild repository to reside at the top level of its own git
repository. It was very easy to call tar2sqfs manually though.

Signed-off-by: James Le Cuirot <jlecuirot@microsoft.com>
2024-07-15 14:27:59 +01:00
Thilo Fromm
361eda220b sysext_prod_builder: fix build id mismatch
This change fixes a version mismatch of FLATCAR_BUILD_ID when performing
a dev build of an existing release tag. The build ID is part of the
version string of dev builds, separated by a "+" from the main version.
If common.sh detects a dev build (COREOS_OFFICIAL != 1) and
FLATCAR_BUILD_ID is empty, common.sh will generate a new ID based on a
timestamp.

For official releases, FLATCAR_BUILD_ID is not set in version.txt. A dev
build of a release tag would make common.sh generate a new ID each time
it is sourced by different processes. build_image sources common.sh
first, and writes the resulting version string the OS image's
os-release file. build_sysext runs later and also sources common.sh,
leading its version check to fail as its own VERSION now differs from
the version of the OS image it's supposed to generate sysexts for.

This change reads BUILD_ID from the OS image rootfs in
sysext_prod_builder and exports FLATCAR_BUILD_ID accordingly before
calling build_sysext. Hence FLATCAR_BUILD_ID is not empty, so common.sh
in build_sysext will not re-generate it.

Signed-off-by: Thilo Fromm <thilofromm@microsoft.com>
2024-06-25 11:44:24 +02:00
James Le Cuirot
6732c23e8b
Merge pull request #2047 from flatcar/chewi/drop-cros-eclasses
Drop cros-debug + cros-workon eclasses, new flatcar_workon tool, fix 9999 Cargo ebuilds
2024-06-21 14:45:15 +01:00
James Le Cuirot
26c2e935c1
Drop cros-workon.eclass and replace with git-r3.eclass
The cros_workon tool has been replaced with a simpler flatcar_workon
tool based around git-r3.

Signed-off-by: James Le Cuirot <jlecuirot@microsoft.com>
2024-06-21 10:47:50 +01:00
Adrian Vladu
e7d9faadc8 grub_install: Remove core grub modules from EFI partition for i386-pc
The image also boots on Hyper-V Generation 1 VM (BIOS) if the modules
are removed.

Signed-off-by: Adrian Vladu <avladu@cloudbasesolutions.com>
2024-06-21 11:04:35 +03:00
Jeremi Piotrowski
0624d8cc4a grub_install: Remove core grub modules from EFI partition
Since we build them into the grub executable, they are not needed on
disk. The only case I am unsure of is legacy BIOS boot, so left those
on disk.

Signed-off-by: Jeremi Piotrowski <jpiotrowski@microsoft.com>
Signed-off-by: Adrian Vladu <avladu@cloudbasesolutions.com>
2024-06-21 11:04:35 +03:00
Jeremi Piotrowski
14f1c4f735 grub_install: Remove core.{elf,efi} after copying
We currently carry multiple copies of the same grub core.elf or core.efi
on the boot partition. Save some space by removing duplicates that are
never used at runtime. CPIO build needed to be adapted because it
publishes grub efi files.

Signed-off-by: Jeremi Piotrowski <jpiotrowski@microsoft.com>
2024-06-21 11:04:35 +03:00
Mathieu Tortuyaux
441e10bec5
oem: provide akamai images
Signed-off-by: Mathieu Tortuyaux <mtortuyaux@microsoft.com>
2024-06-19 15:37:57 +02:00
Jendrik Weise
64c9ed5820 sysext: Add python sysext
Minimal sysext containing dev-lang/python and dev-python/pip.
Enabled ensurepip for python and added required packages from Gentoo.
2024-05-29 19:18:18 +02:00
Jendrik Weise
cd849d6849 sysext: Add podman sysext
Enabled user session dbus in base image to support podman rootless mode.
Extension images can now be created from multiple packages by seperating
them with a comma. The podman sysext includes app-containers/podman and
net-misc/passt.
It can be enabled by adding podman to /etc/flatcar/enabled-sysext.conf.
Potential TODO: gpgme had to be added as BDEPEND to podman ebuild.
2024-05-03 22:59:36 +09:00
Adrian Vladu
6efe345d89 image: add kubevirt image build
As Ignition supports KubeVirt, add a custom oem for it and also the
required parts to be able to build an image in .qcow2 format that
is already using internal .qcow2 gzip compression.

Fixes: https://github.com/flatcar/Flatcar/issues/1358

Signed-off-by: Adrian Vladu <avladu@cloudbasesolutions.com>
2024-04-30 09:19:16 +03:00
Mathieu Tortuyaux
9f02c8d262
vm_image_util: produce qcow2 images for Scaleway
For importing Scaleway images, extension needs to be '.qcow2'

See: https://www.scaleway.com/en/docs/compute/instances/how-to/snapshot-import-export-feature/
> Make sure that the QCOW / QCOW2 image file you want to import,
> uses the file extension .qcow or .qcow2 to avoid issues while importing the image.

Signed-off-by: Mathieu Tortuyaux <mtortuyaux@microsoft.com>
2024-04-26 09:47:29 +02:00
Mathieu Tortuyaux
5c2a8cf8b9
vm_image_util: add IMAGE_DISK_EXTENSION variable
This variable allows to override the disk extension which is initially
based on the DISK_FORMAT.

Signed-off-by: Mathieu Tortuyaux <mtortuyaux@microsoft.com>
2024-04-26 09:47:29 +02:00
Jeremi Piotrowski
f53f1af51e grub_install: Add btrfs to core modules
The OEM partition is on a btrfs file system and grub has to be able to
read grub.cfg from there so it makes sense to include btrfs in core
modules. This avoids all other fs modules from being autoloaded during
boot.

Signed-off-by: Jeremi Piotrowski <jpiotrowski@microsoft.com>
2024-04-25 12:20:19 +02:00
Jeremi Piotrowski
e78a59cc65 grub_install: Use hd0,gpt1 as a hint when searching for root
In the context of load.cfg in the memdisk, root is set to memdisk, so
passing it as a hint to search is not helpful. While we don't know for
sure whether hd0 is the boot disk, it's a safe hint for most situations.

Signed-off-by: Jeremi Piotrowski <jpiotrowski@microsoft.com>
2024-04-25 12:20:19 +02:00
Mathieu Tortuyaux
0d4031a6d8
Merge pull request #1880 from apricote/hetzner
OEM: Provide Hetzner Images
2024-04-17 15:17:33 +02:00
Kai Lueke
2e3f175fc1 build_library: Use original qemu image name in qemu script
The move to symlinking to the qemu-uefi image also resulted in the
qemu-uefi image being referenced in the qemu-bios and qemu-uefi-secure
scripts instead of referencing the image symlinks. Same for the VM name
shown in the qemu window title.
When generating the qemu scripts, use the original qemu image name and
VM name.
2024-04-17 12:19:08 +09:00
Julian Tölle
48c81bc978 oem: provide hetzner images 2024-04-16 17:08:04 +02:00
Kai Lueke
dcd7ee6fc4 Silence mksquashfs warnings by excluding btrfs attributes
When mksquashfs encounters btrfs attributes which indicate that the file
is transparently compressed, it can't embed this info in the squashfs
and prints a warning about that.
Silence the warnings by excluding btrfs attributes as done already in
the rest of the code base. This aligns the mksquashfs invocation in this
regard.
2024-04-15 20:15:05 +09:00
Kai Lüke
de3a39b39c
Merge pull request #1861 from flatcar/kai/grub-tpm
build_library/grub.cfg: Enable TPM module by default
2024-04-10 13:20:27 +02:00
Kai Lueke
286a8ca4c1 Skip non-UEFI qemu image symlink/script for arm64
We didn't generate this before and don't need it.
2024-04-10 16:42:36 +09:00
Kai Lueke
834d32efa8 build_library/grub.cfg: Enable TPM module by default
For binding a secret to the OS we need TPM PCRs that measure the kernel
and boot configuration (UEFI). Used for:
https://github.com/flatcar/flatcar-website/pull/317
2024-04-09 22:17:18 +09:00
Kai Lueke
de4eb8f755 Set up symlinks for same image artifacts to remove qemu/qemu_uefi_secure
The qemu and qemu_uefi_secure images have the same contents as the
qemu_uefi image which wastes space on the release server. A similar
case is the PXE vmlinuz which is the same as the regular one, too.

Set up symlinks for same images, and also detect this when compressing
to set up symlinks there as well. To reduce complexity, the qemu and
qemu_uefi_secure images are not supported anymore and the Jenkins or
GitHub CI will skip over them if specified. Users that build their own
images need to adapt, though.
2024-04-09 15:09:29 +02:00
Adrian Vladu
7d4917d67c image_to_vm: add support for hyper-v vhdx format
Add support for Gen 2 Hyper-V VMs.

`./image_to_vm` tool has now a new supported format: `hyperv_vhdx`,
that produces .vhdx dynamic disks.

How to use:

```bash
 ./image_to_vm.sh --from ../build/images/amd64-usr/developer-latest/ --format hyperv_vhdx
```

See: https://github.com/flatcar/Flatcar/issues/1009

Uses PR: https://github.com/flatcar/bootengine/pull/92

Signed-off-by: Adrian Vladu <avladu@cloudbasesolutions.com>
2024-04-09 10:52:06 +03:00
Kai Lueke
5e7b4b6b3d qemu_template.sh: Allow parameters for kernel and initrd
With the PXE script it is easy to boot different versions from one
folder without any copies because the kernel and PXE initrd are always
"fresh".
Instead of only supporting hardcoded file names, support parameters for
the kernel and initrd file to be used.
2024-04-04 16:53:08 +09:00
Kai Lueke
9d3200bc47 build_library/qemu_template.sh: Add notes for swtpm init commands
For the swtpm version in Ubuntu some init command is required first.
2024-04-04 16:53:08 +09:00
Kai Lueke
71866e4824 qemu_template.sh: Allow parameters for VM pflash firmware
The qemu UEFI and regular qemu script only differ by having a default
value for the firmware. If one tries to switch between different
firmwares one normally would modify the script.
Make it easier to switch boot modes and use custom firmwares by
supporting a flag to set the pflash contents.
2024-04-04 12:55:37 +09:00
Kai Lueke
48780dc375 qemu_template.sh: Add support for attaching a software TPM
For testing TPM2-backed rootfs encryption it is handy to have a software
TPM option for the qemu script.
Add a flag for a software TPM with swtpm like kola also does. The user
has to specify a folder for the secret state and this won't be removed
because the same store should be able to be passed when booting the VM
again after shutdown.
2024-04-04 12:55:37 +09:00
Kai Lueke
7379db37e8 vm_image_util.sh: Bump default VM memory to 2 GB
While Flatcar itself runs fine with 1 GB, many workloads do not and
having to debug this is time consuming when one forgets to bump the VM
memory, e.g., in the Qemu script.
Default to 2 GB as known-good setting for things like Kubernetes or
setting up LUKS devices.
2024-04-04 12:55:37 +09:00
Kai Lueke
4d5e46432a qemu_template.sh: Allow parameters for VM image and memory
When testing multiple images one always has to copy them to the
expected file name, and when trying to run two VMs this means one needs
to either use separate directories or modify the qemu script. One also
needs to modify the qemu script to bump the memory for K8s or for LUKS.

Support parameters for the VM image name and the VM memory.
2024-04-04 12:55:37 +09:00
Kai Lueke
1513f3a966 Remove ACI image building bits
The ACI OEM container image was used with rkt for GCE. For long time
this has been migrated to systemd-nspawn and now systemd-sysext.
Remove the unused build library code.
2024-04-03 16:18:56 +09:00
Jeremi Piotrowski
9b50112c5a build_library: Reduce xattr spam when creating cpio
Mksquashfs running against a btrfs filesystem tries to capture btrfs specific
xattrs (btrfs.compression) generating a lot of spam. Remove the spam by
ignoring btrfs xattrs.

Signed-off-by: Jeremi Piotrowski <jpiotrowski@microsoft.com>
2024-03-15 09:26:36 +01:00
Jeremi Piotrowski
0eb0bb38e8 build_library: Use lbzip2 to decompress gcc binpkg
Speeds things up a bit.

Signed-off-by: Jeremi Piotrowski <jpiotrowski@microsoft.com>
2024-03-14 17:50:21 +00:00
Kai Lüke
e5867917ec
Merge pull request #1742 from flatcar/jepio/zfs-sysext
Build ZFS sysext with each release
2024-03-13 23:24:30 +01:00
Jeremi Piotrowski
61c3af32fa
Merge pull request #1730 from flatcar/jepio/btrfs-opt
Mount btrfs fs with rescue= option
2024-03-12 15:05:08 +01:00
Jeremi Piotrowski
1ec40b2dac build_library: create_prod_sysexts: Move artifacts to BUILD_DIR
Putting things in a sysexts subdir results in the same layout on
bincache and does not follow the expected url schema for fetching the
sysext.

Signed-off-by: Jeremi Piotrowski <jpiotrowski@microsoft.com>
2024-03-11 21:03:16 +01:00