| Summary: | systemd-resolved: /etc/resolv.conf link broken on per-package build | ||
|---|---|---|---|
| Product: | buildroot | Reporter: | Michael Nosthoff <buildroot> |
| Component: | Other | Assignee: | unassigned |
| Status: | RESOLVED FIXED | ||
| Severity: | normal | CC: | buildroot, leojrfs, yann.morin.1998 |
| Priority: | P5 | ||
| Version: | 2021.02 | ||
| Target Milestone: | --- | ||
| Hardware: | All | ||
| OS: | Linux | ||
| Host: | Target: | ||
| Build: | |||
| Attachments: | skeleton-init-systemd per-package workaround | ||
|
Description
Michael Nosthoff
2020-10-13 13:53:34 UTC
Created attachment 8836 [details]
skeleton-init-systemd per-package workaround
I can confirm this.
This kind of issues might happen when using `per-package`.
The reason for this is that `target-finalize` rsyncs all the target subdirectories under the package directory (example: `$O/per-package/foo/target`) in alphabetic order:
```
$(call per-package-rsync,$(sort $(PACKAGES)),target,$(TARGET_DIR))
```
So, files in the final target, might get consecutively overwritten in that process by the content of each package `per-package` `target` directory.
In this case, `udev` is one of the packages that overrides the `resolv.conf`, it comes after `systemd` in the rsync order previously mentioned.
`udev` depends on `toolchain` which in turn depends on `skeleton-init-systemd`, where `resolv.conf` is a link to `../tmp/resolv.conf`, thus, `$O/per-package/udev/target/etc/resolv.conf` gets its value by rsyncing `$O/per-package/toolchain/target/etc/resolv.conf` just before building.
Ideally, rsync would execute in dependency order instead of alphabetic order. I tried to tinker around that, but had not much success. Im not sure how to solve this problem.
In the meanwhile, I attach a patch for `skeleton-init-systemd.mk`, which solves this specific issue. Im not sure it is the best way to solve this problem, for the reasons I just mentioned.
Any thoughts?
btw, this is still reproducible on 2021.02 Michael, All,
> define SYSTEMD_INSTALL_RESOLVCONF_HOOK
> ln -sf ../run/systemd/resolve/resolv.conf \
> $(TARGET_DIR)/etc/resolv.conf
> endef
> [...]
> SYSTEMD_POST_INSTALL_TARGET_HOOKS += \
> SYSTEMD_INSTALL_RESOLVCONF_HOOK
Indeed, a hook doing such changes should be made to be a target-fianlize
hook rather than a post-target-install hook.
In systemd, there is already a target-finalize hook, for the nsswitch
configuration file.
Care to send a patch, please?
Regards,
Yann E. MORIN.
Michael, All, Thanks for the report. This is now supposedly fixed with commit 511fbda0be that has just been pushed. Regards, Yann E. MORIN. |