diff options
Diffstat (limited to 'scripts/rpm2cpio.sh')
| -rwxr-xr-x | scripts/rpm2cpio.sh | 65 |
1 files changed, 0 insertions, 65 deletions
diff --git a/scripts/rpm2cpio.sh b/scripts/rpm2cpio.sh deleted file mode 100755 index 8199b43784..0000000000 --- a/scripts/rpm2cpio.sh +++ /dev/null | |||
| @@ -1,65 +0,0 @@ | |||
| 1 | #!/bin/sh -efu | ||
| 2 | # This file comes from rpm 4.x distribution | ||
| 3 | |||
| 4 | fatal() { | ||
| 5 | echo "$*" >&2 | ||
| 6 | exit 1 | ||
| 7 | } | ||
| 8 | |||
| 9 | pkg="$1" | ||
| 10 | [ -n "$pkg" ] && [ -e "$pkg" ] || | ||
| 11 | fatal "No package supplied" | ||
| 12 | |||
| 13 | _dd() { | ||
| 14 | local o="$1"; shift | ||
| 15 | dd if="$pkg" skip="$o" iflag=skip_bytes status=none $* | ||
| 16 | } | ||
| 17 | |||
| 18 | calcsize() { | ||
| 19 | |||
| 20 | case "$(_dd $1 bs=4 count=1 | tr -d '\0')" in | ||
| 21 | "$(printf '\216\255\350')"*) ;; # '\x8e\xad\xe8' | ||
| 22 | *) fatal "File doesn't look like rpm: $pkg" ;; | ||
| 23 | esac | ||
| 24 | |||
| 25 | offset=$(($1 + 8)) | ||
| 26 | |||
| 27 | local i b b0 b1 b2 b3 b4 b5 b6 b7 | ||
| 28 | |||
| 29 | i=0 | ||
| 30 | while [ $i -lt 8 ]; do | ||
| 31 | # add . to not loose \n | ||
| 32 | # strip \0 as it gets dropped with warning otherwise | ||
| 33 | b="$(_dd $(($offset + $i)) bs=1 count=1 | tr -d '\0' ; echo .)" | ||
| 34 | b=${b%.} # strip . again | ||
| 35 | |||
| 36 | [ -z "$b" ] && | ||
| 37 | b="0" || | ||
| 38 | b="$(exec printf '%u\n' "'$b")" | ||
| 39 | eval "b$i=\$b" | ||
| 40 | i=$(($i + 1)) | ||
| 41 | done | ||
| 42 | |||
| 43 | rsize=$((8 + ((($b0 << 24) + ($b1 << 16) + ($b2 << 8) + $b3) << 4) + ($b4 << 24) + ($b5 << 16) + ($b6 << 8) + $b7)) | ||
| 44 | offset=$(($offset + $rsize)) | ||
| 45 | } | ||
| 46 | |||
| 47 | case "$(_dd 0 bs=4 count=1 | tr -d '\0')" in | ||
| 48 | "$(printf '\355\253\356\333')"*) ;; # '\xed\xab\xee\xdb' | ||
| 49 | *) fatal "File doesn't look like rpm: $pkg" ;; | ||
| 50 | esac | ||
| 51 | |||
| 52 | calcsize 96 | ||
| 53 | sigsize=$rsize | ||
| 54 | |||
| 55 | calcsize $(($offset + (8 - ($sigsize % 8)) % 8)) | ||
| 56 | hdrsize=$rsize | ||
| 57 | |||
| 58 | case "$(_dd $offset bs=2 count=1 | tr -d '\0')" in | ||
| 59 | "$(printf '\102\132')") _dd $offset | bunzip2 ;; # '\x42\x5a' | ||
| 60 | "$(printf '\037\213')") _dd $offset | gunzip ;; # '\x1f\x8b' | ||
| 61 | "$(printf '\375\067')") _dd $offset | xzcat ;; # '\xfd\x37' | ||
| 62 | "$(printf '\135')") _dd $offset | unlzma ;; # '\x5d\x00' | ||
| 63 | "$(printf '\050\265')") _dd $offset | unzstd ;; # '\x28\xb5' | ||
| 64 | *) fatal "Unrecognized payload compression format in rpm file: $pkg" ;; | ||
| 65 | esac | ||
