Package: plymouth
Severity: grave
Version: 24.004.60-4
X-Debbugs-CC: sjo...@debian.org bi...@debian.org

Hi,

I hate to report like this, but the recent fontconfig-based method
does not seem to work well under certain setup.

On my main workstation running Debian Sid, it has a setup with the
following fontconfig matching pattern:

-> % fc-match -f %{file}
/usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc

-> % fc-match -f %{file} monospace
/usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc

Now consider the following lines:

https://sources.debian.org/src/plymouth/24.004.60-4/debian/local/plymouth.hook/#L107-L110

                DEFAULT_FONT=$(fc-match -f %{file} 2> /dev/null)
                [ ! -z "$DEFAULT_FONT" ] && copy_file font "$DEFAULT_FONT"
                DEFAULT_MONOSPACE_FONT=$(fc-match -f %{file} monospace 2> 
/dev/null)
                [ ! -z "$DEFAULT_MONOSPACE_FONT" ] && copy_file font 
"$DEFAULT_MONOSPACE_FONT"

When $DEFAULT_FONT equals to $DEFAULT_MONOSPACE_FONT , it is expected that
"copy_file font $whatever" will be invoked twice, causing troubles in postinst:

-> % (Edit /usr/share/initramfs-tools/hooks/plymouth to use "set -x" first)

-> % LC_ALL=zh_CN.UTF-8 sudo apt-get install plymouth plymouth-themes -f -y 
2>&1 | tee /tmp/plymouth-error.txt

[...]
+ fc-match -f %{file}
+ DEFAULT_FONT=/usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc
+ [ ! -z /usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc ]
+ copy_file font /usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc
+ local type src target link_target
+ type=font
+ src=/usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc
+ target=/usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc
+ [ -f /usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc ]
+ [ -d 
/var/tmp/mkinitramfs_H8pRsB//usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc
 ]
+ [ /usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc != 
/usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc ]
+ realpath -ms //usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc
+ target=/usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc
+ [ -e 
/var/tmp/mkinitramfs_H8pRsB//usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc
 ]
+ mkdir -p /var/tmp/mkinitramfs_H8pRsB//usr/share/fonts/opentype/noto
+ readlink -f /usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc
+ link_target=/usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc
+ realpath -s /usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc
+ [ /usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc != 
/usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc ]
+ [ n = y ]
+ cp -pP /usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc 
/var/tmp/mkinitramfs_H8pRsB//usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc
+ fc-match -f %{file} monospace
+ DEFAULT_MONOSPACE_FONT=/usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc
+ [ ! -z /usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc ]
+ copy_file font /usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc
+ local type src target link_target
+ type=font
+ src=/usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc
+ target=/usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc
+ [ -f /usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc ]
+ [ -d 
/var/tmp/mkinitramfs_H8pRsB//usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc
 ]
+ [ /usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc != 
/usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc ]
+ realpath -ms //usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc
+ target=/usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc
+ [ -e 
/var/tmp/mkinitramfs_H8pRsB//usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc
 ]
+ return 1
E: /usr/share/initramfs-tools/hooks/plymouth failed with return 1.
update-initramfs: failed for /boot/initrd.img-6.12.27-amd64 with 1.

(See the full output in the attachment.)

Do notice that I am using the zh_CN.UTF-8 locale, where fc-match will
have the certain output as I mentioned above.

The proposed solution:

diff --git a/debian/local/plymouth.hook b/debian/local/plymouth.hook
index 7a64541..8824103 100644
--- a/debian/local/plymouth.hook
+++ b/debian/local/plymouth.hook
@@ -107,7 +107,7 @@ case "${THEME_NAME}" in
                DEFAULT_FONT=$(fc-match -f %{file} 2> /dev/null)
                [ ! -z "$DEFAULT_FONT" ] && copy_file font "$DEFAULT_FONT"
                DEFAULT_MONOSPACE_FONT=$(fc-match -f %{file} monospace 2> 
/dev/null)
-               [ ! -z "$DEFAULT_MONOSPACE_FONT" ] && copy_file font 
"$DEFAULT_MONOSPACE_FONT"
+               [ ! -z "$DEFAULT_MONOSPACE_FONT" ] && [ 
"$DEFAULT_MONOSPACE_FONT" != "$DEFAULT_FONT" ] && copy_file font 
"$DEFAULT_MONOSPACE_FONT"
 
                [ ! -z "$DEFAULT_FONT" ] && ln -s "$DEFAULT_FONT" 
${DESTDIR}/usr/share/fonts/Plymouth.ttf
                [ ! -z "$DEFAULT_MONOSPACE_FONT" ] && ln -s 
"$DEFAULT_MONOSPACE_FONT" ${DESTDIR}/usr/share/fonts/Plymouth-monospace.ttf


Please let me know if you have any questions.

Best Regards,
Boyuan Yang

Attachment: plymouth-error.txt.gz
Description: application/gzip

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to