Merge ~gunnarhj/casper:localized-desktop-dir into casper:main

Proposed by Gunnar Hjalmarsson
Status: Needs review
Proposed branch: ~gunnarhj/casper:localized-desktop-dir
Merge into: casper:main
Diff against target: 51 lines (+17/-5)
2 files modified
debian/changelog (+8/-0)
scripts/casper-bottom/25adduser (+9/-5)
Reviewer Review Type Date Requested Status
Ubuntu Installer Team Pending
Review via email: mp+400294@code.launchpad.net

Description of the change

Caveat: Not tested

Provided that the user selected language is reflected in the environment when the proposed gettext() command is run, it ought to address the bug.

To post a comment you must log in.
Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

I sort of doubt the translations are available in the initramfs, which is where this runs from. It might be necessary to have this script create a oneshot systemd service that does the addusering, or something like that.

Revision history for this message
Gunnar Hjalmarsson (gunnarhj) wrote :

Thanks for your comment, Michael. It's the translations provided by the xdg-user-dirs package that gettext would need for its lookup.

Could it possibly help to change

DESKTOPDIR=$(gettext -d xdg-user-dirs Desktop)

to

DESKTOPDIR=$(chroot /root gettext -d xdg-user-dirs Desktop)

? I'm guessing wildly here (don't know how to test).

Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

Oh yes that might work. BTW to test this:

1) download an ISO, mount it at say /mnt
2) mkdir -p ~/tmp/initrd; cd ~/tmp/initrd
3) unpack the initramfs with (cpio -t; cpio -t; lz4cat | cpio -i) < /mnt/casper/initrd
4) copy your version of 25adduser over the unpacked one
5) repack the initrd with find . | LC_ALL=C sort | cpio -R 0:0 -o -H newc | gzip > ../casper-initrd.gz
6) boot it in kvm with something like truncate -s 10G image.img && kvm -m 4096 -smp 2 -drive file=~/images/image.img,format=raw,cache=none,if=virtio -kernel /mnt/casper/vmlinuz -initrd ~/tmp/casper-initrd.gz -cdrom /path/to.iso

Probably these instructions should be in the casper source tree somewhere...

Revision history for this message
Gunnar Hjalmarsson (gunnarhj) wrote :

