Commit Graph

174 Commits

Author SHA1 Message Date
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
Sayan Chowdhury
c1bdbd9d90 build_image_util: Sign the vmlinuz with the shim key
Signed-off-by: Sayan Chowdhury <schowdhury@microsoft.com>
2024-02-26 12:01:10 +01:00
Kai Lueke
5590da400e build_image_util: Store path list for recreating tmpfiles rules
The removal of files in the overlay present in the lowerdir creates
whiteout entries that mask the lowerdir entries. For those files that
have a tmpfile rule for creation, a reboot would cause the file to be
created in the upperdir, meaning this file is not updated from the
lowerdir when it changes. In addition we have filtered out some tmpfile
rules that caused upcopies (symlinks and directories) which meant that
removing the /etc/resolv.conf symlink didn't bring it back after reboot.
To make files from the lowerdir show up if they have a tmpfile rule that
normally would recreate them we keep a list of whiteout entries that we
clean up on boot. This also prevents freezing files because
systemd-tmpfiles does not need to recreate them in the upperdir.
2023-11-30 11:57:27 +01:00
Thilo Fromm
b775036a62 torcx removal: address PR comments
- updated github actions for runc, containerd, and docker to not handle
  nonexistent ebuilds in app-torcx/ anymore
- removed spurious package_run_dependencies from build_image_util.sh
- build_sysext: generate pkginfo before mangle script runs
  use zstd for compression; add cli flag to select compression
- ci_automation_common.sh: remove spurious `/` from match string
- coreos, board-packages, bootengine: bump ebuild revisions
- kernel commonconfig: add squashfs zstd support

Signed-off-by: Thilo Fromm <thilofromm@microsoft.com>
2023-10-23 16:05:45 +02:00
Thilo Fromm
89555ed2bd base OS sysexts: separate build script, inventory generation
This change refactors base OS sysext builds to use a separate build
script `build_library/sysext_prod_builder`, which is called from
`build_library/prod_image_util.sh` when `build_image` runs.

This allows for better separation of cleanup traps: prod image sysext
builds need its own trap / cleanup function for temporary build
directories and loopback mounts.

Prod sysext builds properly generate lincense and SBOM information, and
provide detailed file listings and disk space usage stats.

- SBOM / licenses JSON now include all packages of the
  final image, i.e. a combined list of base image and all base OS
  sysexts.
- Packages lists, files list and detailed files list include the sysext
  squashfs files for the base image, and separate sections with files /
  packages lists for each sysext.
- Disk usage contains both final disk image usage as well as usage of
  each individual sysext squashfs.
2023-10-23 16:05:45 +02:00
Thilo Fromm
8e01a2c8f9 build_image: add sysext command line option
This change refactors sysext builds during build_image and generalises
the code (no hard-coded containerd and docker anymore).

A command line option is added to build_image for sysexts to include in
the OS image. It defaults to containerd and docker but may be set to
arbitrary packages. The command line supports simple depenencies, i.e.
the "docker" sysext will re-use package information from the
"containerd" sysext and not include another containerd.

Signed-off-by: Thilo Fromm <thilofromm@microsoft.com>
2023-10-23 16:05:45 +02:00
Thilo Fromm
8f8f262f19 torcx: remove from scripts, use docker+containerd sysexts
This change removes torcx libraries, references, and commandline options
from build automation scripts and from build_library/.

Containerd and docker are shipped via sysexts which are included in the
base image.

