Commit Graph

199 Commits

Author SHA1 Message Date
Kai Lueke
834e0c11d7 Support running under UID 500
When started by the Flatcar core user, the SDK failed to use UID 500
because inside the SDK there already is the core user from nss-altfiles
with the same ID. This way, the SDK user was continuing with UID 1000
and had permission errors.
Allow to reuse an existing ID for the SDK user. However, this only
works when usermod doesn't find a process that uses this ID, and we had
a race between the SDK entry points called by "docker start" and by
"docker exec". The race is unwanted anyway because we don't want to
execute the commands while setup_board is still running. Solve it by
setting the entrypoint for "docker start" directly to "bash -l" in
"docker create" (this is also what the entry point does as last step:
sudo su -l).
2022-08-31 15:16:21 +02:00
Krzesimir Nowak
89e82185d0 sdk: Forward SIGNER environment variable
Some of the signing may happen inside the SDK container, so make sure
to forward the SIGNER environment variable, as it will be used by the
signing function, when it's introduced.
2022-06-03 14:59:26 +02:00
Thilo Fromm
8f2d36025d update_sdk_container_image: work around sandbox permission errors
This change temporarily disables the Gentoo sandbox when updating the
SDK to work around sandbox permission errors some pakage builds (like
e.g. GO) run into.

Fixes e.g.
```
Building Go cmd/dist using /usr/lib/go-bootstrap. (go1.5.3 linux/amd64)
 * /var/tmp/portage/sys-apps/sandbox-2.12/work/sandbox-2.12/libsandbox/trace.c:do_peekstr():125: failure (Operation not permitted):
 * ISE:do_peekstr:process_vm_readv(6863, 0x00007ffe4a502180{0x00007f01abd3e010, 0x570}, 1, 0x00007ffe4a502190{0x000000c820012a90, 0x570}, 1, 0) failed: Operation not permitted
 * ERROR: dev-lang/go-1.17.8::coreos failed (compile phase):
```

Signed-off-by: Thilo Fromm <thilo@kinvolk.io>
2022-05-06 11:20:03 +02:00
Kai Lueke
db7220eced ci-automation: set the channel from the git tag
For now we had only "developer" images in the new pipeline.
Based on the git tag like "alpha-1234.0.0" set the channel (group) for
the image and also use this logic when finding the channel in the QEMU
update test.
2022-03-04 13:49:18 +01:00
Thilo Fromm
38d85729bf update_sdk_container_image: update SDK container image
This change introduces update_sdk_container_image, a script to generate
a new SDK container image based on an existing SDK container. The
script is meant to be used for minor / patch level SDK changes (like
test suite updates).

Signed-off-by: Thilo Fromm <thilo@kinvolk.io>
2022-02-21 20:06:30 +01:00
Thilo Fromm
719689992c SDK container: enable binpkg cache for nightly builds
Signed-off-by: Thilo Fromm <thilo@kinvolk.io>
2022-01-12 15:44:30 +01:00
Thilo Fromm
ee43062399
Merge pull request #205 from flatcar-linux/t-lo/fix-sdk_entry-setup_board-fallout
fix sdk_entry.sh setup_board fallout
2022-01-07 13:26:38 +01:00
Thilo Fromm
43e8730ffe sdk_container: better docker / podman detection
In bce3bd9031, we added support for podman
for building and running the SDK container. The presence of podman is
auto-detected in sdk_container_common.sh. However, podman is preverred
over docker, requiring users to use *sudo* (which podman requires and
docker does not).

This change uses docker when present, podman otherwise. It also improves
podman detection - 'podman' uses argv[0] in its version string, so if
'docker' is a symlink to 'podman', 'podman --version' output uses
'docker'. This broke the SDK container on hosts which have a 'docker'
symlink to 'podman' since 'podman' is then run w/o 'sudo'.

Signed-off-by: Thilo Fromm <thilo@kinvolk.io>
2022-01-07 11:06:30 +01:00
Thilo Fromm
4273b51cd6 sdk_lib/sdk_entry.sh: only call setup_board if /build/... exists
Signed-off-by: Thilo Fromm <thilo@kinvolk.io>
2022-01-07 09:58:34 +01:00
Thilo Fromm
e6a4349355 sdk_lib/Dockerfile.sdk-import: use root user by default
sdk_entry.sh is expected to be called by the root user, so we set USER
root:root. Also we add a "root" entry to passwd and group since it does
not exist in the SDK tarball.

