summaryrefslogtreecommitdiff
path: root/build-images
blob: 316fcaf527a497f5c3380420b0647d0e5f4a06a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/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/infrastructure/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 $*