Andy Doan | df9dfd7 | 2012-04-26 13:45:15 -0500 | [diff] [blame] | 1 | #!/bin/sh |
Fathi Boudra | cd8f58d | 2012-06-15 17:43:39 +0300 | [diff] [blame] | 2 | |
Andy Doan | df9dfd7 | 2012-04-26 13:45:15 -0500 | [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 | { |
| 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 | |
| 38 | while getopts "ho:b:w:t:" optn; do |
| 39 | case $optn in |
| 40 | o ) OUTDIR=$OPTARG;; |
| 41 | esac |
| 42 | done |
| 43 | |
| 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 |
| 49 | echo "${m%?} " |
| 50 | sudo apt-get install -y ${m%?} |
| 51 | done |
| 52 | fi |
| 53 | |
| 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 | df9dfd7 | 2012-04-26 13:45:15 -0500 | [diff] [blame] | 61 | exit 1 |
| 62 | fi |
| 63 | |
| 64 | [ -n "$LITREPO" ] || LITREPO="lp:linaro-image-tools" |
| 65 | [ -n "$LFIREPO" ] || LFIREPO="lp:linaro-fetch-image" |
| 66 | |
| 67 | LITDIR=${OUTDIR}/linaro-image-tools |
| 68 | LFIDIR=${OUTDIR}/linaro-fetch-image |
| 69 | if [ ! -d ${OUTDIR} ] ; then |
| 70 | mkdir ${OUTDIR} |
Ricardo Salveti de Araujo | 7b47624 | 2012-06-27 19:40:43 -0300 | [diff] [blame] | 71 | echo "INFO: Cloning ${LITREPO} at ${LITDIR}" |
Andy Doan | df9dfd7 | 2012-04-26 13:45:15 -0500 | [diff] [blame] | 72 | bzr branch ${LITREPO} ${LITDIR} |
Ricardo Salveti de Araujo | 7b47624 | 2012-06-27 19:40:43 -0300 | [diff] [blame] | 73 | echo "INFO: Cloning ${LFIREPO} at ${LFIDIR}" |
Andy Doan | df9dfd7 | 2012-04-26 13:45:15 -0500 | [diff] [blame] | 74 | bzr branch ${LFIREPO} ${LFIDIR} |
| 75 | fi |
| 76 | |
| 77 | export PYTHONPATH="${LITDIR}:${LFIDIR}" |
Ricardo Salveti de Araujo | 7b47624 | 2012-06-27 19:40:43 -0300 | [diff] [blame] | 78 | # force stdout to be unbuffered (sync logs at jenkins) |
| 79 | export PYTHONUNBUFFERED="1" |
Andy Doan | df9dfd7 | 2012-04-26 13:45:15 -0500 | [diff] [blame] | 80 | SCRIPTDIR=$(dirname $(readlink -f $0)) |
| 81 | ${SCRIPTDIR}/build_release.py $* |