Commit Graph

1056 Commits

Author SHA1 Message Date
Krzesimir Nowak
c23dde1713 build_library/grub_install: Try mounting ESP directory in a loop
Apparently successful `[[ -b "${LOOP_DEV}p1" ]]` check is not enough -
the mount can still fail. So instead of doing those checks, try
mounting and reprobing in the loop with some small exponential
backoffs.
2023-10-13 08:38:11 +02:00
Mathieu Tortuyaux
b36cb28768
overlay coreos-base/oem-packet: migrate to sysext format
Signed-off-by: Mathieu Tortuyaux <mtortuyaux@microsoft.com>
2023-10-09 14:35:08 +02:00
Mathieu Tortuyaux
989d20a2f1
overlay core-base/oem-digitalocean: migrate to sysext format
Signed-off-by: Mathieu Tortuyaux <mtortuyaux@microsoft.com>
2023-10-09 14:35:07 +02:00
Mathieu Tortuyaux
57e7b5aebc
overlay coreos-base/oem-openstack: add oem-openstack
Signed-off-by: Mathieu Tortuyaux <mtortuyaux@microsoft.com>
2023-10-09 14:35:07 +02:00
Thilo Fromm
17512925e7 SDK prefix: implement suggestions from code review
- remove explicit "-multilib" from prefix keywordsas it is set in
  profile
- split heredoc for generating emerge wrapper so we don't need to
  escape
- add sys-apps/bubblewrap and virtual/tmpfiles to package update
  automation list
- use prefix build fix for libgpg-error from upstream

Signed-off-by: Thilo Fromm <thilofromm@microsoft.com>
2023-09-29 15:22:45 +02:00
Thilo Fromm
ba4342d2b7 Apply suggestions from code review
Thank you @krnowak! Great review and awesome feedback, as always.

Co-authored-by: Krzesimir Nowak <knowak@microsoft.com>
2023-09-29 15:22:45 +02:00
Thilo Fromm
a4d4a94068 Flatcar SDK: add experimental prefix builds
This change adds experimental prefix builds to the Flatcar SDK.

Prefix builds use a custom sys prefix path and emerge all binaries and
runtime dependencies into that prefix.

This path can then e.g. be shipped as a portable sysext since it
includes all dependencies, and has libraries at a custom path so these
do not conflict with libraries on target systems.

Prefix uses a staging environment (path) featuring a full-blown
development environment, and a "final" environment for installing.
Staging and final need to be created using setup_prefix first,
which will also create an emerge wrapper to emerge ebuilds into staging
and subsequently final. The root fs in final may then e.g. be used to
create a distro independent, portable sysext.

Co-authored-by: James Le Cuirot <chewi@gentoo.org>
Co-authored-by: Jeremi Piotrowski <jpiotrowski@microsoft.com>
Co-authored-by: Thilo Fromm <thilofromm@microsoft.com>
2023-09-29 15:22:45 +02:00
Mathieu Tortuyaux
ce2c0e7475
overlay coreos-base/oem-ami: new sysext image
Signed-off-by: Mathieu Tortuyaux <mtortuyaux@microsoft.com>
2023-09-26 13:34:09 +02:00
Kai Lüke
9ffceaf3fe
Merge pull request #1132 from krishjainx/qcow2-inline-compression
Allow use qcow2 inline compression
2023-09-25 17:37:15 +02:00
Krzesimir Nowak
fa3dc6b649 build_library/vm_image_util: Opt VMware OEM into sysext images 2023-09-20 09:18:43 +02:00
Krzesimir Nowak
7b2199c24a build_library/build_image_util: Fix locale generation
The `localedef` tool expects `/usr/lib/locale` directory to
exist. This directory used to be created by the `sys-libs/glibc`
package (with the `keepdir` directive), but after the update of the
package, the locale generation stuff (and the `keepdir` directive )was
moved to the `sys-libs/locale-gen` package. This package is not
installed in the production images, so the `/usr/lib/locale` directory
was not created. In such a situation, calling localedef to generate
C.UTF-8 locale resulted in an error like:

