#!/bin/sh
#
# Copyright 2004 Todd Kulesza
#
# The Dropline GNOME Installation System 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 software 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, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA
#

# ${DLG_ROOT} should be the root directory of the Dropline Build System.
# This only needs to be set if you try to run ./build from outside of
# the root directory.
#DLG_ROOT=/usr/src/dlg

if [ -z ${DLG_ROOT} ]; then
	DLG_ROOT="`pwd`"
fi

export DLG_ROOT

. ${DLG_ROOT}/SCRIPTS/dropline-header

if [ -d ${DLG_ISODIR} ]; then
	rm -rf ${DLG_ISODIR} || die
fi

mkdir -p ${DLG_ISODIR}/dropline-gnome || die
mkdir -p ${DLG_ISODIR}/dropline-build-system || die
mkdir -p ${DLG_ISODIR}/dropline-build-system/SOURCES || die
mkdir -p ${DLG_ISODIR}/dropline-build-system/SCRIPTS || die

cp ${DLG_ROOT}/DroplineFiles2c ${DLG_ISODIR}/dropline-gnome/ &&
cp ${DLG_DOCDIR}/README ${DLG_ISODIR}/ &&
cp ${DLG_ROOT}/ChangeLog ${DLG_ISODIR}/dropline-build-system/ &&
cp ${DLG_ROOT}/DroplineFiles2c ${DLG_ISODIR}/dropline-build-system/ &&
cp ${DLG_ROOT}/README ${DLG_ISODIR}/dropline-build-system/ &&
cp ${DLG_ROOT}/build ${DLG_ISODIR}/dropline-build-system/ &&
cp ${DLG_ROOT}/compile-order ${DLG_ISODIR}/dropline-build-system/ &&
cp ${DLG_ROOT}/copy-pkg-to-server ${DLG_ISODIR}/dropline-build-system/ &&
cp ${DLG_ROOT}/copy-src-to-server ${DLG_ISODIR}/dropline-build-system/ &&
cp ${DLG_ROOT}/create-iso-pkg ${DLG_ISODIR}/dropline-build-system/ &&
cp ${DLG_ROOT}/create-iso-src ${DLG_ISODIR}/dropline-build-system/ &&
cp ${DLG_ROOT}/create-iso-full ${DLG_ISODIR}/dropline-build-system/ &&
cp ${DLG_ROOT}/update-filelist ${DLG_ISODIR}/dropline-build-system/ &&
cp ${DLG_SCRIPTDIR}/dropline-build.sh ${DLG_ISODIR}/dropline-build-system/SCRIPTS/ &&
cp ${DLG_SCRIPTDIR}/dropline-files-update.sh ${DLG_ISODIR}/dropline-build-system/SCRIPTS/ &&
cp ${DLG_SCRIPTDIR}/dropline-header ${DLG_ISODIR}/dropline-build-system/SCRIPTS/ || die

file="1"
while [ -n "${file}" ]
do
	read file
	if [ "${file}" == "" ]; then
		break;
	fi
	filename=`echo "${file}" | cut -d ':' -f 1`
	status=`echo "${file}" | cut -d ':' -f 2`
	if [[ "${status}" == "required" || "${status}" == "optional" ]]; then
		echo "copying ${filename}..."
		cp -r ${DLG_PACKAGEDIRROOT}/${filename} ${DLG_ISODIR}/dropline-gnome/ || die
	fi
done < ${DLG_ROOT}/DroplineFiles2c

# copy the source & script files
file="1"
while [ -n "${file}" ]
do
	read file
	if [ "${file}" == "" ]; then
		break;
	fi
	echo "copying ${file}..."
	cp -r ${DLG_SRCDIR}/${file} ${DLG_ISODIR}/dropline-build-system/SOURCES || die
	cp -r ${DLG_SCRIPTDIR}/${file} ${DLG_ISODIR}/dropline-build-system/SCRIPTS || die
done < ${DLG_ROOT}/compile-order

mkisofs -J -r -V "Dropline GNOME ${DLG_VERSION}" -o ~/dlg-full-${DLG_VERSION}.iso ${DLG_ISODIR} || die
