summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott Garman <scott.a.garman@intel.com>2010-08-13 10:50:37 -0700
committerRichard Purdie <rpurdie@linux.intel.com>2010-08-20 16:20:10 +0100
commitf35a8d4079777453a2b60b7df5524b217260d252 (patch)
tree50748003fbaaeffaceacd2478f23ef11b4826928
parente4bc3e36e455e7fca48ccc5431c6bb83f531fab6 (diff)
downloadpoky-f35a8d4079777453a2b60b7df5524b217260d252.tar.gz
poky-find-native-sysroot: helper script for locating the native sysroot path
Various poky scripts make use of binaries from the native sysroot. This helper script can be used to reduce code duplication, and sets up some environment variables you can use to identify and obtain the correct filesystem path to the native sysroot. It works for both in-tree Poky setups as well as toolchain installations. Signed-off-by: Scott Garman <scott.a.garman@intel.com>
-rw-r--r--meta/packages/qemu/qemu-helper-nativesdk_1.0.bb1
-rwxr-xr-xscripts/poky-find-native-sysroot77
2 files changed, 78 insertions, 0 deletions
diff --git a/meta/packages/qemu/qemu-helper-nativesdk_1.0.bb b/meta/packages/qemu/qemu-helper-nativesdk_1.0.bb
index a764a0e28a..6b4979d790 100644
--- a/meta/packages/qemu/qemu-helper-nativesdk_1.0.bb
+++ b/meta/packages/qemu/qemu-helper-nativesdk_1.0.bb
@@ -10,6 +10,7 @@ SRC_URI = "file://${POKYBASE}/scripts/poky-qemu \
10 file://${POKYBASE}/scripts/poky-addptable2image \ 10 file://${POKYBASE}/scripts/poky-addptable2image \
11 file://${POKYBASE}/scripts/poky-qemu-ifup \ 11 file://${POKYBASE}/scripts/poky-qemu-ifup \
12 file://${POKYBASE}/scripts/poky-qemu-ifdown \ 12 file://${POKYBASE}/scripts/poky-qemu-ifdown \
13 file://${POKYBASE}/scripts/poky-find-native-sysroot \
13 file://tunctl.c \ 14 file://tunctl.c \
14 file://raw2flash.c \ 15 file://raw2flash.c \
15 " 16 "
diff --git a/scripts/poky-find-native-sysroot b/scripts/poky-find-native-sysroot
new file mode 100755
index 0000000000..fe36a2a932
--- /dev/null
+++ b/scripts/poky-find-native-sysroot
@@ -0,0 +1,77 @@
1#!/bin/bash
2#
3# Find a native sysroot to use - either from an in-tree Poky build or
4# from a toolchain installation in /opt/poky. It then sets the variables
5# $NATIVE_SYSROOT_DIR to the sysroot's base directory, $PSEUDO to the
6# path of the pseudo binary, and $SYSROOT_MODE is set to "in-tree" or
7# "toolchain".
8#
9# This script is intended to be run within other scripts by source'ing
10# it, e.g:
11#
12# SYSROOT_SETUP_SCRIPT=`which poky-find-native-sysroot`
13# . $SYSROOT_SETUP_SCRIPT
14#
15# This script will terminate execution of your calling program unless
16# you set a variable $SKIP_STRICT_SYSROOT_CHECK to a non-empty string
17# beforehand.
18#
19# Copyright (c) 2010 Intel Corp.
20#
21# This program is free software; you can redistribute it and/or modify
22# it under the terms of the GNU General Public License version 2 as
23# published by the Free Software Foundation.
24#
25# This program is distributed in the hope that it will be useful,
26# but WITHOUT ANY WARRANTY; without even the implied warranty of
27# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28# GNU General Public License for more details.
29#
30# You should have received a copy of the GNU General Public License along
31# with this program; if not, write to the Free Software Foundation, Inc.,
32# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
33
34BITBAKE=`which bitbake`
35if [ -z "$BITBAKE" ]; then
36 SYSROOT_MODE="toolchain"
37 NATIVE_SYSROOT_DIR=`find /opt/poky -name "tunctl" | sed 's/\/usr\/bin\/tunctl//'`
38else
39 SYSROOT_MODE="in-tree"
40 if [ "$UID" = "0" ]; then
41 # Root cannot run bitbake unless sanity checking is disabled
42 if [ ! -d "./conf" ]; then
43 echo "Error: root cannot run bitbake by default, and I cannot find a ./conf directory to be able to disable sanity checking"
44 exit 1
45 fi
46 touch conf/sanity.conf
47 NATIVE_SYSROOT_DIR=`bitbake -e | grep ^STAGING_DIR_NATIVE | cut -d '=' -f2 | cut -d '"' -f2`
48 rm -f conf/sanity.conf
49 else
50 NATIVE_SYSROOT_DIR=`bitbake -e | grep ^STAGING_DIR_NATIVE | cut -d '=' -f2 | cut -d '"' -f2`
51 fi
52fi
53
54if [ -z "$NATIVE_SYSROOT_DIR" ]; then
55 echo "Error: Unable to locate your native sysroot."
56 echo "Did you forget to source the Poky environment script?"
57
58 if [ -z "$SKIP_STRICT_SYSROOT_CHECK" ]; then
59 exit 1
60 fi
61fi
62
63# Set up pseudo command
64if [ ! -e "$NATIVE_SYSROOT_DIR/usr/bin/pseudo" ]; then
65 echo "Error: Unable to find pseudo binary in $NATIVE_SYSROOT_DIR/usr/bin/"
66
67 if [ "$SYSROT_MODE" = "in-tree" ]; then
68 echo "Have you run 'bitbake pseudo-native'?"
69 else
70 echo "This shouldn't happen - something is wrong with your toolchain installation"
71 fi
72
73 if [ -z "$SKIP_STRICT_SYSROOT_CHECK" ]; then
74 exit 1
75 fi
76fi
77PSEUDO="$NATIVE_SYSROOT_DIR/usr/bin/pseudo"