| #!/bin/sh |
| |
| # Copyright (C) 2012 Linaro |
| # |
| # Author: Andy Doan <andy.doan@linaro.org> |
| # |
| # This file is part of Linaro Daily Prebuilt Images. Its a small wrapper that |
| # sets up the environment so that build-images.py can run |
| # |
| # Linaro Daily Prebuilt Images is free software; you can redistribute it and/or |
| # modify it under the terms of the GNU General Public License |
| # as published by the Free Software Foundation; either version 2 |
| # of the License, or (at your option) any later version. |
| # |
| # Linaro Daily Prebuilt Images 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 Linaro Image Tools; if not, write to the Free Software |
| # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, |
| # USA. |
| |
| set -e |
| |
| OUTDIR="./out" |
| |
| usage() |
| { |
| echo "Usage: please see build_images.py" |
| echo "In addition, this script accepts the ENV variables:" |
| echo " LITREPO - for the linaro image tools repo" |
| echo " LFIREPO - for the linaro fetch image repo" |
| exit 1 |
| } |
| |
| while getopts "hro:b:w:d:p:f" optn; do |
| case $optn in |
| o ) OUTDIR=$OPTARG;; |
| esac |
| done |
| |
| PKGS='zsync python-xdg python-parted' |
| MISSING=`dpkg-query -W -f='${Status}\n' ${PKGS} 2>&1 | grep 'No packages found matching' | cut -d' ' -f5` |
| if [ -n "$MISSING" ] ; then |
| echo "Missing some required packages. Attempting to install:" |
| for m in $MISSING ; do |
| echo "${m%?} " |
| sudo apt-get install -y ${m%?} |
| done |
| fi |
| |
| if [ ! -z $DELETEDIR ] && [ -d ${OUTDIR} ] ; then |
| echo "INFO: Deleting past output directory: ${OUTDIR}" |
| rm -rf ${OUTDIR} |
| fi |
| |
| if [ -d ${OUTDIR} ] && [ -z $REUSE ] ; then |
| echo "ERROR: directory [$OUTDIR] already exists. Delete this or run with REUSE=1" |
| exit 1 |
| fi |
| |
| [ -n "$LITREPO" ] || LITREPO="git://git.linaro.org/ci/linaro-image-tools.git" |
| [ -n "$LFIREPO" ] || LFIREPO="lp:linaro-fetch-image" |
| |
| LITDIR=${OUTDIR}/linaro-image-tools |
| LFIDIR=${OUTDIR}/linaro-fetch-image |
| if [ ! -d ${OUTDIR} ] ; then |
| mkdir ${OUTDIR} |
| echo "INFO: Cloning ${LITREPO} at ${LITDIR}" |
| git clone ${LITREPO} ${LITDIR} |
| echo "INFO: Cloning ${LFIREPO} at ${LFIDIR}" |
| bzr branch ${LFIREPO} ${LFIDIR} |
| fi |
| |
| export PYTHONPATH="${LITDIR}:${LFIDIR}" |
| # force stdout to be unbuffered (sync logs at jenkins) |
| export PYTHONUNBUFFERED="1" |
| SCRIPTDIR=$(dirname $(readlink -f $0)) |
| ${SCRIPTDIR}/build_images.py $* |