2012-11-10 10:48:27 +01:00
|
|
|
# Copyright 2004-2010 Sabayon Project
|
2013-12-06 13:43:46 +01:00
|
|
|
# Copyright 2013 Sablink Project
|
2012-11-10 10:48:27 +01:00
|
|
|
# Distributed under the terms of the GNU General Public License v2
|
|
|
|
# $
|
|
|
|
|
|
|
|
# @ECLASS-VARIABLE: K_SABPATCHES_VER
|
|
|
|
# @DESCRIPTION:
|
2013-12-06 13:43:46 +01:00
|
|
|
# The version of the sablink patches tarball(s) to apply.
|
2012-11-10 10:48:27 +01:00
|
|
|
# A value of "5" would apply 2.6.12-5 to my-sources-2.6.12.ebuild
|
|
|
|
|
|
|
|
# @ECLASS-VARIABLE: K_SABKERNEL_NAME
|
|
|
|
# @DESCRIPTION:
|
|
|
|
# The kernel name used by the ebuild, it should be the ending ${PN} part
|
2013-12-06 13:43:46 +01:00
|
|
|
# for example, of linux-sablink it is "${PN/${PN/-*}-}" (sablink)
|
2012-11-10 10:48:27 +01:00
|
|
|
K_SABKERNEL_NAME="${K_SABKERNEL_NAME:-${PN/${PN/-*}-}}"
|
|
|
|
|
|
|
|
# @ECLASS-VARIABLE: K_SABKERNEL_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}"
|
|
|
|
|
|
|
|
# @ECLASS-VARIABLE: K_SABKERNEL_SELF_TARBALL_NAME
|
|
|
|
# @DESCRIPTION:
|
|
|
|
# If the main kernel sources tarball is generated in-house and available
|
2013-12-06 13:43:46 +01:00
|
|
|
# on the "sablink" mirror, set this variable to the extension name (see example
|
2012-11-10 10:48:27 +01:00
|
|
|
# below). This will disable ALL the extra/local patches (since they have to
|
|
|
|
# be applied inside the tarball). Moreover, K_SABKERNEL_URI_CONFIG,
|
|
|
|
# K_SABPATCHES_VER, K_SABKERNEL_NAME, K_KERNEL_PATCH_VER will be ignored.
|
|
|
|
# Example:
|
2013-12-06 13:43:46 +01:00
|
|
|
# K_SABKERNEL_SELF_TARBALL_NAME="sablink"
|
2012-11-10 10:48:27 +01:00
|
|
|
# This would generate:
|
2013-12-06 13:43:46 +01:00
|
|
|
# SRC_URI="mirror://sablink/sys-kernel/linux-${PV}+sablink.tar.${K_TARBALL_EXT}"
|
2012-11-10 10:48:27 +01:00
|
|
|
K_SABKERNEL_SELF_TARBALL_NAME="${K_SABKERNEL_SELF_TARBALL_NAME:-}"
|
|
|
|
|
|
|
|
# @ECLASS-VARIABLE: K_SABKERNEL_FORCE_SUBLEVEL
|
|
|
|
# @DESCRIPTION:
|
|
|
|
# Force the rewrite of SUBLEVEL in kernel sources Makefile
|
|
|
|
K_SABKERNEL_FORCE_SUBLEVEL="${K_SABKERNEL_FORCE_SUBLEVEL:-}"
|
|
|
|
|
|
|
|
# @ECLASS-VARIABLE: K_SABKERNEL_RESET_EXTRAVERSION
|
|
|
|
# @DESCRIPTION:
|
|
|
|
# Force the rewrite of EXTRAVERSION in kernel sources Makefile (setting it to "")
|
|
|
|
K_SABKERNEL_RESET_EXTRAVERSION="${K_SABKERNEL_RESET_EXTRAVERSION:-}"
|
|
|
|
|
|
|
|
# @ECLASS-VARIABLE: K_SABKERNEL_LONGTERM
|
|
|
|
# @DESCRIPTION:
|
|
|
|
# Consider Kernel stable patchset as longterm (changing URL)
|
|
|
|
K_SABKERNEL_LONGTERM="${K_SABKERNEL_LONGTERM:-}"
|
|
|
|
|
|
|
|
# @ECLASS-VARIABLE: K_KERNEL_SOURCES_PKG
|
|
|
|
# @DESCRIPTION:
|
|
|
|
# The kernel sources package used to build this kernel binary
|
|
|
|
K_KERNEL_SOURCES_PKG="${K_KERNEL_SOURCES_PKG:-${CATEGORY}/${PN/*-}-sources-${PVR}}"
|
|
|
|
|
|
|
|
# @ECLASS-VARIABLE: K_KERNEL_PATCH_VER
|
|
|
|
# @DESCRIPTION:
|
|
|
|
# If set to "3" for example, it applies the upstream kernel
|
2013-12-06 13:43:46 +01:00
|
|
|
# patch corresponding to patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}.3.${K_TARBALL_EXT}
|
2012-11-10 10:48:27 +01:00
|
|
|
# @TODO: deprecate and remove once 2.6.x kernels are retired
|
|
|
|
K_KERNEL_PATCH_VER="${K_KERNEL_PATCH_VER:-}"
|
|
|
|
|
|
|
|
# @ECLASS-VARIABLE: K_KERNEL_PATCH_HOTFIXES
|
|
|
|
# @DESCRIPTION:
|
|
|
|
# If there is the need to quickly apply patches to the kernel
|
|
|
|
# without bumping the kernel patch tarball (for eg. in case
|
|
|
|
# of just released security fixes), set this variable in your ebuild
|
|
|
|
# pointing to space separated list of patch paths.
|
|
|
|
K_KERNEL_PATCH_HOTFIXES="${K_KERNEL_PATCH_HOTFIXES:-}"
|
|
|
|
|
|
|
|
# @ECLASS-VARIABLE: K_KERNEL_DISABLE_PR_EXTRAVERSION
|
|
|
|
# @DESCRIPTION:
|
|
|
|
# Set this to "1" if you want to tell kernel-2 eclass to
|
|
|
|
# not use ${PR} in kernel EXTRAVERSION (K_NOUSEPR). Otherwise, set
|
|
|
|
# this to "0" to not set K_NOUSEPR at all.
|
|
|
|
K_KERNEL_DISABLE_PR_EXTRAVERSION="${K_KERNEL_DISABLE_PR_EXTRAVERSION:-1}"
|
|
|
|
|
|
|
|
# @ECLASS-VARIABLE: K_KERNEL_SLOT_USEPVR
|
|
|
|
# @DESCRIPTION:
|
|
|
|
# Set this to "1" if you want to use ${PVR} in SLOT variable, instead of ${PV}
|
|
|
|
# sys-kernel/linux-vserver (vserver-sources) require this. This won't work for
|
|
|
|
# firmware pkgs.
|
|
|
|
K_KERNEL_SLOT_USEPVR="${K_KERNEL_SLOT_USEPVR:-0}"
|
|
|
|
|
2013-12-06 13:43:46 +01:00
|
|
|
# @ECLASS-VARIABLE: K_KERNEL_NEW_VERSIONING
|
|
|
|
# @DESCRIPTION:
|
|
|
|
# Set this to "1" if your kernel ebuild uses the new Linux kernel upstream
|
|
|
|
# versioning and ${PV} contains the stable revision, like 3.7.1.
|
|
|
|
# In the example above, this makes the SLOT variable contain only "3.7".
|
|
|
|
# The sublevel version can be forced using K_SABKERNEL_FORCE_SUBLEVEL
|
|
|
|
K_KERNEL_NEW_VERSIONING="${K_KERNEL_NEW_VERSIONING:-0}"
|
|
|
|
|
|
|
|
# @ECLASS-VARIABLE: K_KERNEL_IMAGE_NAME
|
|
|
|
# @DESCRIPTION:
|
|
|
|
# Set this to a custom kernel image make target if the default does not
|
|
|
|
# fit your needs. This value if set, is passed to genkernel through the
|
|
|
|
# --kernel-target= flag.
|
|
|
|
K_KERNEL_IMAGE_NAME="${K_KERNEL_IMAGE_NAME:-}"
|
|
|
|
|
|
|
|
# @ECLASS-VARIABLE: K_KERNEL_LTS
|
|
|
|
# @DESCRIPTION:
|
|
|
|
# Set this to 1 to mark the kernel as Long Term Stable. "virtual/linux-binary-lts"
|
|
|
|
# shall be appended to ${PROVIDE}.
|
|
|
|
K_KERNEL_LTS="${K_KERNEL_LTS:-}"
|
|
|
|
|
|
|
|
# @ECLASS-VARIABLE: K_KERNEL_IMAGE_PATH
|
|
|
|
# @DESCRIPTION:
|
|
|
|
# Set this to a custom relative kernel image path to override the default
|
|
|
|
# one. This value if set, is passed to genkernel through the
|
|
|
|
# --kernel-binary= flag.
|
|
|
|
K_KERNEL_IMAGE_PATH="${K_KERNEL_IMAGE_PATH:-}"
|
|
|
|
|
2012-11-10 10:48:27 +01:00
|
|
|
# @ECLASS-VARIABLE: K_SABKERNEL_FIRMWARE
|
|
|
|
# @DESCRIPTION:
|
|
|
|
# Set this to "1" if your ebuild is a kernel firmware package
|
|
|
|
K_FIRMWARE_PACKAGE="${K_FIRMWARE_PACKAGE:-}"
|
|
|
|
|
|
|
|
# @ECLASS-VARIABLE: K_ONLY_SOURCES
|
|
|
|
# @DESCRIPTION:
|
|
|
|
# For every kernel binary package, there is a kernel source package associated
|
|
|
|
# if your ebuild is one of them, set this to "1"
|
|
|
|
K_ONLY_SOURCES="${K_ONLY_SOURCES:-}"
|
|
|
|
|
|
|
|
# @ECLASS-VARIABLE: K_REQUIRED_LINUX_FIRMWARE_VER
|
|
|
|
# @DESCRIPTION:
|
|
|
|
# Minimum required version of sys-kernel/linux-formware package, if any
|
|
|
|
K_REQUIRED_LINUX_FIRMWARE_VER="${K_REQUIRED_LINUX_FIRMWARE_VER:-}"
|
|
|
|
|
|
|
|
# @ECLASS-VARIABLE: K_WORKAROUND_SOURCES_COLLISION
|
|
|
|
# @DESCRIPTION:
|
|
|
|
# For kernel binary packages, Workaround file collisions with kernel
|
|
|
|
# sources already providing certain files (like Makefile). Used
|
|
|
|
# by linux-openvz and linux-vserver
|
|
|
|
K_WORKAROUND_SOURCES_COLLISION="${K_WORKAROUND_SOURCES_COLLISION:-}"
|
|
|
|
|
|
|
|
# @ECLASS-VARIABLE: K_WORKAROUND_USE_REAL_EXTRAVERSION
|
|
|
|
# @DESCRIPTION:
|
|
|
|
# Some kernel sources are shipped with their own EXTRAVERSION and
|
|
|
|
# we're kindly asked to not touch it, if this is your case, set
|
|
|
|
# this variable and depmod will work correctly.
|
|
|
|
K_WORKAROUND_USE_REAL_EXTRAVERSION="${K_WORKAROUND_USE_REAL_EXTRAVERSION:-}"
|
|
|
|
|
2013-12-06 13:43:46 +01:00
|
|
|
# @ECLASS-VARIABLE: K_SABKERNEL_ZFS
|
|
|
|
# @DESCRIPTION:
|
|
|
|
# If set, this kernel features ZFS.
|
|
|
|
K_SABKERNEL_ZFS="${K_SABKERNEL_ZFS:-}"
|
|
|
|
|
2012-11-10 10:48:27 +01:00
|
|
|
# @ECLASS-VARIABLE: K_GENKERNEL_ARGS
|
|
|
|
# @DESCRIPTION:
|
|
|
|
# Provide extra genkernel arguments using K_GENKERNEL_ARGS
|
|
|
|
K_GENKERNEL_ARGS="${K_GENKERNEL_ARGS:-}"
|
|
|
|
|
|
|
|
# @ECLASS-VARIABLE: K_MKIMAGE_RAMDISK_ADDRESS
|
|
|
|
# @DESCRIPTION:
|
|
|
|
# [ARM ONLY] Provide the ramdisk load address to be used with mkimage
|
|
|
|
K_MKIMAGE_RAMDISK_ADDRESS="${K_MKIMAGE_RAMDISK_ADDRESS:-}"
|
|
|
|
|
|
|
|
# @ECLASS-VARIABLE: K_MKIMAGE_RAMDISK_ENTRYPOINT
|
|
|
|
# @DESCRIPTION:
|
|
|
|
# [ARM ONLY] Provide the ramdisk entry point address to be used with mkimage
|
|
|
|
K_MKIMAGE_RAMDISK_ENTRYPOINT="${K_MKIMAGE_RAMDISK_ENTRYPOINT:-}"
|
|
|
|
|
2013-12-06 13:43:46 +01:00
|
|
|
# @ECLASS-VARIABLE: K_MKIMAGE_WRAP_INITRAMFS
|
|
|
|
# @DESCRIPTION:
|
|
|
|
# [ARM ONLY] Execute mkimage against the generated initramfs Default is yes ("1").
|
|
|
|
K_MKIMAGE_WRAP_INITRAMFS="${K_MKIMAGE_WRAP_INITRAMFS:-1}"
|
|
|
|
|
|
|
|
# @ECLASS-VARIABLE: K_MKIMAGE_KERNEL_ADDRESS
|
|
|
|
# @DESCRIPTION:
|
|
|
|
# [ARM ONLY] Provide the kernel load address to be used with mkimage
|
|
|
|
K_MKIMAGE_KERNEL_ADDRESS="${K_MKIMAGE_KERNEL_ADDRESS:-}"
|
|
|
|
|
2012-11-10 10:48:27 +01:00
|
|
|
KERN_INITRAMFS_SEARCH_NAME="${KERN_INITRAMFS_SEARCH_NAME:-initramfs-genkernel*${K_SABKERNEL_NAME}}"
|
|
|
|
|
|
|
|
# Disable deblobbing feature
|
|
|
|
K_DEBLOB_AVAILABLE=0
|
|
|
|
ETYPE="sources"
|
2013-12-06 13:43:46 +01:00
|
|
|
K_TARBALL_EXT="${K_TARBALL_EXT:-xz}"
|
|
|
|
|
|
|
|
inherit versionator
|
|
|
|
if [ "${K_KERNEL_NEW_VERSIONING}" = "1" ]; then
|
|
|
|
CKV="$(get_version_component_range 1-2)"
|
|
|
|
fi
|
2012-11-10 10:48:27 +01:00
|
|
|
|
2013-12-06 13:43:46 +01:00
|
|
|
inherit eutils multilib kernel-2 mount-boot linux-info
|
2012-11-10 10:48:27 +01:00
|
|
|
|
|
|
|
# from kernel-2 eclass
|
|
|
|
detect_version
|
|
|
|
detect_arch
|
|
|
|
|
2013-12-06 13:43:46 +01:00
|
|
|
DESCRIPTION="Sablink Linux kernel functions and phases"
|
2012-11-10 10:48:27 +01:00
|
|
|
|
|
|
|
|
|
|
|
K_LONGTERM_URL_STR=""
|
|
|
|
if [ -n "${K_SABKERNEL_LONGTERM}" ]; then
|
|
|
|
K_LONGTERM_URL_STR="/longterm/v${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
## kernel-2 eclass settings
|
|
|
|
if [ -n "${K_SABKERNEL_SELF_TARBALL_NAME}" ]; then
|
2013-12-06 13:43:46 +01:00
|
|
|
SRC_URI="mirror://sablink/${CATEGORY}/linux-${PVR}+${K_SABKERNEL_SELF_TARBALL_NAME}.tar.${K_TARBALL_EXT}"
|
2012-11-10 10:48:27 +01:00
|
|
|
elif [ -n "${K_SABPATCHES_VER}" ]; then
|
|
|
|
UNIPATCH_STRICTORDER="yes"
|
2013-12-06 13:43:46 +01:00
|
|
|
K_SABPATCHES_PKG="sablink-patches-${PV}-${K_SABPATCHES_VER}.tar.${K_TARBALL_EXT}"
|
2012-11-10 10:48:27 +01:00
|
|
|
UNIPATCH_LIST="${DISTFILES}/${K_SABPATCHES_PKG}"
|
|
|
|
SRC_URI="${KERNEL_URI}
|
2013-12-06 13:43:46 +01:00
|
|
|
mirror://sablink/${CATEGORY}/linux-sablink-patches/${K_SABPATCHES_PKG}"
|
2012-11-10 10:48:27 +01:00
|
|
|
else
|
|
|
|
SRC_URI="${KERNEL_URI}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "${K_SABKERNEL_SELF_TARBALL_NAME}" ]; then
|
|
|
|
if [ -n "${K_KERNEL_PATCH_VER}" ]; then
|
2013-12-06 13:43:46 +01:00
|
|
|
K_PATCH_NAME="patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}.${K_KERNEL_PATCH_VER}.${K_TARBALL_EXT}"
|
2012-11-10 10:48:27 +01:00
|
|
|
SRC_URI="${SRC_URI}
|
|
|
|
mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}${K_LONGTERM_URL_STR}/${K_PATCH_NAME}"
|
|
|
|
UNIPATCH_LIST="${DISTDIR}/${K_PATCH_NAME}
|
|
|
|
${UNIPATCH_LIST}"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if [ -n "${K_KERNEL_PATCH_HOTFIXES}" ]; then
|
|
|
|
UNIPATCH_LIST="${K_KERNEL_PATCH_HOTFIXES} ${UNIPATCH_LIST}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
_get_real_kv_full() {
|
|
|
|
if [[ "${KV_MAJOR}${KV_MINOR}" -eq 26 ]]; then
|
|
|
|
echo "${ORIGINAL_KV_FULL}"
|
|
|
|
elif [[ "${OKV/.*}" = "3" ]]; then
|
2013-12-06 13:43:46 +01:00
|
|
|
# Linux 3.x support, KV_FULL is set to: 3.0-sablink
|
2012-11-10 10:48:27 +01:00
|
|
|
# need to add another final .0 to the version part
|
2013-12-07 15:30:22 +01:00
|
|
|
echo "${ORIGINAL_KV_FULL/-/.0-}"
|
2012-11-10 10:48:27 +01:00
|
|
|
else
|
|
|
|
echo "${ORIGINAL_KV_FULL}"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# replace "linux" with K_SABKERNEL_NAME, usually replaces
|
2013-12-06 13:43:46 +01:00
|
|
|
# "linux" with "sablink" or "server" or "openvz"
|
2012-11-10 10:48:27 +01:00
|
|
|
KV_FULL="${KV_FULL/${PN/-*}/${K_SABKERNEL_NAME}}"
|
|
|
|
EXTRAVERSION="${EXTRAVERSION/${PN/-*}/${K_SABKERNEL_NAME}}"
|
|
|
|
# drop -rX if exists
|
|
|
|
if [[ -n "${PR//r0}" ]] && [[ "${K_KERNEL_DISABLE_PR_EXTRAVERSION}" = "1" ]] \
|
|
|
|
&& [[ -z "${K_NOSETEXTRAVERSION}" ]]; then
|
|
|
|
EXTRAVERSION="${EXTRAVERSION%-r*}"
|
|
|
|
KV_FULL="${KV_FULL%-r*}"
|
|
|
|
KV="${KV%-r*}"
|
|
|
|
fi
|
|
|
|
# rewrite it
|
|
|
|
ORIGINAL_KV_FULL="${KV_FULL}"
|
|
|
|
KV_FULL="$(_get_real_kv_full)"
|
|
|
|
|
|
|
|
# Starting from linux-3.0, we still have to install
|
2013-12-06 13:43:46 +01:00
|
|
|
# sources stuff into /usr/src/linux-3.0.0-sablink (example)
|
2012-11-10 10:48:27 +01:00
|
|
|
# where the last part must always match uname -r
|
|
|
|
# otherwise kernel-switcher (and RELEASE_LEVEL file)
|
|
|
|
# will complain badly
|
|
|
|
KV_OUT_DIR="/usr/src/linux-${KV_FULL}"
|
|
|
|
S="${WORKDIR}/linux-${KV_FULL}"
|
|
|
|
|
|
|
|
|
|
|
|
if [ -n "${K_FIRMWARE_PACKAGE}" ]; then
|
|
|
|
SLOT="0"
|
|
|
|
elif [ "${K_KERNEL_SLOT_USEPVR}" = "1" ]; then
|
|
|
|
SLOT="${PVR}"
|
2013-12-06 13:43:46 +01:00
|
|
|
elif [ "${K_KERNEL_NEW_VERSIONING}" = "1" ]; then
|
|
|
|
SLOT="$(get_version_component_range 1-2)"
|
2012-11-10 10:48:27 +01:00
|
|
|
else
|
|
|
|
SLOT="${PV}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
_is_kernel_binary() {
|
|
|
|
if [ -z "${K_ONLY_SOURCES}" ] && [ -z "${K_FIRMWARE_PACKAGE}" ]; then
|
|
|
|
# yes it is
|
|
|
|
return 0
|
|
|
|
else
|
|
|
|
# no it isn't
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2013-12-06 13:43:46 +01:00
|
|
|
_is_kernel_lts() {
|
|
|
|
local _ver="$(get_version_component_range 1-2)"
|
|
|
|
[ "${_ver}" = "3.0" ] && return 0
|
|
|
|
[ "${_ver}" = "3.2" ] && return 0
|
|
|
|
[ "${_ver}" = "3.4" ] && return 0
|
|
|
|
[ "${_ver}" = "3.10" ] && return 0
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
2013-12-07 10:45:15 +01:00
|
|
|
# Returns the arm kernel config file extension for the current subarch
|
|
|
|
_get_arm_subarch() {
|
|
|
|
local target="${CTARGET:-${CHOST}}"
|
|
|
|
local arm_arch=${target%%-*}
|
|
|
|
if [[ ${arm_arch} == armv7? ]]; then
|
|
|
|
echo "armv7"
|
|
|
|
elif [[ ${arm_arch} == armv6? ]]; then
|
|
|
|
echo "armv6"
|
|
|
|
elif [[ ${arm_arch} == armv5? ]]; then
|
|
|
|
echo "armv5"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2012-11-10 10:48:27 +01:00
|
|
|
# provide extra virtual pkg
|
|
|
|
if _is_kernel_binary; then
|
|
|
|
PROVIDE="virtual/linux-binary"
|
2013-12-06 13:43:46 +01:00
|
|
|
# LTS support
|
|
|
|
if [ "${K_KERNEL_LTS}" = "1" ] || _is_kernel_lts; then
|
|
|
|
PROVIDE+=" virtual/linux-binary-lts"
|
|
|
|
fi
|
2012-11-10 10:48:27 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -n "${K_SABKERNEL_SELF_TARBALL_NAME}" ]; then
|
2013-12-06 13:43:46 +01:00
|
|
|
HOMEPAGE="http://git.disconnected-by-peer.at/sablink/kernel/"
|
2012-11-10 10:48:27 +01:00
|
|
|
else
|
2013-12-06 13:43:46 +01:00
|
|
|
HOMEPAGE="http://www.sablink.org"
|
2012-11-10 10:48:27 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
# set SRC_URI
|
|
|
|
if [ -z "${K_SABKERNEL_SELF_TARBALL_NAME}" ]; then
|
|
|
|
if [ "${K_SABKERNEL_URI_CONFIG}" = "yes" ]; then
|
|
|
|
tmp_K_SABKERNEL_CONFIG_FILE="${K_SABKERNEL_CONFIG_FILE:-${K_SABKERNEL_NAME}-${PVR}-__ARCH__.config}"
|
|
|
|
# ARM not supported, if put in SRC_URI it tries to fetch it
|
2013-12-06 13:43:46 +01:00
|
|
|
tmp_K_SABKERNEL_FW_CONFIG_FILE="${K_SABKERNEL_FW_CONFIG_FILE:-${K_SABKERNEL_NAME}-fw_env-__ARCH__.config}"
|
|
|
|
if [ -n "${K_SABCONFIGS_VER}" ]; then
|
|
|
|
K_SABCONFIGS_PKG="sablink-configs-${PV}-${K_SABCONFIGS_VER}.tar.${K_TARBALL_EXT}"
|
2013-12-07 10:45:15 +01:00
|
|
|
K_ARM_ARCH=$(_get_arm_subarch)
|
2013-12-06 13:43:46 +01:00
|
|
|
SRC_URI="${SRC_URI}
|
2013-12-07 10:45:15 +01:00
|
|
|
mirror://sablink/${CATEGORY}/linux-sablink-configs/${K_SABCONFIGS_PKG}
|
|
|
|
arm? ( mirror://sablink/${CATEGORY}/linux-sablink-patches/config/${tmp_K_SABKERNEL_FW_CONFIG_FILE/__ARCH__/arm} )"
|
2013-12-06 13:43:46 +01:00
|
|
|
else
|
|
|
|
SRC_URI="${SRC_URI}
|
|
|
|
arm? ( mirror://sablink/${CATEGORY}/linux-sablink-patches/config/${tmp_K_SABKERNEL_FW_CONFIG_FILE/__ARCH__/arm} )
|
|
|
|
amd64? ( mirror://sablink/${CATEGORY}/linux-sablink-patches/config/${tmp_K_SABKERNEL_CONFIG_FILE/__ARCH__/amd64} )
|
|
|
|
x86? ( mirror://sablink/${CATEGORY}/linux-sablink-patches/config/${tmp_K_SABKERNEL_CONFIG_FILE/__ARCH__/x86} )"
|
|
|
|
fi
|
2012-11-10 10:48:27 +01:00
|
|
|
# K_SABKERNEL_CONFIG_FILE will be set in _set_config_file_vars
|
|
|
|
unset tmp_K_SABKERNEL_CONFIG_FILE
|
2013-12-06 13:43:46 +01:00
|
|
|
unset tmp_K_SABKERNEL_FW_CONFIG_FILE
|
2012-11-10 10:48:27 +01:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Returns success if _set_config_file_vars was called.
|
|
|
|
_is_config_file_set() {
|
|
|
|
[[ ${_config_file_set} = 1 ]]
|
|
|
|
}
|
|
|
|
|
|
|
|
_set_config_file_vars() {
|
|
|
|
# Setup kernel configuration file name
|
2013-12-06 13:43:46 +01:00
|
|
|
local pvr="${PVR}"
|
|
|
|
local pv="${PV}"
|
|
|
|
if [ "${K_KERNEL_NEW_VERSIONING}" = "1" ]; then
|
|
|
|
pvr="$(get_version_component_range 1-2)"
|
|
|
|
pv="${pvr}"
|
|
|
|
if [ "${PR}" != "r0" ]; then
|
|
|
|
pvr+="-${PR}"
|
|
|
|
fi
|
|
|
|
fi
|
2012-11-10 10:48:27 +01:00
|
|
|
if [ -z "${K_SABKERNEL_SELF_TARBALL_NAME}" ]; then
|
|
|
|
if [ "${K_SABKERNEL_URI_CONFIG}" = "yes" ]; then
|
2013-12-06 13:43:46 +01:00
|
|
|
K_SABKERNEL_CONFIG_FILE="${K_SABKERNEL_CONFIG_FILE:-${K_SABKERNEL_NAME}-${pvr}-__ARCH__.config}"
|
|
|
|
K_SABKERNEL_FW_CONFIG_FILE="${K_SABKERNEL_FW_CONFIG_FILE:-${K_SABKERNEL_NAME}-fw_env-__ARCH__.config}"
|
|
|
|
use arm && K_SABKERNEL_CONFIG_FILE=${K_SABKERNEL_CONFIG_FILE/__ARCH__/$(_get_arm_subarch)}
|
2013-12-07 10:45:15 +01:00
|
|
|
use arm && K_SABKERNEL_FW_CONFIG_FILE=${K_SABKERNEL_FW_CONFIG_FILE/__ARCH__/arm}
|
2013-12-06 13:43:46 +01:00
|
|
|
use amd64 && K_SABKERNEL_CONFIG_FILE="${K_SABKERNEL_CONFIG_FILE/__ARCH__/amd64}"
|
|
|
|
use x86 && K_SABKERNEL_CONFIG_FILE="${K_SABKERNEL_CONFIG_FILE/__ARCH__/x86}"
|
2012-11-10 10:48:27 +01:00
|
|
|
else
|
2013-12-06 13:43:46 +01:00
|
|
|
use arm && K_SABKERNEL_CONFIG_FILE="${K_SABKERNEL_CONFIG_FILE:-${K_SABKERNEL_NAME}-${pvr}-$(_get_arm_subarch).config}"
|
|
|
|
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}"
|
2012-11-10 10:48:27 +01:00
|
|
|
fi
|
|
|
|
else
|
2013-12-06 13:43:46 +01:00
|
|
|
K_SABKERNEL_CONFIG_FILE="${K_SABKERNEL_CONFIG_FILE:-${K_SABKERNEL_NAME}-${pvr}-__ARCH__.config}"
|
|
|
|
K_SABKERNEL_ALT_CONFIG_FILE="${K_SABKERNEL_ALT_CONFIG_FILE:-${K_SABKERNEL_NAME}-${pv}-__ARCH__.config}"
|
|
|
|
K_SABKERNEL_FW_CONFIG_FILE="${K_SABKERNEL_FW_CONFIG_FILE:-${K_SABKERNEL_NAME}-${pvr}-fw_env-__ARCH__.config}"
|
2012-11-10 10:48:27 +01:00
|
|
|
if use amd64; then
|
2013-12-06 13:43:46 +01:00
|
|
|
K_SABKERNEL_CONFIG_FILE="${K_SABKERNEL_CONFIG_FILE/__ARCH__/amd64}"
|
|
|
|
K_SABKERNEL_ALT_CONFIG_FILE="${K_SABKERNEL_ALT_CONFIG_FILE/__ARCH__/amd64}"
|
2012-11-10 10:48:27 +01:00
|
|
|
elif use x86; then
|
2013-12-06 13:43:46 +01:00
|
|
|
K_SABKERNEL_CONFIG_FILE="${K_SABKERNEL_CONFIG_FILE/__ARCH__/x86}"
|
|
|
|
K_SABKERNEL_ALT_CONFIG_FILE="${K_SABKERNEL_ALT_CONFIG_FILE/__ARCH__/x86}"
|
2012-11-10 10:48:27 +01:00
|
|
|
elif use arm; then
|
2013-12-06 13:43:46 +01:00
|
|
|
K_SABKERNEL_CONFIG_FILE="${K_SABKERNEL_CONFIG_FILE/__ARCH__/$(_get_arm_subarch)}"
|
|
|
|
K_SABKERNEL_ALT_CONFIG_FILE="${K_SABKERNEL_ALT_CONFIG_FILE/__ARCH__/$(_get_arm_subarch)}"
|
2013-12-07 10:45:15 +01:00
|
|
|
K_SABKERNEL_FW_CONFIG_FILE="${K_SABKERNEL_FW_CONFIG_FILE/__ARCH__/arm}"
|
2012-11-10 10:48:27 +01:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
_config_file_set=1
|
|
|
|
}
|
|
|
|
|
|
|
|
if [ -n "${K_ONLY_SOURCES}" ] || [ -n "${K_FIRMWARE_PACKAGE}" ]; then
|
|
|
|
IUSE="${IUSE}"
|
|
|
|
DEPEND="sys-apps/sed"
|
|
|
|
RDEPEND="${RDEPEND}"
|
|
|
|
else
|
2013-12-06 13:43:46 +01:00
|
|
|
IUSE="dmraid dracut iscsi luks lvm mdadm"
|
|
|
|
if [ -n "${K_SABKERNEL_ZFS}" ]; then
|
|
|
|
IUSE="${IUSE} zfs"
|
|
|
|
fi
|
2012-11-10 10:48:27 +01:00
|
|
|
DEPEND="app-arch/xz-utils
|
|
|
|
sys-apps/sed
|
2013-12-06 13:43:46 +01:00
|
|
|
sys-devel/autoconf
|
2012-11-10 10:48:27 +01:00
|
|
|
sys-devel/make
|
2013-12-06 13:43:46 +01:00
|
|
|
sys-fs/dosfstools
|
2013-12-11 15:03:22 +01:00
|
|
|
dev-util/ccache
|
2013-12-06 13:43:46 +01:00
|
|
|
|| ( >=sys-kernel/genkernel-next-5 >=sys-kernel/genkernel-3.4.45-r2 )
|
|
|
|
arm? ( dev-embedded/u-boot-tools sys-block/devio )
|
|
|
|
amd64? ( sys-apps/v86d )
|
|
|
|
x86? ( sys-apps/v86d )
|
|
|
|
lvm? ( sys-fs/lvm2 sys-block/thin-provisioning-tools )
|
|
|
|
dracut? ( sys-apps/v86d sys-kernel/dracut )"
|
2012-11-10 10:48:27 +01:00
|
|
|
RDEPEND="sys-apps/sed
|
|
|
|
sys-kernel/linux-firmware"
|
|
|
|
if [ -n "${K_REQUIRED_LINUX_FIRMWARE_VER}" ]; then
|
|
|
|
RDEPEND+=" >=sys-kernel/linux-firmware-${K_REQUIRED_LINUX_FIRMWARE_VER}"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
# internal function
|
|
|
|
#
|
|
|
|
# FUNCTION: _update_depmod
|
|
|
|
# @USAGE: _update_depmod <-r depmod>
|
|
|
|
# DESCRIPTION:
|
|
|
|
# It updates the modules.dep file for the current kernel.
|
|
|
|
# This is more or less the same of linux-mod update_depmod, with the
|
|
|
|
# exception of accepting parameter which is passed to depmod -r switch
|
|
|
|
_update_depmod() {
|
|
|
|
|
|
|
|
# if we haven't determined the version yet, we need too.
|
|
|
|
get_version;
|
|
|
|
|
|
|
|
ebegin "Updating module dependencies for ${KV_FULL}"
|
|
|
|
if [ -r "${KV_OUT_DIR}"/System.map ]; then
|
|
|
|
depmod -ae -F "${KV_OUT_DIR}"/System.map -b "${ROOT}" -r "${1}"
|
|
|
|
eend $?
|
|
|
|
else
|
|
|
|
ewarn
|
|
|
|
ewarn "${KV_OUT_DIR}/System.map not found."
|
|
|
|
ewarn "You must manually update the kernel module dependencies using depmod."
|
|
|
|
eend 1
|
|
|
|
ewarn
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2013-12-06 13:43:46 +01:00
|
|
|
sablink-kernel_pkg_setup() {
|
2012-11-10 10:48:27 +01:00
|
|
|
if [ -n "${K_FIRMWARE_PACKAGE}" ]; then
|
|
|
|
einfo "Preparing kernel firmwares"
|
|
|
|
else
|
|
|
|
einfo "Preparing kernel and its modules"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2013-12-06 13:43:46 +01:00
|
|
|
sablink-kernel_src_unpack() {
|
2012-11-10 10:48:27 +01:00
|
|
|
local okv="${OKV}"
|
|
|
|
if [ -n "${K_SABKERNEL_SELF_TARBALL_NAME}" ]; then
|
|
|
|
OKV="${PVR}+${K_SABKERNEL_SELF_TARBALL_NAME}"
|
|
|
|
fi
|
2013-12-06 15:46:10 +01:00
|
|
|
if [ -n "${K_SABCONFIGS_VER}" ]; then
|
2013-12-06 13:43:46 +01:00
|
|
|
unpack "${K_SABCONFIGS_PKG}"
|
|
|
|
fi
|
|
|
|
if [ "${K_KERNEL_NEW_VERSIONING}" = "1" ]; then
|
|
|
|
# workaround for kernel-2's universal_unpack assumptions
|
|
|
|
UNIPATCH_LIST_DEFAULT= KV_MAJOR=0 kernel-2_src_unpack
|
|
|
|
else
|
|
|
|
kernel-2_src_unpack
|
|
|
|
fi
|
2012-11-10 10:48:27 +01:00
|
|
|
if [ -n "${K_SABKERNEL_FORCE_SUBLEVEL}" ]; then
|
|
|
|
# patch out Makefile with proper sublevel
|
|
|
|
sed -i "s:^SUBLEVEL = .*:SUBLEVEL = ${K_SABKERNEL_FORCE_SUBLEVEL}:" \
|
|
|
|
"${S}/Makefile" || die
|
|
|
|
fi
|
2013-12-06 13:43:46 +01:00
|
|
|
|
|
|
|
#comment out Extra verion change by CK patch
|
|
|
|
sed -i -e 's/\(^EXTRAVERSION :=.*$\)/# \1/' "${S}/Makefile"
|
|
|
|
|
2012-11-10 10:48:27 +01:00
|
|
|
if [ -n "${K_SABKERNEL_RESET_EXTRAVERSION}" ]; then
|
|
|
|
sed -i "s:^EXTRAVERSION =.*:EXTRAVERSION = :" "${S}/Makefile" || die
|
|
|
|
# some sources could have multiple append-based EXTRAVERSIONs
|
|
|
|
sed -i "s/^EXTRAVERSION :=.*//" "${S}/Makefile" || die
|
|
|
|
fi
|
|
|
|
OKV="${okv}"
|
|
|
|
|
|
|
|
# Let's handle EAPIs 0 and 1...
|
|
|
|
case ${EAPI:-0} in
|
2013-12-06 13:43:46 +01:00
|
|
|
0|1) sablink-kernel_src_prepare ;;
|
2012-11-10 10:48:27 +01:00
|
|
|
esac
|
2013-12-06 13:43:46 +01:00
|
|
|
|
|
|
|
# delete empty directories
|
|
|
|
pushd "${S}"
|
|
|
|
find . -depth -type d -empty -delete
|
|
|
|
popd
|
2012-11-10 10:48:27 +01:00
|
|
|
}
|
|
|
|
|
2013-12-06 13:43:46 +01:00
|
|
|
sablink-kernel_src_prepare() {
|
2012-11-10 10:48:27 +01:00
|
|
|
_set_config_file_vars
|
|
|
|
}
|
|
|
|
|
2013-12-06 13:43:46 +01:00
|
|
|
sablink-kernel_src_compile() {
|
2012-11-10 10:48:27 +01:00
|
|
|
if [ -n "${K_FIRMWARE_PACKAGE}" ]; then
|
|
|
|
_firmwares_src_compile
|
|
|
|
elif [ -n "${K_ONLY_SOURCES}" ]; then
|
|
|
|
kernel-2_src_compile
|
|
|
|
else
|
|
|
|
_kernel_src_compile
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
_firmwares_src_compile() {
|
|
|
|
einfo "Starting to compile firmwares..."
|
|
|
|
_kernel_copy_config "${S}/.config"
|
|
|
|
cd "${S}" || die "cannot find source dir"
|
|
|
|
|
|
|
|
export LDFLAGS=""
|
|
|
|
OLDARCH="${ARCH}"
|
|
|
|
unset ARCH
|
|
|
|
emake firmware || die "cannot compile firmwares"
|
|
|
|
ARCH="${OLDARCH}"
|
|
|
|
}
|
|
|
|
|
|
|
|
_kernel_copy_config() {
|
|
|
|
_is_config_file_set \
|
2013-12-06 13:43:46 +01:00
|
|
|
|| die "Kernel configuration file not set. Was sablink-kernel_src_prepare() called?"
|
2012-11-10 10:48:27 +01:00
|
|
|
|
|
|
|
if [ -n "${K_SABKERNEL_SELF_TARBALL_NAME}" ]; then
|
2013-12-06 13:43:46 +01:00
|
|
|
local base_path="${S}/sablink/config"
|
2012-11-10 10:48:27 +01:00
|
|
|
if [ -f "${base_path}/${K_SABKERNEL_ALT_CONFIG_FILE}" ]; then
|
|
|
|
# new path, without revision
|
2013-12-06 13:43:46 +01:00
|
|
|
cp "${base_path}/${K_SABKERNEL_ALT_CONFIG_FILE}" "${1}" || die "cannot copy kernel config 1"
|
2012-11-10 10:48:27 +01:00
|
|
|
else
|
|
|
|
# PVR path (old)
|
2013-12-06 13:43:46 +01:00
|
|
|
cp "${base_path}/${K_SABKERNEL_CONFIG_FILE}" "${1}" || die "cannot copy kernel config 2"
|
2012-11-10 10:48:27 +01:00
|
|
|
fi
|
|
|
|
else
|
|
|
|
if [ "${K_SABKERNEL_URI_CONFIG}" = "no" ]; then
|
2013-12-06 13:43:46 +01:00
|
|
|
# Legacy stuff, not supporting K_KERNEL_NEW_VERSIONING
|
|
|
|
cp "${FILESDIR}/${PF/-r0/}-${ARCH}.config" "${1}" || die "cannot copy kernel config 3"
|
2012-11-10 10:48:27 +01:00
|
|
|
else
|
2013-12-06 13:43:46 +01:00
|
|
|
if [ -n "${K_SABCONFIGS_VER}" ]; then
|
|
|
|
rm -rf "${S}/sablink"
|
|
|
|
cp -rf "${WORKDIR}"/sablink "${S}"
|
|
|
|
pushd "${S}"
|
|
|
|
sablink/scripts/prepareconfig ${K_SABKERNEL_NAME}-${CHOST/-*/}
|
|
|
|
mv .config "${1}.tmp"
|
|
|
|
mv "${1}.tmp" "${1}"
|
|
|
|
popd
|
|
|
|
else
|
|
|
|
cp "${DISTDIR}/${K_SABKERNEL_CONFIG_FILE}" "${1}" || die "cannot copy kernel config 4"
|
|
|
|
fi
|
2012-11-10 10:48:27 +01:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
_kernel_src_compile() {
|
|
|
|
# disable sandbox
|
|
|
|
export SANDBOX_ON=0
|
|
|
|
|
|
|
|
# needed anyway, even if grub use flag is not used here
|
|
|
|
if use amd64 || use x86; then
|
|
|
|
mkdir -p "${WORKDIR}"/boot/grub
|
|
|
|
else
|
2013-12-06 13:43:46 +01:00
|
|
|
if use arm; then
|
|
|
|
mkdir -p "${WORKDIR}"/boot/dtb
|
|
|
|
else
|
|
|
|
mkdir -p "${WORKDIR}"/boot
|
|
|
|
fi
|
2012-11-10 10:48:27 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
einfo "Starting to compile kernel..."
|
|
|
|
_kernel_copy_config "${WORKDIR}"/config
|
|
|
|
|
|
|
|
# do some cleanup
|
|
|
|
rm -rf "${WORKDIR}"/lib
|
|
|
|
rm -rf "${WORKDIR}"/cache
|
|
|
|
rm -rf "${S}"/temp
|
|
|
|
|
|
|
|
# creating workdirs
|
|
|
|
# some kernels fail with make 3.82 if firmware dir is not created
|
|
|
|
mkdir "${WORKDIR}"/lib/lib/firmware -p
|
|
|
|
mkdir "${WORKDIR}"/cache
|
|
|
|
mkdir "${S}"/temp
|
|
|
|
|
|
|
|
cd "${S}" || die
|
2013-12-06 13:43:46 +01:00
|
|
|
local GKARGS=()
|
2014-01-18 14:57:08 +01:00
|
|
|
GKARGS+=( "--no-save-config" )
|
2015-08-10 19:25:51 +02:00
|
|
|
#GKARGS+=( "--udev" )
|
2013-12-06 13:43:46 +01:00
|
|
|
use dmraid && GKARGS+=( "--dmraid" )
|
|
|
|
use iscsi && GKARGS+=( "--iscsi" )
|
|
|
|
use mdadm && GKARGS+=( "--mdadm" )
|
|
|
|
use luks && GKARGS+=( "--luks" )
|
|
|
|
use lvm && GKARGS+=( "--lvm" )
|
|
|
|
if [ -n "${K_SABKERNEL_ZFS}" ]; then
|
|
|
|
use zfs && GKARGS+=( "--zfs" )
|
|
|
|
fi
|
2012-11-10 10:48:27 +01:00
|
|
|
|
|
|
|
export DEFAULT_KERNEL_SOURCE="${S}"
|
|
|
|
export CMD_KERNEL_DIR="${S}"
|
|
|
|
for opt in ${MAKEOPTS}; do
|
|
|
|
if [ "${opt:0:2}" = "-j" ]; then
|
|
|
|
mkopts="${opt}"
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
[ -z "${mkopts}" ] && mkopts="-j3"
|
|
|
|
|
2013-12-06 13:43:46 +01:00
|
|
|
if [ -n "${K_KERNEL_IMAGE_NAME}" ]; then
|
|
|
|
GKARGS+=( "--kernel-target=${K_KERNEL_IMAGE_NAME}" )
|
|
|
|
# elif use arm; then
|
|
|
|
# # backward compat + provide sane defaults.
|
|
|
|
# GKARGS+=( "--kernel-target=uImage" )
|
2012-11-10 10:48:27 +01:00
|
|
|
fi
|
2013-12-06 13:43:46 +01:00
|
|
|
if [ -n "${K_KERNEL_IMAGE_PATH}" ]; then
|
|
|
|
GKARGS+=( "--kernel-binary=${K_KERNEL_IMAGE_PATH}" )
|
|
|
|
# elif use arm; then
|
|
|
|
# # backward compat + provide sane defaults.
|
|
|
|
# GKARGS+=( "--kernel-binary=arch/arm/boot/uImage" )
|
2012-11-10 10:48:27 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Workaround bug in splash_geninitramfs corrupting the initramfs
|
|
|
|
# if xz compression is used (newer genkernel >3.4.24)
|
|
|
|
local support_comp=$(genkernel --help | grep compress-initramfs-type)
|
|
|
|
if [ -n "${support_comp}" ]; then
|
2013-12-06 13:43:46 +01:00
|
|
|
GKARGS+=( "--compress-initramfs-type=gzip" )
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Use --disklabel if genkernel supports it
|
|
|
|
local support_disklabel=$(genkernel --help | grep -- --disklabel)
|
|
|
|
if [ -n "${support_disklabel}" ]; then
|
|
|
|
GKARGS+=( "--disklabel" )
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -n "${K_MKIMAGE_KERNEL_ADDRESS}" ]; then
|
|
|
|
export LOADADDR="${K_MKIMAGE_KERNEL_ADDRESS}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
K_SABKERNEL_DTB="none"
|
|
|
|
|
|
|
|
#################################### ARM V5 ######################################
|
|
|
|
# Buffalo anounced a new box named Pro Live (video transcode streaming)
|
|
|
|
# so the old ls_pro_live has to be split to ls_pro ls_live
|
|
|
|
# for now let it stay but a move schould be done to ls_pro
|
|
|
|
if [ "${K_SABKERNEL_NAME}" = "buffalo_kb_pro" ]; then
|
|
|
|
devio > foo 'wl 0xe3a01c05,4' 'wl 0xe38110e5,4' # KuroBox Pro 1509
|
|
|
|
K_SABKERNEL_TYPE="buffalo"
|
|
|
|
K_SABKERNEL_DEVICE="Buffalo/Revogear Kurobox Pro"
|
|
|
|
fi
|
|
|
|
if [ "${K_SABKERNEL_NAME}" = "buffalo_ls_chl" ]; then
|
|
|
|
devio > foo 'wl 0xe3a01c0b,4' 'wl 0xe3811061,4' # Linkstation Live V3 (2.6.34) 2913
|
|
|
|
K_SABKERNEL_TYPE="buffalo"
|
|
|
|
K_SABKERNEL_DEVICE="Buffalo Linkstation LiveV3 (LS-CHL)"
|
|
|
|
fi
|
|
|
|
if [ "${K_SABKERNEL_NAME}" = "buffalo_ls_chl2" ]; then
|
|
|
|
if [[ "${KV_MAJOR}${KV_MINOR}" -ge 35 ]]; then
|
|
|
|
# new Device tree no need for devio
|
|
|
|
K_SABKERNEL_DTB="kirkwood-lschlv2.dtb"
|
|
|
|
else
|
|
|
|
devio > foo 'wl 0xe3a01c0b,4' 'wl 0xe38110be,4' # Linkstation XHL/CHLv2 3006
|
|
|
|
fi
|
|
|
|
K_SABKERNEL_TYPE="buffalo"
|
|
|
|
K_SABKERNEL_DEVICE="Buffalo Linkstation LS-CHLv2"
|
|
|
|
fi
|
|
|
|
if [ "${K_SABKERNEL_NAME}" = "buffalo_ls_hgl" ]; then
|
|
|
|
devio > foo 'wl 0xe3a01c07,4' 'wl 0xe38110d5,4' # Linkstation HGL (2.6.31) 2005
|
|
|
|
K_SABKERNEL_TYPE="buffalo"
|
|
|
|
K_SABKERNEL_DEVICE="Buffalo Linkstation LS-HGL"
|
|
|
|
fi
|
|
|
|
if [ "${K_SABKERNEL_NAME}" = "buffalo_ls_mini" ]; then
|
|
|
|
devio > foo 'wl 0xe3a01c07,4' 'wl 0xe3811042,4' # Linkstation mini (2.6.29) 1858
|
|
|
|
K_SABKERNEL_TYPE="buffalo"
|
|
|
|
K_SABKERNEL_DEVICE="Buffalo Linkstation Mini"
|
|
|
|
fi
|
|
|
|
if [ "${K_SABKERNEL_NAME}" = "buffalo_ls_pro_live" ]; then
|
|
|
|
devio > foo 'wl 0xe3a01c06,4' 'wl 0xe3811031,4' # Linkstation Pro/Live (2.6.26) 1585
|
|
|
|
K_SABKERNEL_TYPE="buffalo"
|
|
|
|
K_SABKERNEL_DEVICE="Buffalo Linkstation Pro/Live"
|
|
|
|
fi
|
|
|
|
if [ "${K_SABKERNEL_NAME}" = "buffalo_ls_pro_duo_rev1" ]; then
|
|
|
|
devio > foo 'wl 0xe3a01c07,4' 'wl 0xe3811027,4' # Linkstation Pro Duo (2.6.30) 1831
|
|
|
|
K_SABKERNEL_TYPE="buffalo"
|
|
|
|
K_SABKERNEL_DEVICE="Buffalo Linkstation Pro Duo - Revision 1"
|
|
|
|
fi
|
|
|
|
if [ "${K_SABKERNEL_NAME}" = "buffalo_ls_pro_duo_rev2" ]; then
|
|
|
|
devio > foo 'wl 0xe3a01c07,4' 'wl 0xe3811027,4' # Linkstation Pro Duo (2.6.30) 1831
|
|
|
|
K_SABKERNEL_TYPE="buffalo"
|
|
|
|
K_SABKERNEL_DEVICE="Buffalo Linkstation Pro Duo - Revision 2"
|
|
|
|
fi
|
|
|
|
if [ "${K_SABKERNEL_NAME}" = "buffalo_ls_ql" ]; then
|
|
|
|
devio > foo 'wl 0xe3a01c10,4' 'wl 0xe381108e,4' # Buffalo Linkstation Quad LSQL. Registered 2012.06.15. 4238
|
|
|
|
K_SABKERNEL_TYPE="buffalo"
|
|
|
|
K_SABKERNEL_DEVICE="Buffalo Linkstation Quad"
|
|
|
|
fi
|
|
|
|
if [ "${K_SABKERNEL_NAME}" = "buffalo_ls_vl" ]; then
|
|
|
|
devio > foo 'wl 0xe3a01c14,4' 'wl 0xe381109d,4' # Linkstation vl is not in the db so took one 5277
|
|
|
|
K_SABKERNEL_TYPE="buffalo"
|
|
|
|
K_SABKERNEL_DEVICE="Buffalo LS-VL Series"
|
|
|
|
fi
|
|
|
|
if [ "${K_SABKERNEL_NAME}" = "buffalo_ls_wvl" ]; then
|
|
|
|
if [[ "${KV_MAJOR}${KV_MINOR}" -ge 39 ]]; then
|
|
|
|
# new Device tree no need for devio
|
|
|
|
K_SABKERNEL_DTB="kirkwood-lswvl.dtb"
|
|
|
|
else
|
|
|
|
devio > foo 'wl 0xe3a01c14,4' 'wl 0xe381109e,4' # Linkstation wvl is not in the db so took one 5278
|
|
|
|
fi
|
|
|
|
K_SABKERNEL_TYPE="buffalo"
|
|
|
|
K_SABKERNEL_DEVICE="Buffalo Linkstation LS-WVL"
|
|
|
|
fi
|
|
|
|
if [ "${K_SABKERNEL_NAME}" = "buffalo_ts_wxl" ]; then
|
|
|
|
devio > foo 'wl 0xe3a01c0a,4' 'wl 0xe3811089,4' # Terastation WXL (2.6.35) 2697
|
|
|
|
K_SABKERNEL_TYPE="buffalo"
|
|
|
|
# Broken hardware name needs to be correct in u-boot firmware
|
|
|
|
K_SABKERNEL_DEVICE="Buffalo Linkstation Pro/Live"
|
|
|
|
fi
|
|
|
|
if [ "${K_SABKERNEL_NAME}" = "buffalo_ls_xhl" ]; then
|
|
|
|
if [[ "${KV_MAJOR}${KV_MINOR}" -ge 35 ]]; then
|
|
|
|
# new Device tree no need for devio
|
|
|
|
K_SABKERNEL_DTB="kirkwood-lsxhl.dtb"
|
|
|
|
else
|
|
|
|
devio > foo 'wl 0xe3a01c0a,4' 'wl 0xe3811067,4' # Linkstation XHL/CHLv2 (2.6.30) 2663
|
|
|
|
fi
|
|
|
|
K_SABKERNEL_TYPE="buffalo"
|
|
|
|
K_SABKERNEL_DEVICE="Buffalo Linkstation LS-XHL"
|
|
|
|
fi
|
|
|
|
|
|
|
|
#################################### ARM V6 ######################################
|
|
|
|
# oxnas
|
|
|
|
if [ "${K_SABKERNEL_NAME}" = "medion_stg212" ]; then
|
|
|
|
K_SABKERNEL_TYPE="default"
|
|
|
|
K_SABKERNEL_DEVICE="Oxford NAS"
|
|
|
|
K_GENKERNEL_ARGS+=" --kernel-target=uImage --kernel-binary=arch/arm/boot/uImage"
|
|
|
|
fi
|
|
|
|
if [ "${K_SABKERNEL_NAME}" = "pogoplug_pro" ]; then
|
|
|
|
K_SABKERNEL_TYPE="default"
|
|
|
|
K_SABKERNEL_DEVICE="Oxford NAS"
|
|
|
|
K_GENKERNEL_ARGS+=" --kernel-target=uImage --kernel-binary=arch/arm/boot/uImage"
|
|
|
|
fi
|
|
|
|
if [ "${K_SABKERNEL_NAME}" = "pogoplug_pro_pci" ]; then
|
|
|
|
K_SABKERNEL_TYPE="default"
|
|
|
|
K_SABKERNEL_DEVICE="Oxford NAS"
|
|
|
|
K_GENKERNEL_ARGS+=" --kernel-target=uImage --kernel-binary=arch/arm/boot/uImage"
|
|
|
|
fi
|
|
|
|
if [ "${K_SABKERNEL_NAME}" = "iomega_hmnd_ce" ]; then
|
|
|
|
K_SABKERNEL_TYPE="default"
|
|
|
|
K_SABKERNEL_DEVICE="Oxford NAS"
|
|
|
|
K_GENKERNEL_ARGS+=" --kernel-target=uImage --kernel-binary=arch/arm/boot/uImage"
|
2012-11-10 10:48:27 +01:00
|
|
|
fi
|
|
|
|
|
2013-12-06 13:43:46 +01:00
|
|
|
|
|
|
|
#################################### ARM V7 ######################################
|
|
|
|
# Freescale
|
|
|
|
if [ "${K_SABKERNEL_NAME}" = "freescale_mx53_loco" ]; then
|
|
|
|
K_SABKERNEL_TYPE="default"
|
|
|
|
K_SABKERNEL_DEVICE="Freescale MX53 LOCO Board"
|
|
|
|
K_GENKERNEL_ARGS+=" --kernel-target=uImage --kernel-binary=arch/arm/boot/uImage"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Freescale
|
|
|
|
if [ "${K_SABKERNEL_NAME}" = "pandaboard" ]; then
|
|
|
|
K_SABKERNEL_TYPE="default"
|
|
|
|
K_SABKERNEL_DEVICE="OMAP4 Panda board"
|
|
|
|
K_GENKERNEL_ARGS+=" --kernel-target=uImage --kernel-binary=arch/arm/boot/uImage"
|
|
|
|
fi
|
|
|
|
|
|
|
|
OLDARCH="${ARCH}"
|
|
|
|
unset ARCH
|
2012-11-10 10:48:27 +01:00
|
|
|
unset LDFLAGS
|
2013-12-06 13:43:46 +01:00
|
|
|
|
2013-12-06 16:13:41 +01:00
|
|
|
pushd "${S}"/3rdparty
|
|
|
|
perl ./mkbuild.pl
|
|
|
|
popd
|
2013-12-06 13:43:46 +01:00
|
|
|
|
|
|
|
DEFAULT_KERNEL_SOURCE="${S}" CMD_KERNEL_DIR="${S}" genkernel "${GKARGS[@]}" ${K_GENKERNEL_ARGS} \
|
2012-11-10 10:48:27 +01:00
|
|
|
--kerneldir="${S}" \
|
|
|
|
--kernel-config="${WORKDIR}"/config \
|
|
|
|
--cachedir="${WORKDIR}"/cache \
|
|
|
|
--makeopts="${mkopts}" \
|
|
|
|
--tempdir="${S}"/temp \
|
|
|
|
--logfile="${WORKDIR}"/genkernel.log \
|
|
|
|
--bootdir="${WORKDIR}"/boot \
|
|
|
|
--mountboot \
|
|
|
|
--module-prefix="${WORKDIR}"/lib \
|
2013-12-11 15:03:22 +01:00
|
|
|
--kernel-cc=/usr/lib/ccache/bin/${CHOST}-gcc \
|
2013-12-12 13:24:34 +01:00
|
|
|
--kernel-ld=${CHOST}-ld.bfd \
|
2012-11-10 10:48:27 +01:00
|
|
|
all || die "genkernel failed"
|
2013-12-06 13:43:46 +01:00
|
|
|
|
|
|
|
if [ -n "${K_MKIMAGE_KERNEL_ADDRESS}" ]; then
|
|
|
|
unset LOADADDR
|
|
|
|
fi
|
|
|
|
|
2012-11-10 10:48:27 +01:00
|
|
|
ARCH=${OLDARCH}
|
2013-12-06 13:43:46 +01:00
|
|
|
|
2013-12-06 16:13:41 +01:00
|
|
|
if [ "${K_SABKERNEL_DTB}" != "none" ]; then
|
|
|
|
emake ${K_SABKERNEL_DTB}
|
|
|
|
cp "${S}"/arch/arm/boot/${K_SABKERNEL_DTB} "${S}"
|
|
|
|
fi
|
|
|
|
|
2013-12-06 13:43:46 +01:00
|
|
|
# Buffalo Boxes have a special naming and start address
|
|
|
|
if [ "${K_SABKERNEL_TYPE}" = "buffalo" ]; then
|
|
|
|
if [ "${K_SABKERNEL_DTB}" = "none" ]; then
|
|
|
|
einfo "Prepend the correct Device ID to the Kenel Image"
|
2013-12-08 09:21:21 +01:00
|
|
|
cat foo "${WORKDIR}"/boot/kernel-genkernel-${ARCH}-${KV_FULL} > zImage.new
|
2013-12-06 13:43:46 +01:00
|
|
|
einfo "Create uImage of the resulting Image"
|
|
|
|
mkimage -A arm -O linux -T kernel -C none -a 0x00008000 -e 0x00008000 -n uImage-${KV_FULL} \
|
|
|
|
-d zImage.new "${WORKDIR}"/boot/uImage-genkernel-${ARCH}-${KV_FULL}.buffalo
|
|
|
|
einfo "Create uInitrd with correct start address"
|
|
|
|
mkimage -A arm -O linux -T ramdisk -C none -a 0x00000000 -e 0x00000000 -n initrd-${KV_FULL} \
|
2013-12-08 09:21:21 +01:00
|
|
|
-d "${WORKDIR}"/boot/initramfs-genkernel-${ARCH}-${KV_FULL} "${WORKDIR}"/boot/uInitramfs-genkernel-${ARCH}-${KV_FULL}.buffalo
|
2013-12-06 13:43:46 +01:00
|
|
|
else
|
|
|
|
einfo "Append the device-tree-blob to the Kenel Image"
|
2013-12-08 09:21:21 +01:00
|
|
|
cat "${WORKDIR}"/boot/kernel-genkernel-${ARCH}-${KV_FULL} "${S}"/${K_SABKERNEL_DTB} > zImage.new
|
2013-12-06 13:43:46 +01:00
|
|
|
cp "${S}"/${K_SABKERNEL_DTB} "${WORKDIR}"/boot/dtb/
|
|
|
|
einfo "Create uImage of the resulting Image"
|
|
|
|
mkimage -A arm -O linux -T kernel -C none -a 0x00008000 -e 0x00008000 -n uImage-${KV_FULL} \
|
|
|
|
-d zImage.new "${WORKDIR}"/boot/uImage-genkernel-${ARCH}-${KV_FULL}.buffalo
|
|
|
|
einfo "Create uInitrd with correct start address"
|
|
|
|
mkimage -A arm -O linux -T ramdisk -C none -a 0x00000000 -e 0x00000000 -n initrd-${KV_FULL} \
|
2013-12-08 09:21:21 +01:00
|
|
|
-d "${WORKDIR}"/boot/initramfs-genkernel-${ARCH}-${KV_FULL} "${WORKDIR}"/boot/uInitramfs-genkernel-${ARCH}-${KV_FULL}.buffalo
|
2013-12-06 13:43:46 +01:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "${K_SABKERNEL_TYPE}" = "default" ]; then
|
|
|
|
einfo "Rename Kernel Image for consistency"
|
2013-12-08 09:21:21 +01:00
|
|
|
mv "${WORKDIR}"/boot/kernel-genkernel-${ARCH}-${KV_FULL} "${WORKDIR}"/boot/uImage-genkernel-${ARCH}-${KV_FULL}
|
2013-12-06 13:43:46 +01:00
|
|
|
einfo "Create uInitrd with correct start address"
|
|
|
|
mkimage -A arm -O linux -T ramdisk -C none -a 0x00000000 -e 0x00000000 -n initrd-${KV_FULL} \
|
2013-12-08 09:21:21 +01:00
|
|
|
-d "${WORKDIR}"/boot/initramfs-genkernel-${ARCH}-${KV_FULL} "${WORKDIR}"/boot/uInitramfs-genkernel-${ARCH}-${KV_FULL}
|
2013-12-06 13:43:46 +01:00
|
|
|
fi
|
|
|
|
|
2013-12-07 21:38:54 +01:00
|
|
|
# move System.map for filname consistency
|
2013-12-08 09:21:21 +01:00
|
|
|
mv "${WORKDIR}"/boot/System.map-genkernel-${ARCH}-${KV_FULL} "${WORKDIR}"/boot/System.map-genkernel-${ARCH}-${KV_FULL}
|
2013-12-07 21:38:54 +01:00
|
|
|
|
2013-12-06 13:43:46 +01:00
|
|
|
# cleanup
|
|
|
|
rm -rf foo zImage.new ${K_SABKERNEL_DTB}
|
2013-12-08 09:21:21 +01:00
|
|
|
rm "${WORKDIR}"/boot/kernel-genkernel-${ARCH}-${KV_FULL} "${WORKDIR}"/boot/initramfs-genkernel-${ARCH}-${KV_FULL}
|
2012-11-10 10:48:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
_setup_mkimage_ramdisk() {
|
|
|
|
local initramfs=$(ls "${WORKDIR}"/boot/${KERN_INITRAMFS_SEARCH_NAME}* 2> /dev/null)
|
|
|
|
if [ ! -e "${initramfs}" ] || [ ! -f "${initramfs}" ]; then
|
|
|
|
ewarn "No initramfs at ${initramfs}, cannot run mkimage on it!"
|
2013-12-06 13:43:46 +01:00
|
|
|
elif [ "${K_MKIMAGE_WRAP_INITRAMFS}" = "1" ]; then
|
2012-11-10 10:48:27 +01:00
|
|
|
einfo "Setting up u-boot initramfs for: ${initramfs}"
|
2013-12-06 13:43:46 +01:00
|
|
|
mkimage -A arm -O linux -T ramdisk -C none -a \
|
|
|
|
"${K_MKIMAGE_RAMDISK_ADDRESS}" \
|
2012-11-10 10:48:27 +01:00
|
|
|
-e "${K_MKIMAGE_RAMDISK_ENTRYPOINT}" -d "${initramfs}" \
|
|
|
|
"${initramfs}.u-boot" || return 1
|
|
|
|
mv "${initramfs}.u-boot" "${initramfs}" || return 1
|
2013-12-06 13:43:46 +01:00
|
|
|
else
|
|
|
|
einfo "mkimage won't be called for: ${initramfs}"
|
2012-11-10 10:48:27 +01:00
|
|
|
fi
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2013-12-06 13:43:46 +01:00
|
|
|
sablink-kernel_src_install() {
|
2012-11-10 10:48:27 +01:00
|
|
|
if [ -n "${K_FIRMWARE_PACKAGE}" ]; then
|
|
|
|
_firmwares_src_install
|
|
|
|
elif [ -n "${K_ONLY_SOURCES}" ]; then
|
|
|
|
_kernel_sources_src_install
|
|
|
|
else
|
|
|
|
_kernel_src_install
|
|
|
|
fi
|
2013-12-06 13:43:46 +01:00
|
|
|
# File collisions between slots, debug stuff
|
|
|
|
# not really needed for a kernel
|
|
|
|
rm -rf "${D}/usr/lib/debug"
|
2012-11-10 10:48:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
_firmwares_src_install() {
|
|
|
|
dodir /lib/firmware
|
|
|
|
keepdir /lib/firmware
|
|
|
|
cd "${S}" || die
|
|
|
|
emake INSTALL_FW_PATH="${D}/lib/firmware" firmware_install || die "cannot install firmwares"
|
|
|
|
}
|
|
|
|
|
|
|
|
_kernel_sources_src_install() {
|
|
|
|
_kernel_copy_config ".config"
|
|
|
|
kernel-2_src_install
|
|
|
|
cd "${D}${KV_OUT_DIR}" || die
|
|
|
|
local oldarch="${ARCH}"
|
|
|
|
unset ARCH
|
|
|
|
if ! use sources_standalone; then
|
|
|
|
make modules_prepare || die "failed to run modules_prepare"
|
|
|
|
rm .config || die "cannot remove .config"
|
|
|
|
rm Makefile || die "cannot remove Makefile"
|
2013-12-06 13:43:46 +01:00
|
|
|
rm -f include/linux/version.h
|
|
|
|
rm -f include/generated/uapi/linux/version.h
|
2012-11-10 10:48:27 +01:00
|
|
|
fi
|
|
|
|
ARCH="${oldarch}"
|
|
|
|
}
|
|
|
|
|
|
|
|
_kernel_src_install() {
|
2013-12-07 10:45:15 +01:00
|
|
|
# if use arm; then
|
|
|
|
# _setup_mkimage_ramdisk || die "cannot setup mkimage"
|
|
|
|
# fi
|
2012-11-10 10:48:27 +01:00
|
|
|
|
|
|
|
dodir "${KV_OUT_DIR}"
|
|
|
|
insinto "${KV_OUT_DIR}"
|
|
|
|
|
|
|
|
_kernel_copy_config ".config"
|
|
|
|
doins ".config" || die "cannot copy kernel config"
|
|
|
|
doins Makefile || die "cannot copy Makefile"
|
|
|
|
doins Module.symvers || die "cannot copy Module.symvers"
|
|
|
|
doins System.map || die "cannot copy System.map"
|
|
|
|
|
|
|
|
# NOTE: this is a workaround caused by linux-info.eclass not
|
|
|
|
# being ported to EAPI=2 yet
|
2013-12-06 13:43:46 +01:00
|
|
|
local version_h_dir="include/linux"
|
|
|
|
local version_h_dir2="include/generated/uapi/linux"
|
|
|
|
local version_h=
|
|
|
|
local version_h_src=
|
|
|
|
for ver_dir in "${version_h_dir}" "${version_h_dir2}"; do
|
|
|
|
version_h="${ROOT}${KV_OUT_DIR/\//}/${ver_dir}/version.h"
|
|
|
|
if [ -f "${version_h}" ]; then
|
|
|
|
einfo "Discarding previously installed version.h to avoid collisions"
|
|
|
|
addwrite "${version_h}"
|
|
|
|
rm -f "${version_h}"
|
|
|
|
fi
|
2012-11-10 10:48:27 +01:00
|
|
|
|
2013-12-06 13:43:46 +01:00
|
|
|
# Include include/linux/version.h to make Portage happy
|
|
|
|
version_h_src="${S}/${ver_dir}/version.h"
|
|
|
|
if [ -f "${version_h_src}" ]; then
|
|
|
|
dodir "${KV_OUT_DIR}/${ver_dir}"
|
|
|
|
insinto "${KV_OUT_DIR}/${ver_dir}"
|
|
|
|
doins "${version_h_src}" || die "cannot copy version.h"
|
|
|
|
fi
|
|
|
|
done
|
2012-11-10 10:48:27 +01:00
|
|
|
|
|
|
|
insinto "/boot"
|
|
|
|
doins "${WORKDIR}"/boot/* || die "cannot copy /boot over"
|
|
|
|
cp -Rp "${WORKDIR}"/lib/* "${D}/" || die "cannot copy /lib over"
|
|
|
|
|
2013-12-06 13:43:46 +01:00
|
|
|
# Install dtbs if found
|
|
|
|
if use arm; then
|
|
|
|
local dtb_dir="/lib/dts/${KV_FULL}"
|
|
|
|
elog "Installing .dtbs (if any) into ${dtb_dir}"
|
|
|
|
insinto "${dtb_dir}"
|
|
|
|
local dtb=
|
|
|
|
for dtb in "${S}/arch/arm/boot/dts"/*.dtb; do
|
|
|
|
if [ -f "${dtb}" ]; then
|
|
|
|
elog "Installing dtb: ${dtb}"
|
|
|
|
doins "${dtb}"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
2012-11-10 10:48:27 +01:00
|
|
|
# This doesn't always work because KV_FULL (when K_NOSETEXTRAVERSION=1) doesn't
|
|
|
|
# reflect the real value used in Makefile
|
|
|
|
#dosym "../../..${KV_OUT_DIR}" "/lib/modules/${KV_FULL}/source" || die "cannot install source symlink"
|
|
|
|
#dosym "../../..${KV_OUT_DIR}" "/lib/modules/${KV_FULL}/build" || die "cannot install build symlink"
|
|
|
|
cd "${D}"/lib/modules/* || die "cannot enter /lib/modules directory, more than one element?"
|
|
|
|
# cleanup previous
|
|
|
|
rm -f build source || die
|
|
|
|
# create sane symlinks
|
|
|
|
ln -sf "../../..${KV_OUT_DIR}" source || die "cannot create source symlink"
|
|
|
|
ln -sf "../../..${KV_OUT_DIR}" build || die "cannot create build symlink"
|
|
|
|
cd "${S}" || die
|
|
|
|
|
|
|
|
# drop ${D}/lib/firmware, virtual/linux-firmwares provides it
|
|
|
|
rm -rf "${D}/lib/firmware"
|
|
|
|
|
|
|
|
if [ -n "${K_WORKAROUND_SOURCES_COLLISION}" ]; then
|
|
|
|
# Fixing up Makefile collision if already installed by
|
|
|
|
# openvz-sources
|
|
|
|
einfo "Workarounding source package collisions"
|
|
|
|
make_file="${KV_OUT_DIR/\//}/Makefile"
|
|
|
|
einfo "Makefile: ${make_file}"
|
|
|
|
if [ -f "${ROOT}/${make_file}" ]; then
|
|
|
|
elog "Removing ${D}/${make_file}"
|
|
|
|
rm -f "${D}/${make_file}"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Install kernel configuration information
|
|
|
|
# useful for Entropy kernel-switcher
|
2013-12-06 13:43:46 +01:00
|
|
|
# release level is enough for now
|
|
|
|
base_dir="/etc/kernels/${P}"
|
|
|
|
dodir "${base_dir}"
|
|
|
|
insinto "${base_dir}"
|
|
|
|
echo "${KV_FULL}" > "RELEASE_LEVEL"
|
|
|
|
doins "RELEASE_LEVEL"
|
|
|
|
einfo "Installing ${base_dir}/RELEASE_LEVEL file: ${KV_FULL}"
|
|
|
|
|
|
|
|
use dracut && \
|
|
|
|
_dracut_initramfs_create "${KV_FULL}"
|
|
|
|
|
|
|
|
# copy firmware config file to propper location
|
|
|
|
if [ -n "${K_SABKERNEL_SELF_TARBALL_NAME}" ]; then
|
|
|
|
local base_path="${S}/sablink/config"
|
|
|
|
cp "${base_path}/${K_SABKERNEL_FW_CONFIG_FILE}" "${D}/etc/fw_env.config.${K_SABKERNEL_NAME}" || die "cannot copy firmware config"
|
|
|
|
else
|
|
|
|
if [ "${K_SABKERNEL_URI_CONFIG}" = "no" ]; then
|
|
|
|
cp "${FILESDIR}/${PF/-r0/}-${ARCH}.config" "${D}/etc/fw_env.config.${K_SABKERNEL_NAME}" || die "cannot copy firmware config"
|
|
|
|
else
|
|
|
|
cp "${DISTDIR}/${K_SABKERNEL_FW_CONFIG_FILE}" "${D}/etc/fw_env.config.${K_SABKERNEL_NAME}" || die "cannot copy firmware config"
|
|
|
|
fi
|
2012-11-10 10:48:27 +01:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2013-12-06 13:43:46 +01:00
|
|
|
sablink-kernel_pkg_preinst() {
|
2012-11-10 10:48:27 +01:00
|
|
|
if _is_kernel_binary; then
|
|
|
|
mount-boot_pkg_preinst
|
|
|
|
fi
|
|
|
|
}
|
2013-12-06 13:43:46 +01:00
|
|
|
sablink-kernel_grub2_mkconfig() {
|
2012-11-10 10:48:27 +01:00
|
|
|
if [ -x "${ROOT}usr/sbin/grub2-mkconfig" ]; then
|
|
|
|
# Grub 2.00
|
|
|
|
"${ROOT}usr/sbin/grub2-mkconfig" -o "${ROOT}boot/grub/grub.cfg"
|
|
|
|
elif [ -x "${ROOT}sbin/grub-mkconfig" ]; then
|
|
|
|
# Grub 1.99
|
|
|
|
"${ROOT}sbin/grub-mkdevicemap" --device-map="${ROOT}boot/grub/device.map"
|
|
|
|
"${ROOT}sbin/grub-mkconfig" -o "${ROOT}boot/grub/grub.cfg"
|
|
|
|
else
|
|
|
|
echo
|
|
|
|
ewarn "Attention, Grub2 is not installed !!!"
|
|
|
|
ewarn "Grub2 bootloader configuration won't be updated"
|
|
|
|
echo
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
_get_real_extraversion() {
|
|
|
|
make_file="${ROOT}${KV_OUT_DIR}/Makefile"
|
|
|
|
local extraver=$(grep -r "^EXTRAVERSION =" "${make_file}" | cut -d "=" -f 2 | head -n 1)
|
|
|
|
local trimmed=${extraver%% }
|
|
|
|
echo ${trimmed## }
|
|
|
|
}
|
|
|
|
|
|
|
|
_get_release_level() {
|
|
|
|
if [[ -n "${K_WORKAROUND_USE_REAL_EXTRAVERSION}" ]]; then
|
|
|
|
echo "${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}$(_get_real_extraversion)"
|
|
|
|
elif [[ "${KV_MAJOR}${KV_MINOR}" -eq 26 ]]; then
|
|
|
|
echo "${KV_FULL}"
|
|
|
|
elif [[ "${OKV/.*}" = "3" ]] && [[ "${KV_PATCH}" = "0" ]]; then
|
2013-12-06 13:43:46 +01:00
|
|
|
# Linux 3.x support, KV_FULL is set to: 3.0-sablink
|
2012-11-10 10:48:27 +01:00
|
|
|
# need to add another final .0 to the version part
|
|
|
|
echo "${KV_FULL/-/.0-}"
|
|
|
|
else
|
|
|
|
echo "${KV_FULL}"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2013-12-06 13:43:46 +01:00
|
|
|
sablink-kernel_uimage_config() {
|
2012-11-10 10:48:27 +01:00
|
|
|
# Two cases here:
|
|
|
|
# 1. /boot/uImage symlink is broken (pkg_postrm)
|
|
|
|
# 2. /boot/uImage symlink doesn't exist (pkg_postinst)
|
|
|
|
|
|
|
|
if ! has_version app-admin/eselect-uimage; then
|
|
|
|
ewarn "app-admin/eselect-uimage not installed"
|
|
|
|
ewarn "If you are using this tool, please install it"
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
local uimage_file=$(eselect uimage show --quiet 2> /dev/null)
|
|
|
|
if [ -z "${uimage_file}" ]; then
|
|
|
|
# pick the first listed, sorry!
|
|
|
|
local eselect_list=$(eselect uimage list --quiet 2> /dev/null)
|
|
|
|
if [ -n "${eselect_list}" ]; then
|
|
|
|
eselect uimage set 1
|
|
|
|
else
|
|
|
|
echo
|
|
|
|
ewarn "No more kernels available, you won't be able to boot"
|
|
|
|
echo
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo
|
2013-12-06 13:43:46 +01:00
|
|
|
elog "If you use eselect-bzimage, you are currently booting with kernel:"
|
2012-11-10 10:48:27 +01:00
|
|
|
elog "${uimage_file}"
|
|
|
|
elog
|
|
|
|
elog "Use 'eselect uimage' in order to switch between the available ones"
|
|
|
|
echo
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2013-12-06 13:43:46 +01:00
|
|
|
sablink-kernel_bzimage_config() {
|
2012-11-10 10:48:27 +01:00
|
|
|
# Two cases here:
|
|
|
|
# 1. /boot/bzImage symlink is broken (pkg_postrm)
|
|
|
|
# 2. /boot/bzImage symlink doesn't exist (pkg_postinst)
|
|
|
|
local kern_arch
|
|
|
|
use x86 && kern_arch="x86"
|
|
|
|
use amd64 && kern_arch="x86_64"
|
|
|
|
|
|
|
|
if ! has_version app-admin/eselect-bzimage; then
|
|
|
|
ewarn "app-admin/eselect-bzimage not installed"
|
|
|
|
ewarn "If you are using this tool, please install it"
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
local bzimage_file=$(eselect bzimage show --quiet 2> /dev/null)
|
|
|
|
if [ -z "${bzimage_file}" ]; then
|
|
|
|
# try to pic what's being installed
|
|
|
|
local eselect_list=$(eselect bzimage list --quiet 2> /dev/null)
|
|
|
|
if [ -n "${eselect_list}" ]; then
|
|
|
|
eselect bzimage set "kernel-genkernel-${kern_arch}-${KV_FULL}"
|
|
|
|
if [ "${?}" != "0" ]; then
|
|
|
|
# pick the first available, sorry!
|
|
|
|
echo
|
|
|
|
eselect bzimage set 1
|
|
|
|
ewarn "Unable to select the right kernel, falling back"
|
|
|
|
ewarn "to the first available entry. You have been warned"
|
|
|
|
echo
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo
|
|
|
|
ewarn "No more kernels available, you might not be able to boot"
|
|
|
|
echo
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo
|
|
|
|
ewarn "You are currently booting with kernel:"
|
|
|
|
ewarn "${bzimage_file}"
|
|
|
|
ewarn
|
|
|
|
ewarn "Use 'eselect bzimage' in order to switch between the available ones"
|
|
|
|
echo
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2013-12-06 13:43:46 +01:00
|
|
|
_dracut_initramfs_create() {
|
|
|
|
local kver="${1}"
|
|
|
|
|
|
|
|
elog "Creating dracut initramfs for ${kver}"
|
|
|
|
addpredict /etc/ld.so.cache~
|
|
|
|
dracut -q -N -f --kver="${kver}" "${D}/boot/initramfs-dracut-${kver}"
|
|
|
|
}
|
|
|
|
|
|
|
|
sablink-kernel_pkg_postinst() {
|
2012-11-10 10:48:27 +01:00
|
|
|
if _is_kernel_binary; then
|
|
|
|
fstab_file="${ROOT}etc/fstab"
|
|
|
|
einfo "Removing extents option for ext4 drives from ${fstab_file}"
|
|
|
|
# Remove "extents" from /etc/fstab
|
|
|
|
if [ -f "${fstab_file}" ]; then
|
|
|
|
sed -i '/ext4/ s/extents//g' "${fstab_file}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Add kernel to grub.conf
|
|
|
|
if use amd64 || use x86; 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
|
|
|
|
|
2013-12-06 13:43:46 +01:00
|
|
|
sablink-kernel_grub2_mkconfig
|
2012-11-10 10:48:27 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Setup newly installed kernel on ARM
|
|
|
|
if use arm; then
|
2013-12-06 13:43:46 +01:00
|
|
|
sablink-kernel_uimage_config
|
2012-11-10 10:48:27 +01:00
|
|
|
fi
|
|
|
|
# Setup newly installed kernel on x86/amd64
|
|
|
|
# This is quite handy for static grub1/grub2
|
|
|
|
# configurations (like on Amazon EC2)
|
|
|
|
if use x86 || use amd64; then
|
2013-12-06 13:43:46 +01:00
|
|
|
sablink-kernel_bzimage_config
|
2012-11-10 10:48:27 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
kernel-2_pkg_postinst
|
|
|
|
local depmod_r=$(_get_release_level)
|
|
|
|
_update_depmod "${depmod_r}"
|
|
|
|
|
|
|
|
elog "Please report kernel bugs at:"
|
2013-12-06 13:43:46 +01:00
|
|
|
elog "http://bugs.sablink.org"
|
2012-11-10 10:48:27 +01:00
|
|
|
|
|
|
|
elog "The source code of this kernel is located at"
|
|
|
|
elog "=${K_KERNEL_SOURCES_PKG}."
|
2013-12-06 13:43:46 +01:00
|
|
|
elog "Sablink Linux recommends that portage users install"
|
2012-11-10 10:48:27 +01:00
|
|
|
elog "${K_KERNEL_SOURCES_PKG} if you want"
|
|
|
|
elog "to build any packages that install kernel modules"
|
|
|
|
elog "(such as ati-drivers, nvidia-drivers, virtualbox, etc...)."
|
2013-12-06 13:43:46 +01:00
|
|
|
|
|
|
|
# copy the firmware config for the actual hardware to the right place
|
|
|
|
device=$(grep "Hardware[[:space:]]*:" /proc/cpuinfo 2>/dev/null | head -n1 | sed "s/^[^:]*: //")
|
|
|
|
if [ "${K_SABKERNEL_DEVICE}" = "$device" ]; then
|
|
|
|
cp ${ROOT}/etc/fw_env.config.${K_SABKERNEL_NAME} ${ROOT}/etc/fw_env.config
|
|
|
|
fi
|
2012-11-10 10:48:27 +01:00
|
|
|
else
|
|
|
|
kernel-2_pkg_postinst
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2013-12-06 13:43:46 +01:00
|
|
|
sablink-kernel_pkg_prerm() {
|
2012-11-10 10:48:27 +01:00
|
|
|
if _is_kernel_binary; then
|
|
|
|
mount-boot_pkg_prerm
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2013-12-06 13:43:46 +01:00
|
|
|
sablink-kernel_pkg_postrm() {
|
2012-11-10 10:48:27 +01:00
|
|
|
if _is_kernel_binary; then
|
|
|
|
# Remove kernel from grub.conf
|
|
|
|
if use amd64 || use x86; 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
|
|
|
|
|
2013-12-06 13:43:46 +01:00
|
|
|
sablink-kernel_grub2_mkconfig
|
2012-11-10 10:48:27 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Setup newly installed kernel on ARM
|
|
|
|
if use arm; then
|
2013-12-06 13:43:46 +01:00
|
|
|
sablink-kernel_uimage_config
|
2012-11-10 10:48:27 +01:00
|
|
|
fi
|
|
|
|
# Setup newly installed kernel on x86/amd64
|
|
|
|
# This is quite handy for static grub1/grub2
|
|
|
|
# configurations (like on Amazon EC2)
|
|
|
|
if use x86 || use amd64; then
|
2013-12-06 13:43:46 +01:00
|
|
|
sablink-kernel_bzimage_config
|
2012-11-10 10:48:27 +01:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# export all the available functions here
|
|
|
|
case ${EAPI:-0} in
|
|
|
|
0|1) extra_export_funcs= ;;
|
|
|
|
*) extra_export_funcs=src_prepare ;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
EXPORT_FUNCTIONS pkg_setup src_unpack ${extra_export_funcs} \
|
|
|
|
src_compile src_install pkg_preinst pkg_postinst pkg_prerm pkg_postrm
|