Blame SOURCES/redhat-rpm-config-9.1.0-compressed-kmods-support.patch

981821
Index: redhat-rpm-config-9.1.0/find-requires
981821
===================================================================
981821
--- redhat-rpm-config-9.1.0.orig/find-requires	2018-08-24 09:58:45.437193389 +0200
981821
+++ redhat-rpm-config-9.1.0/find-requires	2018-08-24 09:59:31.902739176 +0200
981821
@@ -143,7 +143,7 @@
981821
 unset is_kmod
981821
 
981821
 for f in $filelist; do
981821
-    if [ $(echo "$f" | sed -r -ne 's:^.*/lib/modules/(.*)/(.*).ko$:\2:p') ]
981821
+    if [ $(echo "$f" | sed -r -ne 's:^.*/lib/modules/(.*)/(.*)\.ko(\.gz|\.bz2|\.xz)?$:\2:p') ]
981821
     then
981821
         is_kmod=1;
981821
     elif [ $(echo "$f" | sed -r -ne 's:^.*/boot/(.*):\1:p') ]
981821
Index: redhat-rpm-config-9.1.0/find-requires.ksyms
981821
===================================================================
981821
--- redhat-rpm-config-9.1.0.orig/find-requires.ksyms	2018-08-24 09:55:19.122210171 +0200
981821
+++ redhat-rpm-config-9.1.0/find-requires.ksyms	2018-08-24 10:01:02.895849695 +0200
981821
@@ -9,24 +9,49 @@
981821
 
981821
 # Extract all of the symbols provided by this module.
981821
 all_provides() {
981821
-    if [[ -n $(nm "$@" | sed -r -ne 's:^0*([0-9a-f]+) A __crc_(.+):0x\1 \2:p') ]]; then
981821
-        nm "$@" \
981821
-        | sed -r -ne 's:^0*([0-9a-f]+) A __crc_(.+):0x\1 \2:p' \
981821
-        | awk --non-decimal-data '{printf("%s:0x%08x\n", $2, $1)}' \
981821
-        | LC_ALL=C sort -k1,1 -u
981821
-    else
981821
-        ELFRODATA=$(readelf -R .rodata "$@" | awk '/0x/{printf $2$3$4$5}')
981821
-        if [[ -n $(readelf -h "$@" | grep "little endian") ]]; then
981821
-            RODATA=$(echo $ELFRODATA | sed 's/\(..\)\(..\)\(..\)\(..\)/\4\3\2\1/g')
981821
+    for module in "$@"; do
981821
+        tmpfile=""
981821
+        if [ "x${module%.ko}" = "x${module}" ]; then
981821
+            tmpfile=$(mktemp -t ${0##*/}.XXXXXX.ko)
981821
+            proc_bin=
981821
+            case "${module##*.}" in
981821
+            xz)
981821
+                    proc_bin=xz
981821
+                    ;;
981821
+            bz2)
981821
+                    proc_bin=bzip2
981821
+                    ;;
981821
+            gz)
981821
+                    proc_bin=gzip
981821
+                    ;;
981821
+            esac
981821
+
981821
+            [ -n "$proc_bin" ] || continue
981821
+
981821
+            "$proc_bin" -d -c - < "$module" > "$tmpfile"
981821
+            module="$tmpfile"
981821
+        fi
981821
+
981821
+        if [[ -n $(nm "$module" | sed -r -ne 's:^0*([0-9a-f]+) A __crc_(.+):0x\1 \2:p') ]]; then
981821
+            nm "$module" \
981821
+            | sed -r -ne 's:^0*([0-9a-f]+) A __crc_(.+):0x\1 \2:p' \
981821
+            | awk --non-decimal-data '{printf("%s:0x%08x\n", $2, $1)}'
981821
         else
981821
-            RODATA=$ELFRODATA
981821
+            ELFRODATA=$(readelf -R .rodata "$module" | awk '/0x/{printf $2$3$4$5}')
981821
+            if [[ -n $(readelf -h "$module" | grep "little endian") ]]; then
981821
+                RODATA=$(echo $ELFRODATA | sed 's/\(..\)\(..\)\(..\)\(..\)/\4\3\2\1/g')
981821
+            else
981821
+                RODATA=$ELFRODATA
981821
+            fi
981821
+            for sym in $(nm "$module" | sed -r -ne 's:^0*([0-9a-f]+) R __crc_(.+):0x\1 \2:p'); do
981821
+                echo $sym $RODATA
981821
+            done \
981821
+            | awk --non-decimal-data '{printf("%s:0x%08s\n", $2, substr($3,($1*2)+1,8))}'
981821
         fi
