blob: 8f57c8860fe309100f84c87757985cfa2918c6a6 [file] [log] [blame]
Andy Doandf9dfd72012-04-26 13:45:15 -05001#!/bin/sh
Fathi Boudracd8f58d2012-06-15 17:43:39 +03002
Andy Doandf9dfd72012-04-26 13:45:15 -05003# Copyright (C) 2012 Linaro
4#
5# Author: Andy Doan <andy.doan@linaro.org>
6#
7# This file is part of Linaro Daily Prebuilt Images. Its a small wrapper that
8# sets up the environment so that build-images.py can run
9#
10# Linaro Daily Prebuilt Images is free software; you can redistribute it and/or
11# modify it under the terms of the GNU General Public License
12# as published by the Free Software Foundation; either version 2
13# of the License, or (at your option) any later version.
14#
15# Linaro Daily Prebuilt Images is distributed in the hope that it will be useful,
16# but WITHOUT ANY WARRANTY; without even the implied warranty of
17# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18# GNU General Public License for more details.
19#
20# You should have received a copy of the GNU General Public License
21# along with Linaro Image Tools; if not, write to the Free Software
22# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
23# USA.
24
25set -e
26
27OUTDIR="./out"
28
29usage()
30{
31 echo "Usage: please see build_release.py"
32 echo "In addition, this script accepts the ENV variables:"
33 echo " LITREPO - for the linaro image tools repo"
34 echo " LFIREPO - for the linaro fetch image repo"
35 exit 1
36}
37
38while getopts "ho:b:w:t:" optn; do
39 case $optn in
40 o ) OUTDIR=$OPTARG;;
41 esac
42done
43
44PKGS='zsync python-xdg python-parted'
45MISSING=`dpkg-query -W -f='${Status}\n' ${PKGS} 2>&1 | grep 'No packages found matching' | cut -d' ' -f5`
46if [ -n "$MISSING" ] ; then
47 echo "Missing some required packages. Attempting to install:"
48 for m in $MISSING ; do
49 echo "${m%?} "
50 sudo apt-get install -y ${m%?}
51 done
52fi
53
54if [ ! -z $DELETEDIR ] && [ -d ${OUTDIR} ] ; then
55 echo "INFO: Deleting past output directory: ${OUTDIR}"
56 rm -rf ${OUTDIR}
57fi
58
59if [ -d ${OUTDIR} ] && [ -z $REUSE ] ; then
Ricardo Salveti de Araujoc4ec4f22012-05-29 14:07:54 -030060 echo "ERROR: directory [$OUTDIR] already exists. Delete this or run with REUSE=1"
Andy Doandf9dfd72012-04-26 13:45:15 -050061 exit 1
62fi
63
64[ -n "$LITREPO" ] || LITREPO="lp:linaro-image-tools"
65[ -n "$LFIREPO" ] || LFIREPO="lp:linaro-fetch-image"
66
67LITDIR=${OUTDIR}/linaro-image-tools
68LFIDIR=${OUTDIR}/linaro-fetch-image
69if [ ! -d ${OUTDIR} ] ; then
70 mkdir ${OUTDIR}
Ricardo Salveti de Araujo7b476242012-06-27 19:40:43 -030071 echo "INFO: Cloning ${LITREPO} at ${LITDIR}"
Andy Doandf9dfd72012-04-26 13:45:15 -050072 bzr branch ${LITREPO} ${LITDIR}
Ricardo Salveti de Araujo7b476242012-06-27 19:40:43 -030073 echo "INFO: Cloning ${LFIREPO} at ${LFIDIR}"
Andy Doandf9dfd72012-04-26 13:45:15 -050074 bzr branch ${LFIREPO} ${LFIDIR}
75fi
76
77export PYTHONPATH="${LITDIR}:${LFIDIR}"
Ricardo Salveti de Araujo7b476242012-06-27 19:40:43 -030078# force stdout to be unbuffered (sync logs at jenkins)
79export PYTHONUNBUFFERED="1"
Andy Doandf9dfd72012-04-26 13:45:15 -050080SCRIPTDIR=$(dirname $(readlink -f $0))
81${SCRIPTDIR}/build_release.py $*