Bug 1846034

Summary: systemd-udev-239-33.el8 breaks dracut: /usr/lib/dracut/dracut-init.sh: line 460: [: too many arguments
Product: Red Hat Enterprise Linux 8 Reporter: Petr Pisar <ppisar>
Component: dracutAssignee: Lukáš Nykrýn <lnykryn>
Status: CLOSED ERRATA QA Contact: Frantisek Sumsal <fsumsal>
Severity: high Docs Contact:
Priority: unspecified    
Version: 8.3CC: awalsh, bugproxy, dracut-maint-list, fsumsal, hannsj_uhl, jikortus, jwboyer, lszubowi, mleitner, systemd-maint-list, xiawu
Target Milestone: rcKeywords: Patch, Regression
Target Release: 8.3   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: dracut-049-89.git20200625.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-11-04 01:42:48 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1812825    
Attachments:
Description Flags
sosreport
none
must gather info
none
Prposed patch to fix udevverion none

Description Petr Pisar 2020-06-10 15:48:30 UTC
After upgrading systemd-udev from 239-30.el8_2 to 239-33.el8, installing kernel-core package produces a scriptlet warning:

# dnf --allowerasing  reinstall kernel-core-4.18.0-212.el8.x86_64
[...]
Reinstalling:
 kernel-core                                                        x86_64                                                        4.18.0-212.el8                                                          rhel-8.3.0-baseos                                                         30 M
[...]
Running transaction
  Preparing        :                                                                                                                                                                                                                                                                 1/1
  Reinstalling     : kernel-core-4.18.0-212.el8.x86_64                                                                                                                                                                                                                               1/2
  Running scriptlet: kernel-core-4.18.0-212.el8.x86_64                                                                                                                                                                                                                               1/2
  Running scriptlet: kernel-core-4.18.0-212.el8.x86_64                                                                                                                                                                                                                               2/2
  Cleanup          : kernel-core-4.18.0-212.el8.x86_64                                                                                                                                                                                                                               2/2
  Running scriptlet: kernel-core-4.18.0-212.el8.x86_64                                                                                                                                                                                                                               2/2
/usr/lib/dracut/dracut-init.sh: line 460: [: too many arguments
/usr/lib/dracut/dracut-init.sh: line 460: [: too many arguments
/usr/lib/dracut/dracut-init.sh: line 460: [: too many arguments
/usr/lib/dracut/dracut-init.sh: line 454: [: too many arguments

  Verifying        : kernel-core-4.18.0-212.el8.x86_64                                                                                                                                                                                                                               1/2
  Verifying        : kernel-core-4.18.0-212.el8.x86_64                                                                                                                                                                                                                               2/2

The reason is that "udevadm --version" changed format from:

# udevadm --version
239

to:

# udevadm --version
239 (239-33.el8)

/usr/lib/dracut/dracut-init.sh from dracut-049-86.git20200602.el8.x86_64 parses "udevadm --version" output:

   446  prepare_udev_rules() {
→  447      [ -z "$UDEVVERSION" ] && export UDEVVERSION=$(udevadm --version)
   448  
   449      for f in "$@"; do
   450          f="${initdir}/etc/udev/rules.d/$f"
   451          [ -e "$f" ] || continue
   452          while read line || [ -n "$line" ]; do
   453              if [ "${line%%IMPORT PATH_ID}" != "$line" ]; then
   454                  if [ $UDEVVERSION -ge 174 ]; then
   455                      printf '%sIMPORT{builtin}="path_id"\n' "${line%%IMPORT PATH_ID}"
   456                  else
   457                      printf '%sIMPORT{program}="path_id %%p"\n' "${line%%IMPORT PATH_ID}"
   458                  fi
   459              elif [ "${line%%IMPORT BLKID}" != "$line" ]; then
→  460                  if [ $UDEVVERSION -ge 176 ]; then
   461                      printf '%sIMPORT{builtin}="blkid"\n' "${line%%IMPORT BLKID}"
   462                  else
   463                      printf '%sIMPORT{program}="/sbin/blkid -o udev -p $tempnode"\n' "${line%%IMPORT BLKID}"
   464                  fi
   465              else
   466                  echo "$line"
   467              fi
   468          done < "${f}" > "${f}.new"
   469          mv "${f}.new" "$f"
   470      done

Either systemd-udev should revert the format, or dracut should adapt.

Comment 1 Lenny Szubowicz 2020-06-11 01:12:53 UTC
I just ran into this as well. FWIW, I think dracut should adapt to the change. Seems risky to depend on a version string being a simple integer value.

Perhaps something like this would work:

root@intel-tigerlake-y-02 ~]# diff -u /usr/lib/dracut/dracut-init.sh-orig /usr/lib/dracut/dracut-init.sh
--- /usr/lib/dracut/dracut-init.sh-orig	2020-06-10 20:33:08.214575391 -0400
+++ /usr/lib/dracut/dracut-init.sh	2020-06-10 20:41:26.195045814 -0400
@@ -451,13 +451,13 @@
         [ -e "$f" ] || continue
         while read line || [ -n "$line" ]; do
             if [ "${line%%IMPORT PATH_ID}" != "$line" ]; then
-                if [ $UDEVVERSION -ge 174 ]; then
+                if [[ ! "$UDEVVERSION" < "174" ]]; then
                     printf '%sIMPORT{builtin}="path_id"\n' "${line%%IMPORT PATH_ID}"
                 else
                     printf '%sIMPORT{program}="path_id %%p"\n' "${line%%IMPORT PATH_ID}"
                 fi
             elif [ "${line%%IMPORT BLKID}" != "$line" ]; then
-                if [ $UDEVVERSION -ge 176 ]; then
+                if [[ ! "$UDEVVERSION" < "176" ]]; then
                     printf '%sIMPORT{builtin}="blkid"\n' "${line%%IMPORT BLKID}"
                 else
                     printf '%sIMPORT{program}="/sbin/blkid -o udev -p $tempnode"\n' "${line%%IMPORT BLKID}"

Comment 2 Jan Synacek 2020-06-11 09:36:02 UTC
Upstream PR: https://github.com/dracutdevs/dracut/pull/842

Comment 8 Lukáš Nykrýn 2020-07-03 07:25:06 UTC
*** Bug 1853575 has been marked as a duplicate of this bug. ***

Comment 9 IBM Bug Proxy 2020-07-03 08:51:43 UTC
Created attachment 1699797 [details]
sosreport

Comment 10 IBM Bug Proxy 2020-07-03 08:51:48 UTC
Created attachment 1699798 [details]
must gather info

Comment 11 IBM Bug Proxy 2020-07-03 08:51:51 UTC
Created attachment 1699799 [details]
Prposed patch to fix udevverion

Comment 12 David Tardon 2020-08-03 14:44:17 UTC
*** Bug 1849750 has been marked as a duplicate of this bug. ***

Comment 16 errata-xmlrpc 2020-11-04 01:42:48 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (dracut bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2020:4473