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