Repository: systemd/mkosi

Issue:
postinst has no networking if systemd package is installed
Using main branch on Debian Sid with systemd-networkd and systemd-resolved.

Not sure if bug, but:

```
$ cat mkosi.conf 
[Distribution]
Distribution=ubuntu
Release=jammy

[Content]
Bootable=no
Packages=
    apt
    systemd
WithNetwork=yes

[Output]
Format=tar

$ cat mkosi.postinst 
#!/bin/sh -e
apt-get update
apt-get --yes install vim

$ mkosi
‣ Building default image                                                                                                                                                                                           
‣  Mounting image…                                                                                                                                                                                                 
‣   Installing Ubuntu    
...
‣   Running postinstall script…
Ign:1 http://archive.ubuntu.com/ubuntu jammy InRelease
Ign:2 http://security.ubuntu.com/ubuntu jammy-security InRelease
Ign:3 http://archive.ubuntu.com/ubuntu jammy-updates InRelease
Ign:1 http://archive.ubuntu.com/ubuntu jammy InRelease
Ign:2 http://security.ubuntu.com/ubuntu jammy-security InRelease
Ign:3 http://archive.ubuntu.com/ubuntu jammy-updates InRelease
Ign:1 http://archive.ubuntu.com/ubuntu jammy InRelease
Ign:2 http://security.ubuntu.com/ubuntu jammy-security InRelease
Ign:3 http://archive.ubuntu.com/ubuntu jammy-updates InRelease
Err:1 http://archive.ubuntu.com/ubuntu jammy InRelease
  Temporary failure resolving 'archive.ubuntu.com'
Err:2 http://security.ubuntu.com/ubuntu jammy-security InRelease
  Temporary failure resolving 'security.ubuntu.com'
Err:3 http://archive.ubuntu.com/ubuntu jammy-updates InRelease
  Temporary failure resolving 'archive.ubuntu.com'
Reading package lists... Done
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/jammy/InRelease  Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/jammy-updates/InRelease  Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/jammy-security/InRelease  Temporary failure resolving 'security.ubuntu.com'
W: Some index files failed to download. They have been ignored, or old ones used instead.
Reading package lists... Done
Building dependency tree... Done
E: Unable to locate package vim
‣ "chroot /work/postinst final" returned non-zero exit code 100.
```

Workaround: remove `systemd` from `mkosi.conf` and install it in `postinst`.

This "bug" was introduced with 724e09216e06a26ff1284bfa48d57a77f12a4ef4, so it's kind of expected, because if host's resolv.conf is symlink, then...


Discussion:

Resolving patch:
diff --git a/mkosi/run.py b/mkosi/run.py
--- a/mkosi/run.py
+++ b/mkosi/run.py
@@ -369,7 +369,7 @@ def chroot_cmd(root: Path, *, options: Sequence[PathString] = (), network: bool
             # mkdir(symlink) which obviously fails if multiple components of the dangling symlink path don't
             # exist yet. As a workaround, we resolve the symlink ourselves so that bubblewrap will correctly
             # create all missing components in the target path.
-            resolve = (root / resolve).readlink()
+            resolve = resolve.parent / (root / resolve).readlink()
 
         # If we're using the host network namespace, use the same resolver.
         cmdline += ["--ro-bind", "/etc/resolv.conf", Path("/") / resolve]


Test patch: