Commit Graph

70 Commits

Author SHA1 Message Date
Thilo Fromm
6f651a298c build scripts: separate txt inventory; official naming for sysexts
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
aae3fd8260 prod_image_util.sh: remove pkgdb tarball (replaced by sysext)
Signed-off-by: Thilo Fromm <thilofromm@microsoft.com>
2023-10-23 16:05:45 +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
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
fa48f70a37 *: Make catalyst and emerge verbose by default
That way we can see a report of what emerge is going to do and the
status of the use flags for the installed packages. The downside is
that we are going to have reports about using deprecated and
unsupported profile in even more places.
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
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
6f1d7976f4
Merge pull request #385 from flatcar-linux/jepio/spdx-sbom
add SPDX SBOM generation using syft
2022-07-27 13:55:00 +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
e20cf95bcb prod_image_util: unpack SLSA report along with gcc when building image
Prod images need libstdc++.so and other libraries produced by
sys-devel/gcc build, but because we don't want all of gcc in the image,
the binpkg is manually unpacked instead of installed with emerge. Make
sure to preserve SLSA metadata when unpacking as well.
2022-07-27 13:00:19 +02:00
Jeremi Piotrowski
6735a6d5c0
prod_image_util: extract gcc libs to /usr/lib64
This made no difference back when lib was a symlink to lib64, but now that they are separate,
libs belongs in /usr/lib64. This  mostly doesn't show up because ldconfig configures the ld.so cache
to include both locations, but when updating from an older release ld.so.cache is out of date.
Unfortunately ld.so.cache does not get updated until after multipathd, which causes
multipathd to dump core. This may also affect other packages that need access to
libgcc early.

See also: https://github.com/flatcar-linux/Flatcar/issues/809
2022-07-25 17:33:08 +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
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
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
Kai Lüke
42068f1cbc
build_image: Add prodtar command to build a tar ball
Create a tar ball with the contents of the / and /usr partitions
to be used as follows with systemd-nspawn (via machinectl):
  machinectl import-tar flatcar-container.tar.gz flatcar-container
  machinectl start flatcar-container
  machinectl shell flatcar-container
or with docker by converting it to an OCI image:
  docker import -c "CMD /bin/bash" flatcar-container.tar.gz flatcar-container

