diff options
author | Scott Garman <scott.a.garman@intel.com> | 2010-08-13 11:12:33 -0700 |
---|---|---|
committer | Richard Purdie <rpurdie@linux.intel.com> | 2010-08-20 16:20:11 +0100 |
commit | c23da3d37e4d59322830ebee8a0f5ab919a9843b (patch) | |
tree | 4b1d6cc2305118175fdd7aaa5c70c7695d5d7e73 /scripts | |
parent | f203df83a5627eae8c66ace8533d2212a6b9cff0 (diff) | |
download | poky-c23da3d37e4d59322830ebee8a0f5ab919a9843b.tar.gz |
poky-extract-sdk: script for extracting sdk images using pseudo
This script automates the creation of a rootfs area using pseudo so
it can be used by a QEMU nfsroot boot.
Signed-off-by: Scott Garman <scott.a.garman@intel.com>
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/poky-extract-sdk | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/scripts/poky-extract-sdk b/scripts/poky-extract-sdk new file mode 100755 index 0000000000..70bc44b79b --- /dev/null +++ b/scripts/poky-extract-sdk | |||
@@ -0,0 +1,95 @@ | |||
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 poky-find-native-sysroot` | ||
33 | if [ -z "$SYSROOT_SETUP_SCRIPT" ]; then | ||
34 | echo "Error: Unable to find the poky-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 $NATIVE_SYSROOT_DIR/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 | TAR_OPTS="" | ||
51 | if [[ "$ROOTFS_TARBALL" =~ tar\.bz2$ ]]; then | ||
52 | TAR_OPTS="-xjf" | ||
53 | fi | ||
54 | if [[ "$ROOTFS_TARBALL" =~ tar\.gz$ ]]; then | ||
55 | TAR_OPTS="-xzf" | ||
56 | fi | ||
57 | if [[ "$ROOTFS_TARBALL" =~ \.tar$ ]]; then | ||
58 | TAR_OPTS="-xf" | ||
59 | fi | ||
60 | if [ -z "$TAR_OPTS" ]; then | ||
61 | echo "Error: Unable to determine sdk tarball format" | ||
62 | echo "Accepted types: .tar / .tar.gz / .tar.bz2" | ||
63 | exit 1 | ||
64 | fi | ||
65 | |||
66 | if [ ! -d "$SDK_ROOTFS_DIR" ]; then | ||
67 | echo "Creating directory $SDK_ROOTFS_DIR" | ||
68 | mkdir -p "$SDK_ROOTFS_DIR" | ||
69 | fi | ||
70 | |||
71 | if [ -e "$SDK_ROOTFS_DIR/var/pseudo" ]; then | ||
72 | echo "Error: $SDK_ROOTFS_DIR/var/pseudo already exists!" | ||
73 | echo "Please delete the entire rootfs tree manually if this is really what you want" | ||
74 | exit 1 | ||
75 | fi | ||
76 | |||
77 | mkdir -p "$SDK_ROOTFS_DIR/var/pseudo" | ||
78 | touch "$SDK_ROOTFS_DIR/var/pseudo/pseudo.pid" | ||
79 | PSEUDO_LOCALSTATEDIR="$SDK_ROOTFS_DIR/var/pseudo" | ||
80 | export PSEUDO_LOCALSTATEDIR | ||
81 | |||
82 | echo "Extracting rootfs tarball using pseudo..." | ||
83 | echo "$PSEUDO $PSEUDO_OPTS tar -C \"$SDK_ROOTFS_DIR\" $TAR_OPTS \"$ROOTFS_TARBALL\"" | ||
84 | $PSEUDO $PSEUDO_OPTS tar -C "$SDK_ROOTFS_DIR" $TAR_OPTS "$ROOTFS_TARBALL" | ||
85 | |||
86 | DIRCHECK=`ls -l "$SDK_ROOTFS_DIR" | wc -l` | ||
87 | if [ "$DIRCHECK" -lt 5 ]; then | ||
88 | echo "Warning: I don't see many files in $SDK_ROOTFS_DIR" | ||
89 | echo "Please double-check the extraction worked as intended" | ||
90 | exit 0 | ||
91 | fi | ||
92 | |||
93 | echo "SDK image successfully extracted to $SDK_ROOTFS_DIR" | ||
94 | |||
95 | exit 0 | ||