# --- 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/base/linux24-src/linux24-src.conf
# 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 ---

# include the function to patch and configure the kernel
. $base/package/base/linux24/lx_config.sh

main_lx_src() {
	cd $root/usr/src

	echo "Extracting the Linux Kernel Sources [$vanilla_ver] ... "
	rm -rf linux-$ver-rock ; mkdir -p linux-$ver-rock

	# hack to extract the files into our usr/src dir ...
	ln -sf $PWD/linux-$ver-rock $builddir/linux-${vanilla_ver}
	tar -k $taropt $archdir/$srctar -C $builddir/
	chown -R 0.0 linux-$ver-rock ; chmod go=u,go-w linux-$ver-rock

	if [ "${pkg%-src}" = "$ROCKCFG_DEFAULT_KERNEL" ] ; then
		rm -f linux
		ln -svf linux-$ver-rock linux
	fi

	echo "Copying kernel patches ... "
	rm -rf linux$treever-patches ; mkdir -p linux$treever-patches
	cp -v $base/package/$repository/linux$treever/README linux$treever-patches/
	cp -v $patchfiles linux$treever-patches/

	cd linux-$ver-rock

	lx_config
	# remove debug configs 
	rm -f .config.[1-9] 

	if [ "$ROCKCFG_PKG_LINUX_CONFIG_STYLE" = none ] ; then
		# create a valid .config (new settings may be available etc.)
		yes '' | eval $MAKE oldconfig > /dev/null
	else
		cp -v .config_nomods  ../linux$treever-patches/config_nomods.txt
		cp -v .config_modules ../linux$treever-patches/config_modules.txt
	fi

	# can fail in stage 0-1 ...
	if [ $stagelevel -gt 1 ] && [[ $treever = 24* ]] ; then
		echo "Creating dependencies (e.g. for versioned symbols) ..."
		eval $MAKE dep-files
	fi

	echo "Clean up the *.orig and *~ files ... "
	find -name '*.orig' -o -name '*~' | xargs rm -f
	rm -f .config.old
}

autoextract=0 ; createdocs=0

custmain="main_lx_src"
patchfiles="`echo $base/package/$repository/linux$treever/*.patch` $patchfiles"