Commit Graph

945 Commits

Author SHA1 Message Date
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
89b5505fe6 build_library/catalyst_sdk.sh: Try different way of picking python as default intepreter
Let's see if `eselect python update` would work. It's certainly nicer,
because there would be one place less to change on the next python
update.
2021-12-10 20:06:40 +01:00
Krzesimir Nowak
790fd0fd2c build_library/catalyst_sdk.sh: Select python 3.9 as a default interpreter
At this point nothing pulls python2 anymore, so it became an invalid
target.
2021-12-10 20:06:40 +01:00
Krzesimir Nowak
186f1de4fa update_chroot: Add a way to remove hard blockers
And set it to remove some old version of dev-python/setuptools_scm
package.
2021-12-10 20:06:40 +01:00
Mathieu Tortuyaux
dc0f93015b
build_library/set_release: add CPE_NAME - v2.3
Flatcar is in the NIST CPE dictionary. Let's programmatically build the
`CPE_NAME` in the build process in order to be scanned.

`CPE_NAME` is part of `/etc/os-release` with the following manual entry:

```
CPE_NAME=
  A CPE name for the operating system, in URI binding syntax, following the Common Platform Enumeration Specification[2] as proposed by the NIST.
  This field is optional. Example: "CPE_NAME="cpe:/o:fedoraproject:fedora:17""
...
[^2]: Common Platform Enumeration Specification
           http://scap.nist.gov/specifications/cpe/
```

Which indicates that the current version of CPE is 2.3.

Closes: https://github.com/flatcar-linux/Flatcar/issues/536

Signed-off-by: Mathieu Tortuyaux <mtortuyaux@microsoft.com>
2021-11-23 18:22:16 +01:00
Thilo Fromm
7f80cb138b
Merge pull request #159 from flatcar-linux/t-lo/use-new-bincache-mirror
setup_board, update_chroot, dev container: use new bincache mirror
2021-10-07 11:57:30 +02:00
Thilo Fromm
cc469d2f47
build_library/release_util.sh: improve ssh opts for rsync
Co-authored-by: Kai Lüke <pothos@users.noreply.github.com>
2021-10-07 11:17:33 +02:00
Thilo Fromm
0aad4b9dd1
release_util.sh: script improvements
Co-authored-by: Krzesimir Nowak <knowak@microsoft.com>
2021-10-07 10:48:26 +02:00
Thilo Fromm
9c3ba12936 release_util.sh: add rsync:// upload 2021-10-07 09:27:49 +02:00
Thilo Fromm
eaff2d47eb build_image: add binhost option for dev container
Signed-off-by: Thilo Fromm <thilo@kinvolk.io>
2021-10-05 16:38:43 +02:00
Thilo Fromm
51aac23dc8 setup_board, update_chroot, dev container: use new bincache mirror
This updates the default settings in build scripts to use
https://mirror.release.flatcar-linux.net/
instead of the google storage bucket if no binhost or FLATCAR_DEV_BUILDS
is specified.

Defaults are updated for
* update_chroot (runs at SDK initialisation time)
* setup_board (creates /boards/[ARCH]/) chroots
* the development container
* set_version
2021-10-05 15:03:00 +02:00
Sayan Chowdhury
ccdc52cc15
Merge pull request #155 from flatcar-linux/krnowak/trap-fixes
Fix the traps to align with bash 5.1 upgrade
2021-10-01 21:49:27 +05:30
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
d801ecccdf build_library/board_options: Fix pkg_version function
The documentation says it always returns zero, which is not true -
portageq could return a non-zero return value and that would be the
return value of the function. Fix the function to actually follow the
documentation - apparently the function should just return an empty
string in case of failure (like package not found).
2021-09-28 16:32:30 +02:00
Krzesimir Nowak
eee6b50aa5 *: Do not use RETURN traps
It has some weird semantics that seem to trip us up after updating
bash to 5.1. We tried to use it inside functions to clean up some
stuff after function returns. This can be emulated with an EXIT trap
within a subshell. Fortunately all the users of the RETURN trap were
not setting any global variables - modifications of such variables are
local to the subshell and are lost when the subshell exits.
2021-09-27 20:18:22 +02:00
Dongsu Park
ec19fd5aa2 build_library: add entries to the GLSA allow list
Now that GLSA metadata was updated as of 2021-09-03, we need to
add the following entries to the GLSA allow list, to avoid build
failures caused by `glsa-check -t all`.

