Commit Graph

9 Commits (79e69cf70df3586bd4ef4b15f577b42719380f38)

Author SHA1 Message Date
Dustin b1afb4adf1 Configure Home Assistant Podman container
The default Home Assistant configuration does not allow running a
reverse proxy in front of the application.  To enable this, the
`use_x_forwarded_for` and `trusted_proxies` options have to be set.

Since we want `/var/lib/homeassistant` to be a Btrfs subvolume, we can't
simply include the necessary files in the correct location in the rootfs
image.  Instead, we must define "copy tree" (`C`) actions for
`systemd-tmpfiles` to copy them from `/usr/share/factory`.
Unfortunately, `systemd-tmpfiles` considers `v` and `C` actions
conflicting, and thus will not copy the directory contents recursively.
Each file has to be listed explicitly.
2023-03-30 08:56:14 -05:00
Dustin 0bc861ced1 Split out base squashfs.exclude
Variants no longer need to specify the full contents of the
`squashfs.exclude` file.  The "base" file in the source directory gets
combined with the one from the config directory (if it exists).
2023-03-29 18:44:45 -05:00
Dustin 31d8a98f64 build: Implement CONFIGDIR setting
In effort to support different builds of Aimee OS using the same
scripts, without necessarily having to fork this repository, the build
system now supports a `CONFIGDIR` setting.  When this variable is set,
files defining the target environment, such as the lists of packages to
install, the kernel configuration, the Portage configuration, etc. are
found in the path it specifes.

The reference build, for the Home Assistant Yellow board, is configured
in the `yellow` directory.  To build it, run:

```sh
CONFIGDIR=yellow ./vm-build.sh
```
2023-03-15 21:12:04 -05:00
Dustin 2b6b777282 Omit more unnecessary files from rootfs.squashfs
These are related to making SELinux policy changes at runtime.
2023-03-12 21:35:37 -05:00
Dustin 328b59e84a Omit /var/.updated from rootfs image
This file should not pre present when a machine is first booted, so that
systemd units with `ConditionNeedsUpdate=/var` will be activated.
2023-03-12 12:53:16 -05:00
Dustin f2d6db5af1 Enable SELinux
Enabling SELinux on the target system needs build-time and run-time
configuration changes for ther kernel and userspace.  Additionally,
SELinux requires a policy that defines allowed operations.  Gentoo
provides a reasonable baseline for all of these changes, but some
modifications are required.

First and foremost, the Gentoo SELinux policy is missing several
necessary rules for systemd-based systems.  Notably, services that use
alternate namespaces will fail to start because the base policy does not
allow systemd components the necessary privileges, so these rules have
to be added.  Similarly, `systemd-journald` needs additional privileges
in order to be able to capture all metadata for processes generating
syslog messages.  Finally, additional rules are necessary in order to
allow systemd to create files and directories prior to launching
servies.

Besides patching the policy, we also do some hackery to avoid shipping
the Python runtime in SELinux-enabled builds.  Several SELinux-related
packages, including *libselinux* and *policycoreutils* have dependencies
on Python modules for some of their functionality.  Unfortunately, the
Python build system does NOT properly cross-compile native extension
modules, so this functionality is not available on the target system.
Fortunately, none of the features provided by these modules are actually
needed at runtime, so we can safely ignore them and thus omit the entire
Python runtime and all Python programs from the final image.

It is important to note that it is impossible to build an
SELinux-enabled image on a host that is itself SELinux-enabled.
Operations such as changing file labels are checked against the SELinux
policy in the running kernel, and may be denied if the target policy
differs significantly from the running policy.  The `setfiles` command
fails, for example, when run on a Fedora host.  As such, building an
SELinux-enabled system should be done in a virtual machine using a
kernel that does not have a loaded SELinux policy.  The `ocivm` script
can be used to create a suitable runtime from a container image.
2023-03-12 12:34:12 -05:00
Dustin b19c0941a7 squashfs: Omit /usr/lib/udev/hwdb.d
This path is redundant and not necesssary on the installed system.
2023-02-14 21:09:13 -06:00
Dustin d4fdb36d45 Exclude more extraneous files from rootfs image 2023-02-14 00:30:32 -06:00
Dustin 025b7c6115 Initial commit 2023-02-13 23:24:36 -06:00