981821
-        for sym in $(nm "$@" | sed -r -ne 's:^0*([0-9a-f]+) R __crc_(.+):0x\1 \2:p'); do
981821
-            echo $sym $RODATA
981821
-        done \
981821
-        | awk --non-decimal-data '{printf("%s:0x%08s\n", $2, substr($3,($1*2)+1,8))}' \
981821
-        | LC_ALL=C sort -k1,1 -u
981821
-    fi
981821
+
981821
+        [ -z "$tmpfile" ] || rm -f -- "$tmpfile"
981821
+    done \
981821
+    | LC_ALL=C sort -k1,1 -u
981821
 }
981821
 
981821
 # Extract all of the requirements of this module.
981821
@@ -100,7 +125,7 @@
981821
     fi
981821
 }
981821
 
981821
-modules=($(grep -E '/lib/modules/.+\.ko$'))
981821
+modules=($(grep -E '/lib/modules/.+\.ko(\.gz|\.bz2|\.xz)?$'))
981821
 if [ ${#modules[@]} -gt 0 ]; then
981821
     kernel=$(/sbin/modinfo -F vermagic "${modules[0]}" | sed -e 's: .*::' -e q)
981821
 
981821
Index: redhat-rpm-config-9.1.0/find-provides
981821
===================================================================
981821
--- redhat-rpm-config-9.1.0.orig/find-provides	2010-02-02 10:24:04.000000000 +0100
981821
+++ redhat-rpm-config-9.1.0/find-provides	2018-08-24 10:02:26.666030820 +0200
981821
@@ -92,7 +92,7 @@
981821
 
981821
 is_kmod=1
981821
 for f in $filelist; do
981821
-    if [ $(echo "$f" | sed -r -ne 's:^.*/lib/modules/(.*)/(.*).ko$:\2:p') ]
981821
+    if [ $(echo "$f" | sed -r -ne 's:^.*/lib/modules/(.*)/(.*)\.ko(\.gz|\.bz2|\.xz)?$:\2:p') ]
981821
     then
981821
         is_kernel=1;
981821
     fi
981821
Index: redhat-rpm-config-9.1.0/find-provides.ksyms
981821
===================================================================
981821
--- redhat-rpm-config-9.1.0.orig/find-provides.ksyms	2018-08-24 09:55:19.065210728 +0200
981821
+++ redhat-rpm-config-9.1.0/find-provides.ksyms	2018-08-24 10:03:17.727531681 +0200
981821
@@ -2,7 +2,29 @@
981821
 
981821
 IFS=$'\n'
981821
 
981821
-for module in $(grep -E '/lib/modules/.+\.ko$'); do
981821
+for module in $(grep -E '/lib/modules/.+\.ko(\.gz|\.bz2|\.xz)?$'); do
981821
+    tmpfile=""
981821
+    if [ "x${module%.ko}" = "x${module}" ]; then
981821
+        tmpfile=$(mktemp -t ${0##*/}.XXXXXX.ko)
981821
+        proc_bin=
981821
+        case "${module##*.}" in
981821
+        xz)
981821
+                proc_bin=xz
981821
+                ;;
981821
+        bz2)
981821
+                proc_bin=bzip2
981821
+                ;;
981821
+        gz)
981821
+                proc_bin=gzip
981821
+                ;;
981821
+        esac
981821
+
981821
+        [ -n "$proc_bin" ] || continue
981821
+
981821
+        "$proc_bin" -d -c - < "$module" > "$tmpfile"
981821
+        module="$tmpfile"
981821
+    fi
981821
+
981821
     if [[ -n $(nm $module | sed -r -ne 's:^0*([0-9a-f]+) A __crc_(.+):0x\1 \2:p') ]]; then
981821
         nm $module \
981821
         | sed -r -ne 's:^0*([0-9a-f]+) A __crc_(.+):0x\1 \2:p' \
981821
@@ -21,4 +43,6 @@
981821
         | awk --non-decimal-data '{printf("ksym(%s) = 0x%08s\n", $2, substr($3,($1*2)+1,8))}' \
981821
         | LC_ALL=C sort -u
981821
     fi
981821
+
981821
+    [ -z "$tmpfile" ] || rm -f -- "$tmpfile"
981821
 done