Signed-off-by: Thilo Fromm <thilofromm@microsoft.com>
2023-10-23 16:05:45 +02:00
Krish Jain
3c4639b0ce use sudo_clobber function 2023-10-23 16:05:45 +02:00
Krish Jain
298e283944 fix permissions issue 2023-10-23 16:05:45 +02:00
Krish Jain
4633cc3e7c Fix syntax errors, quoting 2023-10-23 16:05:45 +02:00
Krish Jain
f6f5c32417 add information about the packages contained in the built sysext 2023-10-23 16:05:45 +02:00
Krish Jain
fe949f5900 Make sure binary packages are built in build_packages already 2023-10-23 16:05:45 +02:00
Krish Jain
4e8b276319 Remove duplicate making directory root_fs_dir/etc/extensions 2023-10-23 16:05:45 +02:00
Krish Jain
abe8bf683a Use helper function query_available_package() 2023-10-23 16:05:45 +02:00
Krish Jain
4b00bc14a4 tail, not head 2023-10-23 16:05:45 +02:00
Krish Jain
9709a64239 incorporate suggestions from Jeremi 2023-10-23 16:05:45 +02:00
Krish Jain
2be2e884b3 Add manglefs script for containerd 2023-10-23 16:05:45 +02:00
Krish Jain
3d17f65088 Create seperate docker and containerd sysext 2023-10-23 16:05:45 +02:00
krishjainx
851009c6cc Install docker as a system extension, use manglefs script ( convert the unit dependencies from wants to upholds); one sysext for all docker for now 2023-10-23 16:05:45 +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
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
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
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
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
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
Krzesimir Nowak
520b92ad7e *: Expand short emerge flags and use bash arrays
Emerge flags are cryptic in general, but short flags even more so, so
expand them. While at it, I noticed some places where bash arrays
could be used, so convert those places too.
2023-02-16 13:57:05 +01:00
Krzesimir Nowak
edc90b4e59 build_library: Add generation of disk space usage
This could replace an ad-hoc calculations we do in package-diff.
2023-02-01 14:43:24 +01:00
Krzesimir Nowak
1c1c0099c7 build_library: Generate content files for initrd too 2023-02-01 14:43:24 +01:00
Krzesimir Nowak
f4829fd860 build_library: Add generation of image contents with different details
Timestamp and user/group information are out, in are device ID and
inode number. That way, the file can be used for accounting size
differences of files/image.
2023-02-01 14:43:24 +01:00
Krzesimir Nowak
375ffa6579 common.sh: Drop the unnecessary hack
We have a user patch in coreos-overlay fixing this issue directly in
gcc-config.
2023-01-12 08:37:57 +01:00
Krzesimir Nowak
97bf185815 common: Extend liblto link fixup function
We need to fix another symlink created by gcc-config, so extend the
function that was doing it for some other links and rename it - it's
not about only liblto any more.
2022-11-09 10:13:24 +01:00
Kai Lueke
91a26e5e1e Use new github org name "flatcar"
The "flatcar-linux" github org was renamed to "flatcar". There are no
github redirections in place and we have to update all links.
2022-09-14 14:33:27 +02:00
Kai Lueke
e171ecd69d Fix broken docs link 2022-09-14 14:32:49 +02:00
Jeremi Piotrowski
dc21dda002
Merge pull request #378 from flatcar-linux/slsa-provenance-by-default
Generate SLSA provenance by default
2022-08-15 13:39:13 +02:00
Jeremi Piotrowski
3f39f48389 build_library: install initramfs/torcx SLSA reports into rootfs
Some packages are currently missing from the /usr/share/SLSA directory
compared to flatcar_production_image_packages.txt. For torcx packages,
extract the reports from the torcx bundle when adding it to the rootfs.
For initramfs packages, as a substitute we enumerate build dependencies
of coreos-kernel (image_packages_implicit()). At this time these are
bootengine and intel-microcode.
2022-07-27 13:00:20 +02:00
Jeremi Piotrowski
d3edc97063 build_image: use syft to generate SBOM for prod image
Since v0.51.0 syft supports generating parsing the gentoo package
database. This is a first go at integrating that into our image build
process. This doesn't yet include packages inside torcx packages, or the
kernel, or initramfs-only packages.
2022-07-15 11:52:33 +00:00
Krzesimir Nowak
e65072910d build_library: Try to clean up unused stuff
There is some cruft left after grub hashes generation. After the
contents are zipped into archive, they don't need to be around any
more.

Try to remove the rootfs directory after unmounting the
image. disk_util can recreate it again if there is a need for it.

Remove the build directory used for generating ACI images - it's not
needed after successful installation.
2022-07-14 15:08:12 +02:00
Gabriel Adrian Samfira
f126debb37 Allow specifying multiple compression formats
Add the ability to specify a comma separated list of compression formats.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2022-03-07 12:01:21 +00:00
Jeremi Piotrowski
f8efad73bf
Merge pull request #231 from flatcar-linux/jepio/build-image-disable-ebuild-locks
build_library/build_image_util: disable ebuild-locks when merging binary packages.
2022-02-22 13:52:46 +01:00
Jeremi Piotrowski
4cdacf5ae4 build_library/build_image_util: disable ebuild-locks when merging binary packages
Disable ebuild-locks for the emerge command that creates the image.
Ebuild-locks protect unsandboxed ebuild phases from running
concurrently, but also slow things down greatly when a lot of
concurrency would otherwise be possible. The image build phase merges a
big amount of binary packages, and I am not aware of us having any
phases that risk concurrently modifying shared files.

I have been testing this for the last months and have not seen any
failures. The time savings are significant: this cuts image build time
from 20m to 10m for me.

