From c6c57bf35d79a111ffb60cc4912b93c06c1a1afe Mon Sep 17 00:00:00 2001 From: Samuli Piippo <samuli.piippo@digia.com> Date: Wed, 24 Sep 2014 18:18:06 +0300 Subject: [PATCH] New initialization scripts These initialization script will create a build environment which has only the needed meta layers from upstream. Other repos are ignored and not even downloaded. Google's repo tool is used to fetch upstream repos and it can then be used to manage the repos while developing. This has also support for using local mirror repos. The required repos are defined in the manifest.xml file, which can be overwritten using a machine specific manifest_<device>.xml file. Task-number: QTEE-760 Change-Id: I12ed9a6fddceb4de1217baaebf46277c6ef7224f Reviewed-by: Eirik Aavitsland <eirik.aavitsland@digia.com> --- b2qt-init-build-env | 181 +++++++++++++++++++++++------------ conf/bblayers.conf.sample | 24 ++--- scripts/manifest.xml | 53 ++++++++++ scripts/setup_environment.sh | 98 +++++++++++++++++++ 4 files changed, 281 insertions(+), 75 deletions(-) create mode 100644 scripts/manifest.xml create mode 100755 scripts/setup_environment.sh diff --git a/b2qt-init-build-env b/b2qt-init-build-env index f1ad0bb1..03c64395 100755 --- a/b2qt-init-build-env +++ b/b2qt-init-build-env @@ -24,92 +24,147 @@ set -e usage() { - echo "Usage: $0 <yocto build directory> [--force] [--reference <other build directory>]" + echo "Usage: $(basename $0) COMMAND [ARGS]" + echo + echo "Initialize build environment:" + echo " $(basename $0) init --device <name> [--reference <mirror path>]" + echo "Initialize local mirror:" + echo " $(basename $0) mirror" + echo "List available devices:" + echo " $(basename $0) list-devices" } while test -n "$1"; do case "$1" in - "--help" | "-h") + "help" | "--help" | "-h") usage exit 0 ;; - "--force" | "-f") - FORCE_UPDATE=1 - ;; "--reference" | "-r") shift - REFDIR=$1 + REFERENCE=$1 + ;; + "--device" | "-d") + shift + DEVICE=$1 ;; *) - BUILDDIR=$1 + if [ -n "$COMMAND" ]; then + echo "Unknown argument: $1" + usage + exit 1 + fi + COMMAND=$1 ;; esac shift done -if [ -z "${BUILDDIR}" ]; then +if [ -z "${COMMAND}" ]; then usage exit 1 fi DIR=$(readlink -f $(dirname $0)) -BUILDDIR=$(readlink -f $BUILDDIR) -if [ -n "${REFDIR}" ]; then - REFDIR=$(readlink -f ${REFDIR}) +if [ -n "${REFERENCE}" ]; then + REFERENCE="--reference $(readlink -f ${REFERENCE})" fi -checkout() { - REPO=$1 - REPODIR=${REPO##*/} - if [ ${REPODIR} != "poky" ]; then - REPODIR="poky/${REPODIR}" - fi - REF=${2%%:*} - SHA1=${2##*:} - mkdir -p ${BUILDDIR}/${REPODIR} - cd ${BUILDDIR}/${REPODIR} - if [ ! -d ${BUILDDIR}/${REPODIR}/.git ]; then - echo "Checking out ${REPODIR}" - git init - if [ -n "${REFDIR}" ]; then - REPOREFDIR=${REFDIR}/${REPODIR}/.git/objects - if [ -d ${REPOREFDIR} ]; then - echo ${REPOREFDIR} > .git/objects/info/alternates - fi - fi - git remote add origin ${REPO} -f - git checkout ${REF} - git reset --hard ${SHA1} - elif [ -n "${FORCE_UPDATE}" ]; then - echo "Updating ${REPODIR}" - git fetch origin - git reset --hard ${SHA1} - fi +get_repo() { + REPO="./repo" + if [ -n "$(command -v repo)" ]; then + REPO="repo" + elif [ ! -x "./repo" ]; then + curl -s https://storage.googleapis.com/git-repo-downloads/repo > "./repo" + chmod +x ./repo + fi } -checkout git://git.yoctoproject.org/poky "daisy:b2f045c400fa8bd20b319c60137b1575f967cef1" -checkout git://git.yoctoproject.org/meta-fsl-arm "daisy:e9bf647e10ff1e31f911d3236dbb22a1ad7ace9f" -checkout git://github.com/Freescale/meta-fsl-arm-extra "daisy:e041d9a118c5eecf4010bcb41bb5c554636090ab" -checkout git://github.com/beagleboard/meta-beagleboard "master:b5c709b2b6bd3bf236df923fa8f245a00fbb1b60" -checkout git://git.yoctoproject.org/meta-ti "daisy:41457c50e21168faf04f3cdd4168954890d6cdab" -checkout git://git.yoctoproject.org/meta-raspberrypi "daisy:946b69299737cc2f1378c864f1b9075280db1b53" -checkout git://git.toradex.com/meta-toradex "V2.2:b47dad6cf9bd5be5287dac3835ea037a2fd30cf7" -checkout git://git.openembedded.org/meta-openembedded "daisy:662cf409c1175450699d498085f3c894e0fe81d0" - -if [ ! -d ${BUILDDIR}/poky/meta-b2qt ]; then - ln -s ${DIR} ${BUILDDIR}/poky/meta-b2qt -fi +get_groups() { + case ${DEVICE} in + apalis-imx6) + GROUPS="toradex" + ;; + imx53qsb|imx6qsabresd|nitrogen6x) + GROUPS="fsl" + ;; + beagleboard|am335x-evm) + GROUPS="ti" + ;; + beaglebone) + GROUPS="bbb" + ;; + raspberrypi) + GROUPS="rpi" + ;; + emulator) + GROUPS="emulator" + ;; + *) + echo "Unknown device configuration, no matching repo group defined" + exit 1 + ;; + esac + + GROUPS="${GROUPS} default" +} + +list_devices() { + echo "Available device configurations:" + for device in $(ls $DIR/conf/distro/include/*.conf); do + echo " $(basename ${device%%.*})" + done +} + +mirror() { + mkdir -p .repo/manifests + cp ${DIR}/scripts/manifest.xml .repo/manifests/ + MANIFEST="manifest.xml" + ${REPO} init -u https://gerrit.googlesource.com/git-repo -m ${MANIFEST} -g all --mirror + ${REPO} sync +} -echo -echo "Yocto build system is ready" -echo "next initialize the build env for your target machine, for example:" -echo -echo "cd ${BUILDDIR}" -echo "export TEMPLATECONF=meta-b2qt/conf" -echo "export MACHINE=raspberrypi" -echo ". ./poky/oe-init-build-env build-raspberrypi" -echo -echo "and build B2Qt image with:" -echo -echo "bitbake b2qt-embedded-image" -echo +init() { + if [ -z "${DEVICE}" ]; then + echo "device not defined" + usage + exit 1 + fi + + get_groups + mkdir -p .repo/manifests + cp ${DIR}/scripts/manifest*.xml .repo/manifests + if [ -f .repo/manifests/manifest_${DEVICE}.xml ]; then + MANIFEST="manifest_${DEVICE}.xml" + else + MANIFEST="manifest.xml" + fi + ${REPO} init -u https://gerrit.googlesource.com/git-repo -m ${MANIFEST} -g "${GROUPS}" ${REFERENCE} + ${REPO} sync + + if [ ! -e "sources/meta-b2qt" ]; then + ln -s ${DIR} sources/meta-b2qt + fi + + cp ${DIR}/scripts/setup_environment.sh . + +} + +get_repo + +case "$COMMAND" in + "init") + init + ;; + "mirror") + mirror + ;; + "list-devices") + list_devices + ;; + *) + echo "Unknown command" + usage + exit 1 + ;; +esac diff --git a/conf/bblayers.conf.sample b/conf/bblayers.conf.sample index 46e69d86..36362973 100644 --- a/conf/bblayers.conf.sample +++ b/conf/bblayers.conf.sample @@ -30,18 +30,18 @@ BBFILES ?= "" BBLAYERS ?= " \ ##COREBASE##/meta \ ##COREBASE##/meta-yocto \ - ##COREBASE##/meta-fsl-arm \ - ##COREBASE##/meta-fsl-arm-extra \ - ##COREBASE##/meta-beagleboard/common-bsp \ - ##COREBASE##/meta-ti \ - ##COREBASE##/meta-raspberrypi \ - ##COREBASE##/meta-toradex \ - ##COREBASE##/meta-openembedded/meta-oe \ - ##COREBASE##/meta-b2qt \ - ##COREBASE##/meta-b2qt/meta-ti-extras \ - ##COREBASE##/meta-b2qt/meta-fsl-extras \ - ##COREBASE##/meta-b2qt/meta-beagleboard-extras \ - ##COREBASE##/meta-b2qt/meta-toradex-extras \ + ##COREBASE##/../meta-fsl-arm \ + ##COREBASE##/../meta-fsl-arm-extra \ + ##COREBASE##/../meta-beagleboard/common-bsp \ + ##COREBASE##/../meta-ti \ + ##COREBASE##/../meta-raspberrypi \ + ##COREBASE##/../meta-toradex \ + ##COREBASE##/../meta-openembedded/meta-oe \ + ##COREBASE##/../meta-b2qt \ + ##COREBASE##/../meta-b2qt/meta-ti-extras \ + ##COREBASE##/../meta-b2qt/meta-fsl-extras \ + ##COREBASE##/../meta-b2qt/meta-beagleboard-extras \ + ##COREBASE##/../meta-b2qt/meta-toradex-extras \ " BBLAYERS_NON_REMOVABLE ?= " \ ##COREBASE##/meta \ diff --git a/scripts/manifest.xml b/scripts/manifest.xml new file mode 100644 index 00000000..8f931168 --- /dev/null +++ b/scripts/manifest.xml @@ -0,0 +1,53 @@ +<?xml version="1.0" encoding="UTF-8"?> +<manifest> + + <default sync-j="4" revision="daisy"/> + + <remote fetch="git://git.yoctoproject.org" name="yocto"/> + <remote fetch="git://git.openembedded.org" name="oe"/> + <remote fetch="git://github.com/Freescale" name="freescale"/> + <remote fetch="git://github.com/beagleboard" name="beagleboard"/> + <remote fetch="git://git.toradex.com" name="toradex"/> + + <project name="poky" + remote="yocto" + revision="b2f045c400fa8bd20b319c60137b1575f967cef1" + path="sources/poky"/> + <project name="meta-openembedded" + remote="oe" + revision="662cf409c1175450699d498085f3c894e0fe81d0" + path="sources/meta-openembedded"/> + + <project name="meta-fsl-arm" + remote="yocto" + revision="e9bf647e10ff1e31f911d3236dbb22a1ad7ace9f" + path="sources/meta-fsl-arm" + groups="notdefault,fsl,toradex"/> + <project name="meta-ti" + remote="yocto" + revision="41457c50e21168faf04f3cdd4168954890d6cdab" + path="sources/meta-ti" + groups="notdefault,ti,bbb"/> + <project name="meta-raspberrypi" + remote="yocto" + revision="946b69299737cc2f1378c864f1b9075280db1b53" + path="sources/meta-raspberrypi" + groups="notdefault,rpi"/> + <project name="meta-fsl-arm-extra" + remote="freescale" + revision="e041d9a118c5eecf4010bcb41bb5c554636090ab" + path="sources/meta-fsl-arm-extra" + groups="notdefault,fsl,toradex"/> + <project name="meta-beagleboard" + remote="beagleboard" + revision="b5c709b2b6bd3bf236df923fa8f245a00fbb1b60" + path="sources/meta-beagleboard" + groups="notdefault,bbb"/> + <project name="meta-toradex" + remote="toradex" + revision="b47dad6cf9bd5be5287dac3835ea037a2fd30cf7" + path="sources/meta-toradex" + groups="notdefault,toradex"/> + +</manifest> + diff --git a/scripts/setup_environment.sh b/scripts/setup_environment.sh new file mode 100755 index 00000000..63f59cf2 --- /dev/null +++ b/scripts/setup_environment.sh @@ -0,0 +1,98 @@ +#!/bin/sh +############################################################################# +## +## Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +## +## This file is part of the Qt Enterprise Embedded Scripts of the Qt +## framework. +## +## $QT_BEGIN_LICENSE$ +## Commercial License Usage Only +## Licensees holding valid commercial Qt license agreements with Digia +## with an appropriate addendum covering the Qt Enterprise Embedded Scripts, +## may use this file in accordance with the terms contained in said license +## agreement. +## +## For further information use the contact form at +## http://qt.digia.com/contact-us. +## +## +## $QT_END_LICENSE$ +## +############################################################################# + +usage() { + echo "source setup-environment <build-dir>" +} + +clean() { + unset BUILDDIR + unset NEWBUILD + unset TEMPLATECONF +} + +CWD=`pwd` + +while test -n "$1"; do + case "$1" in + "--help" | "-h") + usage + return 0 + ;; + *) + BUILDDIR=$1 + ;; + esac + shift +done + +if [ -z "${BUILDDIR}" ]; then + usage + return 1 +fi + +if [ -z "$MACHINE" ]; then + echo "MACHINE environment variable not defined" + clean + return 1 +fi + +if [ ! -d ${CWD}/${BUILDDIR} ]; then + NEWBUILD=1 +fi + +export TEMPLATECONF=${CWD}/sources/meta-b2qt/conf +cd sources/poky +. ./oe-init-build-env ${CWD}/${BUILDDIR} + +if [ -n "${NEWBUILD}" ]; then + case ${MACHINE} in + apalis-imx6) + LAYERS="meta-raspberrypi meta-beagleboard meta-ti" + ;; + imx53qsb|imx6qsabresd|nitrogen6x) + LAYERS="meta-raspberrypi meta-beagleboard meta-toradex meta-ti" + ;; + beagleboard|am335x-evm) + LAYERS="meta-raspberrypi meta-beagleboard meta-toradex meta-fsl" + ;; + beaglebone) + LAYERS="meta-raspberrypi meta-toradex meta-fsl" + ;; + raspberrypi) + LAYERS="meta-beagleboard meta-toradex meta-ti meta-fsl" + ;; + emulator) + LAYERS="meta-raspberrypi meta-beagleboard meta-toradex meta-ti meta-fsl" + ;; + *) + echo "Unknown MACHINE, bblayer.conf might need manual editing" + ;; + esac + + for layer in ${LAYERS}; do + sed -i -e "/${layer}/d" conf/bblayers.conf + done +fi + +clean -- GitLab