#!/bin/bash
#
# buildinstall
#
# Copyright (C) 2007 Red Hat, Inc. All rights reserved.
#
# This program 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.
#
# This program 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 this program. If not, see .
#
die() {
[ -n "$TREEDIR" ] && rm -rf $TREEDIR
[ -n "$BUILDINSTDIR" ] && rm -rf $BUILDINSTDIR
[ -n "$yumconf" ] && rm -rf $yumconf
echo "Aborting buildinstall"
echo "$@"
exit 1
}
usage() {
echo "Usage: buildinstall --version --brand --product --release [--output outputdir] [--discs ] " >&2
exit 1
}
CWD="$(pwd)"
PRODUCTPATH="anaconda"
while [ $# -gt 0 ]; do
case $1 in
# general options affecting how we build things
--nogr)
NOGRSTR="--nogr"
shift
;;
--debug)
DEBUGSTR="--debug"
shift
;;
--localscripts)
LOCALSCRIPTS="yes"
shift
;;
# release information
--version)
VERSION=$2
shift; shift
;;
--release)
RELEASESTR=$2
shift; shift
;;
--product)
PRODUCTSTR=$2
shift; shift
;;
--brand)
BRANDSTR=$2
shift; shift
;;
--variant)
VARIANT=$2
shift; shift
;;
--bugurl)
BUGURL=$2
shift; shift
;;
--output)
OUTPUT=$2
shift; shift
;;
--updates)
UPDATES=$2
shift; shift
;;
--mirrorlist)
MIRRORLIST="$MIRRORLIST $2"
shift; shift
;;
--yumconf)
yumconf="$2"
shift; shift
;;
*)
if [ -z "$REPO" ]; then
REPO=$1
else
EXTRA_REPOS="$EXTRA_REPOS $1"
fi
shift
;;
esac
done
if [ -z "$PRODUCTSTR" ]; then
usage
fi
if [ -z "$VERSION" ]; then
usage
fi
if [ -z "$REPO" ]; then
usage
fi
if [ -z "$RELEASESTR" ]; then
usage
fi
if [ -z "$BUGURL" ]; then
BUGURL="your distribution provided bug reporting tool."
fi
if [[ "$REPO" =~ ^/ ]]; then
[ -n "$OUTPUT" ] || OUTPUT=$REPO
REPO="file://$REPO"
fi
if [ -z "$OUTPUT" ]; then
usage
fi
if [ ! -d "$OUTPUT" ]; then
mkdir -p $OUTPUT
fi
# The first -release and -logos package we are going to look for is the lowercase
if [ -z "$BRANDSTR" ]; then
BRANDSTR="`echo $PRODUCTSTR | tr '[:upper:]' '[:lower:]'`"
fi
export brandpkgname="$BRANDSTR"
BUILDINSTDIR=$(mktemp -d ${TMPDIR:-/tmp}/buildinstall.tree.XXXXXX)
TREEDIR=$(mktemp -d ${TMPDIR:-/tmp}/treedir.XXXXXX)
CACHEDIR=$(mktemp -d ${TMPDIR:-/tmp}/yumcache.XXXXXX)
if [ -z "$yumconf" ]; then
yumconf=$(mktemp ${TMPDIR:-/tmp}/yum.conf.XXXXXX)
cat > $yumconf <> $yumconf <> $yumconf <