summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorMark Hatle <mark.hatle@windriver.com>2011-02-07 18:18:18 -0600
committerRichard Purdie <richard.purdie@linuxfoundation.org>2011-02-08 18:01:35 +0000
commit906285ff00d6ffd3fd7713af52250e7c6503edb7 (patch)
tree2ae9c99eb5772b965c8c690817407c0327f04e59 /scripts
parent2f3a7348b7da637d2362e7ed50c96a248ff58fc5 (diff)
downloadopenembedded-core-906285ff00d6ffd3fd7713af52250e7c6503edb7.tar.gz
openembedded-core-906285ff00d6ffd3fd7713af52250e7c6503edb7.tar.bz2
openembedded-core-906285ff00d6ffd3fd7713af52250e7c6503edb7.tar.xz
openembedded-core-906285ff00d6ffd3fd7713af52250e7c6503edb7.zip
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-xscripts/rpm2cpio.sh53
1 files changed, 53 insertions, 0 deletions
diff --git a/scripts/rpm2cpio.sh b/scripts/rpm2cpio.sh
new file mode 100755
index 000000000..426fd77bb
--- /dev/null
+++ b/scripts/rpm2cpio.sh
@@ -0,0 +1,53 @@
+#!/bin/sh
+
+# This comes from the RPM5 5.4.0 distribution.
+
+pkg=$1
+if [ "$pkg" = "" -o ! -e "$pkg" ]; then
+ echo "no package supplied" 1>&2
+ exit 1
+fi
+
+leadsize=96
+o=`expr $leadsize + 8`
+set `od -j $o -N 8 -t u1 $pkg`
+il=`expr 256 \* \( 256 \* \( 256 \* $2 + $3 \) + $4 \) + $5`
+dl=`expr 256 \* \( 256 \* \( 256 \* $6 + $7 \) + $8 \) + $9`
+# echo "sig il: $il dl: $dl"
+
+sigsize=`expr 8 + 16 \* $il + $dl`
+o=`expr $o + $sigsize + \( 8 - \( $sigsize \% 8 \) \) \% 8 + 8`
+set `od -j $o -N 8 -t u1 $pkg`
+il=`expr 256 \* \( 256 \* \( 256 \* $2 + $3 \) + $4 \) + $5`
+dl=`expr 256 \* \( 256 \* \( 256 \* $6 + $7 \) + $8 \) + $9`
+# echo "hdr il: $il dl: $dl"
+
+hdrsize=`expr 8 + 16 \* $il + $dl`
+o=`expr $o + $hdrsize`
+EXTRACTOR="dd if=$pkg ibs=$o skip=1"
+
+COMPRESSION=`($EXTRACTOR |file -) 2>/dev/null`
+if echo $COMPRESSION |grep -q gzip; then
+ DECOMPRESSOR=gunzip
+elif echo $COMPRESSION |grep -q bzip2; then
+ DECOMPRESSOR=bunzip2
+elif echo $COMPRESSION |grep -q xz; then
+ DECOMPRESSOR=unxz
+elif echo $COMPRESSION |grep -q cpio; then
+ DECOMPRESSOR=cat
+else
+ # Most versions of file don't support LZMA, therefore we assume
+ # anything not detected is LZMA
+ DECOMPRESSOR=`which unlzma 2>/dev/null`
+ case "$DECOMPRESSOR" in
+ /* ) ;;
+ * ) DECOMPRESSOR=`which lzmash 2>/dev/null`
+ case "$DECOMPRESSOR" in
+ /* ) DECOMPRESSOR="lzmash -d -c" ;;
+ * ) DECOMPRESSOR=cat ;;
+ esac
+ ;;
+ esac
+fi
+
+$EXTRACTOR 2>/dev/null | $DECOMPRESSOR