Since the new "prodtar" command relies on the results of the "prod" command,
it bundles it so that "prod prodtar" and "prodtar" is the same.
2020-02-07 17:33:37 +01:00
Flatcar Buildbot
c7bbb2b1e2 2345.0.0 2019-12-04 14:59:11 +01:00
David Michael
2467923d56 Remove arm64 from supported board operations 2018-10-25 16:00:09 +00:00
David Michael
23c5b018c6 prod_image_util: Drop /usr/include
This should be covered by INSTALL_MASK, but it apparently gets
confused by a symlink loop installed by json-c.  Remove it here.
2018-10-18 16:32:32 +00:00
David Michael
9adb659106 prod_image_util: Drop the portage cache database 2018-10-18 15:58:27 +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
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
Alex Crawford
b924c5ce6c build_library: upload image licenses
We've always generated these license manifests (detailing which ebuilds
are covered by which license), but never published them. This adds these
manifests to the list of published files so that they are publicly
available.
2017-03-15 14:11:01 -07: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
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
9ed9ff7b45 build_image: generate C.UTF-8 locale 2016-09-30 15:24:32 -07:00
Michael Marineau
1092afd240 build_image: clean up PCR policy generation
Pass as an argument to finish_image like most other things.
2016-09-19 12:09:47 -07:00
Michael Marineau
14eb89a5dc build_image: publish kernel along with base image for generating updates 2016-09-19 11:41:30 -07:00
Michael Marineau
7ccb981797 prod_image_util: move pam.d contents, not the directory
The baselayout package now creates and installs /usr/lib/pam.d, causing
mv to fail. Move the contents instead which is happy with both versions.
2016-06-13 14:49:41 -07:00
Michael Marineau
20541226bf prod_image_util: do not check update keys on arm64
arm64-usr doesn't have update_engine yet so this isn't valid.
2016-05-05 17:33:11 -07:00
Nick Owens
704a480379 build_library: use lib for tmpfiles rather than lib64
in arm64-usr, lib is not yet a symlink to arm64, so trying to access
tmpfiles.d in lib64 will not work.
2016-04-14 13:26:02 -07:00
Matthew Garrett
0bd89d3381 Move PAM configuration to /usr at build time
A bunch of packages install PAM configuration fragments in /etc. Rather than
modify them all to install into /usr/lib, just move the entire directory at
image build time.
2016-04-11 11:34:57 -07:00
Matthew Garrett
56aa7e5a17 Add support for generating PCR configuration at image build time
We need to ship some PCR measurements alongside images in order to make it
easier for admins to provide an appropriate policy. Add some tooling to
generate the appropriate hashes during build, pack those into a zip file
and upload it.
2016-04-04 14:47:06 -07:00
Michael Marineau
10fa4b5a0c prod_image_util: move profile.env to /usr
profile is already set up to source /usr/share/baselayout/profile.env
but it never has because I forgot to add this line during the migration
to amd64-usr images. Sure took us a while to notice that one... :(
2016-02-29 18:54:12 -08:00
Michael Marineau
743d4bce37 build_image: Add support for --getbinpkg
Allows build_image to be used without first running build_packages.

Note: setup_board --force is required before build_packages will work
properly after doing this since baselayout won't be installed otherwise.
2016-02-20 14:26:50 -08:00
Geoff Levand
3f3b2f2e8c build_image: Run ldconfig in qemu
ldconfig does not work for non-native arches.  Create a new
build_image routine run_ldconfig that uses qemu user emulation
to run the board ldconfig on the board rootfs when the board and
SDK arches are different.

See: http://code.google.com/p/chromium/issues/detail?id=378377

Prior to calling run_ldconfig the board rootfs must have ldconfig
installed.  To arrange this move the call of run_ldconfig to after
the base package install.

Fixes build_image errors like these when building for arm64:

  /sbin/ldconfig: /lib64/libXXX is for unknown machine 183.

Signed-off-by: Geoff Levand <geoff@infradead.org>
2015-08-05 14:47:58 -07:00
George Tankersley
283452e883 verity: add verity plumbing and hash injection to build scripts 2015-07-01 17:34:11 -07:00
George Tankersley
93f033c59e verity: add support for root hash output to disk_util 2015-06-11 18:37:51 -07:00
Michael Marineau
3b8cf7d1fb build_image_util: generate package license list for each image
There isn't a sane way for users to know the licenses of individual
packages in CoreOS images in built images. The information is hidden
away back in the original ebuilds. This extends our existing package
list with a new file that also includes licenses:

```
app-admin/flannel-0.3.0-r3::coreos Apache-2.0
app-admin/fleet-0.9.1::coreos Apache-2.0
app-admin/locksmith-0.2.3::coreos Apache-2.0
app-admin/sdnotify-proxy-0.1.0::coreos Apache-2.0
app-admin/sudo-1.8.10_p2::portage-stable ISC BSD
app-admin/toolbox-0.0.0-r4::coreos Apache-2.0
app-arch/bzip2-1.0.6-r6::portage-stable BZIP2
app-arch/gzip-1.5::portage-stable GPL-3
app-arch/tar-1.27.1-r2::portage-stable GPL-3+
...
```
2015-03-24 18:10:45 -07:00
Alex Crawford
db1f826632 build_library: add extract_docs() 2015-01-16 13:12:21 -08:00
Alex Polvi
1854bc2028 build_image: add ability to pick different base package 2015-01-02 15:07:52 -05:00
Michael Marineau
3587784bc4 disk_util: Add support for computing verity hashes 2014-11-15 18:58:10 -08:00
Michael Marineau
da86c34d75 prod_image_util: clean up /etc cleanup code
Pruning files via INSTALL_MASK in the profile is a bit more apropriate
since it allows us to keep most of that info in one place. The only
parts that need to be deleted or adjusted here are inputs and outputs of
`env-update` which has to be run after everything is installed.

Previously we didn't actually clean up `env.d` at all which lead at
least one user to think they should edit those files and run
`env-update` themselves but we don't ship that tool on prod images.
2014-09-25 16:13:29 -07:00
Michael Marineau
3de1613a99 Merge pull request #324 from marineam/grub
Grub2 preview
2014-09-02 10:22:27 -07:00
Michael Marineau
0cc06c9c5c build_image_util: pass the disk image through to configure_bootloaders
Required so that configure_bootloaders can now handle installing the
bootloaders as well.
2014-08-30 16:39:05 -07:00
Michael Marineau
70051bf6ef prod_image_util: install GCC libraries to /usr/lib
Normally GCC is installed in a way that allows installing multiple
versions and switching between them. Our production images do not need
this and additionally the only things from the GCC package that are
needed are the shared libraries. To ensure these libraries are *always*
locatable regardless of the presence of /etc/ld.so.conf and
/etc/ld.so.cache we can install those libraries to plain old /usr/lib.
The GCC packages don't have a built in way to do this but we can get
away with extracting the libraries directly from the binary package.

This is actually similar to what ChromeOS did with a few exceptions:
 - We use a native GCC build instead of the cross toolchain
 - The archive is properly extracted from the package instead of feeding
   the package directly to tar and ignoring the resulting warnings.

As an added benefit switching from a blacklist to a whitelist ensures
that extra cruft does not slip through the cracks, saving 5-10MB.
2014-08-27 20:23:39 -07:00
Michael Marineau
5377e7870d prod_image_util: update /etc/ld.so.conf on every boot
Early images created this as a file instead of a symlink, these systems
will not be able to find the new GCC libraries using the older config.
2014-08-26 18:28:07 -07:00