#!/var/cfengine/bin/cfagent -vf

import:

	hardware.conf
	version.conf

control:

	

	kernel_config_file = ( /etc/kernels/kernel-config-x86-$(kernel_major_version).$(kernel_minor_version)-$(kernel_flavour)-$(kernel_revision) )
	initrd_config_file = ( /usr/share/genkernel/x86/modules_load )
	autoload_config_file = ( /etc/modules.autoload.d/kernel-$(kernel_major_version) )

	editfilesize = ( 63000 )

	actionsequence = ( shellcommands.emerge links.kernel_src copy.kernel_config editfiles.kernel_config editfiles.initrd_config shellcommands.genkernel editfiles.autoload_config )

shellcommands:

	emerge::

		"/usr/bin/emerge -n =$(kernel_flavour)-sources-$(kernel_major_version).$(kernel_minor_version)-$(kernel_revision)"

	genkernel::

		"/usr/bin/genkernel --kerneldir=/usr/src/linux --kernel-config=$(kernel_config_file) --udev --install all"

copy:

	kernel_config::

		$(kernel_config_orig)
			dest=$(kernel_config_file)
			type=sum
			owner=root
			group=root
			mode=640

links:

	kernel_src::

		/usr/src/linux ->! /usr/src/linux-$(kernel_major_version).$(kernel_minor_version)-$(kernel_flavour)-$(kernel_revision)

editfiles:

	kernel_config::

		{ $(kernel_config_file)
			Backup "off"

			HashCommentLinesMatching "^CONFIG.*$"

			# ...

	}

	initrd_config::

		{ $(initrd_config_file)

			Backup "off"

			DeleteLinesMatching "^.*$"

			# ...

		}

	autoload_config::

		{ $(autoload_config_file)

			Backup "off"

			HashCommentLinesMatching "^[^#].*"
		}

