Commit Graph

139 Commits (6e49d6a254c654c6604318f0aef60db928b6979e)

Author SHA1 Message Date
Dustin 6e49d6a254 squashfs.exclude: Add /usr/src
It's empty, but let's get rid of it anyway.
2024-12-13 19:32:01 -06:00
Dustin c35b7cfb72 overlay: default.network: Enable UseDomains
For whatever reason, _systemd-networkd_ does not resepect the DNS domain
search list sent by the DHCP server by default.  This means single-label
name lookups will fail in most cases.
2024-12-13 19:30:56 -06:00
Dustin c2e85681a8 install.packages: Add kbd
This is needed for _systemd-vconsole-setup.service_.
2024-12-13 19:30:31 -06:00
Dustin fef6685876 build-rootfs: Ignore USE changes for baselayout
We don't want to reinstall _baselayout_ when its USE flags change.
Indeed, USE flag changes are expected, because we first install it with
USE=build, but only temporarily.  Once the initial symlinks for
merged-usr are in place, it can be reinstalled without that flag.  We
don't need to keep reinstalling and toggling between states, so we
ignore USE flag changes for the first pass.
2024-12-13 19:29:55 -06:00
Dustin 869257701c make: rootfs: Support customize.sh
Projects can now include a `customize.sh` script.  If present, this
script will be run after the root filesystem hierarchy has been created,
but before the image is captured.  This allows projects to apply
additional customizations beyond adding or removing files.
2024-12-13 19:26:05 -06:00
Dustin 6fff371b81 make: Build GRUB after packages are built
The `build-grub.sh` script needs the GRUB image from the target build
root.
2024-12-13 19:24:13 -06:00
Dustin 4a27f46e68 make: Add busybox.symlinks dep for rootfs
This ensures the root filesystem image will be regenerated if the
base `busybox.symlinks` file from Aimee OS changes.
2024-12-13 19:22:49 -06:00
Dustin b9356f619c init-storage: Skip fs relabel w/o SELinux
If SELinux support is not available or enabled, attempting to relabel
files will fail.
2024-12-13 19:21:26 -06:00
Dustin 8d28c55b79 install.packages: Add gentoo-functions
This package installs the `functions.sh` script library, which is used
by the `install-update` script.
2024-12-13 19:20:07 -06:00
Dustin 3cdd4c24c5 install-update: Do not use find -printf
Busybox `find` does not implement `-printf`.  We have to use `awk` to
get the base name of the file from its path.
2024-12-13 19:17:21 -06:00
Dustin 2beae39208 busybox: Enable find applet
The `install-update` script uses `find` to identify the kernel image
included in the new root filesystem.
2024-12-13 19:15:33 -06:00
Dustin 0b7519c07d overlay: Remove obsolete files 2024-12-13 19:14:31 -06:00
Dustin a51dc99b9b build-grub: Support setting rootflags from config
The project configuration file can now contain an optional `rootflags`
variable.  If specified, this variable will be used to set the GRUB
environment variable of the same name.  The value will be appended to
the kernel command line.
2024-12-13 18:58:08 -06:00
Dustin a244197d3c install.packages: Add awk
The _app-alternatives/awk_ package installs a symlink to `busybox` for
for `awk`.  Using this package instead of `busybox.symlinks` allows
it to satisfy other packages that depend on a generic `awk`
implementation.
2024-12-13 18:52:58 -06:00
Dustin e4407b1573 init-storage: Drop -c argument to cp
Busybox `cp` doesn't implement `-c` (copy SELinux context).  GNU
coreutils has deprecated it as well.
2024-12-13 18:50:15 -06:00
Dustin b3760e7345 build-rootfs: Run ldconfig via QEMU
Using the host's `ldconfig` doesn't work, as it only considers libraries
for the same machine type as itself.  THus, we have to execute the
target's copy, which means running it via QEMU userspace emulation.
2024-12-13 18:47:51 -06:00
Dustin da64f49bd6 build-rootfs: Run ldconfig
Need to update the loader search path in the final root filesystem.
2024-12-10 16:56:12 -06:00
Dustin 79e69cf70d build{,-rootfs}: Do not force TTY
The `-o` argument to `xargs` tells it to reopen a TTY to pass to the
spawned process's standard input.  If there is no controlling TTY, this
will fail.  There's no reason to do this anyway, so let's avoid it.
2024-12-09 12:11:53 -06:00
Dustin 565497cab1 wip: prepare: do not set profile 2024-12-09 08:32:27 -06:00
Dustin f55d50bd60 prepare: Unset make environment variables
These interfere with building/installing packages with Portage.
2024-12-08 18:14:49 -06:00
Dustin 8e82643e10 build: Install util-linux from binpkg if possible
_sys-apps/util-linux_ first must be built (in the prepare stage) with
`USE=build` and then reinstalled later without that flag.  We can save
time in the second step by using binary packages if they are already
available (i.e. from a previous build).
2024-12-08 16:00:57 -06:00
Dustin d728ccfa97 build-rootfs: Install baselayout first
The _sys-apps/baselayout_ package handles initializing a new filesystem
hierarchy.  With `USE=build`, it will create the appropriate symlinks in
`/` for a merged-usr tree.
2024-12-08 16:00:57 -06:00
Dustin 0d6ace4fc7 portage: Provide a base Portage configuration
Instead of requiring every Aimee OS project to carry around a full
Portage configuration tree, including patches, saved configurations,
etc., we now support a "layered" configuration system.  Aimee OS core
provides a base configuration that includes all settings, patches, etc.
common for all Aimee OS projects.  At build time, this base
configuration is combined with the project's configuration, which need
only specify USE flags, etc. for that specific project.  This should
make maintenance across multiple projects easier, and make getting a new
project started _significantly_ less cumbersome.
2024-12-08 16:00:57 -06:00
Dustin 39f5b8464d build: Install GRUB, but not RPi firmware
GRUB is needed for all machines that run Aimee OS.  The Raspberry Pi
firmware, of course, is only needed to run Aimee OS on a Raspberry Pi.
Thus, the former should be listed in the global `build.packages` file,
while the latter should be built only for projects targeting Raspberry
Pis.
2024-12-05 22:45:41 -06:00
Dustin 238c3aff05 build-rootfs: Disable SELinux for now
Until we have a working CI pipeline that can appropriately manage the
SELinux policy in the target environment, anyway.
2024-12-05 22:43:19 -06:00
Dustin 62cdb405a3 prepare: Update to modern Portage profile
The 17.0 profiles are deprecated.  Let's use the project's configured
profile at this stage, so as not to have to rebuild stuff because we
change USE flages, etc. once we set it later.

