Commit Graph

139 Commits

Author SHA1 Message Date
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
Krzesimir Nowak
6ed7cd66d5 *: Drop jobs parameter
The `--jobs` parameter that some scripts defined was not used anywhere
in jenkins or mantle. So the value of the parameter always ended up
being equal to `${NUM_JOBS}` set by `common.sh`. Also, even if the
`--jobs` parameter was used for some script, that script usually
didn't forward the jobs value to other scripts, so the other scripts
ended up using `${NUM_JOBS}` again. Also, the `${FLAGS_jobs}` variable
was used by some functions in the build library, and those functions
were sometimes invoked by scripts that didn't define the
`${FLAGS_jobs}` variable. It is tedious to track which script should
actually define the parameter, and where it should be forwarded.

Just get rid of this half-working pretense. If you want to affect how
many jobs `emerge` uses, export the `NUM_JOBS` environment variable
before calling any script.

For `EMERGE_FLAGS` and `REBUILD_FLAGS` we unconditionally specify the
`--jobs` flag's value to `${NUM_JOBS}` because they are passed to
`emerge`. On the other hand we drop the `--jobs` parameter from the
`UPDATE_ARGS` variable, because this variable passed to `setup_board`
or `update_chroot`, which don't have this flag any more.
2021-02-17 13:26:36 +01:00
Kai Lüke
bd34d059f3 Fall back to source repository license files if not in portage
When a license file is newly added, portage may not yet have it in the
shared folder and the license inclusion step fails.
Fall back to the source repositories and look for the license file
there, too. Print a warning if not found instead of failing to build.
2021-01-20 17:03:05 +01:00
Krzesimir Nowak
45d3a0d9a9 build_library: Fix git URLs
The repos were moved to kinvolk. Redirects still work, but it's better
not to rely on them.
2021-01-19 17:31:17 +01:00
Thilo Fromm
22b08b0ae4 build_packages, build_image_util.sh: fix up liblto symlink
Signed-off-by: Thilo Fromm <thilo@kinvolk.io>
2020-11-16 19:06:59 +01:00
Kai Lüke
3dadf125c8
Filter out unicode characters in package content list
For some unicode characters in ca-certificates file names "rev" complains
about an "invalid or incomplete multibyte or wide character"
and gives no output.
Filter out any unexpected characters for "rev" and replace them with "?"
so that "ls some?name" will still resolve the original name.
2020-06-11 18:00:12 +02:00
Kai Lüke
c7ad59e28c
build_library: Enhance license info and store it on the image
The license JSON file did only include the package names but not
any other metadata. Also since the file was not on the image itself,
it had to be downloaded.
Add more metadata to the license JSON and store it on the image.
2020-06-09 21:09:44 +02:00
Flatcar Buildbot
c7bbb2b1e2 2345.0.0 2019-12-04 14:59:11 +01:00
Flatcar Buildbot
1dad511f69 2317.0.1 2019-11-07 19:40:01 +01:00
David Michael
2467923d56 Remove arm64 from supported board operations 2018-10-25 16:00:09 +00:00
Benjamin Gilbert
b1beff7462 build_library: upload kernel config as release artifact
It's useful to have this information available without starting an
image or digging up a binpkg.
2017-11-09 01:28:03 -08:00
David Michael
8fde256e45 build_library: Add torcx source packages to the package list
This includes the source package of all torcx packages that are
installed on disk, including cases where multiple versions of the
same package are available.
2017-09-11 15:32:11 -07:00
Euan Kemp
d3867403ed build_image: populate torcx store from manifest
This moves the default symlinking logic into build image as well.

This assumes that a torcx store is available locally with all images
referenced in the torcx manifest.

This is accomplished with a highly-indented double-for-loop, but I think
it's still decently readable.
2017-09-08 16:58:51 -07:00
David Michael
a0bebcc38b build_image: copy torcx images into the vendor store
This adds the option --torcx_store to specify the path to a
directory containing torcx images to be baked into the OS image.  A
blank string can be given instead of a path to restore the previous
behavior and leave an empty vendor store.

The default value is the default path created by build_torcx_store,
which is used when build_packages updates torcx images.  This means
that the current pattern "./build_packages && ./build_image prod"
should result in a fully updated OS image with all torcx images
available in the vendor store.
2017-06-02 14:23:03 -07:00
Benjamin Gilbert
329f4bd113 build_library: Run dd with status=none
Avoid dumping dd statistics to stderr.
2017-04-21 14:06:00 -07:00
Alex Crawford
287662c7e0 build_library: skip licenses for virtual packages 2017-04-12 13:54:11 -07:00
Alex Crawford
664eadff1b build_library: reformat the license file as json
This changes the format from:

    sys-apps/systemd-212-r8::coreos GPL-2 LGPL-2.1 MIT public-domain

to a JSON structure:

    [
      {
        "project": "sys-apps/systemd-212-r8::coreos",
        "license": ["GPL-2", "LGPL-2.1", "MIT", "public-domain"]
      }
    ]

We don't have to worry about the changing format because the previous
format was never published. This is designed to match the
bill-of-materials [1] format so that it can be consumed by the site.

