update nas kernel eclass

git-svn-id: https://svn.disconnected-by-peer.at/svn/linamh/trunk/genlink@2540 6952d904-891a-0410-993b-d76249ca496b
This commit is contained in:
geos_one 2010-10-17 19:45:41 +00:00
parent 3698f4499e
commit bb2bb0a00b

View File

@ -2,23 +2,23 @@
# Distributed under the terms of the GNU General Public License v2
# $
# @ECLASS-VARIABLE: K_SABPATCHES_VER
# @ECLASS-VARIABLE: K_NASPATCHES_VER
# @DESCRIPTION:
# The version of the sabayon patches tarball(s) to apply.
# The version of the nas patches tarball(s) to apply.
# A value of "5" would apply 2.6.12-5 to my-sources-2.6.12.ebuild
# @ECLASS-VARIABLE: K_SABKERNEL_NAME
# @ECLASS-VARIABLE: K_NASKERNEL_NAME
# @DESCRIPTION:
# The kernel name used by the ebuild, it should be the ending ${PN} part
# for example, of linux-sabayon it is "${PN/${PN/-*}-}" (sabayon)
K_SABKERNEL_NAME="${K_SABKERNEL_NAME:-${PN/${PN/-*}-}}"
# for example, of linux-nas it is "${PN/${PN/-*}-}" (nas)
K_NASKERNEL_NAME="${K_NASKERNEL_NAME:-${PN/${PN/-*}-}}"
# @ECLASS-VARIABLE: K_SABKERNEL_URI_CONFIG
# @ECLASS-VARIABLE: K_NASKERNEL_URI_CONFIG
# @DESCRIPTION:
# Set this either to "no" or "yes" depending on the location of the
# kernel config files. If they are inside FILESDIR (old location)
# leave this option set to "no", otherwise set this to "yes"
K_SABKERNEL_URI_CONFIG="${K_SABKERNEL_URI_CONFIG:-no}"
K_NASKERNEL_URI_CONFIG="${K_NASKERNEL_URI_CONFIG:-no}"
# @ECLASS-VARIABLE: K_KERNEL_SOURCES_PKG
# @DESCRIPTION:
@ -53,7 +53,7 @@ K_KERNEL_DISABLE_PR_EXTRAVERSION="${K_KERNEL_DISABLE_PR_EXTRAVERSION:-1}"
# firmware pkgs.
K_KERNEL_SLOT_USEPVR="${K_KERNEL_SLOT_USEPVR:-0}"
# @ECLASS-VARIABLE: K_SABKERNEL_FIRMWARE
# @ECLASS-VARIABLE: K_NASKERNEL_FIRMWARE
# @DESCRIPTION:
# Set this to "1" if your ebuild is a kernel firmware package
K_FIRMWARE_PACKAGE="${K_FIRMWARE_PACKAGE:-}"
@ -80,7 +80,7 @@ K_WORKAROUND_SOURCES_COLLISION="${K_WORKAROUND_SOURCES_COLLISION:-}"
# calculated using EXTRAVERSION in Makefile.
K_WORKAROUND_DIFFERENT_EXTRAVERSION="${K_WORKAROUND_DIFFERENT_EXTRAVERSION:-}"
KERN_INITRAMFS_SEARCH_NAME="${KERN_INITRAMFS_SEARCH_NAME:-initramfs-genkernel*${K_SABKERNEL_NAME}}"
KERN_INITRAMFS_SEARCH_NAME="${KERN_INITRAMFS_SEARCH_NAME:-initramfs-genkernel*${K_NASKERNEL_NAME}}"
# Disable deblobbing feature
K_DEBLOB_AVAILABLE=0
@ -91,15 +91,15 @@ inherit eutils kernel-2 mount-boot linux-mod
detect_version
detect_arch
DESCRIPTION="Sabayon Linux kernel functions and phases"
DESCRIPTION="NAS Linux kernel functions and phases"
## kernel-2 eclass settings
if [ -n "${K_SABPATCHES_VER}" ]; then
if [ -n "${K_NASPATCHES_VER}" ]; then
UNIPATCH_STRICTORDER="yes"
K_SABPATCHES_PKG="${PV}-${K_SABPATCHES_VER}.tar.bz2"
UNIPATCH_LIST="${DISTFILES}/${K_SABPATCHES_PKG}"
K_NASPATCHES_PKG="nas-patches-${PV}-${K_NASPATCHES_VER}.tar.bz2"
UNIPATCH_LIST="${DISTFILES}/${K_NASPATCHES_PKG}"
SRC_URI="${KERNEL_URI}
http://distfiles.sabayon.org/${CATEGORY}/linux-sabayon-patches/${K_SABPATCHES_PKG}"
http://ftp.disconnected-by-peer.at/genlink/${CATEGORY}/linux-nas-patches/${K_NASPATCHES_PKG}"
else
SRC_URI="${KERNEL_URI}"
fi
@ -115,10 +115,10 @@ if [ -n "${K_KERNEL_PATCH_HOTFIXES}" ]; then
UNIPATCH_LIST="${K_KERNEL_PATCH_HOTFIXES} ${UNIPATCH_LIST}"
fi
# replace "linux" with K_SABKERNEL_NAME, usually replaces
# "linux" with "sabayon" or "server" or "openvz"
KV_FULL="${KV_FULL/${PN/-*}/${K_SABKERNEL_NAME}}"
EXTRAVERSION="${EXTRAVERSION/${PN/-*}/${K_SABKERNEL_NAME}}"
# replace "linux" with K_NASKERNEL_NAME, usually replaces
# "linux" with "nas" or "server" or "openvz"
KV_FULL="${KV_FULL/${PN/-*}/${K_NASKERNEL_NAME}}"
EXTRAVERSION="${EXTRAVERSION/${PN/-*}/${K_NASKERNEL_NAME}}"
# drop -rX if exists
[[ -n "${PR//r0}" ]] && [[ "${K_KERNEL_DISABLE_PR_EXTRAVERSION}" = "1" ]] && \
EXTRAVERSION="${EXTRAVERSION/-r*}" && KV_FULL="${KV_FULL/-r*}" && \
@ -140,17 +140,14 @@ if [ -z "${K_FIRMWARE_PACKAGE}" ]; then
PROVIDE="${PROVIDE} virtual/linux-binary"
fi
HOMEPAGE="http://www.sabayon.org"
if [ "${K_SABKERNEL_URI_CONFIG}" = "yes" ]; then
K_SABKERNEL_CONFIG_FILE="${K_SABKERNEL_CONFIG_FILE:-${K_SABKERNEL_NAME}-${PVR}-__ARCH__.config}"
HOMEPAGE="http://www.nas.org"
if [ "${K_NASKERNEL_URI_CONFIG}" = "yes" ]; then
K_NASKERNEL_CONFIG_FILE="${K_NASKERNEL_CONFIG_FILE:-${K_NASKERNEL_NAME}-${PVR}-__ARCH__.config}"
SRC_URI="${SRC_URI}
amd64? ( http://distfiles.sabayon.org/${CATEGORY}/linux-sabayon-patches/config/${K_SABKERNEL_CONFIG_FILE/__ARCH__/amd64} )
x86? ( http://distfiles.sabayon.org/${CATEGORY}/linux-sabayon-patches/config/${K_SABKERNEL_CONFIG_FILE/__ARCH__/x86} )"
use amd64 && K_SABKERNEL_CONFIG_FILE=${K_SABKERNEL_CONFIG_FILE/__ARCH__/amd64}
use x86 && K_SABKERNEL_CONFIG_FILE=${K_SABKERNEL_CONFIG_FILE/__ARCH__/x86}
arm? ( http://ftp.disconnected-by-peer.at/genlink/${CATEGORY}/linux-nas-patches/config/${K_NASKERNEL_CONFIG_FILE/__ARCH__/arm} )"
use arm && K_NASKERNEL_CONFIG_FILE=${K_NASKERNEL_CONFIG_FILE/__ARCH__/arm}
else
use amd64 && K_SABKERNEL_CONFIG_FILE="${K_SABKERNEL_CONFIG_FILE:-${K_SABKERNEL_NAME}-${PVR}-amd64.config}"
use x86 && K_SABKERNEL_CONFIG_FILE="${K_SABKERNEL_CONFIG_FILE:-${K_SABKERNEL_NAME}-${PVR}-x86.config}"
use arm && K_NASKERNEL_CONFIG_FILE="${K_NASKERNEL_CONFIG_FILE:-${K_NASKERNEL_NAME}-${PVR}-arm.config}"
fi
if [ -n "${K_ONLY_SOURCES}" ] || [ -n "${K_FIRMWARE_PACKAGE}" ]; then
@ -158,19 +155,15 @@ if [ -n "${K_ONLY_SOURCES}" ] || [ -n "${K_FIRMWARE_PACKAGE}" ]; then
DEPEND="sys-apps/sed"
RDEPEND="${RDEPEND}"
else
IUSE="dmraid dracut grub splash"
IUSE="dmraid"
DEPEND="sys-apps/sed
app-arch/xz-utils
sys-kernel/genkernel
splash? ( x11-themes/sabayon-artwork-core )
dracut? ( sys-kernel/dracut )"
# FIXME: when grub-legacy will be removed, remove sys-boot/grub-handler
RDEPEND="grub? ( || ( >=sys-boot/grub-1.98 ( <sys-boot/grub-1 sys-boot/grub-handler ) ) )
sys-apps/sed
>=sys-kernel/linux-firmwares-${PV}"
sys-block/devio
dev-embedded/u-boot-tools"
fi
sabayon-kernel_pkg_setup() {
nas-kernel_pkg_setup() {
# do not run linux-mod-pkg_setup
if [ -n "${K_FIRMWARE_PACKAGE}" ]; then
einfo "Preparing to build kernel firmwares"
@ -179,7 +172,7 @@ sabayon-kernel_pkg_setup() {
fi
}
sabayon-kernel_src_compile() {
nas-kernel_src_compile() {
if [ -n "${K_FIRMWARE_PACKAGE}" ]; then
_firmwares_src_compile
elif [ -n "${K_ONLY_SOURCES}" ]; then
@ -202,10 +195,10 @@ _firmwares_src_compile() {
}
_kernel_copy_config() {
if [ "${K_SABKERNEL_URI_CONFIG}" = "no" ]; then
if [ "${K_NASKERNEL_URI_CONFIG}" = "no" ]; then
cp "${FILESDIR}/${PF/-r0/}-${ARCH}.config" "${1}" || die "cannot copy kernel config"
else
cp "${DISTDIR}/${K_SABKERNEL_CONFIG_FILE}" "${1}" || die "cannot copy kernel config"
cp "${DISTDIR}/${K_NASKERNEL_CONFIG_FILE}" "${1}" || die "cannot copy kernel config"
fi
}
@ -232,8 +225,6 @@ _kernel_src_compile() {
unset ARCH
cd "${S}"
GKARGS="--disklabel"
use dracut && GKARGS="${GKARGS} --dracut"
use splash && GKARGS="${GKARGS} --splash=sabayon"
use dmraid && GKARGS="${GKARGS} --dmraid"
export DEFAULT_KERNEL_SOURCE="${S}"
export CMD_KERNEL_DIR="${S}"
@ -243,10 +234,11 @@ _kernel_src_compile() {
break
fi
done
[ -z "${mkopts}" ] && mkopts="-j3"
[ -z "${mkopts}" ] && mkopts="-j2"
DEFAULT_KERNEL_SOURCE="${S}" CMD_KERNEL_DIR="${S}" genkernel ${GKARGS} \
--kerneldir="${S}" \
--arch-override="${OLDARCH}" \
--kernel-config="${WORKDIR}"/config \
--cachedir="${WORKDIR}"/cache \
--makeopts="${mkopts}" \
@ -262,7 +254,7 @@ _kernel_src_compile() {
ARCH=${OLDARCH}
}
sabayon-kernel_src_install() {
nas-kernel_src_install() {
if [ -n "${K_FIRMWARE_PACKAGE}" ]; then
_firmwares_src_install
elif [ -n "${K_ONLY_SOURCES}" ]; then
@ -290,7 +282,7 @@ _kernel_sources_src_install() {
kernel-2_src_install
cd "${D}/usr/src/linux-${KV_FULL}"
local oldarch="${ARCH}"
cp "${DISTDIR}/${K_SABKERNEL_CONFIG_FILE}" .config || die "cannot copy kernel config"
cp "${DISTDIR}/${K_NASKERNEL_CONFIG_FILE}" .config || die "cannot copy kernel config"
unset ARCH
if ! use sources_standalone; then
make modules_prepare || die "failed to run modules_prepare"
@ -305,10 +297,10 @@ _kernel_src_install() {
dodir "${KV_OUT_DIR}"
insinto "${KV_OUT_DIR}"
if [ "${K_SABKERNEL_URI_CONFIG}" = "no" ]; then
if [ "${K_NASKERNEL_URI_CONFIG}" = "no" ]; then
cp "${FILESDIR}/${PF/-r0/}-${OLDARCH}.config" .config || die "cannot copy kernel config"
else
cp "${DISTDIR}/${K_SABKERNEL_CONFIG_FILE}" .config || die "cannot copy kernel config"
cp "${DISTDIR}/${K_NASKERNEL_CONFIG_FILE}" .config || die "cannot copy kernel config"
fi
doins ".config" || die "cannot copy kernel config"
doins Makefile || die "cannot copy Makefile"
@ -370,21 +362,15 @@ _get_real_extraversion() {
echo ${trimmed## }
}
sabayon-kernel_pkg_preinst() {
nas-kernel_pkg_preinst() {
if [ -z "${K_ONLY_SOURCES}" ] && [ -z "${K_FIRMWARE_PACKAGE}" ]; then
mount-boot_pkg_preinst
linux-mod_pkg_preinst
UPDATE_MODULEDB=false
fi
}
sabayon-kernel_grub2_mkconfig() {
if [ -x "${ROOT}sbin/grub-mkconfig" ]; then
"${ROOT}sbin/grub-mkdevicemap" --device-map="${ROOT}boot/grub/device.map"
"${ROOT}sbin/grub-mkconfig" -o "${ROOT}boot/grub/grub.cfg"
fi
}
sabayon-kernel_pkg_postinst() {
nas-kernel_pkg_postinst() {
if [ -z "${K_ONLY_SOURCES}" ] && [ -z "${K_FIRMWARE_PACKAGE}" ]; then
fstab_file="${ROOT}etc/fstab"
einfo "Removing extents option for ext4 drives from ${fstab_file}"
@ -393,26 +379,6 @@ sabayon-kernel_pkg_postinst() {
sed -i '/ext4/ s/extents//g' "${fstab_file}"
fi
# Update kernel initramfs to match user customizations
update_sabayon_kernel_initramfs_splash
# Add kernel to grub.conf
if use grub; then
if use amd64; then
local kern_arch="x86_64"
else
local kern_arch="x86"
fi
# grub-legacy
if [ -x "${ROOT}usr/sbin/grub-handler" ]; then
"${ROOT}usr/sbin/grub-handler" add \
"/boot/kernel-genkernel-${kern_arch}-${KV_FULL}" \
"/boot/initramfs-genkernel-${kern_arch}-${KV_FULL}"
fi
sabayon-kernel_grub2_mkconfig
fi
kernel-2_pkg_postinst
if [ -n "${K_WORKAROUND_DIFFERENT_EXTRAVERSION}" ]; then
UPDATE_DEPMOD="false"
@ -425,7 +391,7 @@ sabayon-kernel_pkg_postinst() {
linux-mod_pkg_postinst
elog "Please report kernel bugs at:"
elog "http://bugs.sabayon.org"
elog "http://bugs.nas.org"
elog "The source code of this kernel is located at"
elog "=${K_KERNEL_SOURCES_PKG}."
@ -438,30 +404,14 @@ sabayon-kernel_pkg_postinst() {
fi
}
sabayon-kernel_pkg_prerm() {
nas-kernel_pkg_prerm() {
if [ -z "${K_ONLY_SOURCES}" ] && [ -z "${K_FIRMWARE_PACKAGE}" ]; then
mount-boot_pkg_prerm
fi
}
sabayon-kernel_pkg_postrm() {
nas-kernel_pkg_postrm() {
if [ -z "${K_ONLY_SOURCES}" ] && [ -z "${K_FIRMWARE_PACKAGE}" ]; then
# Remove kernel from grub.conf
if use grub; then
if use amd64; then
local kern_arch="x86_64"
else
local kern_arch="x86"
fi
if [ -x "${ROOT}usr/sbin/grub-handler" ]; then
"${ROOT}usr/sbin/grub-handler" remove \
"/boot/kernel-genkernel-${kern_arch}-${KV_FULL}" \
"/boot/initramfs-genkernel-${kern_arch}-${KV_FULL}"
fi
sabayon-kernel_grub2_mkconfig
fi
linux-mod_pkg_postrm
fi
}