diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2011-04-20 23:24:51 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2011-04-21 00:29:31 +0100 |
commit | 2c2e61743c8d6620a04aa5cb534af78f51b2845e (patch) | |
tree | 769b7139eb86f49d9d78153c8e673ed8f04d9bde /scripts/runqemu-extract-sdk | |
parent | 0b70e298fbb2cf0a9aa1bab193a66a7edfe99e10 (diff) | |
download | poky-2c2e61743c8d6620a04aa5cb534af78f51b2845e.tar.gz |
Rename the remaining poky-* scripts to oe-* or runqemu-*
(From OE-Core rev: 877b3d84597fcfc3abf5aa332019d412f2717896)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/runqemu-extract-sdk')
-rw-r--r-- | scripts/runqemu-extract-sdk | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/scripts/runqemu-extract-sdk b/scripts/runqemu-extract-sdk new file mode 100644 index 0000000000..ed349dd306 --- /dev/null +++ b/scripts/runqemu-extract-sdk | |||
@@ -0,0 +1,100 @@ | |||
1 | #!/bin/bash | ||
2 | # | ||
3 | # This utility extracts an SDK image tarball using pseudo, and stores | ||
4 | # the pseudo database in var/pseudo within the rootfs. If you want to | ||
5 | # boot QEMU using an nfsroot, you *must* use this script to create the | ||
6 | # rootfs to ensure it is done correctly with pseudo. | ||
7 | # | ||
8 | # Copyright (c) 2010 Intel Corp. | ||
9 | # | ||
10 | # This program is free software; you can redistribute it and/or modify | ||
11 | # it under the terms of the GNU General Public License version 2 as | ||
12 | # published by the Free Software Foundation. | ||
13 | # | ||
14 | # This program is distributed in the hope that it will be useful, | ||
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
17 | # See the GNU General Public License for more details. | ||
18 | # | ||
19 | # You should have received a copy of the GNU General Public License | ||
20 | # along with this program; if not, write to the Free Software | ||
21 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
22 | |||
23 | function usage() { | ||
24 | echo "Usage: $0 <poky-sdk-tarball> <extract-dir>" | ||
25 | } | ||
26 | |||
27 | if [ $# -ne 2 ]; then | ||
28 | usage | ||
29 | exit 1 | ||
30 | fi | ||
31 | |||
32 | SYSROOT_SETUP_SCRIPT=`which oe-find-native-sysroot` | ||
33 | if [ -z "$SYSROOT_SETUP_SCRIPT" ]; then | ||
34 | echo "Error: Unable to find the oe-find-native-sysroot script" | ||
35 | echo "Did you forget to source your Poky environment script?" | ||
36 | exit 1 | ||
37 | fi | ||
38 | . $SYSROOT_SETUP_SCRIPT | ||
39 | PSEUDO_OPTS="-P $OECORE_NATIVE_SYSROOT/usr" | ||
40 | |||
41 | ROOTFS_TARBALL=$1 | ||
42 | SDK_ROOTFS_DIR=$2 | ||
43 | |||
44 | if [ ! -e "$ROOTFS_TARBALL" ]; then | ||
45 | echo "Error: sdk tarball '$ROOTFS_TARBALL' does not exist" | ||
46 | usage | ||
47 | exit 1 | ||
48 | fi | ||
49 | |||
50 | # Convert SDK_ROOTFS_DIR to a full pathname | ||
51 | if [[ ${SDK_ROOTFS_DIR:0:1} != "/" ]]; then | ||
52 | SDK_ROOTFS_DIR=$(pwd)/$SDK_ROOTFS_DIR | ||
53 | fi | ||
54 | |||
55 | TAR_OPTS="" | ||
56 | if [[ "$ROOTFS_TARBALL" =~ tar\.bz2$ ]]; then | ||
57 | TAR_OPTS="-xjf" | ||
58 | fi | ||
59 | if [[ "$ROOTFS_TARBALL" =~ tar\.gz$ ]]; then | ||
60 | TAR_OPTS="-xzf" | ||
61 | fi | ||
62 | if [[ "$ROOTFS_TARBALL" =~ \.tar$ ]]; then | ||
63 | TAR_OPTS="-xf" | ||
64 | fi | ||
65 | if [ -z "$TAR_OPTS" ]; then | ||
66 | echo "Error: Unable to determine sdk tarball format" | ||
67 | echo "Accepted types: .tar / .tar.gz / .tar.bz2" | ||
68 | exit 1 | ||
69 | fi | ||
70 | |||
71 | if [ ! -d "$SDK_ROOTFS_DIR" ]; then | ||
72 | echo "Creating directory $SDK_ROOTFS_DIR" | ||
73 | mkdir -p "$SDK_ROOTFS_DIR" | ||
74 | fi | ||
75 | |||
76 | if [ -e "$SDK_ROOTFS_DIR/var/pseudo" ]; then | ||
77 | echo "Error: $SDK_ROOTFS_DIR/var/pseudo already exists!" | ||
78 | echo "Please delete the entire rootfs tree manually if this is really what you want" | ||
79 | exit 1 | ||
80 | fi | ||
81 | |||
82 | mkdir -p "$SDK_ROOTFS_DIR/var/pseudo" | ||
83 | touch "$SDK_ROOTFS_DIR/var/pseudo/pseudo.pid" | ||
84 | PSEUDO_LOCALSTATEDIR="$SDK_ROOTFS_DIR/var/pseudo" | ||
85 | export PSEUDO_LOCALSTATEDIR | ||
86 | |||
87 | echo "Extracting rootfs tarball using pseudo..." | ||
88 | echo "$PSEUDO $PSEUDO_OPTS tar -C \"$SDK_ROOTFS_DIR\" $TAR_OPTS \"$ROOTFS_TARBALL\"" | ||
89 | $PSEUDO $PSEUDO_OPTS tar -C "$SDK_ROOTFS_DIR" $TAR_OPTS "$ROOTFS_TARBALL" | ||
90 | |||
91 | DIRCHECK=`ls -l "$SDK_ROOTFS_DIR" | wc -l` | ||
92 | if [ "$DIRCHECK" -lt 5 ]; then | ||
93 | echo "Warning: I don't see many files in $SDK_ROOTFS_DIR" | ||
94 | echo "Please double-check the extraction worked as intended" | ||
95 | exit 0 | ||
96 | fi | ||
97 | |||
98 | echo "SDK image successfully extracted to $SDK_ROOTFS_DIR" | ||
99 | |||
100 | exit 0 | ||