Signed-off-by: Jeremi Piotrowski <jpiotrowski@microsoft.com>
2022-02-22 09:42:42 +00:00
Kai Lueke
cc509e77d3 build_library: move package sysusers to /usr database
Package users nowadays get created through systemd-sysuser files.
Gentoo uses the acct-user|groups packages to allocate stable IDs for
these users. Since they get created at runtime, we have the problem
that they end up in /etc/passwd at boot time which would be fine if
they follow the acct-user allocations but it could also be that there
is a package that uses its own sysuser files, leading to dynamic ID
allocation which we can't control and may result in ugly user ID
mismatches that are hard to resolve again. Normally we intend to ship
all system users under /usr/share/baselayout/passwd so that /etc/passwd
is really left to the user's own entries.
Generate the /etc/passwd sysuser entries at image build time and move
these entries over to /usr/share/baselayout/passwd so that all
system users reside in this database. We should still ensure to have
acct-user packages for all system users or at least hardcoded user
IDs, therefore, add a check for that.
2022-02-18 16:57:42 +01:00
Krzesimir Nowak
96b37b89f8 *: Replace kinvolk github org with flatcar-linux
Stop relying on github redirects, they are a mixed blessing and using
them broke emerge-gitclone inside dev-container in silent way. The
script could not find a desired revision of portage-stable or
coreos-overlay, because it tried to pull from kinvolk instead of
flatcar-linux github org. The redirects seem to hinder fetching a
specific commit, so the script pulled something else (HEAD or main?).
2021-12-21 17:22:48 +01:00
Krzesimir Nowak
ba29a29717 build_library: Ignore more categories in write_licenses
acct-user and acct-group categories aren't licensed too.
2021-09-28 17:55:17 +02:00
Krzesimir Nowak
b6c6a05404 build_library: Fix python script extension
It's not a shell script. It never was a shell script. Must have been a
mistake to name it as such.
2021-08-18 18:57:04 +02:00
Dongsu Park
34cb6d305a build_library: support multi-arch in generate_au_zip
To be able to support arm64 native SDK without cross builds, we should
make generate_au_zip support both architectures, amd64 and arm64.
Without doing that, `build_image` fails with `ERROR : Required
WHITE_LIST items ld-linux-x86-64.so.2 not found!!!`, because the
script recognizes only amd64 libs in WHITE_LIST.

We should first determine the architecture in build_image, before
running generate_au_zip, and pass the architecture, either amd64 or
arm64. Also add allow_list and ld_linux parameters to necessary
functions.
2021-08-13 10:03:33 +02:00
Kai Lüke
c1b2d88aa2 build_image_util.sh: delete vmlinuz file from /usr partition
The vmlinuz kernel image gets installed to /usr/boot/ but isn't usable
for dm-verity until it gets copied over to /boot/flatcar/ and the hash
gets embedded at a particular offset. The file in /usr/boot/ uses space
while it's not having a real purpose as long as dm-verity is used.

Delete the vmlinuz file under /usr/boot/ to free up space. When
generating the ISO image we use the vmlinuz file from /boot/flatcar/
which also has the advantage that we only distribute a single vmlinuz
file with one particular checksum.
2021-07-28 20:59:16 +02:00
Kai Lüke
d0cf1a4d19 disk_util: support compressed btrfs filesystems
The limited /usr and OEM partiton size is a challenge when adding new
packages or updating a package. Since the disk layout can't be changed
for compatibility reasons when updating an existing instance, we can't
simply try out something without ensuring first that enough space is
there by removing something else. This situation can be relaxed by
leveraging btrfs compression. There was some support for btrfs but it
was a bit outdated and didn't allow to configure compression or setting
read-only flags.
Fix the btrfs support, allow to mark the default subvolume as read only
and add a compression variable that allows to select a compression
algorithm. Instead of enabling compression by setting the mount option,
we can set the filesystem attribute which has the benefit that
compression is still used with the default mount options for this (top)
directory and its contents. While for the ext2 /usr partition a hack
existed to force read-only mode by modifying some bytes and checking
these bytes could also be used to know if read-only should be used to
prevent corruption of dm-verity data, we rather check directly whether
dm-verity is active for this partition and mount it read-only (and
with the norecovery option to really prevent any write attempt).
2021-07-27 14:08:42 +02:00
Kai Lüke
177bea4a74 Generate test update payload and run the kola update test
The kola update tests need a dev-key-signed update payload. This was
lacking and caused the update tests to be skipped.
Generate the test update payload for both dev builds and release builds
and run the kola tests for both. The test update payload has a special
name to not confuse it with the real update payload for releases, and
we keep the previous behavior to sign releases. Therefore, the
generate_update function wasn't used but the extract_update function
extended with generating the additional test payload.
2021-07-12 18:49:54 +02:00