Signed-off-by: Thilo Fromm <thilo@kinvolk.io>
2022-01-06 20:17:19 +01:00
Kai Lueke
38729ac1dc sdk_lib/sdk_entry: handle permission error for target version file
The creation of the target version file failed:
/home/sdk/sdk_entry.sh: line 32: /build/amd64-usr/etc/target-version.txt: Permission denied
Use root permissions to create the file.
2022-01-06 18:52:40 +01:00
Kai Lueke
bce3bd9031 run/build_sdk_container: support Podman
When the docker wrapper script for Podman is used, we need to
explicitly create a root user container with "sudo podman".
Podman also has its own bridge for root user containers which we need
to detect, and it requires to explicitly say to use the Docker Hub
Caddy image.
Add a "$docker" variable that uses sudo podman as needed, and also
check which bridge interface to use. The filter had to be changed
because it didn't work with Podman. Use the Docker Hub Caddy image
explicitly.
2022-01-06 18:05:24 +01:00
Thilo Fromm
8fd5fc8a65 sdk_entry.sh: ensure currect binpkg host
This change ensures the binpkg host is updated if the board (OS) version
differs from the SDK version.

This is to ensure /build/[arch] uses the correct binary package cache.

Signed-off-by: Thilo Fromm <thilo@kinvolk.io>
2022-01-05 21:03:42 +01:00
flatcar-ci
459fcb89c6 sdk_lib/sdk_entry.sh: use a login shell to source /etc/profile
For execution of the compiled binaries in /build/arm64-usr we rely on
qemu-user binfmt emulation and have to tell it where the root is with
QEMU_LD_PREFIX because build systems don't chroot into /build/arm64-usr
themselves (which also works just by chance on amd64 because we have
similar glibc versions and so on). The env var setup was done in
/etc/profile.d/qemu-aarch64.sh but is now not read anymore since the
container runs the shell not as login shell.

Add the login options to the bash and su calls when starting the
container.
2022-01-05 18:06:37 +01:00
Thilo Fromm
1d1c6048d4 sdk-container: add @krnowak's suggestions from code review
Co-authored-by: Krzesimir Nowak <knowak@microsoft.com>
2021-11-26 17:54:43 +01:00
flatcar-ci
7f874e491e sdk-container: address feedback from @krnowak review
Signed-off-by: flatcar-ci <infra+ci@flatcar-linux.org>
2021-11-26 17:54:43 +01:00
Thilo Fromm
b567344234 sdk-container: add scripts for containerised SDK
This change introduces a containerised SDK as a replacement for cork SDK
operations. It also simplifies versioning by removing the need for
manifest repos as well as usage of the "repo" tool by use of git
submodules for coreos-overlay and portage-stable.

The following feature scripts are added:
- run_sdk_container: Run a command in an SDK container, using the
        current scripts repo + ebuild submodules.
        current scripts repo + ebuild submodules.
- bootstrap_sdk_container / build_sdk_container_image: Bootstrap a new
        SDK and create an SDK container from the resulting SDK tarball.

The following additions have been made to SDK scripts:
- setup_board: add --pkgdir parameter to use a custom binary packge
  directory.

