# --- 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/vserver/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 pkgcheck vserver X; then
	if [ ${pkg:0:7} == linux24 ]; then
		echo_status "Including Security Contexts (vserver) patch..."
		pkg_vserver_confdir=$base/package/mnemoc/vserver
		pkg_vserver_archdir=$base/download/mnemoc/vserver
		pkg_ctx_ver=`grep "^\[D\]" $pkg_vserver_confdir/vserver.desc | cut -d' ' -f3 \
			| sed -n 's,patch-\(.*\)ctx-\(.*\).gz,\2,p'`
		pkg_ctx_patch="patch-${ver}ctx-$pkg_ctx_ver.bz2"

		if [ ! -r $pkg_vserver_archdir/$pkg_ctx_patch ]; then
			abort "File \$base${pkg_lvs_archdir##$base}/$pkg_ctx_patch not found"
		fi

		pkg_ctx_tempdir=`mktemp -d`
		bzip2 -d -c $pkg_vserver_archdir/$pkg_ctx_patch > $pkg_ctx_tempdir/ctx-$pkg_ctx_ver.patch
		if [ ! -s $pkg_ctx_tempdir/ctx-$pkg_ctx_ver.patch ]; then
			abort "Patch $pkg_ctx_tempdir/ctx-$pkg_ctx_ver.patch not found... what happened?"
		fi

		hook_add postpatch 6 "rm -rf $pkg_ctx_tempdir"

		# remove EXTRAVERSION from Makefile
		hook_add postpatch 5 'sed 's,^EXTRAVERSION =.*,EXTRAVERSION =,' Makefile > Makefile.new; mv -f Makefile.new Makefile'

		# it SHALL be before vquota patch
		var_insert_before_regex patchfiles ' ' $pkg_ctx_tempdir/ctx-$pkg_ctx_ver.patch '.*\/ctx-vquota.*'

		var_append pkg_linux_brokenfiles ' ' $pkg_vserver_confdir/kernel-disable.lst
	fi
fi
