Andy Doan | 15aa23b | 2012-02-02 16:40:58 -0600 | [diff] [blame] | 1 | #!/bin/sh |
Fathi Boudra | cd8f58d | 2012-06-15 17:43:39 +0300 | [diff] [blame] | 2 | |
Andy Doan | 15aa23b | 2012-02-02 16:40:58 -0600 | [diff] [blame] | 3 | # 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 | |
| 25 | set -e |
| 26 | |
| 27 | OUTDIR="./out" |
| 28 | |
| 29 | usage() |
| 30 | { |
Andy Doan | 9c638b1 | 2012-04-26 12:23:49 -0500 | [diff] [blame] | 31 | echo "Usage: please see build_images.py" |
Andy Doan | d198b3e | 2012-03-15 14:16:39 -0500 | [diff] [blame] | 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" |
Andy Doan | 15aa23b | 2012-02-02 16:40:58 -0600 | [diff] [blame] | 35 | exit 1 |
| 36 | } |
| 37 | |
Ricardo Salveti de Araujo | 688f24f | 2012-10-17 02:40:36 -0300 | [diff] [blame] | 38 | while getopts "hro:b:w:d:p:f" optn; do |
Andy Doan | 15aa23b | 2012-02-02 16:40:58 -0600 | [diff] [blame] | 39 | case $optn in |
| 40 | o ) OUTDIR=$OPTARG;; |
| 41 | esac |
| 42 | done |
| 43 | |
Andy Doan | a787e57 | 2012-03-21 15:19:45 -0500 | [diff] [blame] | 44 | PKGS='zsync python-xdg python-parted' |
| 45 | MISSING=`dpkg-query -W -f='${Status}\n' ${PKGS} 2>&1 | grep 'No packages found matching' | cut -d' ' -f5` |
| 46 | if [ -n "$MISSING" ] ; then |
| 47 | echo "Missing some required packages. Attempting to install:" |
| 48 | for m in $MISSING ; do |
Andy Doan | 4202d88 | 2012-03-29 21:36:09 -0500 | [diff] [blame] | 49 | echo "${m%?} " |
Andy Doan | a787e57 | 2012-03-21 15:19:45 -0500 | [diff] [blame] | 50 | sudo apt-get install -y ${m%?} |
| 51 | done |
| 52 | fi |
| 53 | |
Andy Doan | cee877a | 2012-02-15 14:02:04 -0600 | [diff] [blame] | 54 | if [ ! -z $DELETEDIR ] && [ -d ${OUTDIR} ] ; then |
| 55 | echo "INFO: Deleting past output directory: ${OUTDIR}" |
| 56 | rm -rf ${OUTDIR} |
| 57 | fi |
| 58 | |
| 59 | if [ -d ${OUTDIR} ] && [ -z $REUSE ] ; then |
Ricardo Salveti de Araujo | c4ec4f2 | 2012-05-29 14:07:54 -0300 | [diff] [blame] | 60 | echo "ERROR: directory [$OUTDIR] already exists. Delete this or run with REUSE=1" |
Andy Doan | cee877a | 2012-02-15 14:02:04 -0600 | [diff] [blame] | 61 | exit 1 |
| 62 | fi |
Andy Doan | 15aa23b | 2012-02-02 16:40:58 -0600 | [diff] [blame] | 63 | |
Fathi Boudra | 2a45148 | 2014-08-08 20:36:50 +0300 | [diff] [blame^] | 64 | [ -n "$LITREPO" ] || LITREPO="git://git.linaro.org/ci/linaro-image-tools.git" |
Andy Doan | d198b3e | 2012-03-15 14:16:39 -0500 | [diff] [blame] | 65 | [ -n "$LFIREPO" ] || LFIREPO="lp:linaro-fetch-image" |
| 66 | |
Andy Doan | 15aa23b | 2012-02-02 16:40:58 -0600 | [diff] [blame] | 67 | LITDIR=${OUTDIR}/linaro-image-tools |
Andy Doan | d198b3e | 2012-03-15 14:16:39 -0500 | [diff] [blame] | 68 | LFIDIR=${OUTDIR}/linaro-fetch-image |
Andy Doan | cee877a | 2012-02-15 14:02:04 -0600 | [diff] [blame] | 69 | if [ ! -d ${OUTDIR} ] ; then |
| 70 | mkdir ${OUTDIR} |
Ricardo Salveti de Araujo | ec085ce | 2012-06-23 00:12:18 -0300 | [diff] [blame] | 71 | echo "INFO: Cloning ${LITREPO} at ${LITDIR}" |
Fathi Boudra | e4c2e83 | 2013-12-15 14:33:14 +0200 | [diff] [blame] | 72 | git clone ${LITREPO} ${LITDIR} |
Ricardo Salveti de Araujo | ec085ce | 2012-06-23 00:12:18 -0300 | [diff] [blame] | 73 | echo "INFO: Cloning ${LFIREPO} at ${LFIDIR}" |
Andy Doan | d198b3e | 2012-03-15 14:16:39 -0500 | [diff] [blame] | 74 | bzr branch ${LFIREPO} ${LFIDIR} |
Andy Doan | cee877a | 2012-02-15 14:02:04 -0600 | [diff] [blame] | 75 | fi |
Andy Doan | 15aa23b | 2012-02-02 16:40:58 -0600 | [diff] [blame] | 76 | |
Andy Doan | d198b3e | 2012-03-15 14:16:39 -0500 | [diff] [blame] | 77 | export PYTHONPATH="${LITDIR}:${LFIDIR}" |
Ricardo Salveti de Araujo | 0ffec4c | 2012-06-23 03:07:59 -0300 | [diff] [blame] | 78 | # force stdout to be unbuffered (sync logs at jenkins) |
| 79 | export PYTHONUNBUFFERED="1" |
Andy Doan | 15aa23b | 2012-02-02 16:40:58 -0600 | [diff] [blame] | 80 | SCRIPTDIR=$(dirname $(readlink -f $0)) |
Andy Doan | 9c638b1 | 2012-04-26 12:23:49 -0500 | [diff] [blame] | 81 | ${SCRIPTDIR}/build_images.py $* |