cannot create temporary file: ${SOME_ROOTFS}/usr/lib/locale/locale-archive.ufpG15: No such file or directory

Create the directory before calling localedef to fix the problem.
2023-09-15 16:14:29 +02:00
Kai Lueke
d711725fe0 vm_image_util: Fix variable quoting to create correct OEM sysext file
The OEM sysext image file in the OEM partition had the version variable
name being part of the filename instead of the substituted version value
because of wrong quoting when the fixed string got replaced by ${…}.
2023-09-14 11:46:40 +02:00
krishjainx
2124f63dcb Allow use qcow2 compressed format in place of additional compressed layer 2023-09-12 11:21:08 -04:00
Kai Lueke
995ae2cdbc Support OEM systemd-sysext images and Flatcar extensions
The vendor tools on the OEM partition weren't updated. We now want to
ship them as systemd-sysext images which we can easily update. This
change extends the Flatcar A/B update mechanism to cover the OEM
systemd-sysext images. The same mechanism is also able to support
"official" Flatcar extensions, e.g., a ZFS extension.
2023-09-08 14:50:43 +02:00
Sayan Chowdhury
abb6bdb682
build_library/grub: Remove the grub modules not ported/removed
Signed-off-by: Sayan Chowdhury <schowdhury@microsoft.com>
2023-08-24 13:22:41 +05:30
Krish Jain
fadf4c2ebc Check the url in get_sdk_binhost before echoing
When running the build_packages script, one can encounter an error such as
'Error fetching binhost package info from.' This pertains to SDK packages (not
board packages). Since we have transitioned to the SDK container, the SDK
packages are no longer published independently from the container image.
2023-07-17 15:03:18 +05:30
Thilo Fromm
1f2706d44e build_sysext: guess image build dir and auto-create it
Signed-off-by: Thilo Fromm <thilofromm@microsoft.com>
2023-07-07 14:49:50 +02:00
Thilo Fromm
190fd2c38e build_sysext: bugfixes, QoL changes, help updated
This change improves build_sysext by sourcing a missing lib dependency,
adding a number of comfort / quality-of-life options, and updating the
output of '--help' accordingly.

The OEM sysext finction in build_library/vm_image_util.sh is also
updated to use new command line format.

1. Include missing dependency toolchain_util.sh to fix an error in
   board_options.sh (get_board_arch undefined).
2. Use positional parameters for mandatory arguments.
   build_dir and sysext_name are mandatory and are now positional
   arguments instead of options.
   binary_package is the third positional argument but can be omitted
   if --metapkgs was specified.
3. --squashfs_base is now guessed better and will use the most recent
   build by default.
4. A new boolean flag --ignore_version_mismatch for the more daring
   developer was added. The flag will cause the script to continue if a
   version mismatch between SDK board packages and squashfs base is
   detected.
5. Error messages were improved for when mandatory parameters were not
   provided.
6. The '--help' message was improved and adjusted to the new parameters.

Signed-off-by: Thilo Fromm <thilofromm@microsoft.com>
2023-07-07 11:44:39 +02:00
Krzesimir Nowak
00ac7586a4 *: Remove support for niftycloud OEM 2023-07-05 14:34:17 +02:00
Krzesimir Nowak
ad0360e744 *: Remove support for interoute OEM 2023-07-05 14:33:26 +02:00
Krzesimir Nowak
2c1d89277d *: Drop unused oem sysext files 2023-07-05 08:43:25 +02:00
Krzesimir Nowak
ec723be9d9 *: Drop unused pkgdb stuff 2023-07-05 08:43:25 +02:00
Krzesimir Nowak
16fee4f5b1 build_library/vm_image_util.sh: Switch OEM sysext image building to build_sysext 2023-07-05 08:43:25 +02:00
Krzesimir Nowak
8c2883114a build_library/vm_image_util.sh: Set up a path to sysext base image 2023-07-05 08:40:15 +02:00
Kai Lüke
eb2f3d543d
Merge pull request #920 from krishjainx/sysext-internship
Build_sysext script to enable sysext builds in the OS image build process
2023-07-04 13:37:43 +02:00
krishjainx
6380a43b4f Add script to enable sysext builds in the OS image build process
Included a script to enable generating systemd-sysexts. Successfully
tested sysext generation with a fresh Flatcar image (e.g., Python and
Neofetch system extension). Part of my internship work.