[1]: https://github.com/coreos/license-bill-of-materials
2017-04-12 13:54:11 -07:00
Benjamin Gilbert
d0e89d1752 build_image_util: Don't query the $BUILD_DIR vdb
Jenkins uses separate chroots for package and image builds, so
$BUILD_DIR may not have the relevant packages installed.
2017-03-30 15:43:56 -07:00
Benjamin Gilbert
d8fb403f69 build_image_util: Fix warnings when building OEM ACIs
INFO    build_oem_aci: Writing coreos_oem_gce_aci_stage_packages.txt
    awk: cmd. line:1: fatal: cannot open file `/build/amd64-usr/var/db/pkg//DEPEND' for reading (No such file or directory)
    INFO    build_oem_aci: Writing coreos_oem_gce_aci_stage_licenses.txt
    awk: cmd. line:1: fatal: cannot open file `/build/amd64-usr/var/db/pkg//DEPEND' for reading (No such file or directory)
2017-03-29 16:31:05 -07:00
Benjamin Gilbert
d234da9ffc Merge pull request #651 from bgilbert/firstboot-file
Set coreos.first_boot based on existence of file in ESP
2017-03-23 18:29:41 -07:00
Benjamin Gilbert
0b010279e0 build_image: Create /boot/coreos/first_boot 2017-03-01 15:54:05 -08:00
Euan Kemp
20325a547f build_image_util: allow unchecked emerges too
This is useful for emerges that are meant for incomplete rootfs's, such
as ACI building emerges. There are cases where the #! check is expected
to fail while doing those.
2017-03-01 10:52:17 -08:00
Benjamin Gilbert
7bab03e772 Merge pull request #638 from bgilbert/reinject
Add script to inject kernel/GRUB/shim
2017-02-02 17:39:08 -08:00
Benjamin Gilbert
5541e1521e Merge pull request #639 from bgilbert/other-boards
build_image: Correctly disable verity on unsupported boards
2017-02-02 17:18:22 -08:00
Benjamin Gilbert
b11d3a7c1d build_image: Correctly disable verity on unsupported boards
Fixes up missing bit from e630a36e50.
2017-02-02 17:08:01 -08:00
Benjamin Gilbert
e65d5101cf build_image: Extract and upload GRUB/shim EFI images for signing
On arm64, extract only GRUB, since there is no shim.  On dev builds,
extract neither.
2017-02-02 17:00:15 -08:00
Benjamin Gilbert
5443a101f7 build_image: Move one message to logging framework 2017-02-02 16:51:58 -08:00
David Michael
e630a36e50 Revert "build_image: Remove disable_read_write variable"
This reverts commit a7ffba9a9f.

The build_image script can build multiple formats.  When our
releases and automated builds are creating developer containers and
production images from the same command, the verity flag would be
disabled while building the container and remain disabled when building
the production image.  This resulted in no verity in all our builds.
2017-02-02 15:08:43 -08:00
Michael Marineau
74edf63449 Merge pull request #611 from glevand/for-merge-arm64-verity
scripts: Add arm64 verity support
2017-01-30 11:07:21 -08:00
Benjamin Gilbert
e878dc51ea build_image: Include {ignition,bootengine} in {packages,licenses}.txt
They're not in the root fs, but they are in the initramfs.  Handle this
by augmenting the package list with packages that are both

- build dependencies of coreos-kernel, and
- configured to cause rebuilds of coreos-kernel when their sub-slot
  changes.
2017-01-18 16:37:37 -08:00
Geoff Levand
2839b73177 build_image: Add arm64 rootfs verification
Signed-off-by: Geoff Levand <geoff@infradead.org>
2016-12-13 13:46:05 -08:00
Geoff Levand
4ca0c5bc19 build_image: Cleanup enable_rootfs_verification
To clean things up and prepare for arrm64 support move
all the enable_rootfs_verification processing into one
location and add some comments.

Signed-off-by: Geoff Levand <geoff@infradead.org>
2016-12-13 13:46:05 -08:00
Geoff Levand
0ef44633ef build_image: Remove enable_verity flag
To make verity work both enable_rootfs_verification and enable_verity
need to be set.  Without one verity just gets half enabled.  Remove
the enable_verity flag and do the full verity setup when
enable_rootfs_verification is set.

Signed-off-by: Geoff Levand <geoff@infradead.org>
2016-12-13 13:46:05 -08:00
Geoff Levand
a7ffba9a9f build_image: Remove disable_read_write variable
The disable_read_write variable was just a copy of FLAGS_enable_rootfs_verification,
so to make things less confusing just use FLAGS_enable_rootfs_verification.

Signed-off-by: Geoff Levand <geoff@infradead.org>
2016-12-13 13:46:05 -08:00
David Michael
2dfab3fd79 build_library: remove extract_docs()
Since coreos-doc was removed from coreos-overlay, there are no more
files in /usr/share/coreos/doc, causing this function to fail.
2016-11-09 11:44:11 -08:00
Michael Marineau
4ed9a1a2a5 build_image: disable verity again
The Xen loader in GRUB never received support for our hacky scheme of
adding the verity hash to the kernel cmdline. Disable till that's fixed.

Partially reverts 2016567 and 533b1b9.
2016-10-10 14:08:05 -07:00