--- sablink-kernel.eclass 2014-12-08 14:16:23.384596162 +0100 +++ sablink-kernel.eclass.old 2014-01-18 14:56:43.493014069 +0100 @@ -1,33 +1,39 @@ -# Copyright 2004-2010 sablink Project +# Copyright 2004-2010 Sabayon Project +# Copyright 2013 Sablink Project # Distributed under the terms of the GNU General Public License v2 # $ +# @ECLASS-VARIABLE: K_SABPATCHES_VER +# @DESCRIPTION: +# The version of the sablink 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 # @DESCRIPTION: # The kernel name used by the ebuild, it should be the ending ${PN} part # for example, of linux-sablink it is "${PN/${PN/-*}-}" (sablink) 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 # on the "sablink" mirror, set this variable to the extension name (see example # below). This will disable ALL the extra/local patches (since they have to -# be applied inside the tarball). Moreover, K_SABKERNEL_NAME, -# K_KERNEL_PATCH_VER will be ignored. +# be applied inside the tarball). Moreover, K_SABKERNEL_URI_CONFIG, +# K_SABPATCHES_VER, K_SABKERNEL_NAME, K_KERNEL_PATCH_VER will be ignored. # Example: # K_SABKERNEL_SELF_TARBALL_NAME="sablink" # This would generate: # SRC_URI="mirror://sablink/sys-kernel/linux-${PV}+sablink.tar.${K_TARBALL_EXT}" K_SABKERNEL_SELF_TARBALL_NAME="${K_SABKERNEL_SELF_TARBALL_NAME:-}" -# @ECLASS-VARIABLE: K_SABKERNEL_PATCH_UPSTREAM_TARBALL -# @DESCRIPTION: -# If set to 1, the ebuild will fetch the upstream kernel tarball and -# apply the sablink patch against it. This strategy avoids the need of -# creating complete kernel source tarballs. The default value is 0. -K_SABKERNEL_PATCH_UPSTREAM_TARBALL="${K_SABKERNEL_PATCH_UPSTREAM_TARBALL:-0}" - # @ECLASS-VARIABLE: K_SABKERNEL_FORCE_SUBLEVEL # @DESCRIPTION: # Force the rewrite of SUBLEVEL in kernel sources Makefile @@ -177,13 +183,13 @@ CKV="$(get_version_component_range 1-2)" fi -inherit eutils multilib kernel-2 sablink-artwork mount-boot linux-info +inherit eutils multilib kernel-2 mount-boot linux-info # from kernel-2 eclass detect_version detect_arch -DESCRIPTION="sablink Linux kernel functions and phases" +DESCRIPTION="Sablink Linux kernel functions and phases" K_LONGTERM_URL_STR="" @@ -192,15 +198,14 @@ fi ## kernel-2 eclass settings -if [ "${K_SABKERNEL_PATCH_UPSTREAM_TARBALL}" = "1" ]; then - _patch_name="$(get_version_component_range 1-2)-${K_SABKERNEL_SELF_TARBALL_NAME}-${PVR}.patch.xz" - SRC_URI="${KERNEL_URI} - mirror://sablink/${CATEGORY}/${_patch_name} - " - UNIPATCH_LIST="${UNIPATCH_LIST} ${DISTDIR}/${_patch_name}" - unset _patch_name -elif [ -n "${K_SABKERNEL_SELF_TARBALL_NAME}" ]; then +if [ -n "${K_SABKERNEL_SELF_TARBALL_NAME}" ]; then SRC_URI="mirror://sablink/${CATEGORY}/linux-${PVR}+${K_SABKERNEL_SELF_TARBALL_NAME}.tar.${K_TARBALL_EXT}" +elif [ -n "${K_SABPATCHES_VER}" ]; then + UNIPATCH_STRICTORDER="yes" + K_SABPATCHES_PKG="sablink-patches-${PV}-${K_SABPATCHES_VER}.tar.${K_TARBALL_EXT}" + UNIPATCH_LIST="${DISTFILES}/${K_SABPATCHES_PKG}" + SRC_URI="${KERNEL_URI} + mirror://sablink/${CATEGORY}/linux-sablink-patches/${K_SABPATCHES_PKG}" else SRC_URI="${KERNEL_URI}" fi @@ -215,7 +220,7 @@ fi fi if [ -n "${K_KERNEL_PATCH_HOTFIXES}" ]; then - UNIPATCH_LIST="${UNIPATCH_LIST} ${K_KERNEL_PATCH_HOTFIXES}" + UNIPATCH_LIST="${K_KERNEL_PATCH_HOTFIXES} ${UNIPATCH_LIST}" fi _get_real_kv_full() { @@ -280,11 +285,22 @@ [ "${_ver}" = "3.2" ] && return 0 [ "${_ver}" = "3.4" ] && return 0 [ "${_ver}" = "3.10" ] && return 0 - [ "${_ver}" = "3.12" ] && return 0 - [ "${_ver}" = "3.14" ] && return 0 return 1 } +# 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 +} + # provide extra virtual pkg if _is_kernel_binary; then PROVIDE="virtual/linux-binary" @@ -295,39 +311,40 @@ fi if [ -n "${K_SABKERNEL_SELF_TARBALL_NAME}" ]; then - HOMEPAGE="https://github.com/sablink/kernel" + HOMEPAGE="http://git.disconnected-by-peer.at/sablink/kernel/" else HOMEPAGE="http://www.sablink.org" 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 + 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}" + K_ARM_ARCH=$(_get_arm_subarch) + SRC_URI="${SRC_URI} + 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} )" + 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 + # K_SABKERNEL_CONFIG_FILE will be set in _set_config_file_vars + unset tmp_K_SABKERNEL_CONFIG_FILE + unset tmp_K_SABKERNEL_FW_CONFIG_FILE + fi +fi + # Returns success if _set_config_file_vars was called. _is_config_file_set() { [[ ${_config_file_set} = 1 ]] } -# 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 -} - -_get_arch() { - if use arm; then - _get_arm_subarch - elif use amd64; then - echo "amd64" - elif use x86; then - echo "x86" - fi -} - _set_config_file_vars() { # Setup kernel configuration file name local pvr="${PVR}" @@ -339,11 +356,35 @@ pvr+="-${PR}" fi fi - - K_SABKERNEL_CONFIG_FILES=() - K_SABKERNEL_CONFIG_FILES+=( "${K_SABKERNEL_NAME}-${pvr}-$(_get_arch).config" ) - K_SABKERNEL_CONFIG_FILES+=( "${K_SABKERNEL_NAME}-${pv}-$(_get_arch).config" ) - K_SABKERNEL_CONFIG_FILES+=( "${K_SABKERNEL_NAME}-$(_get_arch).config" ) + if [ -z "${K_SABKERNEL_SELF_TARBALL_NAME}" ]; then + if [ "${K_SABKERNEL_URI_CONFIG}" = "yes" ]; then + 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)} + use arm && K_SABKERNEL_FW_CONFIG_FILE=${K_SABKERNEL_FW_CONFIG_FILE/__ARCH__/arm} + use amd64 && K_SABKERNEL_CONFIG_FILE="${K_SABKERNEL_CONFIG_FILE/__ARCH__/amd64}" + use x86 && K_SABKERNEL_CONFIG_FILE="${K_SABKERNEL_CONFIG_FILE/__ARCH__/x86}" + else + 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}" + fi + else + 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}" + if use amd64; then + K_SABKERNEL_CONFIG_FILE="${K_SABKERNEL_CONFIG_FILE/__ARCH__/amd64}" + K_SABKERNEL_ALT_CONFIG_FILE="${K_SABKERNEL_ALT_CONFIG_FILE/__ARCH__/amd64}" + elif use x86; then + K_SABKERNEL_CONFIG_FILE="${K_SABKERNEL_CONFIG_FILE/__ARCH__/x86}" + K_SABKERNEL_ALT_CONFIG_FILE="${K_SABKERNEL_ALT_CONFIG_FILE/__ARCH__/x86}" + elif use arm; then + 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)}" + K_SABKERNEL_FW_CONFIG_FILE="${K_SABKERNEL_FW_CONFIG_FILE/__ARCH__/arm}" + fi + fi _config_file_set=1 } @@ -353,7 +394,7 @@ DEPEND="sys-apps/sed" RDEPEND="${RDEPEND}" else - IUSE="dmraid dracut iscsi luks lvm mdadm plymouth splash" + IUSE="dmraid dracut iscsi luks lvm mdadm" if [ -n "${K_SABKERNEL_ZFS}" ]; then IUSE="${IUSE} zfs" fi @@ -361,16 +402,13 @@ sys-apps/sed sys-devel/autoconf sys-devel/make + sys-fs/dosfstools + dev-util/ccache || ( >=sys-kernel/genkernel-next-5 >=sys-kernel/genkernel-3.4.45-r2 ) - arm? ( dev-embedded/u-boot-tools ) + arm? ( dev-embedded/u-boot-tools sys-block/devio ) amd64? ( sys-apps/v86d ) x86? ( sys-apps/v86d ) - splash? ( x11-themes/sablink-artwork-core ) lvm? ( sys-fs/lvm2 sys-block/thin-provisioning-tools ) - plymouth? ( - || ( >=sys-kernel/genkernel-next-5 >=sys-kernel/genkernel-5 ) - sys-boot/plymouth - ) dracut? ( sys-apps/v86d sys-kernel/dracut )" RDEPEND="sys-apps/sed sys-kernel/linux-firmware" @@ -415,9 +453,12 @@ sablink-kernel_src_unpack() { local okv="${OKV}" - if [ -n "${K_SABKERNEL_SELF_TARBALL_NAME}" ] && [ "${K_SABKERNEL_PATCH_UPSTREAM_TARBALL}" != "1" ]; then + if [ -n "${K_SABKERNEL_SELF_TARBALL_NAME}" ]; then OKV="${PVR}+${K_SABKERNEL_SELF_TARBALL_NAME}" fi + if [ -n "${K_SABCONFIGS_VER}" ]; then + 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 @@ -429,6 +470,10 @@ sed -i "s:^SUBLEVEL = .*:SUBLEVEL = ${K_SABKERNEL_FORCE_SUBLEVEL}:" \ "${S}/Makefile" || die fi + + #comment out Extra verion change by CK patch + sed -i -e 's/\(^EXTRAVERSION :=.*$\)/# \1/' "${S}/Makefile" + if [ -n "${K_SABKERNEL_RESET_EXTRAVERSION}" ]; then sed -i "s:^EXTRAVERSION =.*:EXTRAVERSION = :" "${S}/Makefile" || die # some sources could have multiple append-based EXTRAVERSIONs @@ -440,6 +485,11 @@ case ${EAPI:-0} in 0|1) sablink-kernel_src_prepare ;; esac + + # delete empty directories + pushd "${S}" + find . -depth -type d -empty -delete + popd } sablink-kernel_src_prepare() { @@ -472,22 +522,33 @@ _is_config_file_set \ || die "Kernel configuration file not set. Was sablink-kernel_src_prepare() called?" - local base_path="${DISTDIR}" if [ -n "${K_SABKERNEL_SELF_TARBALL_NAME}" ]; then - base_path="${S}/sablink/config" - fi - - local found= cfg= - for cfg in "${K_SABKERNEL_CONFIG_FILES[@]}"; do - cfg="${base_path}/${cfg}" - if [ -f "${cfg}" ]; then - cp "${cfg}" "${1}" || die "cannot copy kernel config ${cfg} -> ${1}" - elog "Using kernel config: ${cfg}" - found=1 - break + local base_path="${S}/sablink/config" + if [ -f "${base_path}/${K_SABKERNEL_ALT_CONFIG_FILE}" ]; then + # new path, without revision + cp "${base_path}/${K_SABKERNEL_ALT_CONFIG_FILE}" "${1}" || die "cannot copy kernel config 1" + else + # PVR path (old) + cp "${base_path}/${K_SABKERNEL_CONFIG_FILE}" "${1}" || die "cannot copy kernel config 2" fi - done - [[ -z "${found}" ]] && die "cannot find kernel configs among: ${K_SABKERNEL_CONFIG_FILES[*]}" + else + if [ "${K_SABKERNEL_URI_CONFIG}" = "no" ]; then + # Legacy stuff, not supporting K_KERNEL_NEW_VERSIONING + cp "${FILESDIR}/${PF/-r0/}-${ARCH}.config" "${1}" || die "cannot copy kernel config 3" + else + 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 + fi + fi } _kernel_src_compile() { @@ -498,7 +559,11 @@ if use amd64 || use x86; then mkdir -p "${WORKDIR}"/boot/grub else - mkdir -p "${WORKDIR}"/boot + if use arm; then + mkdir -p "${WORKDIR}"/boot/dtb + else + mkdir -p "${WORKDIR}"/boot + fi fi einfo "Starting to compile kernel..." @@ -517,9 +582,8 @@ cd "${S}" || die local GKARGS=() - GKARGS+=( "--no-save-config" "--e2fsprogs" "--udev" ) - use splash && GKARGS+=( "--splash=sablink" ) - use plymouth && GKARGS+=( "--plymouth" "--plymouth-theme=${PLYMOUTH_THEME}" ) + GKARGS+=( "--no-save-config" ) + GKARGS+=( "--udev" ) use dmraid && GKARGS+=( "--dmraid" ) use iscsi && GKARGS+=( "--iscsi" ) use mdadm && GKARGS+=( "--mdadm" ) @@ -541,15 +605,15 @@ 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" ) +# elif use arm; then +# # backward compat + provide sane defaults. +# GKARGS+=( "--kernel-target=uImage" ) fi 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" ) +# elif use arm; then +# # backward compat + provide sane defaults. +# GKARGS+=( "--kernel-binary=arch/arm/boot/uImage" ) fi # Workaround bug in splash_geninitramfs corrupting the initramfs @@ -568,9 +632,142 @@ 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" + fi + + + #################################### 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 unset LDFLAGS + + pushd "${S}"/3rdparty + perl ./mkbuild.pl + popd + DEFAULT_KERNEL_SOURCE="${S}" CMD_KERNEL_DIR="${S}" genkernel "${GKARGS[@]}" ${K_GENKERNEL_ARGS} \ --kerneldir="${S}" \ --kernel-config="${WORKDIR}"/config \ @@ -581,6 +778,8 @@ --bootdir="${WORKDIR}"/boot \ --mountboot \ --module-prefix="${WORKDIR}"/lib \ + --kernel-cc=/usr/lib/ccache/bin/${CHOST}-gcc \ + --kernel-ld=${CHOST}-ld.bfd \ all || die "genkernel failed" if [ -n "${K_MKIMAGE_KERNEL_ADDRESS}" ]; then @@ -588,6 +787,50 @@ fi ARCH=${OLDARCH} + + if [ "${K_SABKERNEL_DTB}" != "none" ]; then + emake ${K_SABKERNEL_DTB} + cp "${S}"/arch/arm/boot/${K_SABKERNEL_DTB} "${S}" + fi + + # 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" + cat foo "${WORKDIR}"/boot/kernel-genkernel-${ARCH}-${KV_FULL} > zImage.new + 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} \ + -d "${WORKDIR}"/boot/initramfs-genkernel-${ARCH}-${KV_FULL} "${WORKDIR}"/boot/uInitramfs-genkernel-${ARCH}-${KV_FULL}.buffalo + else + einfo "Append the device-tree-blob to the Kenel Image" + cat "${WORKDIR}"/boot/kernel-genkernel-${ARCH}-${KV_FULL} "${S}"/${K_SABKERNEL_DTB} > zImage.new + 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} \ + -d "${WORKDIR}"/boot/initramfs-genkernel-${ARCH}-${KV_FULL} "${WORKDIR}"/boot/uInitramfs-genkernel-${ARCH}-${KV_FULL}.buffalo + fi + fi + + if [ "${K_SABKERNEL_TYPE}" = "default" ]; then + einfo "Rename Kernel Image for consistency" + mv "${WORKDIR}"/boot/kernel-genkernel-${ARCH}-${KV_FULL} "${WORKDIR}"/boot/uImage-genkernel-${ARCH}-${KV_FULL} + einfo "Create uInitrd with correct start address" + mkimage -A arm -O linux -T ramdisk -C none -a 0x00000000 -e 0x00000000 -n initrd-${KV_FULL} \ + -d "${WORKDIR}"/boot/initramfs-genkernel-${ARCH}-${KV_FULL} "${WORKDIR}"/boot/uInitramfs-genkernel-${ARCH}-${KV_FULL} + fi + + # move System.map for filname consistency + mv "${WORKDIR}"/boot/System.map-genkernel-${ARCH}-${KV_FULL} "${WORKDIR}"/boot/System.map-genkernel-${ARCH}-${KV_FULL} + + # cleanup + rm -rf foo zImage.new ${K_SABKERNEL_DTB} + rm "${WORKDIR}"/boot/kernel-genkernel-${ARCH}-${KV_FULL} "${WORKDIR}"/boot/initramfs-genkernel-${ARCH}-${KV_FULL} } _setup_mkimage_ramdisk() { @@ -644,9 +887,9 @@ } _kernel_src_install() { - if use arm; then - _setup_mkimage_ramdisk || die "cannot setup mkimage" - fi +# if use arm; then +# _setup_mkimage_ramdisk || die "cannot setup mkimage" +# fi dodir "${KV_OUT_DIR}" insinto "${KV_OUT_DIR}" @@ -737,6 +980,18 @@ 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 + fi } sablink-kernel_pkg_preinst() { @@ -873,9 +1128,6 @@ sed -i '/ext4/ s/extents//g' "${fstab_file}" fi - # Update kernel initramfs to match user customizations - use splash && update_sablink_kernel_initramfs_splash - # Add kernel to grub.conf if use amd64 || use x86; then if use amd64; then @@ -913,10 +1165,16 @@ elog "The source code of this kernel is located at" elog "=${K_KERNEL_SOURCES_PKG}." - elog "sablink Linux recommends that portage users install" + elog "Sablink Linux recommends that portage users install" 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...)." + + # 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 else kernel-2_pkg_postinst fi