Bug 12726

Summary: systemctl preset-all failed for ctrl-alt-del.target
Product: buildroot Reporter: Melanie <melanie>
Component: OtherAssignee: unassigned
Status: RESOLVED INVALID    
Severity: normal CC: buildroot, yann.morin.1998
Priority: P5    
Version: 2020.02   
Target Milestone: ---   
Hardware: All   
OS: All   
Host: Target:
Build:
Attachments: Console log output

Description Melanie 2020-03-31 12:43:44 UTC
Created attachment 8421 [details]
Console log output

When finalizing target directory, buildroot executes the 'systemctl preset-all' command to preset (enable/disable) all systemd unit files.
This command runs successful during a full rebuild (after 'make clean'), however on subsequent partial rebuild attempts it fails with exit code 1 (log output attached).

A very similar issue was reported to the systemd-developers (ref [1]) but closed as 'not-a-bug'.

A possible solution that works for me is to add the '--force' option to the command.



[1] https://github.com/systemd/systemd/issues/12304#issuecomment-483168112
Comment 1 Yann E. MORIN 2020-04-01 18:09:00 UTC
Mélanie, All,

Sorry, I could not reproduce the failure with this defconfig, enither on 2020.02, nor on master:

    BR2_arm=y
    BR2_cortex_a7=y
    BR2_TOOLCHAIN_EXTERNAL=y
    BR2_INIT_SYSTEMD=y

This is during a make from scratch:
    $ make
    [...]
    /home/ymorin/dev/buildroot/O/host/bin/systemctl --root=/home/ymorin/dev/buildroot/O/target preset-all
    Created symlink /home/ymorin/dev/buildroot/O/target/etc/systemd/system/ctrl-alt-del.target → /usr/lib/systemd/system/reboot.target.
    Created symlink /home/ymorin/dev/buildroot/O/target/etc/systemd/system/getty.target.wants/console-getty.service → /usr/lib/systemd/system/console-getty.service.
    Created symlink /home/ymorin/dev/buildroot/O/target/etc/systemd/system/boot-complete.target.requires/systemd-boot-check-no-failures.service → /usr/lib/systemd/system/systemd-boot-check-no-failures.service.
    Created symlink /home/ymorin/dev/buildroot/O/target/etc/systemd/system/dbus-org.freedesktop.resolve1.service → /usr/lib/systemd/system/systemd-resolved.service.
    Created symlink /home/ymorin/dev/buildroot/O/target/etc/systemd/system/multi-user.target.wants/systemd-resolved.service → /usr/lib/systemd/system/systemd-resolved.service.
    Created symlink /home/ymorin/dev/buildroot/O/target/etc/systemd/system/multi-user.target.wants/remote-fs.target → /usr/lib/systemd/system/remote-fs.target.
    Created symlink /home/ymorin/dev/buildroot/O/target/etc/systemd/system/sockets.target.wants/systemd-networkd.socket → /usr/lib/systemd/system/systemd-networkd.socket.
    Created symlink /home/ymorin/dev/buildroot/O/target/etc/systemd/system/sysinit.target.wants/systemd-time-wait-sync.service → /usr/lib/systemd/system/systemd-time-wait-sync.service.
    Created symlink /home/ymorin/dev/buildroot/O/target/etc/systemd/system/network-pre.target.wants/systemd-network-generator.service → /usr/lib/systemd/system/systemd-network-generator.service.
    Created symlink /home/ymorin/dev/buildroot/O/target/etc/systemd/system/network-online.target.wants/systemd-networkd-wait-online.service → /usr/lib/systemd/system/systemd-networkd-wait-online.service.
    Created symlink /home/ymorin/dev/buildroot/O/target/etc/systemd/system/systemd-remount-fs.service.wants/systemd-pstore.service → /usr/lib/systemd/system/systemd-pstore.service.
    Created symlink /home/ymorin/dev/buildroot/O/target/etc/systemd/system/dbus-org.freedesktop.network1.service → /usr/lib/systemd/system/systemd-networkd.service.
    Created symlink /home/ymorin/dev/buildroot/O/target/etc/systemd/system/multi-user.target.wants/systemd-networkd.service → /usr/lib/systemd/system/systemd-networkd.service.
    Created symlink /home/ymorin/dev/buildroot/O/target/etc/systemd/system/dbus-org.freedesktop.timesync1.service → /usr/lib/systemd/system/systemd-timesyncd.service.
    Created symlink /home/ymorin/dev/buildroot/O/target/etc/systemd/system/sysinit.target.wants/systemd-timesyncd.service → /usr/lib/systemd/system/systemd-timesyncd.service.
    rm -f /home/ymorin/dev/buildroot/O/build/locales.nopurge
    [...]

Then a subsequent make would yield:
    $ make
    [...]
    /home/ymorin/dev/buildroot/O/host/bin/systemctl --root=/home/ymorin/dev/buildroot/O/target preset-all
    rm -f /home/ymorin/dev/buildroot/O/build/locales.nopurge
    [...]

As you can see, neither the first nor the the second invocation cause any issue.

Care to share a bit more info about your config and your host, please?
Comment 2 Melanie 2020-04-11 19:14:12 UTC
Okay, during further troubleshooting I realized that the problem was caused by my custom configuration, which modifies the target directory (deletes all preset-configuration-files) after the 'finalizing target directory' phase where the 'systemctl preset-all' command runs (this explains why a full rebuild had succeeded but subsequent partial rebuild attempts have failed).

The fact that the 'systemctl preset-all' command fails when there are no preset-configuration-files at all on the target file system, is a systemd issue, so I'm closing this bug report here as invalid.
Comment 3 Yann E. MORIN 2020-04-11 19:19:48 UTC
> the problem was caused by my custom configuration [...] closing this bug report here as invalid.

Thanks for the feedback.