The modern profiles are all "merged-usr" by default now, so we do not
need that explicit step anymore.
2024-12-05 22:42:03 -06:00
Dustin 1e8c7e7b85 build-kernel: Set USE=symlink as env var
Since this is the last vestige of the "host" Portage configuration
directory, we can remove it entirely by setting `USE=symlink` as an
environment variable.  This should be safe, since there are not many
other packages besides kernel sources that use this USE flag, and
they're not likely to be pulled in with this `emerge` invocation.
2024-12-05 22:40:24 -06:00
Dustin d117207bd2 Make more project config files optional
`build.packages`, `installonly.packages`, and `busybox.symlinks` are now
optional in the `$CONFIGDIR`.  If they do exist, they are combined with
the same files in the Aimee OS source.
2024-12-05 22:38:49 -06:00
Dustin 26b422ed74 Drop ebuild patches
None of these are necessary anymore.  They do not apply cleanly to
current versions of ebuilds in Gentoo's repository, causing builds to
fail.

Going forward, I think it will be better to maintain patched ebuilds in
the Aimee OS repository, rather than patching them at build time.
2024-12-05 20:04:31 -06:00
Dustin 70771c8067 Use host tools from build container
Instead of building host tools along with the target packages, we now
rely on the build container to contain everything we need to build Aimee
OS.  The _aimee-os.org/build/build-{target}_ image (tentative name)
includes a cross-compilation toolchain and all of the tools that were
originally listed in `host-tools.packages`.
2024-12-05 17:56:34 -06:00
Dustin 0672a80dee patches: app-containers/connmon: Drop go-md2man
This change has been merged upstream.

https://bugs.gentoo.org/902569
2023-07-28 14:19:08 -05:00
Dustin ab311001a5 ocivm.sh: Allow projects to specify build VM name
Projects can now set a `buildvm` variable in their `config` file to
specify a unique name for their build VMs.  This allows multiple
projects to have running VMs simultaneously.