The current OS images we provide are not OK as base for flatcar specific
sysext images: it lacks the package metadata and portage configuration,
in order to keep end user OS image clean. This script retains this
information and allows you to produce systemd-sysexts to extend the
system. This script can be used to build a Flatcar sysext image.
Recommended to run from image build folder.

Signed-off-by: Krish Jain <kjain7@u.rochester.edu>
2023-07-04 13:30:48 +02:00
Jeremi Piotrowski
b2a4a5f0d7 oem_sysext_util: Mount overlay on top of /usr before installing sysext packages
After changes to the inode size, the sysext installation runs out of
space because the installation happens on a mounted production image.
This is problematic because the /usr partition is only 1024MB in size
and gets full. Mount a temporary overlay so that we can use that for
installation, and discard it afterwards.

This also means we no longer need to disable verity and in fact could
live without copying the prod image. I won't make that change since
we're working on a new script to automate building of sysexts using the
overlay approach.

Signed-off-by: Jeremi Piotrowski <jpiotrowski@microsoft.com>
2023-06-23 12:44:11 +00:00
Jeremi Piotrowski
7205c2d742 build_library/disk_util: Switch default ext4 inode size to 256 bytes
Inode sizes smaller than 256:
- don't support extended metadata (nanosecond timestamp resolution)
- cannot handle dates beyond 2038
- are deprecated

Change the default from 128 to 256. There is no way to apply this change on a
mounted filesystem so this change will only apply to new deployments.

Fixes: flatcar/flatcar#1082
Signed-off-by: Jeremi Piotrowski <jpiotrowski@microsoft.com>
2023-06-21 13:30:20 +02:00
Kai Lueke
af4daf3516 Upload dev-key-signed OEM sysext update payload
For release tests and updating a machine to a dev build we already have
the dev-key-signed generic update payload but not yet the OEM sysext
update payload.
Generate the dev-key-signed OEM sysext update payload during build and
upload it.
2023-06-14 18:30:48 +02:00
Kai Lueke
f790e3e648 build_library: For now don't use a version for the OEM sysext image
The initial MVP of the OEM sysext usage we release won't have updates
for the sysext image and, therefore, it is not bound to the OS version.
The special name suffix instead of the version hints bootengine at using
it if no matching version is found. The name will also be used at hint
for update-engine to clean it up when versioned sysext images arrive.
2023-06-14 13:00:30 +02:00
Krzesimir Nowak
23df3170ff build_library: Force initial version of OEM sysexts for now
We don't have an update process of the OEM sysexts implemented yet, so
use a fake "initial" version for them and make them independent from
OS version.
2023-06-06 15:10:07 +02:00
Krzesimir Nowak
8b17ca2b02 overlay coreos-base/oem-qemu: Make it a sysext package
It isn't doing much as nothing QEMU-specific was being installed into
the OEM partition.

