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

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