|
13 | 13 | #include <string.h>
|
14 | 14 | #include <unistd.h>
|
15 | 15 |
|
| 16 | +#include "sd-bus.h" |
| 17 | +#include "sd-login.h" |
| 18 | + |
16 | 19 | #include "libudev-util.h"
|
| 20 | +#include "string-util.h" |
| 21 | +#include "strv.h" |
17 | 22 | #include "time-util.h"
|
18 |
| -#include "udevadm.h" |
19 | 23 | #include "udev-ctrl.h"
|
| 24 | +#include "udevadm.h" |
| 25 | +#include "unit-def.h" |
20 | 26 | #include "util.h"
|
21 | 27 | #include "virt.h"
|
22 | 28 |
|
@@ -79,6 +85,61 @@ static int parse_argv(int argc, char *argv[]) {
|
79 | 85 | return 1;
|
80 | 86 | }
|
81 | 87 |
|
| 88 | +static int emit_deprecation_warning(void) { |
| 89 | + _cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL; |
| 90 | + _cleanup_free_ char *unit = NULL, *unit_path = NULL; |
| 91 | + _cleanup_strv_free_ char **a = NULL, **b = NULL; |
| 92 | + int r; |
| 93 | + |
| 94 | + r = sd_pid_get_unit(0, &unit); |
| 95 | + if (r < 0 || !streq(unit, "systemd-udev-settle.service")) |
| 96 | + return 0; |
| 97 | + |
| 98 | + log_notice("systemd-udev-settle.service is deprecated."); |
| 99 | + |
| 100 | + r = sd_bus_open_system(&bus); |
| 101 | + if (r < 0) |
| 102 | + return log_debug_errno(r, "Failed to open system bus, skipping dependency queries: %m"); |
| 103 | + |
| 104 | + unit_path = unit_dbus_path_from_name("systemd-udev-settle.service"); |
| 105 | + if (!unit_path) |
| 106 | + return -ENOMEM; |
| 107 | + |
| 108 | + (void) sd_bus_get_property_strv( |
| 109 | + bus, |
| 110 | + "org.freedesktop.systemd1", |
| 111 | + unit_path, |
| 112 | + "org.freedesktop.systemd1.Unit", |
| 113 | + "WantedBy", |
| 114 | + NULL, |
| 115 | + &a); |
| 116 | + |
| 117 | + (void) sd_bus_get_property_strv( |
| 118 | + bus, |
| 119 | + "org.freedesktop.systemd1", |
| 120 | + unit_path, |
| 121 | + "org.freedesktop.systemd1.Unit", |
| 122 | + "RequiredBy", |
| 123 | + NULL, |
| 124 | + &b); |
| 125 | + |
| 126 | + r = strv_extend_strv(&a, b, true); |
| 127 | + if (r < 0) |
| 128 | + return r; |
| 129 | + |
| 130 | + if (!strv_isempty(a)) { |
| 131 | + _cleanup_free_ char *t = NULL; |
| 132 | + |
| 133 | + t = strv_join(a, ", "); |
| 134 | + if (!t) |
| 135 | + return -ENOMEM; |
| 136 | + |
| 137 | + log_notice("Hint: please fix %s not to pull it in.", t); |
| 138 | + } |
| 139 | + |
| 140 | + return 0; |
| 141 | +} |
| 142 | + |
82 | 143 | int settle_main(int argc, char *argv[], void *userdata) {
|
83 | 144 | _cleanup_(udev_queue_unrefp) struct udev_queue *queue = NULL;
|
84 | 145 | struct pollfd pfd;
|
@@ -128,6 +189,8 @@ int settle_main(int argc, char *argv[], void *userdata) {
|
128 | 189 | .fd = r,
|
129 | 190 | };
|
130 | 191 |
|
| 192 | + (void) emit_deprecation_warning(); |
| 193 | + |
131 | 194 | for (;;) {
|
132 | 195 | if (arg_exists && access(arg_exists, F_OK) >= 0)
|
133 | 196 | return 0;
|
|
0 commit comments