202006-03: perl 5.26.2, only SDK, allowlist
202008-01: python 2.7.15 & 3.6.5, only SDK, allowlist
202101-18: python 2.7.15 & 3.6.5, only SDK, allowlist
202104-04: python 2.7.15 & 3.6.5, only SDK, allowlist
202105-22: samba 4.12.9, not affected, samba has no ldap flag, no smbd.
202105-34: bash 4.3, non-trivial to update
202107-31: polkit 0.113, in-progress
202107-48: systemd 247.9, backported the fixes to v247.9.
2021-09-06 16:03:13 +02:00
Dongsu Park
dfe49e7bcf build_library: remove unnecessary entries from GLSA allow list
201904-13: git 2.26.3, so not affected
201909-08: dbus 1.12.20, so not affected
201911-01: openssh 8.6, so not affected
202003-12: sudo 1.9.5, so not affected
202003-20: systemd 246+, so not affected
202003-24: file 5.39, so not affected
202003-30: git 2.26.3, so not affected
202003-31: gdb 9.2, so not affected
202003-52: samba 4.12.9, so not affected
202004-10: openssl 1.1.1l, so not affected
202004-13: git 2.26.3, so not affected
202005-02: qemu 5.2, so not affected
2021-09-03 17:43:49 +02:00
Krzesimir Nowak
4ca7027365
Merge pull request #145 from kinvolk/krnowak/drop-unused-stuff
Remove unused scripts
2021-08-30 17:53:05 +02:00
Thilo Fromm
e4c22ef6c7 build_library/disk_util: use byte array for conversion
disk_util sometimes bails out during build with an ASCII conversion
error:

Traceback (most recent call last):
  File "/mnt/host/source/src/scripts/build_library/disk_util", line 1114, in <module>
    main(sys.argv)
  File "/mnt/host/source/src/scripts/build_library/disk_util", line 1110, in main
    options.func(options)
  File "/mnt/host/source/src/scripts/build_library/disk_util", line 779, in Verity
    Tune2fsReadWrite(options, part, disable_rw=True)
  File "/mnt/host/source/src/scripts/build_library/disk_util", line 716, in Tune2fsReadWrite
    image.write(chr(flag_value))
UnicodeEncodeError: 'ascii' codec can't encode character '\xff' in position 0: ordinal not in range(128)

Curiously, the error does not reproduce every time (though the code
leading to the error is straightforward).

This change converts the integer to be written to a byte array (of size
1) instead of using chr(). Also, the file to be written is explicitly
opened in binary mode.

Signed-off-by: Thilo Fromm <thilo@kinvolk.io>
2021-08-27 17:25:34 +02:00
Krzesimir Nowak
ef0dfe5c5c Move cros_vm_constants to build_library
This file used to be imported by scripts coreos-base/cros-devutils,
which we have dropped. Now it is imported only from some other script
in build library so move it there. This leaves lib as a directory
where we keep shflags library.
2021-08-27 14:20:54 +02:00
Krzesimir Nowak
f143645215 generate_au_zip: Remove useless line 2021-08-24 16:08:15 +02:00
Krzesimir Nowak
3f9c073b4b build_library: Fix some typos 2021-08-18 19:03:11 +02:00
Krzesimir Nowak
a314348a38 build_library: Fix getting integer from string
`string.atoi` was deprecated since at least the first release of
python2, and looks like it was dropped in python3.
2021-08-18 19:01:51 +02:00
Krzesimir Nowak
ea0f478cfa build_library: Fix some string vs bytes issues
This is some fallout from converting scripts from python2 to
python3. Output received from the functions in subprocess module now
return bytearrays, but we operate on them as if they were a text. So
decode the bytearrays to strings. Otherwise we are either getting some
junk values passed to the command line utilities (for example:
`b'/dev/loop2'` instead of `/dev/loop2`), or exceptions are thrown,
because a function expected a string.
2021-08-18 18:58:16 +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
Krzesimir Nowak
336a967941 build_library: Convert python2 scripts to python3
This is just a conversion done by 2to3 with a manual updates of
shebangs to mention python3 explicitly. The fixups for bytearray vs
string issues will follow up.
2021-08-18 18:56:48 +02:00
Dongsu Park
04d9fea0c1 build_library: fix docstring issues
Fix several docstring issues, so that the docstrings could match with
the actual code.
2021-08-16 10:39:26 +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
Dongsu Park
a7f251da44 build_library: use proper vocabulary in generate_au_zip
Replace black list with deny list, white list with allow list.
2021-08-13 09:30:53 +02:00
Jeremi Piotrowski
a8a57c733b
Merge pull request #134 from kinvolk/jepio/arm64-sdk-support
bootstrap_sdk: enable arm64 sdk bootstrap
2021-08-03 12:18:01 +02:00
Kai Lüke
4321b2ab83 Revert "Revert "disk_layout: use btrfs for the OEM partition""
This reverts commit bb9ddfb08a,
meaning that the planned change is now done and we switch the OEM
partition to btrfs. The reason for the revert is resolved in
https://github.com/kinvolk/ignition/pull/22
2021-08-03 10:50:06 +02:00
Kai Lüke
bb9ddfb08a Revert "disk_layout: use btrfs for the OEM partition"
This reverts commit bc97e15c3c.
2021-07-30 20:44:36 +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
Jeremi Piotrowski
6ce5d3165f
build_library/toolchain_util: check CBUILD+CHOST for rust warning
For consistency with code further down in the file: aarch64 cross compilation only applies when CBUILD is x86,
for native aarch64 builds rust is guaranteed to have aarch64 rustlibs.
2021-07-28 16:47:13 +02:00
Kai Lüke
e4f811dd0d disk_layout: optimize btrfs filesystem overhead
The defaults already give more space than the ext4 defaults but it's
recommended to use the mixed mode for filesystems smaller than 1-5 GB.
Another aspect is the duplication of metadata and while it currently is
off it's actually related to the underlying block device and could
change as soon as the block device type changes.

