aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDylan Van Assche <me@dylanvanassche.be>2020-12-11 16:39:51 +0100
committerLeo <thinkabit.ukim@gmail.com>2020-12-12 06:35:49 +0000
commit31eb6f6f01a84d510759f31794428a14bf79834c (patch)
tree193acb70b4090a838fe95fccbd92da0ae384fdf0
parentd8038535902a1ee0f12157b9b6f1d25b1da0828a (diff)
community/openrc-settingsd: add hostnamed and utils patches
Necessary for phosh to properly detect the chasis type. Patches are being upstreamed.
-rw-r--r--community/openrc-settingsd/0003-utils-fix-missing-newline-on-new-shell-entries.patch43
-rw-r--r--community/openrc-settingsd/0004-hostnamed-add-support-for-Chassis-Deployment-Locatio.patch325
-rw-r--r--community/openrc-settingsd/0005-hostnamed-add-comments-to-smbios-constants.patch51
-rw-r--r--community/openrc-settingsd/0006-hostnamed-add-detection-for-more-smbios-types.patch61
-rw-r--r--community/openrc-settingsd/0007-hostnamed-guess-chassis-property.patch115
-rw-r--r--community/openrc-settingsd/0008-hostnamed-init-chassis-before-guessing-icon-name.patch61
-rw-r--r--community/openrc-settingsd/APKBUILD16
7 files changed, 670 insertions, 2 deletions
diff --git a/community/openrc-settingsd/0003-utils-fix-missing-newline-on-new-shell-entries.patch b/community/openrc-settingsd/0003-utils-fix-missing-newline-on-new-shell-entries.patch
new file mode 100644
index 00000000000..15ab2cde1f7
--- /dev/null
+++ b/community/openrc-settingsd/0003-utils-fix-missing-newline-on-new-shell-entries.patch
@@ -0,0 +1,43 @@
+From 64debbaf5bdef93302f29c3f6cd395e3e22d65d8 Mon Sep 17 00:00:00 2001
+From: Luca Weiss <luca@z3ntu.xyz>
+Date: Wed, 28 Oct 2020 23:05:52 +0100
+Subject: [PATCH] utils: fix missing newline on new shell entries
+
+Previously if the existing file didn't end with a newline then two shell
+entries would be written without any separator to the file leading to a
+broken file.
+---
+ src/utils.c | 17 +++++++++++++++++
+ 1 file changed, 17 insertions(+)
+
+diff --git a/src/utils.c b/src/utils.c
+index d61274a..041a087 100644
+--- a/src/utils.c
++++ b/src/utils.c
+@@ -488,6 +488,23 @@ shell_parser_set_variable (ShellParser *parser,
+ ret = TRUE;
+ } else {
+ if (add_if_unset) {
++ GList *previous;
++ struct ShellEntry *previous_entry = NULL;
++
++ /* We need to add a separator (\n) between two items if there isn't one already. */
++ if ((previous = g_list_last(parser->entry_list)) != NULL) {
++ previous_entry = previous->data;
++ }
++ if (previous_entry && previous_entry->type != SHELL_ENTRY_TYPE_SEPARATOR) {
++ struct ShellEntry *separator_entry;
++
++ g_debug ("Adding separator entry");
++ separator_entry = g_new0 (struct ShellEntry, 1);
++ separator_entry->type = SHELL_ENTRY_TYPE_SEPARATOR;
++ separator_entry->string = g_strdup ("\n");
++ parser->entry_list = g_list_append (parser->entry_list, separator_entry);
++ }
++
+ found_entry = g_new0 (struct ShellEntry, 1);
+ found_entry->type = SHELL_ENTRY_TYPE_ASSIGNMENT;
+ found_entry->variable = g_strdup (variable);
+--
+2.25.1
+
diff --git a/community/openrc-settingsd/0004-hostnamed-add-support-for-Chassis-Deployment-Locatio.patch b/community/openrc-settingsd/0004-hostnamed-add-support-for-Chassis-Deployment-Locatio.patch
new file mode 100644
index 00000000000..2c8d2ba0422
--- /dev/null
+++ b/community/openrc-settingsd/0004-hostnamed-add-support-for-Chassis-Deployment-Locatio.patch
@@ -0,0 +1,325 @@
+From 7c49162fb18ee886bb9138585e23694daa63a3f1 Mon Sep 17 00:00:00 2001
+From: Luca Weiss <luca@z3ntu.xyz>
+Date: Wed, 28 Oct 2020 22:01:55 +0100
+Subject: [PATCH] hostnamed: add support for Chassis, Deployment & Location
+ properties
+
+---
+ data/org.freedesktop.hostname1.xml | 15 ++
+ src/hostnamed.c | 219 ++++++++++++++++++++++++++++-
+ 2 files changed, 233 insertions(+), 1 deletion(-)
+
+diff --git a/data/org.freedesktop.hostname1.xml b/data/org.freedesktop.hostname1.xml
+index e351096..1a4aa0d 100644
+--- a/data/org.freedesktop.hostname1.xml
++++ b/data/org.freedesktop.hostname1.xml
+@@ -19,9 +19,24 @@
+ <arg direction="in" type="s" name="name"/>
+ <arg direction="in" type="b" name="user_interaction"/>
+ </method>
++ <method name="SetChassis">
++ <arg direction="in" type="s" name="chassis"/>
++ <arg direction="in" type="b" name="interactive"/>
++ </method>
++ <method name="SetDeployment">
++ <arg direction="in" type="s" name="deployment"/>
++ <arg direction="in" type="b" name="interactive"/>
++ </method>
++ <method name="SetLocation">
++ <arg direction="in" type="s" name="location"/>
++ <arg direction="in" type="b" name="interactive"/>
++ </method>
+ <property name="Hostname" type="s" access="read"/>
+ <property name="StaticHostname" type="s" access="read"/>
+ <property name="PrettyHostname" type="s" access="read"/>
+ <property name="IconName" type="s" access="read"/>
++ <property name="Chassis" type="s" access="read"/>
++ <property name="Deployment" type="s" access="read"/>
++ <property name="Location" type="s" access="read"/>
+ </interface>
+ </node>
+diff --git a/src/hostnamed.c b/src/hostnamed.c
+index 92ca794..b837dc8 100644
+--- a/src/hostnamed.c
++++ b/src/hostnamed.c
+@@ -60,6 +60,9 @@ static GFile *static_hostname_file = NULL;
+ G_LOCK_DEFINE_STATIC (static_hostname);
+ static gchar *pretty_hostname = NULL;
+ static gchar *icon_name = NULL;
++static gchar *chassis = NULL;
++static gchar *deployment = NULL;
++static gchar *location = NULL;
+ static GFile *machine_info_file = NULL;
+ G_LOCK_DEFINE_STATIC (machine_info);
+
+@@ -375,6 +378,183 @@ on_handle_set_icon_name (OpenrcSettingsdHostnamedHostname1 *hostname1,
+ return TRUE; /* Always return TRUE to indicate signal has been handled */
+ }
+
++static void
++on_handle_set_chassis_authorized_cb (GObject *source_object,
++ GAsyncResult *res,
++ gpointer user_data)
++{
++ GError *err = NULL;
++ struct invoked_name *data;
++
++ data = (struct invoked_name *) user_data;
++ if (!check_polkit_finish (res, &err)) {
++ g_dbus_method_invocation_return_gerror (data->invocation, err);
++ goto out;
++ }
++
++ G_LOCK (machine_info);
++ /* Don't allow a null chassis */
++ if (data->name == NULL)
++ data->name = g_strdup ("");
++
++ if (!shell_parser_set_and_save (machine_info_file, &err, "CHASSIS", NULL, data->name, NULL)) {
++ g_dbus_method_invocation_return_gerror (data->invocation, err);
++ G_UNLOCK (machine_info);
++ goto out;
++ }
++
++ g_free (chassis);
++ chassis = data->name; /* data->name is g_strdup-ed already */
++ openrc_settingsd_hostnamed_hostname1_complete_set_chassis (hostname1, data->invocation);
++ openrc_settingsd_hostnamed_hostname1_set_chassis (hostname1, chassis);
++ G_UNLOCK (machine_info);
++
++ out:
++ g_free (data);
++ if (err != NULL)
++ g_error_free (err);
++}
++
++static gboolean
++on_handle_set_chassis (OpenrcSettingsdHostnamedHostname1 *hostname1,
++ GDBusMethodInvocation *invocation,
++ const gchar *name,
++ const gboolean user_interaction,
++ gpointer user_data)
++{
++ if (read_only)
++ g_dbus_method_invocation_return_dbus_error (invocation,
++ DBUS_ERROR_NOT_SUPPORTED,
++ "openrc-settingsd hostnamed is in read-only mode");
++ else {
++ struct invoked_name *data;
++ data = g_new0 (struct invoked_name, 1);
++ data->invocation = invocation;
++ data->name = g_strdup (name);
++ check_polkit_async (g_dbus_method_invocation_get_sender (invocation), "org.freedesktop.hostname1.set-machine-info", user_interaction, on_handle_set_chassis_authorized_cb, data);
++ }
++
++ return TRUE; /* Always return TRUE to indicate signal has been handled */
++}
++
++static void
++on_handle_set_deployment_authorized_cb (GObject *source_object,
++ GAsyncResult *res,
++ gpointer user_data)
++{
++ GError *err = NULL;
++ struct invoked_name *data;
++
++ data = (struct invoked_name *) user_data;
++ if (!check_polkit_finish (res, &err)) {
++ g_dbus_method_invocation_return_gerror (data->invocation, err);
++ goto out;
++ }
++
++ G_LOCK (machine_info);
++ /* Don't allow a null deployment */
++ if (data->name == NULL)
++ data->name = g_strdup ("");
++
++ if (!shell_parser_set_and_save (machine_info_file, &err, "DEPLOYMENT", NULL, data->name, NULL)) {
++ g_dbus_method_invocation_return_gerror (data->invocation, err);
++ G_UNLOCK (machine_info);
++ goto out;
++ }
++
++ g_free (deployment);
++ deployment = data->name; /* data->name is g_strdup-ed already */
++ openrc_settingsd_hostnamed_hostname1_complete_set_deployment (hostname1, data->invocation);
++ openrc_settingsd_hostnamed_hostname1_set_deployment (hostname1, deployment);
++ G_UNLOCK (machine_info);
++
++ out:
++ g_free (data);
++ if (err != NULL)
++ g_error_free (err);
++}
++
++static gboolean
++on_handle_set_deployment (OpenrcSettingsdHostnamedHostname1 *hostname1,
++ GDBusMethodInvocation *invocation,
++ const gchar *name,
++ const gboolean user_interaction,
++ gpointer user_data)
++{
++ if (read_only)
++ g_dbus_method_invocation_return_dbus_error (invocation,
++ DBUS_ERROR_NOT_SUPPORTED,
++ "openrc-settingsd hostnamed is in read-only mode");
++ else {
++ struct invoked_name *data;
++ data = g_new0 (struct invoked_name, 1);
++ data->invocation = invocation;
++ data->name = g_strdup (name);
++ check_polkit_async (g_dbus_method_invocation_get_sender (invocation), "org.freedesktop.hostname1.set-machine-info", user_interaction, on_handle_set_deployment_authorized_cb, data);
++ }
++
++ return TRUE; /* Always return TRUE to indicate signal has been handled */
++}
++
++static void
++on_handle_set_location_authorized_cb (GObject *source_object,
++ GAsyncResult *res,
++ gpointer user_data)
++{
++ GError *err = NULL;
++ struct invoked_name *data;
++
++ data = (struct invoked_name *) user_data;
++ if (!check_polkit_finish (res, &err)) {
++ g_dbus_method_invocation_return_gerror (data->invocation, err);
++ goto out;
++ }
++
++ G_LOCK (machine_info);
++ /* Don't allow a null location */
++ if (data->name == NULL)
++ data->name = g_strdup ("");
++
++ if (!shell_parser_set_and_save (machine_info_file, &err, "LOCATION", NULL, data->name, NULL)) {
++ g_dbus_method_invocation_return_gerror (data->invocation, err);
++ G_UNLOCK (machine_info);
++ goto out;
++ }
++
++ g_free (location);
++ location = data->name; /* data->name is g_strdup-ed already */
++ openrc_settingsd_hostnamed_hostname1_complete_set_location (hostname1, data->invocation);
++ openrc_settingsd_hostnamed_hostname1_set_location (hostname1, location);
++ G_UNLOCK (machine_info);
++
++ out:
++ g_free (data);
++ if (err != NULL)
++ g_error_free (err);
++}
++
++static gboolean
++on_handle_set_location (OpenrcSettingsdHostnamedHostname1 *hostname1,
++ GDBusMethodInvocation *invocation,
++ const gchar *name,
++ const gboolean user_interaction,
++ gpointer user_data)
++{
++ if (read_only)
++ g_dbus_method_invocation_return_dbus_error (invocation,
++ DBUS_ERROR_NOT_SUPPORTED,
++ "openrc-settingsd hostnamed is in read-only mode");
++ else {
++ struct invoked_name *data;
++ data = g_new0 (struct invoked_name, 1);
++ data->invocation = invocation;
++ data->name = g_strdup (name);
++ check_polkit_async (g_dbus_method_invocation_get_sender (invocation), "org.freedesktop.hostname1.set-machine-info", user_interaction, on_handle_set_location_authorized_cb, data);
++ }
++
++ return TRUE; /* Always return TRUE to indicate signal has been handled */
++}
++
+ static void
+ on_bus_acquired (GDBusConnection *connection,
+ const gchar *bus_name,
+@@ -391,11 +571,17 @@ on_bus_acquired (GDBusConnection *connection,
+ openrc_settingsd_hostnamed_hostname1_set_static_hostname (hostname1, static_hostname);
+ openrc_settingsd_hostnamed_hostname1_set_pretty_hostname (hostname1, pretty_hostname);
+ openrc_settingsd_hostnamed_hostname1_set_icon_name (hostname1, icon_name);
++ openrc_settingsd_hostnamed_hostname1_set_chassis (hostname1, chassis);
++ openrc_settingsd_hostnamed_hostname1_set_deployment (hostname1, deployment);
++ openrc_settingsd_hostnamed_hostname1_set_location (hostname1, location);
+
+ g_signal_connect (hostname1, "handle-set-hostname", G_CALLBACK (on_handle_set_hostname), NULL);
+ g_signal_connect (hostname1, "handle-set-static-hostname", G_CALLBACK (on_handle_set_static_hostname), NULL);
+ g_signal_connect (hostname1, "handle-set-pretty-hostname", G_CALLBACK (on_handle_set_pretty_hostname), NULL);
+ g_signal_connect (hostname1, "handle-set-icon-name", G_CALLBACK (on_handle_set_icon_name), NULL);
++ g_signal_connect (hostname1, "handle-set-chassis", G_CALLBACK (on_handle_set_chassis), NULL);
++ g_signal_connect (hostname1, "handle-set-deployment", G_CALLBACK (on_handle_set_deployment), NULL);
++ g_signal_connect (hostname1, "handle-set-location", G_CALLBACK (on_handle_set_location), NULL);
+
+ if (!g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (hostname1),
+ connection,
+@@ -451,6 +637,7 @@ hostnamed_init (gboolean _read_only)
+ g_error_free (err);
+ err = NULL;
+ }
++
+ pretty_hostname = shell_source_var (machine_info_file, "${PRETTY_HOSTNAME}", &err);
+ if (pretty_hostname == NULL)
+ pretty_hostname = g_strdup ("");
+@@ -459,6 +646,7 @@ hostnamed_init (gboolean _read_only)
+ g_error_free (err);
+ err = NULL;
+ }
++
+ icon_name = shell_source_var (machine_info_file, "${ICON_NAME}", &err);
+ if (icon_name == NULL)
+ icon_name = g_strdup ("");
+@@ -467,12 +655,38 @@ hostnamed_init (gboolean _read_only)
+ g_error_free (err);
+ err = NULL;
+ }
+-
+ if (icon_name == NULL || *icon_name == 0) {
+ g_free (icon_name);
+ icon_name = guess_icon_name ();
+ }
+
++ chassis = shell_source_var (machine_info_file, "${CHASSIS}", &err);
++ if (chassis == NULL)
++ chassis = g_strdup ("");
++ if (err != NULL) {
++ g_debug ("%s", err->message);
++ g_error_free (err);
++ err = NULL;
++ }
++
++ deployment = shell_source_var (machine_info_file, "${DEPLOYMENT}", &err);
++ if (deployment == NULL)
++ deployment = g_strdup ("");
++ if (err != NULL) {
++ g_debug ("%s", err->message);
++ g_error_free (err);
++ err = NULL;
++ }
++
++ location = shell_source_var (machine_info_file, "${LOCATION}", &err);
++ if (location == NULL)
++ location = g_strdup ("");
++ if (err != NULL) {
++ g_debug ("%s", err->message);
++ g_error_free (err);
++ err = NULL;
++ }
++
+ read_only = _read_only;
+
+ bus_id = g_bus_own_name (G_BUS_TYPE_SYSTEM,
+@@ -495,6 +709,9 @@ hostnamed_destroy (void)
+ g_free (static_hostname);
+ g_free (pretty_hostname);
+ g_free (icon_name);
++ g_free (chassis);
++ g_free (deployment);
++ g_free (location);
+
+ g_object_unref (static_hostname_file);
+ g_object_unref (machine_info_file);
+--
+2.25.1
+
diff --git a/community/openrc-settingsd/0005-hostnamed-add-comments-to-smbios-constants.patch b/community/openrc-settingsd/0005-hostnamed-add-comments-to-smbios-constants.patch
new file mode 100644
index 00000000000..70cd55b37b4
--- /dev/null
+++ b/community/openrc-settingsd/0005-hostnamed-add-comments-to-smbios-constants.patch
@@ -0,0 +1,51 @@
+From 2ca7608889909fb91e76e559419ca6aebf8b84a1 Mon Sep 17 00:00:00 2001
+From: Luca Weiss <luca@z3ntu.xyz>
+Date: Thu, 29 Oct 2020 22:08:13 +0100
+Subject: [PATCH] hostnamed: add comments to smbios constants
+
+---
+ src/hostnamed.c | 24 ++++++++++++------------
+ 1 file changed, 12 insertions(+), 12 deletions(-)
+
+diff --git a/src/hostnamed.c b/src/hostnamed.c
+index b837dc8..706a85c 100644
+--- a/src/hostnamed.c
++++ b/src/hostnamed.c
+@@ -103,22 +103,22 @@ guess_icon_name ()
+
+ if (g_file_get_contents ("/sys/class/dmi/id/chassis_type", &filebuf, NULL, NULL)) {
+ switch (g_ascii_strtoull (filebuf, NULL, 10)) {
+- case 0x3:
+- case 0x4:
+- case 0x5:
+- case 0x6:
+- case 0x7:
++ case 0x3: /* Desktop */
++ case 0x4: /* Low Profile Desktop */
++ case 0x5: /* Pizza Box */
++ case 0x6: /* Mini Tower */
++ case 0x7: /* Tower */
+ ret = g_strdup ("computer-desktop");
+ goto out;
+- case 0x9:
+- case 0xA:
+- case 0xE:
++ case 0x9: /* Laptop */
++ case 0xA: /* Notebook */
++ case 0xE: /* Sub Notebook */
+ ret = g_strdup ("computer-laptop");
+ goto out;
+- case 0x11:
+- case 0x17:
+- case 0x1C:
+- case 0x1D:
++ case 0x11: /* Main Server Chassis */
++ case 0x17: /* Rack Mount Chassis */
++ case 0x1C: /* Blade */
++ case 0x1D: /* Blade Enclosure */
+ ret = g_strdup ("computer-server");
+ goto out;
+ }
+--
+2.25.1
+
diff --git a/community/openrc-settingsd/0006-hostnamed-add-detection-for-more-smbios-types.patch b/community/openrc-settingsd/0006-hostnamed-add-detection-for-more-smbios-types.patch
new file mode 100644
index 00000000000..0e466124530
--- /dev/null
+++ b/community/openrc-settingsd/0006-hostnamed-add-detection-for-more-smbios-types.patch
@@ -0,0 +1,61 @@
+From 13f8d940ba07e47b3865359913104ec8101dde26 Mon Sep 17 00:00:00 2001
+From: Luca Weiss <luca@z3ntu.xyz>
+Date: Thu, 29 Oct 2020 22:39:52 +0100
+Subject: [PATCH] hostnamed: add detection for more smbios types
+
+---
+ src/hostnamed.c | 16 ++++++++++++++--
+ 1 file changed, 14 insertions(+), 2 deletions(-)
+
+diff --git a/src/hostnamed.c b/src/hostnamed.c
+index 706a85c..2608196 100644
+--- a/src/hostnamed.c
++++ b/src/hostnamed.c
+@@ -95,10 +95,10 @@ guess_icon_name ()
+ Taken with a few minor changes from systemd's hostnamed.c,
+ copyright 2011 Lennart Poettering.
+
+- See the SMBIOS Specification 2.7.1 section 7.4.1 for
++ See the SMBIOS Specification 3.4.0 section 7.4.1 for
+ details about the values listed here:
+
+- http://www.dmtf.org/sites/default/files/standards/documents/DSP0134_2.7.1.pdf
++ https://www.dmtf.org/sites/default/files/standards/documents/DSP0134_3.4.0.pdf
+ */
+
+ if (g_file_get_contents ("/sys/class/dmi/id/chassis_type", &filebuf, NULL, NULL)) {
+@@ -108,19 +108,31 @@ guess_icon_name ()
+ case 0x5: /* Pizza Box */
+ case 0x6: /* Mini Tower */
+ case 0x7: /* Tower */
++ case 0xD: /* All in One */
+ ret = g_strdup ("computer-desktop");
+ goto out;
++ case 0x8: /* Portable */
+ case 0x9: /* Laptop */
+ case 0xA: /* Notebook */
+ case 0xE: /* Sub Notebook */
+ ret = g_strdup ("computer-laptop");
+ goto out;
++ case 0xB: /* Hand Held */
++ ret = g_strdup ("computer-handset");
++ goto out;
+ case 0x11: /* Main Server Chassis */
+ case 0x17: /* Rack Mount Chassis */
+ case 0x1C: /* Blade */
+ case 0x1D: /* Blade Enclosure */
+ ret = g_strdup ("computer-server");
+ goto out;
++ case 0x1E: /* Tablet */
++ ret = g_strdup ("computer-tablet");
++ goto out;
++ case 0x1F: /* Convertible */
++ case 0x20: /* Detachable */
++ ret = g_strdup ("computer-convertible");
++ goto out;
+ }
+ }
+ #endif
+--
+2.25.1
+
diff --git a/community/openrc-settingsd/0007-hostnamed-guess-chassis-property.patch b/community/openrc-settingsd/0007-hostnamed-guess-chassis-property.patch
new file mode 100644
index 00000000000..d123e8dded9
--- /dev/null
+++ b/community/openrc-settingsd/0007-hostnamed-guess-chassis-property.patch
@@ -0,0 +1,115 @@
+From 1a6e7e0eec78774c60496d6b4b4e08b3ba03bd65 Mon Sep 17 00:00:00 2001
+From: Luca Weiss <luca@z3ntu.xyz>
+Date: Thu, 29 Oct 2020 23:28:23 +0100
+Subject: [PATCH] hostnamed: guess chassis property
+
+Convert the existing guess_icon_name method to guess the chassis value
+and build the icon name based on that.
+---
+ src/hostnamed.c | 43 ++++++++++++++++++++++++++++++++++---------
+ 1 file changed, 34 insertions(+), 9 deletions(-)
+
+diff --git a/src/hostnamed.c b/src/hostnamed.c
+index 2608196..cde34ce 100644
+--- a/src/hostnamed.c
++++ b/src/hostnamed.c
+@@ -77,7 +77,7 @@ hostname_is_valid (const gchar *name)
+ }
+
+ static gchar *
+-guess_icon_name ()
++guess_chassis ()
+ {
+ gchar *filebuf = NULL;
+ gchar *ret = NULL;
+@@ -85,7 +85,7 @@ guess_icon_name ()
+ #if HAVE_OPENRC
+ /* Note that rc_sys() leaks memory :( */
+ if (rc_sys() != NULL) {
+- ret = g_strdup ("computer-vm");
++ ret = g_strdup ("vm");
+ goto out;
+ }
+ #endif
+@@ -109,39 +109,60 @@ guess_icon_name ()
+ case 0x6: /* Mini Tower */
+ case 0x7: /* Tower */
+ case 0xD: /* All in One */
+- ret = g_strdup ("computer-desktop");
++ ret = g_strdup ("desktop");
+ goto out;
+ case 0x8: /* Portable */
+ case 0x9: /* Laptop */
+ case 0xA: /* Notebook */
+ case 0xE: /* Sub Notebook */
+- ret = g_strdup ("computer-laptop");
++ ret = g_strdup ("laptop");
+ goto out;
+ case 0xB: /* Hand Held */
+- ret = g_strdup ("computer-handset");
++ ret = g_strdup ("handset");
+ goto out;
+ case 0x11: /* Main Server Chassis */
+ case 0x17: /* Rack Mount Chassis */
+ case 0x1C: /* Blade */
+ case 0x1D: /* Blade Enclosure */
+- ret = g_strdup ("computer-server");
++ ret = g_strdup ("server");
+ goto out;
+ case 0x1E: /* Tablet */
+- ret = g_strdup ("computer-tablet");
++ ret = g_strdup ("tablet");
+ goto out;
+ case 0x1F: /* Convertible */
+ case 0x20: /* Detachable */
+- ret = g_strdup ("computer-convertible");
++ ret = g_strdup ("convertible");
+ goto out;
+ }
+ }
+ #endif
+- ret = g_strdup ("computer");
+ out:
+ g_free (filebuf);
+ return ret;
+ }
+
++static gchar *
++guess_icon_name ()
++{
++ gchar *guessed_chassis;
++ gchar *ret;
++
++ /* Take configured chassis if not empty string */
++ if (chassis && *chassis)
++ return g_strconcat ("computer-", chassis, NULL);
++
++ guessed_chassis = guess_chassis();
++ if (guessed_chassis) {
++ ret = g_strconcat ("computer-", guessed_chassis, NULL);
++ goto out;
++ }
++
++ ret = g_strdup ("computer");
++ out:
++ g_free (guessed_chassis);
++ return ret;
++}
++
+ static void
+ on_handle_set_hostname_authorized_cb (GObject *source_object,
+ GAsyncResult *res,
+@@ -680,6 +701,10 @@ hostnamed_init (gboolean _read_only)
+ g_error_free (err);
+ err = NULL;
+ }
++ if (chassis == NULL || *chassis == 0) {
++ g_free (chassis);
++ chassis = guess_chassis ();
++ }
+
+ deployment = shell_source_var (machine_info_file, "${DEPLOYMENT}", &err);
+ if (deployment == NULL)
+--
+2.25.1
+
diff --git a/community/openrc-settingsd/0008-hostnamed-init-chassis-before-guessing-icon-name.patch b/community/openrc-settingsd/0008-hostnamed-init-chassis-before-guessing-icon-name.patch
new file mode 100644
index 00000000000..4ba0a47b176
--- /dev/null
+++ b/community/openrc-settingsd/0008-hostnamed-init-chassis-before-guessing-icon-name.patch
@@ -0,0 +1,61 @@
+From 45a4345c66423d8590da33e4aa14edc26ddaa283 Mon Sep 17 00:00:00 2001
+From: Luca Weiss <luca@z3ntu.xyz>
+Date: Thu, 29 Oct 2020 23:47:30 +0100
+Subject: [PATCH] hostnamed: init chassis before guessing icon name
+
+We check in guess_icon_name for the configured chassis so we must set
+the chassis value first.
+---
+ src/hostnamed.c | 24 ++++++++++++------------
+ 1 file changed, 12 insertions(+), 12 deletions(-)
+
+diff --git a/src/hostnamed.c b/src/hostnamed.c
+index cde34ce..878bc42 100644
+--- a/src/hostnamed.c
++++ b/src/hostnamed.c
+@@ -680,30 +680,30 @@ hostnamed_init (gboolean _read_only)
+ err = NULL;
+ }
+
+- icon_name = shell_source_var (machine_info_file, "${ICON_NAME}", &err);
+- if (icon_name == NULL)
+- icon_name = g_strdup ("");
++ chassis = shell_source_var (machine_info_file, "${CHASSIS}", &err);
++ if (chassis == NULL)
++ chassis = g_strdup ("");
+ if (err != NULL) {
+ g_debug ("%s", err->message);
+ g_error_free (err);
+ err = NULL;
+ }
+- if (icon_name == NULL || *icon_name == 0) {
+- g_free (icon_name);
+- icon_name = guess_icon_name ();
++ if (chassis == NULL || *chassis == 0) {
++ g_free (chassis);
++ chassis = guess_chassis ();
+ }
+
+- chassis = shell_source_var (machine_info_file, "${CHASSIS}", &err);
+- if (chassis == NULL)
+- chassis = g_strdup ("");
++ icon_name = shell_source_var (machine_info_file, "${ICON_NAME}", &err);
++ if (icon_name == NULL)
++ icon_name = g_strdup ("");
+ if (err != NULL) {
+ g_debug ("%s", err->message);
+ g_error_free (err);
+ err = NULL;
+ }
+- if (chassis == NULL || *chassis == 0) {
+- g_free (chassis);
+- chassis = guess_chassis ();
++ if (icon_name == NULL || *icon_name == 0) {
++ g_free (icon_name);
++ icon_name = guess_icon_name ();
+ }
+
+ deployment = shell_source_var (machine_info_file, "${DEPLOYMENT}", &err);
+--
+2.25.1
+
diff --git a/community/openrc-settingsd/APKBUILD b/community/openrc-settingsd/APKBUILD
index ebbb640557c..a72be4d65de 100644
--- a/community/openrc-settingsd/APKBUILD
+++ b/community/openrc-settingsd/APKBUILD
@@ -2,7 +2,7 @@
# Maintainer: Rasmus Thomsen <oss@cogitri.dev>
pkgname=openrc-settingsd
pkgver=1.0.1
-pkgrel=5
+pkgrel=6
pkgdesc="System settings D-Bus service for OpenRC"
url="https://gitweb.gentoo.org/proj/openrc-settingsd.git"
arch="all !mips64 !s390x" # limited by polkit
@@ -15,6 +15,12 @@ source="https://gitweb.gentoo.org/proj/openrc-settingsd.git/snapshot/openrc-sett
use-profiled-instead-of-envd.patch
0001-Make-etc-localtime-a-symlink-if-it-doesn-t-exist-yet.patch
0002-Ensure-0664-permissions-on-etc-localtime.patch
+ 0003-utils-fix-missing-newline-on-new-shell-entries.patch
+ 0004-hostnamed-add-support-for-Chassis-Deployment-Locatio.patch
+ 0005-hostnamed-add-comments-to-smbios-constants.patch
+ 0006-hostnamed-add-detection-for-more-smbios-types.patch
+ 0007-hostnamed-guess-chassis-property.patch
+ 0008-hostnamed-init-chassis-before-guessing-icon-name.patch
"
prepare() {
@@ -48,4 +54,10 @@ package() {
sha512sums="bca589de7d2c96d8d15d93882b7296523a0d6301fe1d33f7fc03386544b5c050f2d819b9e1f005ee10a794883175ea1b1172411aad3598f967a6a5677a5c4aad openrc-settingsd-1.0.1.tar.gz
d06d691c1ef52c0e4c5d68ad7d25eba73ad8fffa3d3675f5c79ff93808131c11f4dbbd13db64c463bb87ec8ebed143878703ba281e1241947d66fcad48063e56 use-profiled-instead-of-envd.patch
7ea84475fe6558d7b26726eefd452e89cb407a9e9beeff70163c1ec1f236988ae0b7e85644ca2baad7238d0c304bc54d899889605dd08e5cc60cbaf8b5e9abe5 0001-Make-etc-localtime-a-symlink-if-it-doesn-t-exist-yet.patch
-2f1008b129472264ebeba985c6355a7317266b3d15dd7e9a2394930a8c4c61761315b005a4632b623957a269bae9f76db1f9e2430afaf042955231a480a5ece8 0002-Ensure-0664-permissions-on-etc-localtime.patch"
+2f1008b129472264ebeba985c6355a7317266b3d15dd7e9a2394930a8c4c61761315b005a4632b623957a269bae9f76db1f9e2430afaf042955231a480a5ece8 0002-Ensure-0664-permissions-on-etc-localtime.patch
+f430e2c13ac9be60f82614f0d30be0daf5166a5704dd14aaf7e58577a72c14172774967156e08db42f94f7dbb14d6d0f70c29c30977023efb943930ac31cc515 0003-utils-fix-missing-newline-on-new-shell-entries.patch
+02f9b795e9c5d197d0fce67818cd1f10fcc49d0658d6276e414f2de57320cf318bc1d83c33193578ad6cff11659953bf56d57029747545685716391918dbc80b 0004-hostnamed-add-support-for-Chassis-Deployment-Locatio.patch
+6a35b99a929b72ebd133e6f6e6a537413e3eadd7b24c77c516bc5e94c5d97b9e8935a781f3fe3e596ded674948b36f5aa8947be94986c3de3e0a8936cf349145 0005-hostnamed-add-comments-to-smbios-constants.patch
+494b61857aa40335483cecb267269987ee54f83e54a837747c5b409e86edaf298405e492fcbb22861dd8560f52fcecd2fc18e28a6ffc111571b03e61571e1d18 0006-hostnamed-add-detection-for-more-smbios-types.patch
+295f55897abab1c6b4d18ed5e6b4b91833e3b1cd7347d8eb3fb73091c05fbd497994eacbf98542a7c3c641dbd86b2476463824bbea26f1918b2eb3b2df0dab91 0007-hostnamed-guess-chassis-property.patch
+19af70d75302d1ac40d985859b2d5bbefd4d74b196bf4c6c872fed41f4bad03ad3be3568fe333a1a15d464a9c55cbfaf56c2ef8afc6807828596a31f2b189a27 0008-hostnamed-init-chassis-before-guessing-icon-name.patch"