Signed-off-by: Thilo Fromm <thilo@kinvolk.io>
2021-11-26 17:54:43 +01:00
Kai Lüke
06c4894f71
SDK: Take environment variable to specify SDK location
The dev build SDKs are not in $FLATCAR_DEV_BUILDS/sdk but published under
$FLATCAR_DEV_BUILDS/developer/sdk.
Add an environment variable to specify where the SDK is to be found
but default to $FLATCAR_DEV_BUILDS/sdk if it is not specified.
From Jenkins this variable is exported as DOWNLOAD_ROOT_SDK.
2020-05-14 16:03:15 +02:00
Flatcar Buildbot
1dad511f69 2317.0.1 2019-11-07 19:40:01 +01:00
Andrew Jeddeloh
118b26d305 sdk_lib: drop obsolete enter/make_chroot 2018-06-08 10:58:29 -07:00
David Michael
45ef8cea91 enter_chroot: Drop special locale-gen handling
The glibc ebuild runs locale-gen itself while installing.
2018-04-04 12:53:20 -04:00
David Michael
7f99054c9d Merge pull request #687 from dm0-/workon-mantle
enter_chroot: initialize with mantle in cros_workon
2017-08-10 17:39:45 -07:00
Benjamin Gilbert
b5f19e5d75 enter_chroot: Fix ownership of /run/user/UID
We were chowning the host directory, not the one in the chroot.

