summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorAlberto Planas <aplanas@suse.com>2023-06-19 08:42:48 +0200
committerSteve Sakoman <steve@sakoman.com>2023-08-19 05:56:59 -1000
commitbbd85cd9f4d7bd336d1739d5b23bbcaab7b248ef (patch)
treee8c17b760eb3dc60b6b7eeb21701b9d1c5007bf3 /scripts
parent28fa51bcf0ec6888d6f9d133057baee847ae899e (diff)
downloadpoky-bbd85cd9f4d7bd336d1739d5b23bbcaab7b248ef.tar.gz
rpm2cpio.sh: update to the last 4.x version
openSUSE RPMs are compressing the RPM payload using zstd, that correspond to the magic ID 0x28, 0xb5, 0x2f. This patch update the script to the last version from the rpm project, and add support to this compression format, and extract the cpio payload using the "unzstd" binary. (From OE-Core rev: 9c0d66e693aa7ab8b3f2a3c68764e4ab6159c085) Signed-off-by: Alberto Planas <aplanas@suse.com> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> (cherry picked from commit 3aba44a75dd565b192f7328f2a0150a313de3cc1) Signed-off-by: Steve Sakoman <steve@sakoman.com>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/rpm2cpio.sh30
1 files changed, 20 insertions, 10 deletions
diff --git a/scripts/rpm2cpio.sh b/scripts/rpm2cpio.sh
index 2034373fe4..8199b43784 100755
--- a/scripts/rpm2cpio.sh
+++ b/scripts/rpm2cpio.sh
@@ -7,7 +7,7 @@ fatal() {
7} 7}
8 8
9pkg="$1" 9pkg="$1"
10[ -n "$pkg" -a -e "$pkg" ] || 10[ -n "$pkg" ] && [ -e "$pkg" ] ||
11 fatal "No package supplied" 11 fatal "No package supplied"
12 12
13_dd() { 13_dd() {
@@ -16,14 +16,23 @@ _dd() {
16} 16}
17 17
18calcsize() { 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
19 offset=$(($1 + 8)) 25 offset=$(($1 + 8))
20 26
21 local i b b0 b1 b2 b3 b4 b5 b6 b7 27 local i b b0 b1 b2 b3 b4 b5 b6 b7
22 28
23 i=0 29 i=0
24 while [ $i -lt 8 ]; do 30 while [ $i -lt 8 ]; do
25 b=$(_dd $(($offset + $i)) bs=1 count=1; echo X) 31 # add . to not loose \n
26 b=${b%X} 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
27 [ -z "$b" ] && 36 [ -z "$b" ] &&
28 b="0" || 37 b="0" ||
29 b="$(exec printf '%u\n' "'$b")" 38 b="$(exec printf '%u\n' "'$b")"
@@ -35,7 +44,7 @@ calcsize() {
35 offset=$(($offset + $rsize)) 44 offset=$(($offset + $rsize))
36} 45}
37 46
38case "$(_dd 0 bs=8 count=1)" in 47case "$(_dd 0 bs=4 count=1 | tr -d '\0')" in
39 "$(printf '\355\253\356\333')"*) ;; # '\xed\xab\xee\xdb' 48 "$(printf '\355\253\356\333')"*) ;; # '\xed\xab\xee\xdb'
40 *) fatal "File doesn't look like rpm: $pkg" ;; 49 *) fatal "File doesn't look like rpm: $pkg" ;;
41esac 50esac
@@ -46,10 +55,11 @@ sigsize=$rsize
46calcsize $(($offset + (8 - ($sigsize % 8)) % 8)) 55calcsize $(($offset + (8 - ($sigsize % 8)) % 8))
47hdrsize=$rsize 56hdrsize=$rsize
48 57
49case "$(_dd $offset bs=3 count=1)" in 58case "$(_dd $offset bs=2 count=1 | tr -d '\0')" in
50 "$(printf '\102\132')"*) _dd $offset | bzip2 -d ;; # '\x42\x5a' 59 "$(printf '\102\132')") _dd $offset | bunzip2 ;; # '\x42\x5a'
51 "$(printf '\037\213')"*) _dd $offset | gunzip ;; # '\x1f\x8b' 60 "$(printf '\037\213')") _dd $offset | gunzip ;; # '\x1f\x8b'
52 "$(printf '\375\067')"*) _dd $offset | xzcat ;; # '\xfd\x37' 61 "$(printf '\375\067')") _dd $offset | xzcat ;; # '\xfd\x37'
53 "$(printf '\135\000')"*) _dd $offset | unlzma ;; # '\x5d\x00' 62 "$(printf '\135')") _dd $offset | unlzma ;; # '\x5d\x00'
54 *) fatal "Unrecognized rpm file: $pkg" ;; 63 "$(printf '\050\265')") _dd $offset | unzstd ;; # '\x28\xb5'
64 *) fatal "Unrecognized payload compression format in rpm file: $pkg" ;;
55esac 65esac