That is far over my skill level. :( It would take me a month to make sense of those instructions.

Any chance you have it set up, and can help to test a non-English "Try Ubuntu" using the modified 25adduser?

553ecd9... by Gunnar Hjalmarsson

Localize the XDG Desktop directory name

LP: #885086

Revision history for this message
Gunnar Hjalmarsson (gunnarhj) wrote :

I added "chroot /root", but it's still an untested theory.

Revision history for this message
Gunnar Hjalmarsson (gunnarhj) wrote :

@Michael: I started a live session successfully using your steps. It didn't take a month - rather a few minutes. :) Thanks!

However, it resulted in an English session (the C.UTF-8 locale). So what I could confirm was that my modified 25adduser didn't screw it up, i.e. the ubiquity.desktop file was located in the ~/Desktop directory. Possibly that is sufficient to commit/upload and study the behavior in a real daily build.

What remains to see is whether the gettext command is run using the user selected locale, so the directory is named ~/Bureau if the user selects French etc.

Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

Oops neglected this for far too long, sorry. Anyway, I still think this runs too early -- there's no opportunity to choose a language before this code runs is there? Is there any other way to choose a language in a live session other than starting ubiquity and choosing a language there?

Revision history for this message
Gunnar Hjalmarsson (gunnarhj) wrote :

On 2021-10-19 03:17, Michael Hudson-Doyle wrote:
> I still think this runs too early

Well, it depends on what you mean. When you select a language in ubiquity, it instantly changes the UI, so somehow the selected language is stored in memory or disk before you click the "Try Ubuntu" button.

While it may be true that it runs too early to see the environment of the live session, it should be safe to do it like this instead:

selected_lang=[grab the selected language somehow]
DESKTOPDIR=$(LANGUAGE=$selected_lang gettext -d xdg-user-dirs Desktop)

I haven't figured out how/where the selected language is available — am kind of hoping that someone in the installer team can help with that. ;)

But with that said, the timing to deal with this 10 years old bug may not be optimal considering that ubiquity is about to be replaced with the new desktop installer. So maybe we'd better figure out how to grab the selected language in the context of the new installer.

Unmerged commits

553ecd9... by Gunnar Hjalmarsson

Localize the XDG Desktop directory name

LP: #885086

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/changelog b/debian/changelog
2index f606c26..5b97cf3 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,3 +1,11 @@
6+casper (1.462) UNRELEASED; urgency=medium
7+
8+ [ Gunnar Hjalmarsson ]
9+ * scripts/casper-bottom/25adduser:
10+ - Localize the XDG Desktop directory name (LP: #885086)
11+
12+ -- Gunnar Hjalmarsson <gunnarhj@ubuntu.com> Mon, 29 Mar 2021 18:51:29 +0200
13+
14 casper (1.461) hirsute; urgency=medium
15
16 [ Gunnar Hjalmarsson ]
17diff --git a/scripts/casper-bottom/25adduser b/scripts/casper-bottom/25adduser
18index 6dcef6a..0da470c 100755
19--- a/scripts/casper-bottom/25adduser
20+++ b/scripts/casper-bottom/25adduser
21@@ -81,13 +81,17 @@ RELEASE="$(cut -d' ' -f1-2 /root/cdrom/.disk/info 2>/dev/null | sed 's/-/ /')" |
22 if [ "$LTS" = "LTS" ] && [ -n "$RELEASE" ]; then
23 RELEASE="$RELEASE LTS"
24 fi
25+
26+# translated Desktop directory
27+DESKTOPDIR=$(chroot /root gettext -d xdg-user-dirs Desktop)
28+
29 for file in /usr/share/applications/ubiquity.desktop /usr/share/applications/kde4/ubiquity-kdeui.desktop /usr/share/applications/lubuntu-calamares.desktop /usr/share/applications/ubuntustudio-calamares.desktop; do
30 if [ -f "/root/$file" ]; then
31 sed -i "s/RELEASE/$RELEASE/" "/root$file"
32- chroot /root install -d -o $USERNAME -g $USERNAME /home/$USERNAME/Desktop
33- chroot /root install -D -o $USERNAME -g $USERNAME $file /home/$USERNAME/Desktop/$(basename "$file")
34+ chroot /root install -d -o $USERNAME -g $USERNAME /home/$USERNAME/"$DESKTOPDIR"
35+ chroot /root install -D -o $USERNAME -g $USERNAME $file /home/$USERNAME/"$DESKTOPDIR"/$(basename "$file")
36 if [ -x "/root/usr/bin/dbus-run-session" ] && [ -x "/root/usr/bin/gio" ]; then
37- chroot /root sudo -i -u $USERNAME dbus-run-session -- gio set /home/$USERNAME/Desktop/$(basename "$file") metadata::trusted true
38+ chroot /root sudo -i -u $USERNAME dbus-run-session -- gio set /home/$USERNAME/"$DESKTOPDIR"/$(basename "$file") metadata::trusted true
39 fi
40 break
41 fi
42@@ -101,8 +105,8 @@ fi
43 # Kubuntu
44 if [ -f "/root/usr/bin/plasma-desktop" ]; then
45 if [ -f "/root/usr/share/kde4/apps/khelpcenter/plugins/kubuntu/a_welcome.desktop" ]; then
46- chroot /root install -d -o $USERNAME -g $USERNAME /home/$USERNAME/Desktop
47- chroot /root install -D -o $USERNAME -g $USERNAME /usr/share/kde4/apps/khelpcenter/plugins/kubuntu/a_welcome.desktop /home/$USERNAME/Desktop/a_welcome.desktop
48+ chroot /root install -d -o $USERNAME -g $USERNAME /home/$USERNAME/"$DESKTOPDIR"
49+ chroot /root install -D -o $USERNAME -g $USERNAME /usr/share/kde4/apps/khelpcenter/plugins/kubuntu/a_welcome.desktop /home/$USERNAME/"$DESKTOPDIR"/a_welcome.desktop
50 fi
51 fi
52

Subscribers

People subscribed via source and target branches