diff options
author | Mark Hatle <mark.hatle@windriver.com> | 2011-02-07 18:18:18 -0600 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2011-02-08 18:01:35 +0000 |
commit | 906285ff00d6ffd3fd7713af52250e7c6503edb7 (patch) | |
tree | 2ae9c99eb5772b965c8c690817407c0327f04e59 /scripts | |
parent | 2f3a7348b7da637d2362e7ed50c96a248ff58fc5 (diff) | |
download | poky-906285ff00d6ffd3fd7713af52250e7c6503edb7.tar.gz |
fetch2: Add SRPM knowledge
Enable the fetcher to be able to unpack and SRPM. By default the system will
unpack the contents of the SRPM into the WORKDIR.
A new syntax "unpack=file" was developed for the SRC_URI, to allow for a
recipe to extract a specific file within an SRPM. An unpack operation will
then be executed on the extracted file.
In order to apply extracted patches (or unpack files not specified with
unpack), you must specify the path using WORKDIR, i.e.:
file://${WORKDIR}/mypatch.patch
Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/rpm2cpio.sh | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/scripts/rpm2cpio.sh b/scripts/rpm2cpio.sh new file mode 100755 index 0000000000..426fd77bb7 --- /dev/null +++ b/scripts/rpm2cpio.sh | |||
@@ -0,0 +1,53 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | # This comes from the RPM5 5.4.0 distribution. | ||
4 | |||
5 | pkg=$1 | ||
6 | if [ "$pkg" = "" -o ! -e "$pkg" ]; then | ||
7 | echo "no package supplied" 1>&2 | ||
8 | exit 1 | ||
9 | fi | ||
10 | |||
11 | leadsize=96 | ||
12 | o=`expr $leadsize + 8` | ||
13 | set `od -j $o -N 8 -t u1 $pkg` | ||
14 | il=`expr 256 \* \( 256 \* \( 256 \* $2 + $3 \) + $4 \) + $5` | ||
15 | dl=`expr 256 \* \( 256 \* \( 256 \* $6 + $7 \) + $8 \) + $9` | ||
16 | # echo "sig il: $il dl: $dl" | ||
17 | |||
18 | sigsize=`expr 8 + 16 \* $il + $dl` | ||
19 | o=`expr $o + $sigsize + \( 8 - \( $sigsize \% 8 \) \) \% 8 + 8` | ||
20 | set `od -j $o -N 8 -t u1 $pkg` | ||
21 | il=`expr 256 \* \( 256 \* \( 256 \* $2 + $3 \) + $4 \) + $5` | ||
22 | dl=`expr 256 \* \( 256 \* \( 256 \* $6 + $7 \) + $8 \) + $9` | ||
23 | # echo "hdr il: $il dl: $dl" | ||
24 | |||
25 | hdrsize=`expr 8 + 16 \* $il + $dl` | ||
26 | o=`expr $o + $hdrsize` | ||
27 | EXTRACTOR="dd if=$pkg ibs=$o skip=1" | ||
28 | |||
29 | COMPRESSION=`($EXTRACTOR |file -) 2>/dev/null` | ||
30 | if echo $COMPRESSION |grep -q gzip; then | ||
31 | DECOMPRESSOR=gunzip | ||
32 | elif echo $COMPRESSION |grep -q bzip2; then | ||
33 | DECOMPRESSOR=bunzip2 | ||
34 | elif echo $COMPRESSION |grep -q xz; then | ||
35 | DECOMPRESSOR=unxz | ||
36 | elif echo $COMPRESSION |grep -q cpio; then | ||
37 | DECOMPRESSOR=cat | ||
38 | else | ||
39 | # Most versions of file don't support LZMA, therefore we assume | ||
40 | # anything not detected is LZMA | ||
41 | DECOMPRESSOR=`which unlzma 2>/dev/null` | ||
42 | case "$DECOMPRESSOR" in | ||
43 | /* ) ;; | ||
44 | * ) DECOMPRESSOR=`which lzmash 2>/dev/null` | ||
45 | case "$DECOMPRESSOR" in | ||
46 | /* ) DECOMPRESSOR="lzmash -d -c" ;; | ||
47 | * ) DECOMPRESSOR=cat ;; | ||
48 | esac | ||
49 | ;; | ||
50 | esac | ||
51 | fi | ||
52 | |||
53 | $EXTRACTOR 2>/dev/null | $DECOMPRESSOR | ||