|
|
69bb10 |
diff --git a/scripts/rpm2cpio.sh b/scripts/rpm2cpio.sh
|
|
|
69bb10 |
index 4531271cc..74aeed851 100755
|
|
|
69bb10 |
--- a/scripts/rpm2cpio.sh
|
|
|
69bb10 |
+++ b/scripts/rpm2cpio.sh
|
|
|
69bb10 |
@@ -15,13 +15,23 @@ _dd() {
|
|
|
69bb10 |
}
|
|
|
69bb10 |
|
|
|
69bb10 |
calcsize() {
|
|
|
69bb10 |
+
|
|
|
69bb10 |
+ case "$(_dd $1 bs=4 count=1 | tr -d '\0')" in
|
|
|
69bb10 |
+ "$(printf '\216\255\350')"*) ;; # '\x8e\xad\xe8'
|
|
|
69bb10 |
+ *) fatal "File doesn't look like rpm: $pkg" ;;
|
|
|
69bb10 |
+ esac
|
|
|
69bb10 |
+
|
|
|
69bb10 |
offset=$(($1 + 8))
|
|
|
69bb10 |
|
|
|
69bb10 |
local i b b0 b1 b2 b3 b4 b5 b6 b7
|
|
|
69bb10 |
|
|
|
69bb10 |
i=0
|
|
|
69bb10 |
while [ $i -lt 8 ]; do
|
|
|
69bb10 |
- b="$(_dd $(($offset + $i)) bs=1 count=1)"
|
|
|
69bb10 |
+ # add . to not loose \n
|
|
|
69bb10 |
+ # strip \0 as it gets dropped with warning otherwise
|
|
|
69bb10 |
+ b="$(_dd $(($offset + $i)) bs=1 count=1 | tr -d '\0' ; echo .)"
|
|
|
69bb10 |
+ b=${b%.} # strip . again
|
|
|
69bb10 |
+
|
|
|
69bb10 |
[ -z "$b" ] &&
|
|
|
69bb10 |
b="0" ||
|
|
|
69bb10 |
b="$(exec printf '%u\n' "'$b")"
|
|
|
69bb10 |
@@ -33,7 +43,7 @@ calcsize() {
|
|
|
69bb10 |
offset=$(($offset + $rsize))
|
|
|
69bb10 |
}
|
|
|
69bb10 |
|
|
|
69bb10 |
-case "$(_dd 0 bs=8 count=1)" in
|
|
|
69bb10 |
+case "$(_dd 0 bs=4 count=1 | tr -d '\0')" in
|
|
|
69bb10 |
"$(printf '\355\253\356\333')"*) ;; # '\xed\xab\xee\xdb'
|
|
|
69bb10 |
*) fatal "File doesn't look like rpm: $pkg" ;;
|
|
|
69bb10 |
esac
|
|
|
69bb10 |
@@ -44,11 +54,11 @@ sigsize=$rsize
|
|
|
69bb10 |
calcsize $(($offset + (8 - ($sigsize % 8)) % 8))
|
|
|
69bb10 |
hdrsize=$rsize
|
|
|
69bb10 |
|
|
|
69bb10 |
-case "$(_dd $offset bs=3 count=1)" in
|
|
|
69bb10 |
- "$(printf '\102\132')"*) _dd $offset | bunzip2 ;; # '\x42\x5a'
|
|
|
69bb10 |
- "$(printf '\037\213')"*) _dd $offset | gunzip ;; # '\x1f\x8b'
|
|
|
69bb10 |
- "$(printf '\375\067')"*) _dd $offset | xzcat ;; # '\xfd\x37'
|
|
|
69bb10 |
- "$(printf '\135\000')"*) _dd $offset | unlzma ;; # '\x5d\x00'
|
|
|
69bb10 |
- "$(printf '\050\265')"*) _dd $offset | unzstd ;; # '\x28\xb5'
|
|
|
69bb10 |
- *) fatal "Unrecognized rpm file: $pkg" ;;
|
|
|
69bb10 |
+case "$(_dd $offset bs=2 count=1 | tr -d '\0')" in
|
|
|
69bb10 |
+ "$(printf '\102\132')") _dd $offset | bunzip2 ;; # '\x42\x5a'
|
|
|
69bb10 |
+ "$(printf '\037\213')") _dd $offset | gunzip ;; # '\x1f\x8b'
|
|
|
69bb10 |
+ "$(printf '\375\067')") _dd $offset | xzcat ;; # '\xfd\x37'
|
|
|
69bb10 |
+ "$(printf '\135')") _dd $offset | unlzma ;; # '\x5d\x00'
|
|
|
69bb10 |
+ "$(printf '\050\265')") _dd $offset | unzstd ;; # '\x28\xb5'
|
|
|
69bb10 |
+ *) fatal "Unrecognized payload compression format in rpm file: $pkg" ;;
|
|
|
69bb10 |
esac
|