With that done, we opt into building an OEM sysext image for QEMU
platform.
2023-06-06 15:10:07 +02:00
Krzesimir Nowak
995910cd78 overlay coreos-base/oem-azure: Make it a sysext package
This package will be used for the sysext image, instead of for
installing files into /usr/share/oem. This means that we can drop some
files or move them elsewhere. The systemd service file is not needed,
because it is installed by the app-emulation/wa-linux-agent package
now. This also means that the ignition file as lost its purpose. The
grub.cfg and oem-release must be installed in /usr/share/oem, next to
the sysext raw image file, so handling of these files is moved to the
newly added coreos-base/common-oem-files package. `eject` symlink to
`/usr/bin/true` is installed in the newly added manglefs.sh script.

With this done, we also opt into building an OEM sysext image for
Azure platform.
2023-06-06 15:10:07 +02:00
Krzesimir Nowak
46b98ba0d2 image_to_vm: Require pkgdb tarball and handle sysext building 2023-06-06 13:01:09 +02:00
Krzesimir Nowak
a5ecf0d79f build_library/prod_image_util.sh: Generate a tarball with portage database
Will come in handy when generating OEM sysexts. We can mount the
generic image, put the image database back into the image and emerge
extra packages without the need to drop all DEPENDS and BDEPENDS from
the ebuilds.
2023-06-06 13:01:09 +02:00
Krzesimir Nowak
86d7eb5894 *: Add OEM sysext building utilities 2023-06-06 13:01:09 +02:00
Krzesimir Nowak
5105ed5677 build_library: Move report function to a separate file
I'd like to use them in other places, and I don't need all the other
stuff build_image_util.sh provides.
2023-06-06 13:01:09 +02:00
Krzesimir Nowak
706356c459 build_library/disk_util: Add btrfs UUID randomizing
This is necessary if we want to mount a copy of the production image.
2023-06-06 13:01:09 +02:00
Krzesimir Nowak
33d2af5600 build_library: Adapt to /oem being the new OEM partition mountpoint
This requires us to add another directory to keep when removing a
regenerable state from rootfs. Other changes were straightforward find
and replace.
2023-05-30 15:53:17 +02:00
Krzesimir Nowak
60aded12f5 build_library/catalyst.sh: Fix and extend snapshot handling
- Fix the snapshot name, it is not "portage-${VERSION}", but rather
  "gentoo-${VERSION}".

- After building the snapshot, remove all the similar files from the
  snapshots directory - Catalyst gets easily confused by them and
  bails out.

- Extend the `build_snapshot` function to optionally accept the config
  path and the snapshot name, so SDK's stage1 code can use this
  function instead of duplicating parts of it.
2023-05-25 12:35:29 +02:00
Krzesimir Nowak
120a746c88 build_library/catalyst.sh: Make some variables local 2023-05-24 13:50:50 +02:00
Krzesimir Nowak
27f20f6e26 build_library/build_image_util.sh: Remove temporary /etc backup
The temporary /etc backup created during emerging packages should only
contain empty files that will make sure that the symlinks pointing to
files within the /etc backup won't dangle at any time.
2023-05-11 12:29:48 +02:00
Krzesimir Nowak
bd2bf6acec build_library/check_root: Silence a warning about cgi.py
The python's minor version has now two digits.
2023-05-11 12:29:48 +02:00
Krzesimir Nowak
979d7d0720
Merge pull request #748 from flatcar/krnowak/blocker-fix
update_chroot: Fix some non-fatal error noise
2023-05-03 09:47:53 +02:00
Krzesimir Nowak
076e6940e2 build_library/build_image_util.sh: Split base_image_var.conf into two
We used to create a base_image_var.conf tmpfiles config file that
contained information about directories under /var that weren't
covered by any other tmpfiles config file. Recently some package
update started installing a directory under /var that belonged to a
user/group not found directly in passwd/group file in /etc. This
user/group was defined in passwd/group in /usr/share/baselayout, but
at the early boot, these are not yet checked for user/group
information, so systemd-tmpfiles running inside initrd failed when
trying to create such an entry using the base_image_var.conf tmpfiles
config file.

