summaryrefslogtreecommitdiff
path: root/scripts/bitbake
blob: 587428c589a8c2ca3b43d548b846920525a84b8a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/bin/sh

export BBFETCH2=True
export BB_ENV_EXTRAWHITE="PSEUDO_BUILD PSEUDO_DISABLED $BB_ENV_EXTRAWHITE"

NO_BUILD_OPTS="--version -h --help -p --parse-only -s --show-versions -e --environment -g --graphviz"
needpseudo="1"
for opt in $@; do
for key in $NO_BUILD_OPTS; do
    if [ $opt = $key ]
    then
        needpseudo="0"
        break
    fi
done
[ $needpseudo = "0" ] && break
done

# Make sure we're not using python v3.x. This check can't go into
# sanity.bbclass because bitbake's source code doesn't even pass
# parsing stage when used with python v3, so we catch it here so we
# can offer a meaningful error message.
py_v3_check=`/usr/bin/env python --version 2>&1 | grep "Python 3"`
if [ "$py_v3_check" != "" ]; then
	echo "Bitbake is not compatible with python v3"
	echo "Please set up python v2 as your default python interpreter"
	exit 1
fi

needtar="1"
TARVERSION=`tar --version | head -n 1 | cut -d ' ' -f 4`
float_test() {
     echo | awk 'END { exit ( !( '"$1"')); }'
}

# Tar version 1.24 and onwards handle symlinks in sstate packages correctly
# but earlier versions do not
float_test "$TARVERSION > 1.23" && needtar="0"

buildpseudo="1"
if [ $needpseudo = "1" ] && [ -e "$BUILDDIR/pseudodone" ]; then
    PSEUDOBINDIR=`cat $BUILDDIR/pseudodone`
    if [ -e "$PSEUDOBINDIR/pseudo" -a -e "$PSEUDOBINDIR/tar" -a "$needtar" = "1" ]; then
        buildpseudo="0"
    fi
    if [ -e "$PSEUDOBINDIR/pseudo" -a $needtar = "0" ]; then
        buildpseudo="0"
    fi
fi
if [ $needpseudo = "0" ]; then
    buildpseudo="0"
fi

OLDPATH=$PATH
export PATH=`echo $PATH | sed s#[^:]*/scripts:##`
if [ $buildpseudo = "1" ]; then
    echo "Pseudo is not present but is required, building this first before the main build"
    export PSEUDO_BUILD=1
    TARTARGET="tar-replacement-native"
    if [ $needtar = "0" ]; then
        TARTARGET=""
    fi
    bitbake pseudo-native $TARTARGET -c populate_sysroot
    ret=$?
    if [ "$ret" != "0" ]; then
        exit 1
    fi
    PSEUDOBINDIR=`bitbake -e | grep STAGING_BINDIR_NATIVE=\" | cut -d '=' -f2 | cut -d '"' -f2`
    ret=$?
    if [ "$ret" != "0" ]; then
        exit 1
    fi
    echo $PSEUDOBINDIR > $BUILDDIR/pseudodone
    # This needs to exist in case pseudo has to log somewhere
    mkdir -p $PSEUDOBINDIR/../../var/pseudo
fi
BITBAKE=`which bitbake`
export PATH=$OLDPATH
if [ $needpseudo = "1" ]; then
    export PSEUDO_BUILD=2
    PSEUDOBINDIR=`cat $BUILDDIR/pseudodone`
    PSEUDO_BINDIR=$PSEUDOBINDIR PSEUDO_LIBDIR=$PSEUDOBINDIR/../lib/pseudo/lib PSEUDO_PREFIX=$PSEUDOBINDIR/../../ PSEUDO_DISABLED=1 $PSEUDOBINDIR/pseudo $BITBAKE $@
else
    export PSEUDO_BUILD=0
    $BITBAKE $@
fi
ret=$?
exit $ret