blob: 316fcaf527a497f5c3380420b0647d0e5f4a06a4 [file] [log] [blame]
Andy Doan15aa23b2012-02-02 16:40:58 -06001#!/bin/sh
Fathi Boudracd8f58d2012-06-15 17:43:39 +03002
Andy Doan15aa23b2012-02-02 16:40:58 -06003# 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{
Andy Doan9c638b12012-04-26 12:23:49 -050031 echo "Usage: please see build_images.py"
Andy Doand198b3e2012-03-15 14:16:39 -050032 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"
Andy Doan15aa23b2012-02-02 16:40:58 -060035 exit 1
36}
37
Ricardo Salveti de Araujo688f24f2012-10-17 02:40:36 -030038while getopts "hro:b:w:d:p:f" optn; do
Andy Doan15aa23b2012-02-02 16:40:58 -060039 case $optn in
40 o ) OUTDIR=$OPTARG;;
41 esac
42done
43
Andy Doana787e572012-03-21 15:19:45 -050044PKGS='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
Andy Doan4202d882012-03-29 21:36:09 -050049 echo "${m%?} "
Andy Doana787e572012-03-21 15:19:45 -050050 sudo apt-get install -y ${m%?}
51 done
52fi
53
Andy Doancee877a2012-02-15 14:02:04 -060054if [ ! -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 Doancee877a2012-02-15 14:02:04 -060061 exit 1
62fi
Andy Doan15aa23b2012-02-02 16:40:58 -060063
Fathi Boudrae4c2e832013-12-15 14:33:14 +020064[ -n "$LITREPO" ] || LITREPO="git://git.linaro.org/infrastructure/linaro-image-tools.git"
Andy Doand198b3e2012-03-15 14:16:39 -050065[ -n "$LFIREPO" ] || LFIREPO="lp:linaro-fetch-image"
66
Andy Doan15aa23b2012-02-02 16:40:58 -060067LITDIR=${OUTDIR}/linaro-image-tools
Andy Doand198b3e2012-03-15 14:16:39 -050068LFIDIR=${OUTDIR}/linaro-fetch-image
Andy Doancee877a2012-02-15 14:02:04 -060069if [ ! -d ${OUTDIR} ] ; then
70 mkdir ${OUTDIR}
Ricardo Salveti de Araujoec085ce2012-06-23 00:12:18 -030071 echo "INFO: Cloning ${LITREPO} at ${LITDIR}"
Fathi Boudrae4c2e832013-12-15 14:33:14 +020072 git clone ${LITREPO} ${LITDIR}
Ricardo Salveti de Araujoec085ce2012-06-23 00:12:18 -030073 echo "INFO: Cloning ${LFIREPO} at ${LFIDIR}"
Andy Doand198b3e2012-03-15 14:16:39 -050074 bzr branch ${LFIREPO} ${LFIDIR}
Andy Doancee877a2012-02-15 14:02:04 -060075fi
Andy Doan15aa23b2012-02-02 16:40:58 -060076
Andy Doand198b3e2012-03-15 14:16:39 -050077export PYTHONPATH="${LITDIR}:${LFIDIR}"
Ricardo Salveti de Araujo0ffec4c2012-06-23 03:07:59 -030078# force stdout to be unbuffered (sync logs at jenkins)
79export PYTHONUNBUFFERED="1"
Andy Doan15aa23b2012-02-02 16:40:58 -060080SCRIPTDIR=$(dirname $(readlink -f $0))
Andy Doan9c638b12012-04-26 12:23:49 -050081${SCRIPTDIR}/build_images.py $*