Split the base_image_var.conf into two files - base_image_var.conf and
base_image_var_late.conf. The former will only contain entries owned
by user/group that are supposed to exist very early in the boot, while
the latter will contain the rest of directories - those will be
created later during the boot.
2023-04-26 15:39:58 +02:00
Krzesimir Nowak
5bc546919f build_library/gen_tmpfiles.py: Add options for allowed users and groups
This will generate tmpfiles config only for directories that are owned
by an allowed user and group if such are passed. Not passing any
allowed users or groups, allows any user or group.
2023-04-26 15:39:58 +02:00
Krzesimir Nowak
1d589ca9d8 build_library/update_chroot_util.sh: Ignore equery's non-zero exit status
The `list` command of `equery` will exit with status 3 if a package is
not found and `--quiet` is in effect. This results in some non-fatal
noise during the SDK build:

INFO    update_chroot: Maybe removing some hard blocks
ERROR   update_chroot: script called: update_chroot '--toolchain_boards=arm64-usr' '--usepkg' '--nousepkgonly' '--getbinpkg'
ERROR   update_chroot: Backtrace:  (most recent call is last)
ERROR   update_chroot:   file update_chroot, line 250, called: remove_hard_blocks 'sudo_e_emerge' 'equery' 'dev-python/setuptools_scm:2'
ERROR   update_chroot:   file update_chroot_util.sh, line 49, called: get_versions_from_equery 'equery' 'dev-python/setuptools_scm'
ERROR   update_chroot:   file update_chroot_util.sh, line 9, called: die_err_trap '"${equery_cmd}" --quiet --no-color list --format='${version} ${fullversion}' "${pkg}"' '3'
ERROR   update_chroot:
ERROR   update_chroot: Command failed:
ERROR   update_chroot:   Command '"${equery_cmd}" --quiet --no-color list --format='${version} ${fullversion}' "${pkg}"' exited with nonzero code: 3
INFO    update_chroot: No hard blockers to remove

Shut the noise up. If package is not found, then there is simply
nothing to do.
2023-04-26 07:49:56 +02:00
Thilo Fromm
401af830d1 scripts, CI, workflows: remove submodule handling (main) 2023-04-13 12:26:36 +02:00
Kai Lueke
54958b813e Drop more tmpfiles rules that cause /etc upcopies
We already drop tmpfile rules that we don't need because we ship the
files through our /etc overlay. However, some rules weren't dropped
because they used tabs and not spaces (/etc/selinux/, /etc/iscsi and
/etc/ssl/*).
Drop rule lines for /etc that use tabs. Also rules modifiers like ! to
only do it during boot or - to allow failure will be removed but those
with + or = will stay as they to explicit recreation.
2023-03-31 11:36:18 +09:00
Kai Lueke
b723d2f15a Ship /etc from /usr through an overlay mount
The existing tmpfile logic took care of folders that the ebuild keepdir
directive wanted to exist on the OS. However, files and symlinks were
not created, causing them to be missing if we didn't explicitly modify
the ebuild files in coreos-overlay to use tmpfiles or patching of
paths to be in /usr. We need a logic to provide /etc files from the
current /usr partition without getting stale. This can be done best
with an overlay mount which requires to keep the original /etc files
under /usr.
Move the final /etc folder of the image build to /usr/share/flatcar/etc
to serve as lower layer in the overlay. Also remove any state from the
rootfs to make sure that we don't rely on it when testing our images
before the release. What we get with an overlay mount is essentially a
similar behavior to a 3-way merge because as long as the user didn't
change the files, the old version is replaced with the new version and
as soon as the user did changes, that file is frozen and wins over the
provided old (in case of a rollback) or new versions from /usr. It does
not work on file lines but on whole file contents, yet that is also
what rpm-ostree does to my knowledge. Also, run tmpfiles once and do
the SELinux labeling to prevent files being created in the upperdir
because they were missing in the lowerdir, or because they had missing
SELinux labels.
2023-02-24 18:41:53 +09:00