--- sabayon-kernel.eclass 2013-12-06 10:17:33.000000000 +0100 +++ nas-kernel.eclass 2013-11-10 23:18:44.459733043 +0100 @@ -2,51 +2,51 @@ # 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 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 +# @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-sablink it is "${PN/${PN/-*}-}" (sablink) +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_SABKERNEL_SELF_TARBALL_NAME +# @ECLASS-VARIABLE: K_NASKERNEL_SELF_TARBALL_NAME # @DESCRIPTION: # If the main kernel sources tarball is generated in-house and available -# on the "sabayon" mirror, set this variable to the extension name (see example +# 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_URI_CONFIG, -# K_SABPATCHES_VER, K_SABKERNEL_NAME, K_KERNEL_PATCH_VER will be ignored. +# be applied inside the tarball). Moreover, K_NASKERNEL_URI_CONFIG, +# K_NASPATCHES_VER, K_NASKERNEL_NAME, K_KERNEL_PATCH_VER will be ignored. # Example: -# K_SABKERNEL_SELF_TARBALL_NAME="sabayon" +# K_NASKERNEL_SELF_TARBALL_NAME="sablink" # This would generate: -# SRC_URI="mirror://sabayon/sys-kernel/linux-${PV}+sabayon.tar.bz2" -K_SABKERNEL_SELF_TARBALL_NAME="${K_SABKERNEL_SELF_TARBALL_NAME:-}" +# SRC_URI="mirror://sablink/sys-kernel/linux-${PV}+sablink.tar.bz2" +K_NASKERNEL_SELF_TARBALL_NAME="${K_NASKERNEL_SELF_TARBALL_NAME:-}" -# @ECLASS-VARIABLE: K_SABKERNEL_FORCE_SUBLEVEL +# @ECLASS-VARIABLE: K_NASKERNEL_FORCE_SUBLEVEL # @DESCRIPTION: # Force the rewrite of SUBLEVEL in kernel sources Makefile -K_SABKERNEL_FORCE_SUBLEVEL="${K_SABKERNEL_FORCE_SUBLEVEL:-}" +K_NASKERNEL_FORCE_SUBLEVEL="${K_NASKERNEL_FORCE_SUBLEVEL:-}" -# @ECLASS-VARIABLE: K_SABKERNEL_RESET_EXTRAVERSION +# @ECLASS-VARIABLE: K_NASKERNEL_RESET_EXTRAVERSION # @DESCRIPTION: # Force the rewrite of EXTRAVERSION in kernel sources Makefile (setting it to "") -K_SABKERNEL_RESET_EXTRAVERSION="${K_SABKERNEL_RESET_EXTRAVERSION:-}" +K_NASKERNEL_RESET_EXTRAVERSION="${K_NASKERNEL_RESET_EXTRAVERSION:-}" -# @ECLASS-VARIABLE: K_SABKERNEL_LONGTERM +# @ECLASS-VARIABLE: K_NASKERNEL_LONGTERM # @DESCRIPTION: # Consider Kernel stable patchset as longterm (changing URL) -K_SABKERNEL_LONGTERM="${K_SABKERNEL_LONGTERM:-}" +K_NASKERNEL_LONGTERM="${K_NASKERNEL_LONGTERM:-}" # @ECLASS-VARIABLE: K_KERNEL_SOURCES_PKG # @DESCRIPTION: @@ -82,7 +82,7 @@ # 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:-}" @@ -127,40 +127,40 @@ # [ARM ONLY] Provide the ramdisk entry point address to be used with mkimage K_MKIMAGE_RAMDISK_ENTRYPOINT="${K_MKIMAGE_RAMDISK_ENTRYPOINT:-}" -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 ETYPE="sources" -inherit eutils kernel-2 sabayon-artwork mount-boot linux-info +inherit eutils kernel-2 mount-boot linux-info # from kernel-2 eclass detect_version detect_arch -DESCRIPTION="Sabayon Linux kernel functions and phases" +DESCRIPTION="sablink Linux kernel functions and phases" K_LONGTERM_URL_STR="" -if [ -n "${K_SABKERNEL_LONGTERM}" ]; then +if [ -n "${K_NASKERNEL_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 - SRC_URI="mirror://sabayon/${CATEGORY}/linux-${PVR}+${K_SABKERNEL_SELF_TARBALL_NAME}.tar.bz2" -elif [ -n "${K_SABPATCHES_VER}" ]; then +if [ -n "${K_NASKERNEL_SELF_TARBALL_NAME}" ]; then + SRC_URI="mirror://sablink/${CATEGORY}/linux-${PVR}+${K_NASKERNEL_SELF_TARBALL_NAME}.tar.bz2" +elif [ -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} - mirror://sabayon/${CATEGORY}/linux-sabayon-patches/${K_SABPATCHES_PKG}" + mirror://sablink/${CATEGORY}/linux-nas-patches/${K_NASPATCHES_PKG}" else SRC_URI="${KERNEL_URI}" fi -if [ -z "${K_SABKERNEL_SELF_TARBALL_NAME}" ]; then +if [ -z "${K_NASKERNEL_SELF_TARBALL_NAME}" ]; then if [ -n "${K_KERNEL_PATCH_VER}" ]; then K_PATCH_NAME="patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}.${K_KERNEL_PATCH_VER}.bz2" SRC_URI="${SRC_URI} @@ -173,22 +173,24 @@ 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 - # Linux 3.x support, KV_FULL is set to: 3.0-sabayon + # Linux 3.x support, KV_FULL is set to: 3.0-sablink # need to add another final .0 to the version part - echo "${ORIGINAL_KV_FULL/-/.0-}" + # echo "${ORIGINAL_KV_FULL/-/.0-}" + echo "${ORIGINAL_KV_FULL}" else echo "${ORIGINAL_KV_FULL}" 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 "sablink" or "server" or "openvz" +KV_FULL="${KV_FULL/${PN/-*}/${K_NASKERNEL_NAME}}" +EXTRAVERSION="${EXTRAVERSION/${PN/-*}/${K_NASKERNEL_NAME}}" # drop -rX if exists if [[ -n "${PR//r0}" ]] && [[ "${K_KERNEL_DISABLE_PR_EXTRAVERSION}" = "1" ]] \ && [[ -z "${K_NOSETEXTRAVERSION}" ]]; then @@ -201,7 +203,7 @@ KV_FULL="$(_get_real_kv_full)" # Starting from linux-3.0, we still have to install -# sources stuff into /usr/src/linux-3.0.0-sabayon (example) +# sources stuff into /usr/src/linux-3.0.0-sablink (example) # where the last part must always match uname -r # otherwise kernel-switcher (and RELEASE_LEVEL file) # will complain badly @@ -232,22 +234,29 @@ PROVIDE="virtual/linux-binary" fi -if [ -n "${K_SABKERNEL_SELF_TARBALL_NAME}" ]; then - HOMEPAGE="http://gitweb.sabayon.org/?p=linux/kernel/sabayon.git;a=summary" +if [ -n "${K_NASKERNEL_SELF_TARBALL_NAME}" ]; then + HOMEPAGE="http://gitweb.sablink.org/?p=linux/kernel/sablink.git;a=summary" else - HOMEPAGE="http://www.sabayon.org" + 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 +if [ -z "${K_NASKERNEL_SELF_TARBALL_NAME}" ]; then + if [ "${K_NASKERNEL_URI_CONFIG}" = "yes" ]; then + tmp_K_NASKERNEL_CONFIG_FILE="${K_NASKERNEL_CONFIG_FILE:-${K_NASKERNEL_NAME}-${PVR}-__ARCH__.config}" + tmp_K_NASKERNEL_FW_CONFIG_FILE="${K_NASKERNEL_FW_CONFIG_FILE:-${K_NASKERNEL_NAME}-fw_env-__ARCH__.config}" + if [ -n "${K_NASCONFIGS_VER}" ]; then + K_NASCONFIGS_PKG="nas-configs-${PV}-${K_NASCONFIGS_VER}.tar.bz2" + SRC_URI="${SRC_URI} + mirror://sablink/${CATEGORY}/linux-nas-configs/${K_NASCONFIGS_PKG}" + else + SRC_URI="${SRC_URI} + arm? ( mirror://sablink/${CATEGORY}/linux-nas-patches/config/${tmp_K_NASKERNEL_FW_CONFIG_FILE/__ARCH__/arm} )" + fi SRC_URI="${SRC_URI} - amd64? ( mirror://sabayon/${CATEGORY}/linux-sabayon-patches/config/${tmp_K_SABKERNEL_CONFIG_FILE/__ARCH__/amd64} ) - x86? ( mirror://sabayon/${CATEGORY}/linux-sabayon-patches/config/${tmp_K_SABKERNEL_CONFIG_FILE/__ARCH__/x86} )" - # K_SABKERNEL_CONFIG_FILE will be set in _set_config_file_vars - unset tmp_K_SABKERNEL_CONFIG_FILE + arm? ( mirror://sablink/${CATEGORY}/linux-nas-patches/config/${tmp_K_NASKERNEL_FW_CONFIG_FILE/__ARCH__/arm} )" + # K_NASKERNEL_CONFIG_FILE will be set in _set_config_file_vars + unset tmp_K_NASKERNEL_CONFIG_FILE fi fi @@ -258,28 +267,24 @@ _set_config_file_vars() { # Setup kernel configuration file name - 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}" - use amd64 && K_SABKERNEL_CONFIG_FILE=${K_SABKERNEL_CONFIG_FILE/__ARCH__/amd64} - use x86 && K_SABKERNEL_CONFIG_FILE=${K_SABKERNEL_CONFIG_FILE/__ARCH__/x86} + if [ -z "${K_NASKERNEL_SELF_TARBALL_NAME}" ]; then + if [ "${K_NASKERNEL_URI_CONFIG}" = "yes" ]; then + K_NASKERNEL_CONFIG_FILE="${K_NASKERNEL_CONFIG_FILE:-${K_NASKERNEL_NAME}-${PVR}-__ARCH__.config}" + K_NASKERNEL_FW_CONFIG_FILE="${K_NASKERNEL_FW_CONFIG_FILE:-${K_NASKERNEL_NAME}-fw_env-__ARCH__.config}" + use arm && K_NASKERNEL_CONFIG_FILE=${K_NASKERNEL_CONFIG_FILE/__ARCH__/arm} + use arm && K_NASKERNEL_FW_CONFIG_FILE=${K_NASKERNEL_FW_CONFIG_FILE/__ARCH__/arm} else - use arm && K_SABKERNEL_CONFIG_FILE="${K_SABKERNEL_CONFIG_FILE:-${K_SABKERNEL_NAME}-${PVR}-arm.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}" - 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__/arm} - K_SABKERNEL_ALT_CONFIG_FILE=${K_SABKERNEL_ALT_CONFIG_FILE/__ARCH__/arm} + use arm && K_NASKERNEL_CONFIG_FILE="${K_NASKERNEL_CONFIG_FILE:-${K_NASKERNEL_NAME}-${PVR}-arm.config}" + use arm && K_NASKERNEL_FW_CONFIG_FILE="${K_NASKERNEL_FW_CONFIG_FILE:-${K_NASKERNEL_NAME}-fw_env-arm.config}" + fi + else + K_NASKERNEL_CONFIG_FILE="${K_NASKERNEL_CONFIG_FILE:-${K_NASKERNEL_NAME}-${PVR}-__ARCH__.config}" + K_NASKERNEL_ALT_CONFIG_FILE="${K_NASKERNEL_ALT_CONFIG_FILE:-${K_NASKERNEL_NAME}-${PV}-__ARCH__.config}" + use arm && K_NASKERNEL_FW_CONFIG_FILE="${K_NASKERNEL_FW_CONFIG_FILE:-${K_NASKERNEL_NAME}-fw_env-arm.config}" + if use arm; then + K_NASKERNEL_CONFIG_FILE=${K_NASKERNEL_CONFIG_FILE/__ARCH__/arm} + K_NASKERNEL_ALT_CONFIG_FILE=${K_NASKERNEL_ALT_CONFIG_FILE/__ARCH__/arm} + K_NASKERNEL_FW_CONFIG_FILE=${K_NASKERNEL_FW_CONFIG_FILE/__ARCH__/arm} fi fi @@ -291,14 +296,15 @@ DEPEND="sys-apps/sed" RDEPEND="${RDEPEND}" else - IUSE="dmraid dracut iscsi luks lvm mdadm splash" + IUSE="dmraid dracut iscsi lvm mdadm" DEPEND="app-arch/xz-utils sys-apps/sed sys-devel/make - >=sys-kernel/genkernel-3.4.16-r1 - arm? ( dev-embedded/u-boot-tools ) - splash? ( x11-themes/sabayon-artwork-core ) - dracut? ( sys-kernel/dracut )" + >=sys-kernel/genkernel-next-30 + dracut? ( sys-kernel/dracut ) + sys-block/devio + dev-embedded/u-boot-tools + sys-fs/dosfstools" RDEPEND="sys-apps/sed sys-kernel/linux-firmware" if [ -n "${K_REQUIRED_LINUX_FIRMWARE_VER}" ]; then @@ -332,7 +338,7 @@ fi } -sabayon-kernel_pkg_setup() { +nas-kernel_pkg_setup() { if [ -n "${K_FIRMWARE_PACKAGE}" ]; then einfo "Preparing kernel firmwares" else @@ -340,18 +346,23 @@ fi } -sabayon-kernel_src_unpack() { +nas-kernel_src_unpack() { local okv="${OKV}" - if [ -n "${K_SABKERNEL_SELF_TARBALL_NAME}" ]; then - OKV="${PVR}+${K_SABKERNEL_SELF_TARBALL_NAME}" + if [ -n "${K_NASKERNEL_SELF_TARBALL_NAME}" ]; then + OKV="${PVR}+${K_NASKERNEL_SELF_TARBALL_NAME}" + fi + if [ -n "${K_NASCONFIGS_VER}" ]; then + unpack "${K_NASCONFIGS_PKG}" fi kernel-2_src_unpack - if [ -n "${K_SABKERNEL_FORCE_SUBLEVEL}" ]; then + if [ -n "${K_NASKERNEL_FORCE_SUBLEVEL}" ]; then # patch out Makefile with proper sublevel - sed -i "s:^SUBLEVEL = .*:SUBLEVEL = ${K_SABKERNEL_FORCE_SUBLEVEL}:" \ + sed -i "s:^SUBLEVEL = .*:SUBLEVEL = ${K_NASKERNEL_FORCE_SUBLEVEL}:" \ "${S}/Makefile" || die fi - if [ -n "${K_SABKERNEL_RESET_EXTRAVERSION}" ]; then + #comment out Extra verion change by CK patch + sed -i -e 's/\(^EXTRAVERSION :=.*$\)/# \1/' "${S}/Makefile" + if [ -n "${K_NASKERNEL_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 @@ -360,15 +371,20 @@ # Let's handle EAPIs 0 and 1... case ${EAPI:-0} in - 0|1) sabayon-kernel_src_prepare ;; + 0|1) nas-kernel_src_prepare ;; esac + + # delete empty directories + pushd "${S}" + find . -depth -type d -empty -delete + popd } -sabayon-kernel_src_prepare() { +nas-kernel_src_prepare() { _set_config_file_vars } -sabayon-kernel_src_compile() { +nas-kernel_src_compile() { if [ -n "${K_FIRMWARE_PACKAGE}" ]; then _firmwares_src_compile elif [ -n "${K_ONLY_SOURCES}" ]; then @@ -392,22 +408,32 @@ _kernel_copy_config() { _is_config_file_set \ - || die "Kernel configuration file not set. Was sabayon-kernel_src_prepare() called?" + || die "Kernel configuration file not set. Was nas-kernel_src_prepare() called?" - if [ -n "${K_SABKERNEL_SELF_TARBALL_NAME}" ]; then - local base_path="${S}/sabayon/config" - if [ -f "${base_path}/${K_SABKERNEL_ALT_CONFIG_FILE}" ]; then + if [ -n "${K_NASKERNEL_SELF_TARBALL_NAME}" ]; then + local base_path="${S}/sablink/config" + if [ -f "${base_path}/${K_NASKERNEL_ALT_CONFIG_FILE}" ]; then # new path, without revision - cp "${base_path}/${K_SABKERNEL_ALT_CONFIG_FILE}" "${1}" || die "cannot copy kernel config" + cp "${base_path}/${K_NASKERNEL_ALT_CONFIG_FILE}" "${1}" || die "cannot copy kernel config" else # PVR path (old) - cp "${base_path}/${K_SABKERNEL_CONFIG_FILE}" "${1}" || die "cannot copy kernel config" + cp "${base_path}/${K_NASKERNEL_CONFIG_FILE}" "${1}" || die "cannot copy kernel config" fi else - 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" + if [ -n "${K_NASCONFIGS_VER}" ]; then + rm -rf "${S}/sablink" + cp -rf "${WORKDIR}"/sablink "${S}" + pushd "${S}" + sablink/scripts/prepareconfig ${K_NASKERNEL_NAME}-${CHOST/-*/} + mv .config "${1}.tmp" + mv "${1}.tmp" "${1}" + popd + else + cp "${DISTDIR}/${K_NASKERNEL_CONFIG_FILE}" "${1}" || die "cannot copy kernel config" + fi fi fi } @@ -417,8 +443,8 @@ 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 + if use arm; then + mkdir -p "${WORKDIR}"/boot/dtb else mkdir -p "${WORKDIR}"/boot fi @@ -440,15 +466,14 @@ cd "${S}" || die GKARGS="--no-save-config --disklabel" use dracut && GKARGS="${GKARGS} --dracut" - use splash && GKARGS="${GKARGS} --splash=sabayon" use dmraid && GKARGS="${GKARGS} --dmraid" use iscsi && GKARGS="${GKARGS} --iscsi" use mdadm && GKARGS="${GKARGS} --mdadm" - use luks && GKARGS="${GKARGS} --luks" use lvm && GKARGS="${GKARGS} --lvm" export DEFAULT_KERNEL_SOURCE="${S}" export CMD_KERNEL_DIR="${S}" + export KERNEL_DIR="${S}" for opt in ${MAKEOPTS}; do if [ "${opt:0:2}" = "-j" ]; then mkopts="${opt}" @@ -474,9 +499,9 @@ fi # If ARM, build the uImage directly - if use arm; then - K_GENKERNEL_ARGS+=" --kernel-target=uImage --kernel-binary=arch/arm/boot/uImage" - fi + #if use arm; then + # K_GENKERNEL_ARGS+=" --kernel-target=uImage --kernel-binary=arch/arm/boot/uImage" + #fi # Workaround bug in splash_geninitramfs corrupting the initramfs # if xz compression is used (newer genkernel >3.4.24) @@ -485,8 +510,145 @@ GKARGS+=" --compress-initramfs-type=gzip" fi + K_NASKERNEL_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_NASKERNEL_NAME}" = "buffalo_kb_pro" ]; then + devio > foo 'wl 0xe3a01c05,4' 'wl 0xe38110e5,4' # KuroBox Pro 1509 + K_NASKERNEL_TYPE="buffalo" + K_NASKERNEL_DEVICE="Buffalo/Revogear Kurobox Pro" + fi + if [ "${K_NASKERNEL_NAME}" = "buffalo_ls_chl" ]; then + devio > foo 'wl 0xe3a01c0b,4' 'wl 0xe3811061,4' # Linkstation Live V3 (2.6.34) 2913 + K_NASKERNEL_TYPE="buffalo" + K_NASKERNEL_DEVICE="Buffalo Linkstation LiveV3 (LS-CHL)" + fi + if [ "${K_NASKERNEL_NAME}" = "buffalo_ls_chl2" ]; then + if [[ "${KV_MAJOR}${KV_MINOR}" -ge 35 ]]; then + # new Device tree no need for devio + K_NASKERNEL_DTB="kirkwood-lschlv2.dtb" + else + devio > foo 'wl 0xe3a01c0b,4' 'wl 0xe38110be,4' # Linkstation XHL/CHLv2 3006 + fi + K_NASKERNEL_TYPE="buffalo" + K_NASKERNEL_DEVICE="Buffalo Linkstation LS-CHLv2" + fi + if [ "${K_NASKERNEL_NAME}" = "buffalo_ls_hgl" ]; then + devio > foo 'wl 0xe3a01c07,4' 'wl 0xe38110d5,4' # Linkstation HGL (2.6.31) 2005 + K_NASKERNEL_TYPE="buffalo" + K_NASKERNEL_DEVICE="Buffalo Linkstation LS-HGL" + fi + if [ "${K_NASKERNEL_NAME}" = "buffalo_ls_mini" ]; then + devio > foo 'wl 0xe3a01c07,4' 'wl 0xe3811042,4' # Linkstation mini (2.6.29) 1858 + K_NASKERNEL_TYPE="buffalo" + K_NASKERNEL_DEVICE="Buffalo Linkstation Mini" + fi + if [ "${K_NASKERNEL_NAME}" = "buffalo_ls_pro_live" ]; then + devio > foo 'wl 0xe3a01c06,4' 'wl 0xe3811031,4' # Linkstation Pro/Live (2.6.26) 1585 + K_NASKERNEL_TYPE="buffalo" + K_NASKERNEL_DEVICE="Buffalo Linkstation Pro/Live" + fi + if [ "${K_NASKERNEL_NAME}" = "buffalo_ls_pro_duo_rev1" ]; then + devio > foo 'wl 0xe3a01c07,4' 'wl 0xe3811027,4' # Linkstation Pro Duo (2.6.30) 1831 + K_NASKERNEL_TYPE="buffalo" + K_NASKERNEL_DEVICE="Buffalo Linkstation Pro Duo - Revision 1" + fi + if [ "${K_NASKERNEL_NAME}" = "buffalo_ls_pro_duo_rev2" ]; then + devio > foo 'wl 0xe3a01c07,4' 'wl 0xe3811027,4' # Linkstation Pro Duo (2.6.30) 1831 + K_NASKERNEL_TYPE="buffalo" + K_NASKERNEL_DEVICE="Buffalo Linkstation Pro Duo - Revision 2" + fi + if [ "${K_NASKERNEL_NAME}" = "buffalo_ls_ql" ]; then + devio > foo 'wl 0xe3a01c10,4' 'wl 0xe381108e,4' # Buffalo Linkstation Quad LSQL. Registered 2012.06.15. 4238 + K_NASKERNEL_TYPE="buffalo" + K_NASKERNEL_DEVICE="Buffalo Linkstation Quad" + fi + if [ "${K_NASKERNEL_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_NASKERNEL_TYPE="buffalo" + K_NASKERNEL_DEVICE="Buffalo LS-VL Series" + fi + if [ "${K_NASKERNEL_NAME}" = "buffalo_ls_wvl" ]; then + if [[ "${KV_MAJOR}${KV_MINOR}" -ge 39 ]]; then + # new Device tree no need for devio + K_NASKERNEL_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_NASKERNEL_TYPE="buffalo" + K_NASKERNEL_DEVICE="Buffalo Linkstation LS-WVL" + fi + if [ "${K_NASKERNEL_NAME}" = "buffalo_ts_wxl" ]; then + devio > foo 'wl 0xe3a01c0a,4' 'wl 0xe3811089,4' # Terastation WXL (2.6.35) 2697 + K_NASKERNEL_TYPE="buffalo" + # Broken hardware name needs to be correct in u-boot firmware + K_NASKERNEL_DEVICE="Buffalo Linkstation Pro/Live" + fi + if [ "${K_NASKERNEL_NAME}" = "buffalo_ls_xhl" ]; then + if [[ "${KV_MAJOR}${KV_MINOR}" -ge 35 ]]; then + # new Device tree no need for devio + K_NASKERNEL_DTB="kirkwood-lsxhl.dtb" + else + devio > foo 'wl 0xe3a01c0a,4' 'wl 0xe3811067,4' # Linkstation XHL/CHLv2 (2.6.30) 2663 + fi + K_NASKERNEL_TYPE="buffalo" + K_NASKERNEL_DEVICE="Buffalo Linkstation LS-XHL" + fi + + #################################### ARM V6 ###################################### + # oxnas + if [ "${K_NASKERNEL_NAME}" = "medion_stg212" ]; then + K_NASKERNEL_TYPE="default" + K_NASKERNEL_DEVICE="Oxford NAS" + K_GENKERNEL_ARGS+=" --kernel-target=uImage --kernel-binary=arch/arm/boot/uImage" + fi + if [ "${K_NASKERNEL_NAME}" = "pogoplug_pro" ]; then + K_NASKERNEL_TYPE="default" + K_NASKERNEL_DEVICE="Oxford NAS" + K_GENKERNEL_ARGS+=" --kernel-target=uImage --kernel-binary=arch/arm/boot/uImage" + fi + if [ "${K_NASKERNEL_NAME}" = "pogoplug_pro_pci" ]; then + K_NASKERNEL_TYPE="default" + K_NASKERNEL_DEVICE="Oxford NAS" + K_GENKERNEL_ARGS+=" --kernel-target=uImage --kernel-binary=arch/arm/boot/uImage" + fi + if [ "${K_NASKERNEL_NAME}" = "iomega_hmnd_ce" ]; then + K_NASKERNEL_TYPE="default" + K_NASKERNEL_DEVICE="Oxford NAS" + K_GENKERNEL_ARGS+=" --kernel-target=uImage --kernel-binary=arch/arm/boot/uImage" + fi + + + #################################### ARM V7 ###################################### + # Freescale + if [ "${K_NASKERNEL_NAME}" = "freescale_mx53_loco" ]; then + K_NASKERNEL_TYPE="default" + K_NASKERNEL_DEVICE="Freescale MX53 LOCO Board" + K_GENKERNEL_ARGS+=" --kernel-target=uImage --kernel-binary=arch/arm/boot/uImage" + fi + + # Freescale + if [ "${K_NASKERNEL_NAME}" = "pandaboard" ]; then + K_NASKERNEL_TYPE="default" + K_NASKERNEL_DEVICE="OMAP4 Panda board" + K_GENKERNEL_ARGS+=" --kernel-target=uImage --kernel-binary=arch/arm/boot/uImage" + fi + unset LDFLAGS - DEFAULT_KERNEL_SOURCE="${S}" CMD_KERNEL_DIR="${S}" genkernel ${GKARGS} ${K_GENKERNEL_ARGS} \ + + if [ "${K_NASKERNEL_DTB}" != "none" ]; then + cp "${WORKDIR}/config" .config + emake ${K_NASKERNEL_DTB} + cp "${S}"/arch/arm/boot/${K_NASKERNEL_DTB} "${S}" + emake mrproper + fi + + emake 3rdparty + + DEFAULT_KERNEL_SOURCE="${S}" CMD_KERNEL_DIR="${S}" KERNEL_DIR="${S}" genkernel ${GKARGS} ${K_GENKERNEL_ARGS} \ --kerneldir="${S}" \ --kernel-config="${WORKDIR}"/config \ --cachedir="${WORKDIR}"/cache \ @@ -498,6 +660,46 @@ --module-prefix="${WORKDIR}"/lib \ all || die "genkernel failed" ARCH=${OLDARCH} + + cp "${S}"/Module.symvers "${S}"/System.map "${S}"/include/linux/version.h "${WORKDIR}" + #cp /usr/src/linux/Module.symvers /usr/src/linux/System.map /usr/src/linux/include/linux/version.h "${WORKDIR}" + + # Buffalo Boxes have a special naming and start address + if [ "${K_NASKERNEL_TYPE}" = "buffalo" ]; then + if [ "${K_NASKERNEL_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_NASKERNEL_DTB} > zImage.new + cp "${S}"/${K_NASKERNEL_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_NASKERNEL_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 + + + # cleanup + rm -rf foo zImage.new ${K_NASKERNEL_DTB} + rm "${WORKDIR}"/boot/kernel-genkernel-${ARCH}-${KV_FULL} "${WORKDIR}"/boot/initramfs-genkernel-${ARCH}-${KV_FULL} } _setup_mkimage_ramdisk() { @@ -514,7 +716,7 @@ return 0 } -sabayon-kernel_src_install() { +nas-kernel_src_install() { if [ -n "${K_FIRMWARE_PACKAGE}" ]; then _firmwares_src_install elif [ -n "${K_ONLY_SOURCES}" ]; then @@ -563,8 +765,8 @@ _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" + doins "${WORKDIR}"/Module.symvers || die "cannot copy Module.symvers" + doins "${WORKDIR}"/System.map || die "cannot copy System.map" # NOTE: this is a workaround caused by linux-info.eclass not # being ported to EAPI=2 yet @@ -579,7 +781,7 @@ # Include include/linux/version.h to make Portage happy dodir "${KV_OUT_DIR}/include/linux" insinto "${KV_OUT_DIR}/include/linux" - doins "${S}/include/linux/version.h" || die "cannot copy version.h" + doins "${WORKDIR}/version.h" || die "cannot copy version.h" insinto "/boot" doins "${WORKDIR}"/boot/* || die "cannot copy /boot over" @@ -623,28 +825,26 @@ doins "RELEASE_LEVEL" einfo "Installing ${base_dir}/RELEASE_LEVEL file: ${KV_FULL}" fi + + # copy firmware config file to propper location + if [ -n "${K_NASKERNEL_SELF_TARBALL_NAME}" ]; then + local base_path="${S}/sablink/config" + cp "${base_path}/${K_NASKERNEL_FW_CONFIG_FILE}" "${D}/etc/fw_env.config.${K_NASKERNEL_NAME}" || die "cannot copy firmware config" + else + if [ "${K_NASKERNEL_URI_CONFIG}" = "no" ]; then + cp "${FILESDIR}/${PF/-r0/}-${ARCH}.config" "${D}/etc/fw_env.config.${K_NASKERNEL_NAME}" || die "cannot copy firmware config" + else + cp "${DISTDIR}/${K_NASKERNEL_FW_CONFIG_FILE}" "${D}/etc/fw_env.config.${K_NASKERNEL_NAME}" || die "cannot copy firmware config" + fi + fi + } -sabayon-kernel_pkg_preinst() { +nas-kernel_pkg_preinst() { if _is_kernel_binary; then mount-boot_pkg_preinst fi } -sabayon-kernel_grub2_mkconfig() { - 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" @@ -659,7 +859,7 @@ elif [[ "${KV_MAJOR}${KV_MINOR}" -eq 26 ]]; then echo "${KV_FULL}" elif [[ "${OKV/.*}" = "3" ]] && [[ "${KV_PATCH}" = "0" ]]; then - # Linux 3.x support, KV_FULL is set to: 3.0-sabayon + # Linux 3.x support, KV_FULL is set to: 3.0-sablink # need to add another final .0 to the version part echo "${KV_FULL/-/.0-}" else @@ -667,7 +867,7 @@ fi } -sabayon-kernel_uimage_config() { +nas-kernel_uimage_config() { # Two cases here: # 1. /boot/uImage symlink is broken (pkg_postrm) # 2. /boot/uImage symlink doesn't exist (pkg_postinst) @@ -699,50 +899,8 @@ fi } -sabayon-kernel_bzimage_config() { - # 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 -} -sabayon-kernel_pkg_postinst() { +nas-kernel_pkg_postinst() { if _is_kernel_binary; then fstab_file="${ROOT}etc/fstab" einfo "Removing extents option for ext4 drives from ${fstab_file}" @@ -751,35 +909,9 @@ 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 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 - - sabayon-kernel_grub2_mkconfig - fi - # Setup newly installed kernel on ARM if use arm; then - sabayon-kernel_uimage_config - 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 - sabayon-kernel_bzimage_config + nas-kernel_uimage_config fi kernel-2_pkg_postinst @@ -787,52 +919,36 @@ _update_depmod "${depmod_r}" elog "Please report kernel bugs at:" - elog "http://bugs.sabayon.org" + elog "http://bugs.sablink.org" elog "The source code of this kernel is located at" elog "=${K_KERNEL_SOURCES_PKG}." - elog "Sabayon 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_NASKERNEL_DEVICE}" = "$device" ]; then + cp ${ROOT}/etc/fw_env.config.${K_NASKERNEL_NAME} ${ROOT}/etc/fw_env.config + fi else kernel-2_pkg_postinst fi } -sabayon-kernel_pkg_prerm() { +nas-kernel_pkg_prerm() { if _is_kernel_binary; then mount-boot_pkg_prerm fi } -sabayon-kernel_pkg_postrm() { +nas-kernel_pkg_postrm() { 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 - - sabayon-kernel_grub2_mkconfig - fi - # Setup newly installed kernel on ARM if use arm; then - sabayon-kernel_uimage_config - 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 - sabayon-kernel_bzimage_config + nas-kernel_uimage_config fi fi }