prepare-build.sh 4.04 KB
Newer Older
1
#!/bin/bash
Florent Revest's avatar
Florent Revest committed
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
# Copyright (C) 2015 Florent Revest <revestflo@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

17 18 19 20 21
function pull_dir {
    if [ -d $1/.git/ ] ; then
        echo -e "\e[32mPulling $1\e[39m"
        [ "$1" != "." ]   && pushd $1 > /dev/null
        git pull --rebase
22
        [ $? -ne 0 ] && echo -e "\e[91mError pulling $1\e[39m"
23 24 25
        [ "$1" != "." ]   && popd > /dev/null
    fi
}
26

27 28 29 30
function clone_dir {
    if [ ! -d $1 ] ; then
        echo -e "\e[32mCloning branch $3 of $2 in $1\e[39m"
        git clone -b $3 $2 $1
31
        [ $? -ne 0 ] &&  echo -e "\e[91mError cloning $1\e[39m"
32 33 34 35 36 37
        if [ $# -eq 4 ]
        then
            pushd $1
            git checkout $4
            popd
        fi
38 39 40 41 42 43 44 45 46 47
    fi
}

# Update layers in src/
if [[ "$1" == "update" ]]; then
    pull_dir .
    for d in src/*/ ; do
        pull_dir $d
    done
    pull_dir src/oe-core/bitbake
48 49 50 51 52 53 54 55 56 57
elif [[ "$1" == "git-"* ]]; then
    base=$(dirname $0)
    gitcmd=${1:4} # drop git-
    shift
    for d in $base $base/src/* $base/src/oe-core/bitbake; do
        if [ $(git -C $d $gitcmd "$@" | wc -c) -ne 0 ]; then
            echo -e "\e[35mgit -C $d $gitcmd $@ \e[39m"
            git -C $d $gitcmd "$@"
        fi
    done
58
# Prepare bitbake
59
else
60 61
    ROOTDIR=`pwd`
    mkdir -p src build/conf tmp sstate-cache downloads uninative
62

63 64 65
    if [ "$#" -gt 0 ]; then
        export MACHINE=${1}
    else
66
        export MACHINE=qemux86
67 68 69
    fi

    # Fetch all the needed layers in src/
70 71 72
    clone_dir src/oe-core              https://github.com/openembedded/openembedded-core.git thud
    clone_dir src/oe-core/bitbake      https://github.com/openembedded/bitbake.git           1.40
    clone_dir src/meta-openembedded    https://github.com/openembedded/meta-openembedded.git thud
73 74
    clone_dir src/meta-qt5             https://code.qt.io/yocto/meta-qt5.git                  5.12
    clone_dir src/meta-nemo            https://source.necunos.com/nemomobile/meta-nemo.git   master
Florent Revest's avatar
Florent Revest committed
75

76
    # Create local.conf and bblayers.conf on first run
77
    if [ ! -e build/conf/local.conf ]; then
78
        echo -e "\e[32mWriting build/conf/local.conf\e[39m"
79 80 81 82 83 84 85 86 87 88 89 90 91
        cat >> $ROOTDIR/build/conf/local.conf << EOF
DISTRO = "nemox86"
PACKAGE_CLASSES = "package_rpm"
PACKAGECONFIG_append_pn_gpgme = " python3"
PATCHRESOLVE = "noop"

TMPDIR = "$ROOTDIR/tmp/"
SSTATE_DIR ?= "$ROOTDIR/sstate-cache"
DL_DIR ?= "$ROOTDIR/downloads"

TARGET_USERNAME = "nemo"

QT_GIT_PROTOCOL = "https"
92 93
#For developing purposes passwordless login:
EXTRA_IMAGE_FEATURES += " debug-tweaks "
94 95

EOF
96
    fi
Florent Revest's avatar
Florent Revest committed
97

98
    if [ ! -e build/conf/bblayers.conf ]; then
99
        echo -e "\e[32mWriting build/conf/bblayers.conf\e[39m"
100 101 102 103 104 105
        echo 'BBPATH = "${TOPDIR}"
SRCDIR = "${@os.path.abspath(os.path.join("${TOPDIR}", "../src/"))}"

BBLAYERS = " \
  ${SRCDIR}/meta-qt5 \
  ${SRCDIR}/oe-core/meta \
106
  ${SRCDIR}/meta-nemo \
107 108 109 110 111 112 113
  ${SRCDIR}/meta-openembedded/meta-oe \
  ${SRCDIR}/meta-openembedded/meta-multimedia \
  ${SRCDIR}/meta-openembedded/meta-gnome \
  ${SRCDIR}/meta-openembedded/meta-networking \
  ${SRCDIR}/meta-openembedded/meta-python \
  ${SRCDIR}/meta-openembedded/meta-filesystems \
  "' > build/conf/bblayers.conf
114
    fi
Florent Revest's avatar
Florent Revest committed
115

116 117
    # Init build env
    cd src/oe-core
118
    . ./oe-init-build-env ../../build > /dev/null
119
    umask 022
Florent Revest's avatar
Florent Revest committed
120

121
    echo "Welcome to the NemoMobile compilation script.
Florent Revest's avatar
Florent Revest committed
122

123 124
If you meet any issue you can report it to the project's git page:
    https://source.necunos.com/NemoMobile
Florent Revest's avatar
Florent Revest committed
125 126

You can now run the following command to get started with the compilation:
127
    bitbake nemox86-image
Florent Revest's avatar
Florent Revest committed
128

129
Have fun!"
130
fi