Traceback (most recent call last):
File "/bin/mkosi", line 3767, in <module>
main()
File "/bin/mkosi", line 3757, in main
build_stuff(args)
File "/bin/mkosi", line 3573, in build_stuff
setup_package_cache(args)
File "/bin/mkosi", line 2412, in setup_package_cache
d = tempfile.TemporaryDirectory(dir=os.path.dirname(args.output), prefix=".mkosi-")
File "/usr/lib64/python3.7/tempfile.py", line 788, in __init__
self.name = mkdtemp(suffix, prefix, dir)
File "/usr/lib64/python3.7/tempfile.py", line 366, in mkdtemp
_os.mkdir(file, 0o700)
FileNotFoundError: [Errno 2] No such file or directory: '/home/lucas/p/mkosi/bla/.mkosi-l3oxfchg'
mkosi: strictly require offline operation from systemctl
It's very likely systemctl will run in one of the scripts. Let's always
make sure it never even tries to talk to PID, simply as a matter of
robustness.
Zygmunt Krynicki [Wed, 24 Oct 2018 11:33:09 +0000 (13:33 +0200)]
Add CommandLineArguments type
This patch adds a new type that is the result of parsing command line
arguments via argparse.ArgumentParser.parse_args(). This type will gain
typed attributes that will allow to type check all the functions using
it, gradually, one by one.
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
fedora: add new dir and make mkosi.default just a symlink
Contributors from other distros will probably want to add similar
configs, so it makes sense to "demote" the Fedora config. A new dir is
created to avoid cluttering the root directory with those files.
Zygmunt Krynicki [Fri, 19 Oct 2018 13:22:27 +0000 (15:22 +0200)]
Add static type annotations
This patch adds a lot of type annotations, as compatible with mypy
0.620. The type checking is not perfect as many places use loosely typed
argparse.Namespace and I didn't want to introduce any changes there.
Some errors reported by mypy now show missing None checks but I also
decided not to fix them and make the review more complex. This patch
should only annotate types, nothing else.
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
By forcing the installation of glibc-minimal-langpack we avoid glibc-all-langpacks
which is quite large. See
https://fedoraproject.org/wiki/Changes/Remove_glibc-langpacks-all_from_buildroot.
While at it, configure the locale as C.utf8 so we don't get the
default which is POSIX.
Add architecture-specific paths before generic ones (they’re more likely
to be correct for the current architecture), and add some paths from the
Arch Linux `ovmf` (“extra” repository) and `edk2-ovmf` (Arch User
Repository) packages.
Chris Patterson [Tue, 13 Feb 2018 16:07:07 +0000 (11:07 -0500)]
mkosi: fix to enable Fedora rawhide support
The Fedora repos require using the release version of 'rawhide' in the URLs,
while mkosi currently forces you to select a specific version number, e.g. 28.
You can not install Fedora '28', but you can install 'rawhide', using the gpg
keys for release version '28'.
These changes:
(1) Assume the latest (known) version when --release=rawhide, but warn the user
(2) Allow user to override a specific rawhide version with the option
--release=rawhide-<version>
Lucas De Marchi [Mon, 8 Oct 2018 23:01:57 +0000 (16:01 -0700)]
Allow to run qemu >= 2.12
While trying to call "mkosi qemu" on a Clear Linux host it reported
qemu: could not load PC BIOS '/usr/share/qemu/OVMF_CODE.fd'
Cross checking with my Fedora host the only real difference I see is the
qemu version. Changing it to pass a pflash drive directly makes it work
and also make it explicit that the it is a readonly device.
By installing glibc-minimal-langpack we avoid the installation of glibc-all-langpacks
(glibc requires glibc-langpack (provided by all langpacks) and suggests
glibc-all-langpacks (so that is the default when there is nothing else to
satisfy the require). By forcing a different langpack package, we avoid the
installation of any others.
git-core is similar to git, but does not pull in some lisp and perl stuff.
kernel-core is similar to kernel, but does not include some fancy drivers.
(The conversion of string concatenation to two writes makes this snippet
more similar to the cmdline snippet below; perhaps we can later refactor
it into a helper function, similar to systemd’s write_string_file().)
Rename "Post Installation Script" to "Postinstall script" (#235)
The short version is pretty well established in packaging world, and
anyway "post-installation" or even "postinstallation" would be more
correct than "post installation" as an adjective.
Before this patch, mkosi wouldn't even run --help on a platform that
wasn't amd64 or arm64. That's unnecessarily harsh, a lot of functionality
is platform-independent and will work anywhere.
Georges Discry [Tue, 23 Jan 2018 23:52:41 +0000 (00:52 +0100)]
arch: better package selection
The package selection for Arch Linux is not optimal, especially when the
image is not bootable. The main issue is that a kernel is still
installed when the image is not bootable.
Optional packages from the `base` group that are required under specific
configurations are first deleted from the package selection and
explicitly re-added when required. For example, the `cryptsetup` and
`device-mapper` packages are included only if the image is bootable and
encrypted. Similarly, a kernel is included only if the image is
bootable or if the user selected one explicitly.
Sets are now better used in the package selection. The appropriate
operators and methods are directly used instead of relying on
intermediary sets.
The installation of the packages is split into two operations. The first
only installs the packages from the `base` group and the second installs
the packages selected by the user. This is necessary because some
packages (e.g. `git`) have an install script that depends on the `base`
group without listing those in their dependencies. If they are installed
before their implicit dependency, their install script will most likely
fail.
Georges Discry [Wed, 18 Oct 2017 01:00:18 +0000 (03:00 +0200)]
arch: always use the custom pacman.conf
The custom pacman.conf is completed to contain a full explicit
configuration based on the `root` directory inside the workspace.
All the calls to pacman (and related commands) use that configuration
and never touch the host system. Particularly, the host keyring and sync
databases are left untouched.
Lucas De Marchi [Thu, 8 Feb 2018 00:23:30 +0000 (16:23 -0800)]
Support copying git submodule files
Besides getting the files from the git directory, iterate through each
submodules to copy them over to the build image as well. We had some
(better) alternative, but each of them failing to provide what we need:
- Recent versions for git-ls-files learned a --recurse-submodules
but they are not support together with --others
- git-submodule foreach --recursive would allow us to git-ls-files
inside each submodule, however there's no easy way to control from
which submodule the command is printing the files in order to
prepend the submodule path
So for now we live with getting the list of submodules from
`git submodule status --recursive` and calling git-ls-files on each of
them.
Lucas De Marchi [Wed, 7 Feb 2018 23:07:54 +0000 (15:07 -0800)]
Fix copy of symlinks
When copying files we should not be following the symlinks. This became
a problem in kmod after removing the git-clone method to copy files
because we have intentionally broken symlinks there:
File "/usr/bin/mkosi", line 170, in open_close
fd = os.open(path, flags | os.O_CLOEXEC, mode)
FileNotFoundError: [Errno 2] No such file or directory:
'/home/lucas/p/kmod/testsuite/rootfs-pristine/test-loaded/sys/module/btusb/drivers/usb:btusb'
make: *** [Makefile:3009: mkosi] Error 1
Although it's worse when the symlink is broken, it would silently succeed when
it's not but producing an invalid output.
Lucas De Marchi [Wed, 7 Feb 2018 21:57:41 +0000 (13:57 -0800)]
Stop using git-clone to copy files
This partially reverts "0c8d7d5 (rework copy_git_files() to use a git
clone)", retaining the fixes to ls-files. Using git clone allowed build
systems to get commit information through git and work with submodules,
but it didn't come without drawbacks like modifying the mtime and
permissions of the copied files. The drawbacks means that the build
cache doesn't really work as intended.
For git-submodules another solution will be provided later.
This variable keeps a colon-delimited list of paths to be prepended to
PATH in the context of mkosi execution. Unlike shell variable
expansion, if any path refers to an unset variable, that path will be
ignored.
Besides the environment variables, the variable SUDO_HOME can be used
to refer to the home directory of the user calling mkosi with
sudo. This allows settings like
Use delimiter as parameter. ListAction with a different delimiter will
be used later for colon delimited lists.
Opted to make a CommaDelimitedListAction instead of making "," the
default delimiter so that the lines adding arguments will be more
explicitly about what kind of list they are using.
mkosi: rework how we reenable kernel-install snippets
The old code doesn't really work: we can't store the list of snippets we
masked in a global variable, since we run the whole build process
multiple times and data from the first run might confuse follow-up runs
and really should not.
This reworks the logic so that we keep track precisely which snippets
are masked and return this from disable_kernel_install(). We then pass
that back into reenable_kernel_install() to undo the effect later on.
This way the information never leaks into later runs.
Let's make the funciton more like the other install_xyz() functions.
Let's invoke it from the same place.
Also, most importantly: let's unconditionally remove /etc/hostname
first, so that either what the user configured takes effect or the file
doesn't exist at all, so that systemd's internal default hostname logic
can take place. This is also the better choice in case /etc/hostname is
a symlink.
When resetting machine-id and it doesn't exist, don't fail, just
proceed to create a new one. The basic filesystem of Clear Linux we
will be using for bootstrap doesn't have a /etc/machine-id
out-of-the-box.
Lénaïc Huard [Mon, 8 Jan 2018 08:37:34 +0000 (09:37 +0100)]
Use an UTF-8 locale on Arch Linux (#214)
Commit 0dc40f40 introduced the generation of an UTF-8 locale at build time.
This commit makes it used.
For example, before this commit, we still had:
```
[root@archlinux ~]# systemctl status
* archlinux
State: running
Jobs: 0 queued
Failed: 0 units
Since: Sun 2018-01-07 22:13:47 CET; 32min ago
CGroup: /
|-user.slice
| `-user-0.slice
| |-session-c1.scope
| | |-125 login -- root
```
whereas with this commit, we now have a prettier printed:
```
[root@archlinux ~]# systemctl status
● archlinux
State: running
Jobs: 0 queued
Failed: 0 units
Since: Sun 2018-01-07 22:13:47 CET; 33min ago
CGroup: /
├─user.slice
│ └─user-0.slice
│ ├─session-c1.scope
│ │ ├─125 login -- root
```
Lénaïc Huard [Sun, 7 Jan 2018 21:27:51 +0000 (22:27 +0100)]
Stop patching nsswitch.conf and make resolv.conf points to stub-resolv.conf on Arch Linux
The `nsswitch.conf` file that comes by default on Arch Linux is now fully systemd-resolved compatible.
Its `hosts:` line is now:
```
hosts: files mymachines resolve [!UNAVAIL=return] dns myhostname
```
So, there is no need to patch this file when enabling systemd-resolved on Arch Linux anymore.
Also make `/etc/resolv.conf` points to the new dynamic `/run/systemd/resolve/stub-resolv.conf` rather than the older static `/usr/lib/systemd/resolv.conf`.
Lucas De Marchi [Fri, 5 Jan 2018 19:12:35 +0000 (11:12 -0800)]
Re-enable kernel install scripts (#211)
After doing the distro installation we'd better re-enable the install
scripts from the distro so we can continue to support scripts that
install kernels following the Bootloader Spec (even though we prefer
a unified image here).
Lucas De Marchi [Thu, 4 Jan 2018 22:45:34 +0000 (14:45 -0800)]
Add tar archive support for extra and skeleton trees
Like documentation here says, it allows one to preseve file ownership
when adding files to the final image. This may be particularly useful if
you are adding configuration files for a daemon that is not supposed to
run as root, but as a pre-defined user.
Lucas De Marchi [Thu, 4 Jan 2018 22:23:40 +0000 (14:23 -0800)]
Simplify assignments by using empty lists as default
Make argparse use empty lists as default rather than None
for arguments that receive lists. This allows us to simplify all the
conditional assign or extend throught the code.
This is done for packages, build_packages, extra_trees and
skeleton_trees, removing the conditional assignments and leaving only
a call to extend() that can handle the case the list is empty. Also
checks for `if X is None` need to be converted to `if not X`.
Lucas De Marchi [Wed, 8 Nov 2017 16:09:32 +0000 (08:09 -0800)]
Add support to skeleton trees
It's already possible to pass extra trees to copy over the final tree
after installing all packages. However in some cases it is desirable to
copy the tree before installing packages or running anything in the
image. One of the cases is if we want to enable additional repositories
for the package manager or want to configure it in a particular way.
Now mkosi can use a mkosi.skeleton directory (or by passing a
--skeleton-tree argument) in the same way it currently supports extra
trees, however copying them before running the "install_distro" phase.
To allow changing the package manager configuration distros may need
more tweaks to point the package manager to the right files. Right now
this has been tested with Fedora 27 by adding
`mkosi.skeleton/etc/yum.repos.d/rpmfusion-free.repo` and installing a
package from that repo.
Sebastian [Mon, 27 Nov 2017 07:04:49 +0000 (08:04 +0100)]
Change opensuse zypper pattern to a form that works everywhere (#109)
[zj: The pattern "lost visibility" at some point. This is fixed in tumbleweed, but
not in some other versions, so let's use the form that works everywhere for now.
See https://bugzilla.opensuse.org/show_bug.cgi?id=1049997.]