Select the mixed mode that uses a merged area for data and metadata
blocks. Also ensure that no metadata duplication gets enabled
automatically.
2021-07-27 14:23:47 +02:00
Kai Lüke
bc97e15c3c disk_layout: use btrfs for the OEM partition
The compression feature of btrfs allows us to store more in the
size-limited /usr and OEM partitions. The size should of course still
be monitored to not bloat the image but more headroom helps to try
things out quickly without hitting the hard limit which fails the
build.
Use btrfs for the OEM partition but with zlib compression because
the outdated GRUB version doesn't support zstd yet.
New subvolumes currently can't be used for the OEM partition as default
subvolumes because GRUB tries to read the grub.cfg from the top
subvolume (at least with our old version). (We could however use
subvolumes for the /usr partition when switching to btrfs if that
makes any sense.)
2021-07-27 14:08:42 +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
Jeremi Piotrowski
8e44a167d5
Merge pull request #133 from kinvolk/jepio/fix-arm64-devcontainer
disk_layout: devcontainer: use architecture agnostic part uuid
2021-07-22 22:10:29 +02:00
Jeremi Piotrowski
4ba3218d6a boostrap_sdk: only build aarch64 cross-rust on x86 hosts
The rust ebuild has some magic to detect cross-toolchains present on the
system and enable building additional cross targets. The code to trigger
the rebuild of rust is part of install_cross_rust, and checks whether
the cross directories exist in the rust installation. If they don't,
then rust is removed and rebuilt to allow for the auto-detection to
happen.

Right now there are two issues with the code. Firstly, the path that is
checked is wrong, which leads to rust always being removed and rebuilt.
The path checked is /usr/lib/rust-*/rustlib but /usr/lib/rustlib is
where the files are installed.

The second issue is that it checks for aarch64 dirs when CHOST is
aarch64-cros-linux-gnu. However, on an aarch64 host the aarch64 dirs
will already exist from building the sdk itself. The rust ebuild is not
ready to handle aarch64 hosts yet and blows up. The correct behavior is
to combine the check for CHOST with a check for the right CBUILD.

On an aarch64 host we should presumably check for the x86 CHOST and rust
dirs, but that can be added later, because it needs more work.

Signed-off-by: Jeremi Piotrowski <jpiotrowski@microsoft.com>
2021-07-19 15:11:12 +00:00
Jeremi Piotrowski
e4f57bea82 bootstrap_sdk: fix issues around lib->lib64 symlink
The arm64 profiles don't specify SYMLINK_LIB=yes, which makes sense
since arm64 systems don't support multilib in the way that we are used
to from x86. What this means is that build artifacts are installed into
separate lib and lib64 directories. The root overlay installed in stage4
needs to check for SYMLINK_LIB before trying to create a symlink,
otherwise it fails to be applied because it collides with the directory
in the rootfs.

