# --- ROCK-COPYRIGHT-NOTE-BEGIN ---
# 
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
# Please add additional copyright information _after_ the line containing
# the ROCK-COPYRIGHT-NOTE-END tag. Otherwise it might get removed by
# the ./scripts/Create-CopyPatch script. Do not edit this copyright text!
# 
# ROCK Linux: rock-src/package/mnemoc/vquota/parse-config
# ROCK Linux is Copyright (C) 1998 - 2003 Clifford Wolf
# 
# 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. A copy of the GNU General Public
# License can be found at Documentation/COPYING.
# 
# Many people helped and are helping developing ROCK Linux. Please
# have a look at http://www.rocklinux.org/ and the Documentation/TEAM
# file for details.
# 
# --- ROCK-COPYRIGHT-NOTE-END ---

if grep -q "^X .* vquota " $base/config/$config/packages ; then
	if [ ${pkg:0:7} == linux24 -o $pkg == vserver -o $pkg == quota ]; then
		echo_status "Including Contexts Quota (vquota) patch..."

		pkg_vquota_confdir=$base/package/mnemoc/vquota
		pkg_vquota_archdir=$base/download/mnemoc/vquota
		pkg_vquota_quotaver=0.35
		pkg_vquota_ctxver=`grep "^\[D\]" $base/package/mnemoc/vserver/vserver.desc \
			| cut -d' ' -f 3 | sed -n 's,patch-[\.0-9]*ctx-\([0-9]*\).gz,\1,p'`
		pkg_vquota_ver=`grep "^\[V\]" $pkg_vquota_confdir/vquota.desc | cut -d' ' -f 2`

		pkg_vquota_patchfile=""; pkg_vquota_patchdir="$pkg_vquota_confdir"

		case "$pkg" in
			vserver)	
				pkg_vquota_patchfile="vserver-$ver-cap_quotactl.diff"
				;;
			quota)
				pkg_vquota_patchfile="quota-tools-$ver-ctx$pkg_vquota_ctxver-v$pkg_vquota_quotaver.diff"
				;;
			*)
				# if on top guarantrees a linux24*
				#
				pkg_vquota_patchdir=`mktemp -d`
				pkg_vquota_patchfile="ctx-vquota-$pkg_vquota_ver.patch"
				bunzip2 -c $pkg_vquota_archdir/linux-$ver-ctx$pkg_vquota_ctxver-vquota-$pkg_vquota_ver.diff.bz2 > \
					$pkg_vquota_patchdir/$pkg_vquota_patchfile

				var_append postpatch ';' "rm -rf $pkg_vquota_patchdir"
                		var_append conffiles ' ' "$pkg_vquota_confdir/kernel.conf.sh"
				;;
		esac	

		if [ $pkg_vquota_patchfile ]; then
			if [ ! -r "$pkg_vquota_patchdir/$pkg_vquota_patchfile" ]; then
				[ "$pkg_vquota_patchdir" != "${pkg_vquota_patchdir#/tmp}" ] && \
					rm -rf "$pkg_vquota_patchdir"
				abort "File ${pkg_vquota_patchdir#$base}/$pkg_vquota_patchfile not found!"
			fi
			var_append patchfiles ' ' "$pkg_vquota_patchdir/$pkg_vquota_patchfile"
		fi
	fi
fi