If a project does not provide a name, the build VM will be called
`aimeebuild`.
2023-04-16 20:09:05 -05:00
Dustin 9ea8e26504 selinux: Allow passing tty devices to containers
The default SELinux policy does not allow passing generic USB devices
and unallocated TTYs to containers.  This prevents the Zigbee and ZWave
USB dongles from being usable by their respective container processes.
2023-04-16 20:07:40 -05:00
Dustin 0c0a06bce1 systemd/network: Rename default network config
`systemd-network-generator`, which parses network configuration from the
kernel command line and generates configuration for *systemd-networkd*,
creates a configuration file with priority 90.  This conflicts with our
default network configuration at the same priority, so the configuration
from the kernel command line never gets used.  By reducing our default
priority to 95, we ensure that the generated configuration file is read
first and thus overrides the defaults.
2023-04-16 20:04:21 -05:00
Dustin c821ec1ec4 Split repo: remove yellow configdir
Splitting the Home Assistant Yellow configuration out of this
repository, leaving only generic Aimee OS build system and
configuration.
2023-04-01 09:22:39 -05:00
Dustin dd178aaaba Add semanage.sh script
The `semanage.sh` script starts an interactive shell in an alternate
mount namespace where `/etc/selinux` and `/var/lib/selinux` are
bind-mounted from the target filesystem.  This allows SELinux management
commands like `setsebool`, `semodule, `semanage`, etc. to work on the
target policy, since not all of them directly support working on an
alternate policy.
2023-03-30 11:02:44 -05:00
Dustin d8e0af477a ocivm: Do not mount tmpfs for Portage
Very large packages cannot be built with `PORTAGE_TMPDIR` on a tmpfs
mount, unless the VM has a tremendous amount of RAM.  The performance
improvement is negligible anyway, so let's not bother.
2023-03-30 11:01:16 -05:00
Dustin 401a58a874 ocivm: Unify Portage cache directories
It turns out that QEMU microvms have a very limited number of I/O ports
available for e.g. attached disks and shared filesystems.  To conserve
ports, we'll use a single volume for both distfiles and binpkgs cache
directories.
2023-03-30 11:01:04 -05:00
Dustin 40bf772034 ocivm: Increase vRAM allocation
Building large packages like *dev-lang/go* and *app-containers/podman*
requires more memory.
2023-03-30 10:57:51 -05:00
Dustin caa303ba3d start-container: Change workdir to match ocivm
The `ocivm.sh` script mounts the source directory at `/tmp/src`, since
we use `/tmp/build` as the output directory.  For consistency, the
`start-container.sh` script, although it's mostly unused anymore, now
does the same.
2023-03-30 10:56:11 -05:00
Dustin 8e3d87cf45 Add flash.sh script
This script simplifies the process of erasing the target disk and
flashing `sdcard.img` onto it.
2023-03-30 09:31:12 -05:00
Dustin b312649a50 genimage: Fix partition alignment
`genimage` does not align partitions appropriately by default, but
simply packs them one-after-another based on their size.  This is easy
enough to fix by setting the `align` property in the `hdimage` block.
2023-03-30 09:31:12 -05:00
Dustin 80077a7934 make: Add build phony target
Now you can run `make build` to (re-)build binary packages.
2023-03-30 09:31:12 -05:00
Dustin 99971b5f50 SELinux: Allow Podman to mount /dev/log
These SELinux policy rules allow containers to log directly to
syslog/the systemd journal via the `/dev/log` socket.  To enable this,
simply mount the socket into a container's mount namespace, e.g. `-v
/dev/log:/dev/log`.
2023-03-30 09:31:12 -05:00
Dustin 77f7e6d8cc init-storage: Create intermediate dirs in /etc
When creating writable paths in the `/etc` subvolume, the `setup_etc`
function needs to create intermediate directories before copying
existing files from the root filesystem.  Without this step, `cp` will
fail with a "no such file or directory" error, referring to the
destination path.
2023-03-30 09:31:12 -05:00
Dustin 670c1f7561 yellow: Install/configure nginx
We're going to use *nginx* as the reverse proxy in front of Home
Assistant, as well as the web consoles for Zigbee2MQTT and ZWaveJS2MQTT.
It will provide TLS termination for all of these applications.

Since *nginx* will not start without a certificate and private key file
for HTTPS, the *gen-nginx-cert.service* systemd unit generates a
self-signed certificate if one does not already exist.  This ensures
that *nginx* can start by default, but still allows the administrator to
replace the certificate with a trusted one later.

The *nginx* container image has symlinks at `/var/log/nginx/error.log`
and `/var/log/nginx/access.log`, pointing to `/dev/stderr` and
`/dev/stdout`, respectively.  The intent here is to send all log
messages to the container runtime.  Unfortunately, when the the
container is managed by Podman from a systemd unit, the standard output
and standard error streams are connected to the systemd journal via a
UNIX socket.  As a result, the `/dev/stdout` and `/dev/stderr`
pseudo-files cannot be "opened" like normal files or pipes.  Thus, to
forward nginx's logs to the systemd journal correctly, we have to do a
bit of trickery.  For the error log at least, setting `error_log stderr`
works well; nginx simply writes messages to the existing file
descriptor.  Unfortunately, the access log has no such mechanism.  For
that, we use nginx's syslog capabilities.  The `/dev/log` socket is
bind-mounted into the container, and nginx is configured to connect to
it.
2023-03-30 09:23:47 -05:00
Dustin 02c3a12c08 Support semanage.mods
Aimee OS variants can now supply a `semange.mods` file in their
configuration directories.  This file contains SELinux customizations,
in the format produced by `semanage export`.  Variants can use this
mechanism to set SELinux booleans, change user/login mappings, and other
SELinux policy customization.  At build time, the base `selinux.mods`
file in the source directory is combined with the variant's file, if it
exists, and the resultant customizations are applied in a single
transaction.
2023-03-30 09:23:44 -05:00
Dustin a1999939eb SELinux: Allow init-storage to set permissions
Files and directories that have restrictive permissions and/or are now
owned by *root:root* require `cp` to have additional process
capabilities in order to copy them to the writable filesystem.
2023-03-30 09:03:45 -05:00
Dustin d1db08966d Define Podman zigbee2mqtt/zwavejs2mqtt containers 2023-03-30 09:03:45 -05:00
Dustin 38b0081012 make: Rebuild sdcard.img when rootfs built 2023-03-30 09:03:45 -05:00