This uncovered a second minor issues - the rust toolchain bootstrap
scripts checked for /usr/lib64/rust*, but the ebuild installs to
/usr/lib/rust.

Signed-off-by: Jeremi Piotrowski <jpiotrowski@microsoft.com>
2021-07-19 15:11:09 +00:00
Jeremi Piotrowski
911da26072 disk_layout: devcontainer: use architecture agnostic part uuid
The previously used uuid 4f68bce3-e8cd-4db1-96e7-fbcaf984b709 is valid
for x86_64 root partitions, which resulted in the dev container not
working with systemd-nspawn on aarch64. systemd-nspawn fails with:

  No suitable root partition found in image

Change the partition uuid to the architecture agnostic one documented
in the man page:

  A GUID partition table (GPT) with a single partition of type 0fc63daf-8483-4772-8e79-3d69d8477de4.

This makes systemd-nspawn happy on aarch64.

Signed-off-by: Jeremi Piotrowski <jpiotrowski@microsoft.com>
2021-07-16 15:35:18 +00:00
Mathieu Tortuyaux
35387cfdff
build_lib/qemu_tmpl: fix short-form warning
starting from qemu-6.0.0, options with short-form are deprecated.

```
$ ./flatcar_production_qemu.sh
qemu-system-x86_64: -fsdev local,id=conf,security_model=none,readonly,path=/tmp/flatcar-configdrive.gyqmdrQqfA: warning: short-form boolean option 'readonly' deprecated
Please use readonly=on instead
```

See this commit: ccd3b3b811

Signed-off-by: Mathieu Tortuyaux <mathieu@kinvolk.io>
2021-07-16 16:04:50 +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
Thilo Fromm
d1e2f6d1f2 catalyst_toolchains: don't touch the SDK
This change removes 8 years old code from the toolchains build which
tries to update SDK libraries for unknown reasons, breaking the
toolchains build in the glibc-2.33 update.

Signed-off-by: Thilo Fromm <thilo@kinvolk.io>
2021-06-25 10:37:21 +02:00
Krzesimir Nowak
3cf5d83056
Merge pull request #121 from kinvolk/krnowak/jobs-be-gone
Drop `--jobs` parameter
2021-05-05 19:25:20 +02:00
Thilo Fromm
12d59f88e0 build_library/catalyst_sdk.sh: save snapshot of coreos-overlay
This change to stage 4 of the SDK bootstrap process will keep a
snapshot of coreos-overlay in the SDK tarball. This snapshot can be
used in future SDK bootstraps' stage1 to ensure a clean stage 1 output
without any package updates.

Signed-off-by: Thilo Fromm <thilo@kinvolk.io>
2021-03-04 18:59:13 +01:00
Thilo Fromm
84d7bf63b1 bootstrap_sdk: no package updates in stage 1
This change updates the stage1 SDK bootstrap build to use local
("known good") package ebuilds only, preventing updated package ebuilds
to apply in stage 1. This fixes SDK build breakage we observed when
upgrading core libraries like readline.

The change also removes the seed update from stage 1 as it should not
be needed anymore now that we postpone any package updates to stage 2.

The following package ebuild repos are used for stage 1:
- for portage-stable, we simply copy /var/gentoo/repos/gentoo
   from the SDK root.
- coreos-overlay is more complicated since ebuilds are missing from
   the SDK. So we grok the version the SDK was built with from
     /mnt/host/source/.repo/manifests/default.xml
   and then we create a local stage 1 clone of
     https://github.com/kinvolk/coreos-overlay.git
   in which we then check out the revision noted in the default mnifest.

Signed-off-by: Thilo Fromm <thilo@kinvolk.io>
2021-03-03 17:32:38 +01: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
Krzesimir Nowak
9cbf3049ea vm_image-util: Forward jobs parameter to build_oem_aci 2021-02-16 08:36:57 +01:00
Krzesimir Nowak
647690e264 build_library/check_root: Port to python3
The script needs to be ported, because it is importing portage code
which became python3 only.

The porting I did is likely a lousy job, but at least it stopped
failing with some p(yt)hony errors.
2021-02-12 10:03:16 +01:00