<?xml version="1.0" encoding="UTF-8" ?>

<bugzilla version="5.2"
          urlbase="https://bugzilla.altlinux.org/"
          
          maintainer="jenya@basealt.ru"
>

    <bug>
          <bug_id>41970</bug_id>
          
          <creation_ts>2022-02-16 10:43:01 +0300</creation_ts>
          <short_desc>/etc/grub.d/30_uefi-firmware does not work with zero</short_desc>
          <delta_ts>2022-02-28 20:02:49 +0300</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>4</classification_id>
          <classification>Development</classification>
          <product>Sisyphus</product>
          <component>grub-common</component>
          <version>unstable</version>
          <rep_platform>all</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>CLOSED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P5</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Ivan A. Melnikov">iv</reporter>
          <assigned_to name="Николай Костригин">nickel</assigned_to>
          <cc>jqt4</cc>
    
    <cc>nickel</cc>
    
    <cc>placeholder</cc>
    
    <cc>rider</cc>
    
    <cc>sin</cc>
          
          <qa_contact>qa-sisyphus</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>207837</commentid>
    <comment_count>0</comment_count>
    <who name="Ivan A. Melnikov">iv</who>
    <bug_when>2022-02-16 10:43:01 +0300</bug_when>
    <thetext>Некоторые реализации UEFI (например, u-boot) не поддерживают ни один из OS Indicators:

# xxd /sys/firmware/efi/efivars/OsIndicationsSupported-8be4df61-93ca-11d2-aa0d-00e098032b8c
00000000: 0600 0000 0000 0000 0000 0000            ............

В этом случае 30_uefi-firmware должен, по идее, ничего не делать, однако он выдаёт ошибку и добавляет в config не рабочий menuentry:

# grub-mkconfig
[...]
### BEGIN /etc/grub.d/30_uefi-firmware ###
/etc/grub.d/30_uefi-firmware: line 34: warning: command substitution: ignored null byte in input
Adding boot menu entry for UEFI Firmware Settings ...
menuentry &apos;UEFI Firmware Settings&apos; $menuentry_id_option &apos;uefi-firmware&apos; {
        fwsetup
}
### END /etc/grub.d/30_uefi-firmware ###
[...]</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>207838</commentid>
    <comment_count>1</comment_count>
    <who name="Ivan A. Melnikov">iv</who>
    <bug_when>2022-02-16 10:53:13 +0300</bug_when>
    <thetext>Очень странный кусок кода:

$(printf 0x%x \&apos;&quot;$(cat $OS_INDICATIONS | cut -b5)&quot;\&apos;)

По всей видимости, от пытается получить младший байт переменной OsIndicationsSupported из 8be4df61-93ca-11d2-aa0d-00e098032b8c (в файлах efivars первые 4 байта заглолвок), однако получается у него совсем не это:

$ xxd test2.bin
00000000: 0600 0000 0000 0000 0000 0000            ............
$ echo  $(printf 0x%x \&apos;&quot;$(cat test2.bin | cut -b5)&quot;\&apos;)
-bash: warning: command substitution: ignored null byte in input
0x27

0x27 -- это одинарная кавычка (&quot;&apos;&quot;).

Вообще, вместо таких сложных подстановок с пайпами можно было бы просто взять od, bash прекрасно умеет побитовые операции и с десятичными числами:

$ od -An -t u8 --read-bytes=1 --skip-bytes=4  test2.bin
                    0
$ xxd test3.bin
00000000: 0600 0000 1122 3344 5566 7788            .....&quot;3DUfw.
$ od -An -t u8 --read-bytes=1 --skip-bytes=4  test3.bin
                   17

(да, 17 == 0x11).

Могу сделать патч.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>207874</commentid>
    <comment_count>2</comment_count>
    <who name="Anton Farygin">rider</who>
    <bug_when>2022-02-16 14:53:21 +0300</bug_when>
    <thetext>Да, давайте конечно патч.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>207881</commentid>
    <comment_count>3</comment_count>
    <who name="Ivan A. Melnikov">iv</who>
    <bug_when>2022-02-16 15:21:21 +0300</bug_when>
    <thetext>(In reply to Anton Farygin from comment #2)
&gt; Да, давайте конечно патч.

По-моему, как-то так:

http://git.altlinux.org/people/iv/packages/?p=grub.git;a=commitdiff;h=6889ce261a7f4bfe91e8507043bad26c94f7ad75</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>207888</commentid>
    <comment_count>4</comment_count>
    <who name="Николай Костригин">nickel</who>
    <bug_when>2022-02-16 15:39:40 +0300</bug_when>
    <thetext>Спасибо за патч</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>208197</commentid>
    <comment_count>5</comment_count>
    <who name="Repository Robot">repository-robot</who>
    <bug_when>2022-02-28 20:02:49 +0300</bug_when>
    <thetext>grub-2.06-alt7 -&gt; sisyphus:

 Thu Feb 24 2022 Nikolai Kostrigin &lt;nickel@altlinux&gt; 2.06-alt7
 - grub-efi: improve RPM filetrigger and post install script to skip all
   actions in case of being invoked at package installing stage by OS installer
   (closes: #42025)
 - 30_uefi-firmware.in: Fix for zero supported indications (closes: #41970)
 - pack 41_custom as there appear to be users of it (closes: #41832)</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>