summaryrefslogtreecommitdiffstats
path: root/scripts/rpm2cpio.sh
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/rpm2cpio.sh')
-rwxr-xr-xscripts/rpm2cpio.sh65
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
4fatal() {
5 echo "$*" >&2
6 exit 1
7}
8
9pkg="$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
18calcsize() {
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
47case "$(_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" ;;
50esac
51
52calcsize 96
53sigsize=$rsize
54
55calcsize $(($offset + (8 - ($sigsize % 8)) % 8))
56hdrsize=$rsize
57
58case "$(_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" ;;
65esac