Host gpg >= 2.1.13 puts the gpg-agent socket in /run/user/UID/gnupg,
which is bind-mounted into the chroot, but the SDK gpg was ignoring it
because /run/user/UID was not owned by UID. This broke tag signing with
YubiKeys.
2017-05-31 13:52:16 -07:00
David Michael
cbe102142b enter_chroot: initialize with mantle in cros_workon 2017-05-26 14:43:42 -07:00
Michael Marineau
8e754f9c2b enter_chroot: do not export variables that weren't previously exported
COREOS_BUILD_ID is set to a default value in common.sh if unset in the
environment. When entering the chroot this default value should not then
get promoted into the environment. Doing so causes catalyst to re-use
stale builds and multiple build_image runs to conflict with each other.
2016-05-25 17:04:38 -07:00
Michael Marineau
db5d937aab Merge pull request #491 from marineam/bind-root
enter_chroot: fix chroot root bind command
2015-12-15 16:44:28 -08:00
Michael Marineau
3fdd2033dc enter_chroot: fix chroot root bind command
Commit 09851b84 didn't do a recursive bind by mistake, so if the host
system has anything mounted under the chroot directory for some reason
the bind would hide those mounts. Recursive ensures existing mounts
remain exposed as they did before.
2015-12-15 16:40:00 -08:00
Michael Marineau
2b43e553e3 Merge pull request #490 from marineam/bind-root
enter_chroot: ensure the chroot's root directory is a mount point
2015-12-15 16:34:01 -08:00
Michael Marineau
09851b8460 enter_chroot: ensure the chroot's root directory is a mount point 2015-12-15 16:30:27 -08:00
Michael Marineau
863dda280f enter_chroot: skip calling locale-gen if it isn't installed 2015-12-10 11:33:57 -08:00
Michael Marineau
ec58813496 enter_chroot: always bind $GNUPGHOME to the default path
The path of $GNUPGHOME outside the chroot may not really make sense
inside the chroot. Although that's probably not a big deal there's no
need to keep the outside value. Instead just bind it to the usual spot.
2015-12-01 14:34:43 -08:00
Michael Marineau
14ada5cfe7 Merge pull request #483 from marineam/jenkins
Updates for jenkins builds
2015-12-01 12:03:13 -08:00
Alex Crawford
47d237ecab sdk_lib: cleanup to support non-standard environs 2015-11-30 18:15:42 -08:00
Michael Marineau
39a3a48a18 enter_chroot: add support for passing through GNUPGHOME
When running under jenkins the $GNUPGHOME may be located under the
current build directory instead of $HOME to avoid conflicting with other
jobs on the same build host.
2015-11-29 14:05:08 -08:00
Michael Marineau
aa4ba8b2bb bootstrap_sdk: do not remove make.conf, turns out catalyst runs sed over it 2015-07-06 13:14:51 -07:00
Michael Marineau
1fa7ef236b update_chroot: remove dependency on complex 'chromeos-cache' links
The distfiles cache is always under .cache in the repo tree but there is
a lot of extra logic to make that configurable along with compatibility
symlinks for previous locations. Just yank it all out.
2015-07-05 17:54:00 -07:00
Michael Marineau
611ed7698e enter_chroot: remove subversion config goo
We do not have any svn based live ebuilds that require credentials which
I presume is the only reason for shuffling svn configs like this.
2015-07-05 17:20:43 -07:00
Michael Marineau
db734ea417 bootstrap_sdk: do not leak catalyst config into sdk tarballs
The version of repos.conf/coreos.conf that catalyst needs isn't valid
for normal SDK chroots and causes env-update to spew errors when it is
run prior to update_chroot which configures portage properly.
2015-07-05 16:57:05 -07:00
Michael Marineau
174a847e36 update_chroot: remove dependence on /usr/local/portage/* symlinks
A step in reducing the amount of initialization code required: drop
needless symlinks under /usr/local/portage to the portage trees. Just
configure portage to point directly at the source instead. Only crossdev
remains in that location because it is a locally managed overlay.
2015-07-05 16:57:05 -07:00
Michael Marineau
729f9da872 common: make sure /etc/mtab is correct before mounting anything
If mtab ever gets replaced by a regular file all sorts of things break.
2014-12-03 16:30:19 -08:00
Michael Marineau
ae9d6252bc make_chroot: remove unneeded modifications
These are assorted tweaks that are already setup in the tarball.
2014-09-15 16:19:25 -07:00
Michael Marineau
81ce75300f cleanup: remove source location migration code
This code is not applicable to us, it predates CoreOS and is a weird
thing for common.sh to be doing as well. Instead always define
CHROOT_TRUNK_DIR to /mnt/host/source, create ~/trunk in make_chroot.
2014-09-14 15:32:10 -07:00
Michael Marineau
09e720e821 cleanup: remove a couple references to chrome-bot 2014-09-14 14:54:35 -07:00
Michael Marineau
6df3bbbe2e sdk: assert host system is running Linux 3.7 or later
Currently building images on older kernels will fail because mkfs.btrfs
enables an incompatible feature 'extref' by default. We never really
made this requirement explicit and the SDK in general has continued to
maintain compatibility with older kernels. Make the requirement explicit
so users will get errors quicker and there is a clear line for what
kernel features can be used in the SDK.
2014-09-02 15:55:52 -07:00
Michael Marineau
2991ad8cd8 chroot: remove git from $PS1
This feature is disabled for now. See c8a62a12 for details.
2014-08-18 16:40:34 -07:00
Michael Marineau
c8a62a12ee make_chroot: don't enable git-prompt via bashcomp
Newer git ebuilds have decided that the "git-prompt" script isn't really
bash completion so stopped installing it via that mechanism. Instead it
installed it started installing it in /usr/share/docs which gets
compressed by default and the path is based on ebuild version. The path
changed again in 1.9.3 to /usr/share/git and didn't compress it so that
makes it actually possibly usable but 1.9.3 or later isn't stable yet.

We can re-enable it the next time git gets updated but not worth fussing
over the current brokenness right now.
2014-08-16 13:36:57 -07:00
Michael Marineau
4d3c198161 tools: remove support for parallel_emerge
Using parallel_emerge has been disabled by default for all commands
except build_image for quite a while now, build_image kept it just
because it was still a bit faster than normal emerge. Keeping
parallel_emerge complicates future changes to build_image so it needs to
drop it entirely. Since that means nothing uses it by default we might
as well just rip out support for it entirely.
2014-07-19 16:38:17 -07:00
Michael Marineau
4b23a26667 update_chroot: fix transition to new os-release location
Previously /etc/os-release was installed both by set_lsb_release and
the baselayout package. Now it is only installed by set_lsb_release but
when baselayout is upgraded it removes /etc/os-release. So the first
update_chroot works but the second detects the chroot's version
incorrectly and tries to apply the one time updates in this directory.
Both of them are very old so we can just delete them. The second run
will now fix up /etc/os-release and we can all move on and be happy.
2014-07-14 17:59:15 -07:00
Michael Marineau
946f730d7f enter_chroot: set reasonable PATH when calling locale-gen 2014-07-03 15:23:18 -07:00
Michael Marineau
a075b1085a make_chroot: explicitly set path when entering the chroot.
The host system's PATH may not be match the one required by the SDK.
When going through the enter_chroot script it gets reset because bash is
invoked as a login shell but this doesn't happen when using the plain
old chroot command.

Fixes https://github.com/coreos/scripts/pull/290
2014-07-03 14:51:32 -07:00