canonical / ubuntu-desktop-installer

Ubuntu Desktop Installer
GNU General Public License v3.0
536 stars 94 forks source link

unowned /usr/share/glib-2.0/schemas/20_ubuntu-desktop-installer-interface.gschema.override after canary install #2315

Open jibel opened 1 year ago

jibel commented 1 year ago

From https://bugs.launchpad.net/ubuntu-desktop-installer/+bug/2033117

After a classic install (no tpm fde) using the 20230825.2 canary image, I have a file /usr/share/glib-2.0/schemas/20_ubuntu-desktop-installer-interface.gschema.override on the target system which according to dpkg has no owner.

The contents of the file are:

$ cat /mnt/2/usr/share/glib-2.0/schemas/20_ubuntu-desktop-installer-interface.gschema.override [org.gnome.desktop.interface:ubuntu] color-scheme='prefer-light' gtk-theme='Yaru' $

I do not remember if the non-canary image prompted me for a theme preference, or if I made the same selection on the non-canary image. However, the installer should not be writing files under /usr to the target system; /usr is owned by the package manager. Overrides need to be written somewhere else, one of /home, /var, /etc in decreasing order of preference (the theme selection should IMHO only apply to the initial user and not to further users on the system who are added post-install).

On both canary and daily-live, I also see a file /usr/share/glib-2.0/schemas/20_ubuntu-desktop-installer-wm.gschema.override which is identical between the two installs.

$ cat /mnt/2/usr/share/glib-2.0/schemas/20_ubuntu-desktop-installer-wm.gschema.override [org.gnome.desktop.wm.keybindings:ubuntu] maximize=@as [] unmaximize=@as [] $

I have no idea what this file is for.

This is done by ubuntu-desktop-installer/snap/local/postinst.d/10_override_desktop_settings and four files are created this way:

#!/bin/sh
set -e

user=ubuntu
target=/target
source_schemas=/usr/share/glib-2.0/schemas
target_schemas=$target/$source_schemas

if [ ! -d $source_schemas ] || [ ! -d $target_schemas ] || ! id $user >/dev/null 2>&1; then
    exit
fi

dconf_dump() {
    target_schema=$target_schemas/20_ubuntu-desktop-installer-$1.gschema.override
    sudo -u $user dconf dump /org/gnome/desktop/$1/ > $target_schema
    # - [foo] -> [org.gnome.desktop.$1.foo:ubuntu]
    sed -i -E "s/^\[([^/]*)\]/\[org.gnome.desktop.$1.\1:ubuntu\]/g" $target_schema
    # - [/] -> [org.gnome.desktop.$1:ubuntu]
    sed -i -E "s/^\[\/\]$/\[org.gnome.desktop.$1:ubuntu\]/g" $target_schema
    [ -s $target_schema ] || rm $target_schema
}

dconf_dump a11y
dconf_dump interface
dconf_dump peripherals
dconf_dump wm

glib-compile-schemas $target_schemas