sysupdated: Drop the Update() D-Bus method
Now that it’s been replaced by `Acquire()` and `Install()`, there’s no need to expose it as a separate method. Wrappers around `sysupdated` can still expose an ‘update’ convenience verb by calling those two methods. Signed-off-by: Philip Withnall <pwithnall@gnome.org> Helps: https://github.com/systemd/systemd/issues/34814
This commit is contained in:
@@ -120,11 +120,6 @@ node /org/freedesktop/sysupdate1/target/host {
|
||||
in t flags,
|
||||
out s json);
|
||||
CheckNew(out s new_version);
|
||||
Update(in s new_version,
|
||||
in t flags,
|
||||
out s new_version,
|
||||
out t job_id,
|
||||
out o job_path);
|
||||
Acquire(in s new_version,
|
||||
in t flags,
|
||||
out s new_version,
|
||||
@@ -173,8 +168,6 @@ node /org/freedesktop/sysupdate1/target/host {
|
||||
|
||||
<variablelist class="dbus-method" generated="True" extra-ref="CheckNew()"/>
|
||||
|
||||
<variablelist class="dbus-method" generated="True" extra-ref="Update()"/>
|
||||
|
||||
<variablelist class="dbus-method" generated="True" extra-ref="Acquire()"/>
|
||||
|
||||
<variablelist class="dbus-method" generated="True" extra-ref="Install()"/>
|
||||
@@ -259,7 +252,8 @@ node /org/freedesktop/sysupdate1/target/host {
|
||||
<listitem><para>A boolean indicating whether this version is incomplete, which means that it is
|
||||
missing some file. Note that only installed incomplete versions will be offered by the service;
|
||||
versions that are incomplete on the server-side are completely ignored. Incomplete versions can
|
||||
be repaired in-place by calling <function>Update()</function> on that version.</para></listitem>
|
||||
be repaired in-place by calling <function>Acquire()</function> and <function>Install()</function>
|
||||
on that version.</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
@@ -275,17 +269,6 @@ node /org/freedesktop/sysupdate1/target/host {
|
||||
<function>Describe()</function> to query more information about the version returned by this method.
|
||||
</para>
|
||||
|
||||
<para><function>Update()</function> installs an update for this target. If a
|
||||
<varname>new_version</varname> is specified, that is the version that gets installed. Otherwise, the
|
||||
latest version is installed. The <varname>flags</varname> argument is added for future
|
||||
extensibility. No flags are currently defined, and the argument is required to be set to
|
||||
<literal>0</literal>. Unlike all the other methods in this interface, <function>Update()</function>
|
||||
does not wait for its job to complete. Instead, it returns the job's numeric ID and object path as soon
|
||||
as the job begins, so that the caller can listen for progress updates or cancel the operation. This
|
||||
method also returns the version the target will be updated to, for cases where no version was specified
|
||||
by the caller. This method pulls both metadata and payload data from the network. Listen for the
|
||||
Manager's <function>JobRemoved()</function> signal to detect when the job is complete.</para>
|
||||
|
||||
<para><function>Acquire()</function> downloads an update for this target, if one is available. If a
|
||||
<varname>new_version</varname> is specified, that is the version that gets downloaded. Otherwise, the
|
||||
latest version is downloaded. Call <function>Install()</function> to install the acquired update.
|
||||
@@ -381,7 +364,7 @@ node /org/freedesktop/sysupdate1/target/host {
|
||||
preemptive decisions to be made about features that are planned to appear in future releases of the OS.
|
||||
The drop-in will have a filename of <literal>50-systemd-sysupdate-enabled.conf</literal>.
|
||||
This method only changes configuration files; to actually apply the changes, clients will need to
|
||||
call <function>Update()</function> (or <function>Acquire()</function> and <function>Install()</function>).
|
||||
call <function>Acquire()</function> and <function>Install()</function>.
|
||||
Depending on the exact needs of the client, it can choose to update the system to the latest available
|
||||
version, or it can extend the newest existing installation in-place (by passing in the version returned
|
||||
by <varname>GetVersion()</varname>).
|
||||
@@ -431,7 +414,7 @@ node /org/freedesktop/sysupdate1/target/host {
|
||||
use the polkit action <interfacename>org.freedesktop.sysupdate1.check</interfacename>.
|
||||
By default, this action is permitted without administrator authentication.</para>
|
||||
|
||||
<para><function>Update()</function>, <function>Acquire()</function> and <function>Install()</function>
|
||||
<para><function>Acquire()</function> and <function>Install()</function>
|
||||
use the polkit action
|
||||
<interfacename>org.freedesktop.sysupdate1.update</interfacename> when no version is specified.
|
||||
By default, this action is permitted without administrator authentication. When a version is
|
||||
@@ -531,15 +514,15 @@ node /org/freedesktop/sysupdate1/job/_1 {
|
||||
|
||||
<para>The <varname>Type</varname> property exposes the type of operation (one of:
|
||||
<literal>list</literal>, <literal>describe</literal>, <literal>check-new</literal>,
|
||||
<literal>update</literal>, <literal>acquire</literal>, <literal>install</literal>,
|
||||
<literal>vacuum</literal>, or <literal>describe-feature</literal>).</para>
|
||||
<literal>acquire</literal>, <literal>install</literal>, <literal>vacuum</literal>, or
|
||||
<literal>describe-feature</literal>).</para>
|
||||
|
||||
<para>The <varname>Offline</varname> property exposes whether the job is permitted to access
|
||||
the network or not.</para>
|
||||
|
||||
<para>The <varname>Progress</varname> property exposes the current progress of the job as a value
|
||||
between 0 and 100. It is only available for <literal>update</literal>, <literal>acquire</literal> and
|
||||
<literal>install</literal> jobs; for all other jobs it is always 0.</para>
|
||||
between 0 and 100. It is only available for <literal>acquire</literal> and <literal>install</literal>
|
||||
jobs; for all other jobs it is always 0.</para>
|
||||
</refsect2>
|
||||
|
||||
<refsect2>
|
||||
@@ -598,7 +581,6 @@ node /org/freedesktop/sysupdate1/job/_1 {
|
||||
<para><function>List()</function>,
|
||||
<function>Describe()</function>,
|
||||
<function>CheckNew()</function>,
|
||||
<function>Update()</function>,
|
||||
<function>Acquire()</function>,
|
||||
<function>Install()</function>,
|
||||
<function>Vacuum()</function>,
|
||||
|
||||
@@ -62,10 +62,6 @@
|
||||
send_interface="org.freedesktop.sysupdate1.Target"
|
||||
send_member="CheckNew"/>
|
||||
|
||||
<allow send_destination="org.freedesktop.sysupdate1"
|
||||
send_interface="org.freedesktop.sysupdate1.Target"
|
||||
send_member="Update"/>
|
||||
|
||||
<allow send_destination="org.freedesktop.sysupdate1"
|
||||
send_interface="org.freedesktop.sysupdate1.Target"
|
||||
send_member="Acquire"/>
|
||||
|
||||
@@ -100,7 +100,6 @@ typedef enum JobType {
|
||||
JOB_LIST,
|
||||
JOB_DESCRIBE,
|
||||
JOB_CHECK_NEW,
|
||||
JOB_UPDATE,
|
||||
JOB_ACQUIRE,
|
||||
JOB_INSTALL,
|
||||
JOB_VACUUM,
|
||||
@@ -123,7 +122,7 @@ struct Job {
|
||||
|
||||
JobType type;
|
||||
bool offline;
|
||||
char *version; /* Passed into sysupdate for JOB_DESCRIBE, JOB_UPDATE, JOB_ACQUIRE and JOB_INSTALL */
|
||||
char *version; /* Passed into sysupdate for JOB_DESCRIBE, JOB_ACQUIRE and JOB_INSTALL */
|
||||
char *feature; /* Passed into sysupdate for JOB_DESCRIBE_FEATURE */
|
||||
|
||||
unsigned progress_percent;
|
||||
@@ -155,7 +154,6 @@ static const char* const job_type_table[_JOB_TYPE_MAX] = {
|
||||
[JOB_LIST] = "list",
|
||||
[JOB_DESCRIBE] = "describe",
|
||||
[JOB_CHECK_NEW] = "check-new",
|
||||
[JOB_UPDATE] = "update",
|
||||
[JOB_ACQUIRE] = "acquire",
|
||||
[JOB_INSTALL] = "install",
|
||||
[JOB_VACUUM] = "vacuum",
|
||||
@@ -226,7 +224,7 @@ static int job_new(JobType type, Target *t, sd_bus_message *msg, JobComplete com
|
||||
|
||||
/* Is Job in the set of jobs which require Target.busy to be set so they run exclusively? */
|
||||
static bool job_requires_busy(Job *j) {
|
||||
return IN_SET(j->type, JOB_UPDATE, JOB_ACQUIRE, JOB_INSTALL, JOB_VACUUM);
|
||||
return IN_SET(j->type, JOB_ACQUIRE, JOB_INSTALL, JOB_VACUUM);
|
||||
}
|
||||
|
||||
static int job_parse_child_output(int _fd, sd_json_variant **ret) {
|
||||
@@ -506,11 +504,6 @@ static int job_start(Job *j) {
|
||||
cmd[k++] = "check-new";
|
||||
break;
|
||||
|
||||
case JOB_UPDATE:
|
||||
cmd[k++] = "update";
|
||||
cmd[k++] = empty_to_null(j->version);
|
||||
break;
|
||||
|
||||
case JOB_ACQUIRE:
|
||||
cmd[k++] = "acquire";
|
||||
cmd[k++] = empty_to_null(j->version);
|
||||
@@ -600,7 +593,6 @@ static int job_method_cancel(sd_bus_message *msg, void *userdata, sd_bus_error *
|
||||
action = "org.freedesktop.sysupdate1.check";
|
||||
break;
|
||||
|
||||
case JOB_UPDATE:
|
||||
case JOB_ACQUIRE:
|
||||
case JOB_INSTALL:
|
||||
if (j->version)
|
||||
@@ -1086,88 +1078,6 @@ static int target_method_check_new(sd_bus_message *msg, void *userdata, sd_bus_e
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int target_method_update_finished_early(
|
||||
sd_bus_message *msg,
|
||||
const Job *j,
|
||||
sd_json_variant *json,
|
||||
sd_bus_error *error) {
|
||||
|
||||
/* Called when job finishes w/ a successful exit code, but before any work begins.
|
||||
* This happens when there is no candidate (i.e. we're already up-to-date), or
|
||||
* specified update is already installed. */
|
||||
return sd_bus_error_setf(error, BUS_ERROR_NO_UPDATE_CANDIDATE,
|
||||
"Job exited successfully with no work to do, assume already updated");
|
||||
}
|
||||
|
||||
static int target_method_update_detach(sd_bus_message *msg, const Job *j) {
|
||||
int r;
|
||||
|
||||
assert(msg);
|
||||
assert(j);
|
||||
|
||||
r = sd_bus_reply_method_return(msg, "sto", j->version, j->id, j->object_path);
|
||||
if (r < 0)
|
||||
return bus_log_parse_error(r);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int target_method_update(sd_bus_message *msg, void *userdata, sd_bus_error *error) {
|
||||
Target *t = ASSERT_PTR(userdata);
|
||||
_cleanup_(job_freep) Job *j = NULL;
|
||||
const char *version, *action;
|
||||
uint64_t flags;
|
||||
int r;
|
||||
|
||||
assert(msg);
|
||||
|
||||
r = sd_bus_message_read(msg, "st", &version, &flags);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
if (flags != 0)
|
||||
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Flags must be 0");
|
||||
|
||||
if (isempty(version))
|
||||
action = "org.freedesktop.sysupdate1.update";
|
||||
else
|
||||
action = "org.freedesktop.sysupdate1.update-to-version";
|
||||
|
||||
const char *details[] = {
|
||||
"class", target_class_to_string(t->class),
|
||||
"name", t->name,
|
||||
"version", version,
|
||||
NULL
|
||||
};
|
||||
|
||||
r = bus_verify_polkit_async(
|
||||
msg,
|
||||
action,
|
||||
details,
|
||||
&t->manager->polkit_registry,
|
||||
error);
|
||||
if (r < 0)
|
||||
return r;
|
||||
if (r == 0)
|
||||
return 1; /* Will call us back */
|
||||
|
||||
r = job_new(JOB_UPDATE, t, msg, target_method_update_finished_early, &j);
|
||||
if (r < 0)
|
||||
return r;
|
||||
j->detach_cb = target_method_update_detach;
|
||||
|
||||
j->version = strdup(version);
|
||||
if (!j->version)
|
||||
return -ENOMEM;
|
||||
|
||||
r = job_start(j);
|
||||
if (r < 0)
|
||||
return sd_bus_error_set_errnof(error, r, "Failed to start job: %m");
|
||||
TAKE_PTR(j);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int target_method_acquire_finished_early(
|
||||
sd_bus_message *msg,
|
||||
const Job *j,
|
||||
@@ -1769,12 +1679,6 @@ static const sd_bus_vtable target_vtable[] = {
|
||||
target_method_check_new,
|
||||
SD_BUS_VTABLE_UNPRIVILEGED),
|
||||
|
||||
SD_BUS_METHOD_WITH_ARGS("Update",
|
||||
SD_BUS_ARGS("s", new_version, "t", flags),
|
||||
SD_BUS_RESULT("s", new_version, "t", job_id, "o", job_path),
|
||||
target_method_update,
|
||||
SD_BUS_VTABLE_UNPRIVILEGED),
|
||||
|
||||
SD_BUS_METHOD_WITH_ARGS("Acquire",
|
||||
SD_BUS_ARGS("s", new_version, "t", flags),
|
||||
SD_BUS_RESULT("s", new_version, "t", job_id, "o", job_path),
|
||||
|
||||
Reference in New Issue
Block a user