diff options
author | BlackNoxis <steven.darklight@gmail.com> | 2014-02-15 23:24:26 +0200 |
---|---|---|
committer | BlackNoxis <steven.darklight@gmail.com> | 2014-02-15 23:24:26 +0200 |
commit | 7224c1253228e5c29c78cb3f0f26ce34770f2356 (patch) | |
tree | 1684924656132935256e034f35f92abee6623265 /eclass |
Added ebuilds for kogaion desktop
Diffstat (limited to 'eclass')
-rw-r--r-- | eclass/avahi.eclass | 102 | ||||
-rw-r--r-- | eclass/compat-drivers-3.7.eclass | 543 | ||||
-rw-r--r-- | eclass/compat-drivers-3.8-r1.eclass | 104 | ||||
-rw-r--r-- | eclass/compat-drivers-3.8.eclass | 560 | ||||
-rw-r--r-- | eclass/kde-l10n.eclass | 32 | ||||
-rw-r--r-- | eclass/kogaion-artwork.eclass | 62 | ||||
-rw-r--r-- | eclass/libreoffice-l10n-2.eclass | 139 | ||||
-rw-r--r-- | eclass/libreoffice-l10n.eclass | 124 | ||||
-rw-r--r-- | eclass/openoffice-l10n.eclass | 68 | ||||
-rw-r--r-- | eclass/rogentos-artwork.eclass | 62 | ||||
-rw-r--r-- | eclass/rogentos-kernel.eclass | 967 | ||||
-rw-r--r-- | eclass/sabayon-artwork.eclass | 55 | ||||
-rw-r--r-- | eclass/sabayon-kernel.eclass | 967 | ||||
-rw-r--r-- | eclass/spl-zfs-kernel.eclass | 183 | ||||
-rw-r--r-- | eclass/spl-zfs-userspace.eclass | 218 | ||||
-rw-r--r-- | eclass/transmission-2.51.eclass | 294 | ||||
-rw-r--r-- | eclass/transmission-2.52.eclass | 295 | ||||
-rw-r--r-- | eclass/webapp.eclass | 575 |
18 files changed, 5350 insertions, 0 deletions
diff --git a/eclass/avahi.eclass b/eclass/avahi.eclass new file mode 100644 index 00000000..c9a9876d --- /dev/null +++ b/eclass/avahi.eclass @@ -0,0 +1,102 @@ +# Copyright 2004-2011 Sabayon +# Distributed under the terms of the GNU General Public License v2 +# $ + +SUPPORTED_AVAHI_MODULES="base gtk gtk3 mono qt" + +# @ECLASS-VARIABLE: AVAHI_MODULE +# @DESCRIPTION: +# Set this variable to the avahi module ebuild name, by default it's used +# the second part of PN, for example: for avahi-glib, it is "glib". +# Supported avahi modules: +# base gtk gtk3 mono qt +AVAHI_MODULE="${AVAHI_MODULE:-${PN/avahi-}}" + +# @ECLASS-VARIABLE: AVAHI_PATCHES +# @DEFAULT-UNSET +# @DESCRIPTION: +# List of patches to apply +if [ -z "${AVAHI_PATCHES}" ]; then + AVAHI_PATCHES=() +fi + +# @ECLASS-VARIABLE: AVAHI_MODULE_DEPEND +# @DESCRIPTION: +# Avahi module built time dependencies list +AVAHI_MODULE_DEPEND="${AVAHI_MODULE_DEPEND:-}" + +# @ECLASS-VARIABLE: AVAHI_MODULE_RDEPEND +# @DESCRIPTION: +# Avahi module run time dependencies list +AVAHI_MODULE_RDEPEND="${AVAHI_MODULE_RDEPEND:-}" + +# @ECLASS-VARIABLE: AVAHI_MODULE_PDEPEND +# @DESCRIPTION: +# Avahi module post dependencies list +AVAHI_MODULE_PDEPEND="${AVAHI_MODULE_PDEPEND:-}" + +_supported="0" +for mod in ${SUPPORTED_AVAHI_MODULES} ; do + if [ "${mod}" = "${AVAHI_MODULE}" ]; then + _supported="1" + break + fi +done +if [ "${_supported}" = "0" ]; then + die "Unsupported avahi module: ${AVAHI_MODULE}" +fi + +MY_P=${P/-${AVAHI_MODULE}} + +inherit autotools eutils flag-o-matic + +DESCRIPTION="avahi ${AVAHI_MODULE} module" +HOMEPAGE="http://avahi.org/" +SRC_URI="http://avahi.org/download/${MY_P}.tar.gz" +S="${WORKDIR}/${MY_P}" + +LICENSE="LGPL-2.1" +SLOT="0" +KEYWORDS="~amd64 ~x86" + +AVAHI_COMMON_DEPEND=">=dev-util/intltool-0.40.5 + >=dev-util/pkgconfig-0.9.0" +DEPEND="${AVAHI_MODULE_DEPEND} ${AVAHI_COMMON_DEPEND}" +RDEPEND="${AVAHI_MODULE_RDEPEND}" +PDEPEND="${AVAHI_MODULE_PDEPEND}" + +avahi_src_prepare() { + sed -i\ + -e "s:\\.\\./\\.\\./\\.\\./doc/avahi-docs/html/:../../../doc/${PF}/html/:" \ + doxygen_to_devhelp.xsl || die + + for i in ${!AVAHI_PATCHES[@]}; do + epatch "${AVAHI_PATCHES[i]}" + done + + eautoreconf +} + +avahi_src_configure() { + use sh && replace-flags -O? -O0 + # We need to unset DISPLAY, else the configure script might have problems detecting the pygtk module + unset DISPLAY + local myconf=" + --disable-static + --localstatedir=/var + --with-distro=gentoo + --disable-xmltoman + --disable-monodoc + --enable-glib + --enable-gobject + --disable-qt3 + $@" + econf ${myconf} +} + +avahi_src_install-cleanup() { + # Remove .la files + find "${D}" -name '*.la' -exec rm -f {} + || die +} + +EXPORT_FUNCTIONS src_prepare src_configure diff --git a/eclass/compat-drivers-3.7.eclass b/eclass/compat-drivers-3.7.eclass new file mode 100644 index 00000000..58bcee62 --- /dev/null +++ b/eclass/compat-drivers-3.7.eclass @@ -0,0 +1,543 @@ +# Copyright 1999-2013 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: $ + + +# @ECLASS: compat-drivers-3.7.eclass +# @MAINTAINER: +# wuodan@pentoo.ch +# @BLURB: Implements functionality of driver-select script for several modules +# @DESCRIPTION: +# Implements functionality of driver-select script for several modules + +# compose IUSE and REQUIRED_USE from the categories +IUSE+=" +build-all-modules" +REQUIRED_USE+=" || (" +for useexp in ${CPD_USE_EXPAND}; do + USE_TEMP="\$CPD_USE_EXPAND_$useexp" + for iuse in `eval echo "\$USE_TEMP"`; do + if [ "${iuse:0:1}" = '+' ]; then + IUSE+=" ${iuse:0:1}compat_drivers_${useexp}_${iuse:1}" || die + REQUIRED_USE+=" compat_drivers_${useexp}_${iuse:1}" || die + else + IUSE+=" compat_drivers_${useexp}_${iuse}" || die + REQUIRED_USE+=" compat_drivers_${useexp}_${iuse} build-all-modules" || die + fi + done +done +REQUIRED_USE+=" )" + +# ============================================================================== +# INTERNAL VARIABLES +# ============================================================================== + +# @VARIABLE: CPD_USE_EXPAND +# @DESCRIPTION: +# This variable needs to be set in the ebuild and contains the categories for +# USE_EXPAND + +# @VARIABLE: CPD_USE_EXPAND_category +# @DESCRIPTION: +# These variables need to be set in the ebuild, one per category in +# CPD_USE_EXPAND. They contain the modules of the categories. + +# @ECLASS-VARIABLE: CPD_MODULE +# @DESCRIPTION: +# This internal variable contains a temporary value, the currently processed +# module. + +# @ECLASS-VARIABLE: CPD_DISABLE_${CPD_MODULE} +# @DESCRIPTION: +# These internal variables contains values, the 'disable-actions' of the +# currently processed module. One variable exists for each active module. + +# @ECLASS-VARIABLE: CPD_MAKEFILES +# @DESCRIPTION: +# This internal variable contains a list of all 'Makefile's +CPD_MAKEFILES=" + MAKEFILE + COMPAT_CONFIG_CW + DRIVERS_MAKEFILE + ATH_MAKEFILE + ATH9K_MAKEFILE + BRCM80211_MAKEFILE + RT2X00_MAKEFILE + TI_MAKEFILE + NET_WIRELESS_MAKEFILE + EEPROM_MAKEFILE + DRIVERS_NET_ATHEROS + DRIVERS_NET_BROADCOM + DRIVERS_NET_USB_MAKEFILE + SSB_MAKEFILE + BCMA_MAKEFILE" + +# @ECLASS-VARIABLE: CPD_MAKEFILES_ARRAY +# @DESCRIPTION: +# This internal variable contains an array with paths to all files +CPD_MAKEFILES_ARRAY=( + MAKEFILE=Makefile + COMPAT_CONFIG_CW=config.mk + DRIVERS_MAKEFILE=drivers/net/wireless/Makefile + ATH_MAKEFILE=drivers/net/wireless/ath/Makefile + ATH9K_MAKEFILE=drivers/net/wireless/ath/ath9k/Makefile + BRCM80211_MAKEFILE=drivers/net/wireless/brcm80211/Makefile + RT2X00_MAKEFILE=drivers/net/wireless/rt2x00/Makefile + TI_MAKEFILE=drivers/net/wireless/ti/Makefile + NET_WIRELESS_MAKEFILE=net/wireless/Makefile + EEPROM_MAKEFILE=drivers/misc/eeprom/Makefile + DRIVERS_NET_ATHEROS=drivers/net/ethernet/atheros/Makefile + DRIVERS_NET_BROADCOM=drivers/net/ethernet/broadcom/Makefile + DRIVERS_NET_USB_MAKEFILE=drivers/net/usb/Makefile + SSB_MAKEFILE=drivers/ssb/Makefile + BCMA_MAKEFILE=drivers/bcma/Makefile +) + +# ============================================================================== +# INTERNAL FUNCTIONS +# ============================================================================== + +# @FUNCTION: get_makefile +# @DESCRIPTION: +# This internal function returns the path to a file from CPD_MAKEFILES_ARRAY +function get_makefile { + for file in "${CPD_MAKEFILES_ARRAY[@]}"; do + if [ "${file%%=*}" = "${1}" ]; then + echo "${file#*=}" + return 0 + fi + done + die "Not found" +} + +# @FUNCTION: select_drivers_from_makefile +# @DESCRIPTION: +# This internal function filters a Makefile +# It deletes all non matching lines! +function select_drivers_from_makefile +{ + local makefile=$(get_makefile "$1") + shift + local configs="" + for i in $@; do + [ "${configs}" != '' ] && configs+='|' + configs+="${i}" + done + einfo "Filtering file ${makefile} for: ${configs}" + sed -r "/${configs}/!d" ${makefile} > ${makefile}.tmp || die + mv ${makefile}.tmp ${makefile} || die +} + +# @FUNCTION: disable +# @DESCRIPTION: +# This internal function registers a 'disable' action for a module. +# It writes to a variable CPD_DISABLE_${CPD_MODULE} +function disable { + eval "CPD_DISABLE_${CPD_MODULE}+=\" ${*}\"" || die +} + +# @FUNCTION: disable_makefile +# @DESCRIPTION: +# This internal function clears a Makefile completely. Use with care! +function disable_makefile { + einfo "Clearing entire file: ${1}" + echo > $1 || die +} + +# @FUNCTION: disable_staging +# @DESCRIPTION: +# This internal function disables "staging" +function disable_staging +{ + # perl -i -ne 'print if ! /CONFIG_COMPAT_STAGING/ ' "${MAKEFILE}" + sed -i '/CONFIG_COMPAT_STAGING/d' "$(get_makefile MAKEFILE)" || die +} + +# @FUNCTION: disable_update-initramfs +# @DESCRIPTION: +# This internal function disables "update-initramfs" +function disable_update-initramfs +{ + # perl -i -ne 'print if ! /update-initramfs/' "${MAKEFILE}" + sed -i '/update-initramfs/d' "$(get_makefile MAKEFILE)" || die +} + +# @FUNCTION: disable_lib80211 +# @DESCRIPTION: +# This internal function disables "update-initramfs" +function disable_lib80211 +{ + # perl -i -ne 'print if ! /LIB80211/ ' $NET_WIRELESS_MAKEFILE + sed -i '/LIB80211/d' "$(get_makefile NET_WIRELESS_MAKEFILE)" || die +} + +# @FUNCTION: disable_b44 +# @DESCRIPTION: +# This internal function disables "b44" +function disable_b44 { + # perl -i -ne 'print if ! /CONFIG_B44/ ' $DRIVERS_NET_BROADCOM + sed -i '/CONFIG_B44/d' "$(get_makefile DRIVERS_NET_BROADCOM)" || die +} + +# @FUNCTION: disable_ssb +# @DESCRIPTION: +# This internal function disables "ssb" +function disable_ssb +{ + disable_makefile "$(get_makefile ${SSB_MAKEFILE})" + # perl -i -ne 'print if ! /drivers\/ssb\//' "${MAKEFILE}" + sed -i '/drivers\/ssb\//d' "$(get_makefile MAKEFILE)" || die +} + +# @FUNCTION: disable_bcma +# @DESCRIPTION: +# This internal function disables "bcma" +function disable_bcma +{ + disable_makefile "$(get_makefile ${BCMA_MAKEFILE})" + # perl -i -ne 'print if ! /drivers\/bcma\//' "${MAKEFILE}" + sed -i '/drivers\/bcma\//d' "$(get_makefile MAKEFILE)" || die +} + +# @FUNCTION: disable_rfkill +# @DESCRIPTION: +# This internal function disables "rfkill" +function disable_rfkill +{ + # perl -i -ne 'print if ! /CONFIG_COMPAT_RFKILL/' "${MAKEFILE}" + sed -i '/CONFIG_COMPAT_RFKILL/d' "$(get_makefile MAKEFILE)" || die +} + +# @FUNCTION: disable_eprom +# @DESCRIPTION: +# This internal function disables "eprom" +function disable_eeprom +{ + disable_makefile "$(get_makefile ${EEPROM_MAKEFILE})" || die + # perl -i -ne 'print if ! /drivers\/misc\/eeprom\//' "${MAKEFILE}" + sed -i '/drivers\/misc\/eeprom\//d' "$(get_makefile MAKEFILE)" || die +} + +# @FUNCTION: disable_usbnet +# @DESCRIPTION: +# This internal function disables "usbnet" +function disable_usbnet +{ + disable_makefile ${DRIVERS_NET_USB_MAKEFILE} || die + # perl -i -ne 'print if ! /drivers\/net\/usb\//' "${MAKEFILE}" + sed -i '/drivers\/net\/usb\//d' "$(get_makefile MAKEFILE)" || die +} + +# @FUNCTION: disable_usbnet +# @DESCRIPTION: +# This internal function disables "usbnet" +# this function is twice in driver-select script!?! +function disable_usbnet { + # perl -i -ne 'print if ! /CONFIG_COMPAT_NET_USB_MODULES/' "${MAKEFILE}" + sed -i '/CONFIG_COMPAT_NET_USB_MODULES/d' "$(get_makefile MAKEFILE)" || die +} + +# @FUNCTION: disable_ethernet +# @DESCRIPTION: +# This internal function disables "ethernet" +function disable_ethernet { + # perl -i -ne 'print if ! /CONFIG_COMPAT_NETWORK_MODULES/' "${MAKEFILE}" + sed -i '/CONFIG_COMPAT_NETWORK_MODULES/d' "$(get_makefile MAKEFILE)" || die +} + +# @FUNCTION: disable_var_03 +# @DESCRIPTION: +# This internal function disables "var_03" +function disable_var_03 { + # perl -i -ne 'print if ! /CONFIG_COMPAT_VAR_MODULES/' "${MAKEFILE}" + sed -i '/CONFIG_COMPAT_VAR_MODULES/d' "$(get_makefile MAKEFILE)" || die +} + +# @FUNCTION: disable_bt +# @DESCRIPTION: +# This internal function disables "bt" +function disable_bt { + # perl -i -ne 'print if ! /CONFIG_COMPAT_BLUETOOTH/' "${MAKEFILE}" + sed -i '/CONFIG_COMPAT_BLUETOOTH/d' "$(get_makefile MAKEFILE)" || die +} + +# @FUNCTION: disable_80211 +# @DESCRIPTION: +# This internal function disables "80211" +function disable_80211 { + # perl -i -ne 'print if ! /CONFIG_COMPAT_WIRELESS/' "${MAKEFILE}" + sed -i '/CONFIG_COMPAT_WIRELESS/d' "$(get_makefile MAKEFILE)" || die +} + +# @FUNCTION: disable_ath9k_rate_control +# @DESCRIPTION: +# This internal function disables "ath9k_rate_control" +# new function, not in driver-select +function disable_ath9k_rate_control { + # perl -i -ne 'print if ! /CONFIG_COMPAT_ATH9K_RATE_CONTROL/ ' $COMPAT_CONFIG_CW + sed -i '/CONFIG_COMPAT_ATH9K_RATE_CONTROL/d' "$(get_makefile COMPAT_CONFIG_CW)" || die +} + +# @FUNCTION: select_drivers +# @DESCRIPTION: +# This internal function registers filters for the drivers Makefile +function select_drivers { + eval "CPD_DRIVERS_MAKEFILE+=\" ${*}\"" || die +} + +# @FUNCTION: select_ath_driver +# @DESCRIPTION: +# This internal function registers filters for the ath Makefile +function select_ath_driver { + eval "CPD_ATH_MAKEFILE+=\" ${*}\"" || die +} + +# @FUNCTION: select_ath_driver_common +# @DESCRIPTION: +# This internal function registers common filters for the ath Makefile +function select_ath_driver_common { + # eval "CPD_ATH_MAKEFILE+=\" CONFIG_ATH_ ath-objs regd.o hw.o\"" || die + select_ath_driver CONFIG_ATH_ ath-objs regd.o hw.o key.o || die +} + +# @FUNCTION: select_brcm80211_driver +# @DESCRIPTION: +# This internal function registers filters for the brcm80211 Makefile +function select_brcm80211_driver { + eval "CPD_BRCM80211_MAKEFILE+=\" ${*}\"" || die +} + +# @FUNCTION: select_ti_driver +# @DESCRIPTION: +# This internal function registers filters for the ti Makefile +function select_ti_drivers { + select_drivers CONFIG_WL_TI + eval "CPD_TI_MAKEFILE+=\" ${*}\"" || die +} + +# @FUNCTION: set_flag +# @DESCRIPTION: +# This internal function contains the configuration for each flag/module +function set_flag { + # clear/set global vars + CPD_MODULE=$1 + case $1 in + ath5k) + disable staging usbnet ethernet bt update-initramfs var_03 || die + select_drivers CONFIG_ATH_COMMON || die + select_ath_driver CONFIG_ATH5K || die + select_ath_driver_common || die + ;; + ath9k) + disable staging usbnet ethernet bt update-initramfs var_03 || die + select_drivers CONFIG_ATH_COMMON || die + select_ath_driver CONFIG_ATH9K_HW || die + select_ath_driver_common || die + ;; + ath9k_ap) + disable staging usbnet ethernet bt update-initramfs var_03 || die + select_drivers CONFIG_ATH_COMMON || die + select_ath_driver CONFIG_ATH9K_HW || die + select_ath_driver_common || die + disable ath9k_rate_control || die + ;; + carl9170) + disable staging usbnet ethernet bt update-initramfs var_03 || die + select_drivers CONFIG_ATH_COMMON || die + select_ath_driver CONFIG_CARL9170 || die + select_ath_driver_common || die + ;; + ath9k_htc) + disable staging usbnet ethernet bt update-initramfs var_03 || die + select_drivers CONFIG_ATH_COMMON || die + select_ath_driver CONFIG_ATH9K_HW || die + select_ath_driver_common || die + ;; + ath6kl) + disable staging usbnet ethernet bt update-initramfs var_03 || die + select_drivers CONFIG_ATH_COMMON || die + select_ath_driver CONFIG_ATH6KL || die + select_ath_driver_common || die + ;; + brcmsmac) + disable staging usbnet ethernet bt update-initramfs var_03 || die + select_drivers CONFIG_BRCMSMAC || die + select_brcm80211_driver CONFIG_BRCMSMAC CONFIG_BRCMUTIL || die + ;; + brcmfmac) + disable staging usbnet ethernet bt update-initramfs var_03 || die + select_drivers CONFIG_BRCMFMAC || die + select_brcm80211_driver CONFIG_BRCMSMAC CONFIG_BRCMUTIL || die + ;; + zd1211rw) + select_drivers CONFIG_COMPAT_ZD1211RW || die + disable staging lib80211 ssb bcma usbnet eeprom update-initramfs || die + ;; + b43) + disable staging usbnet ethernet bt update-initramfs || die + disable eeprom lib80211 || die + select_drivers CONFIG_B43 || die + ;; + rt2x00) + select_drivers CONFIG_RT2X00 || die + disable staging usbnet ethernet bt update-initramfs || die + disable lib80211 ssb bcma usbnet update-initramfs || die + ;; + wl1251) + select_ti_drivers CONFIG_WL1251 || die + disable staging lib80211 ssb bcma usbnet eeprom update-initramfs || die + ;; + wl12xx) + select_ti_drivers CONFIG_WL12XX || die + disable staging lib80211 ssb bcma usbnet eeprom update-initramfs || die + ;; + wl18xx) + select_ti_drivers CONFIG_WL18XX || die + disable staging lib80211 ssb bcma usbnet eeprom update-initramfs || die + ;; + # Ethernet and Bluetooth drivers + atl1) + disable staging usbnet var_03 bt rfkill 80211 b44 || die + echo -e "obj-\$(CONFIG_ATL1) += atlx/" > "$(get_makefile DRIVERS_NET_ATHEROS)" || die + ;; + atl2) + disable staging usbnet var_03 bt rfkill 80211 b44 || die + echo -e "obj-\$(CONFIG_ATL2) += atlx/" > "$(get_makefile DRIVERS_NET_ATHEROS)" || die + ;; + atl1e) + disable staging usbnet var_03 bt rfkill 80211 b44 || die + echo -e "obj-\$(CONFIG_ATL1E) += atl1e/" > "$(get_makefile DRIVERS_NET_ATHEROS)" || die + ;; + atl1c) + disable staging usbnet var_03 bt rfkill 80211 b44 || die + echo -e "obj-\$(CONFIG_ATL1C) += atl1c/" > "$(get_makefile DRIVERS_NET_ATHEROS)" || die + ;; + atlxx) + select_drivers CONFIG_ATL1 CONFIG_ATL2 CONFIG_ATL1E CONFIG_ALX || die + disable staging usbnet var_03 bt rfkill 80211 b44 update-initramfs || die + ;; + bt) + select_drivers CONFIG_BT || die + disable ssb bcma usbnet eeprom update-initramfs ethernet staging 80211 || die + ;; + i915) + # rfkill may be needed if you enable b44 as you may have b43 + disable ethernet staging usbnet var_03 bt rfkill 80211 || die + ;; + drm) + # rfkill may be needed if you enable b44 as you may have b43 + disable ethernet staging usbnet var_03 bt rfkill 80211 || die + ;; + # Manually added options by pentoo + usbnet) + # disable everything else + disable staging update-initramfs lib80211 b44 ssb bcma rfkill eeprom ethernet var_03 bt 80211 ath9k_rate_control || die + ;; + staging) + # disable everything else + disable usbnet update-initramfs lib80211 b44 ssb bcma rfkill eeprom ethernet var_03 bt 80211 ath9k_rate_control || die + ;; + b44) + disable staging usbnet ethernet bt update-initramfs || die + disable eeprom lib80211 || die + select_drivers CONFIG_B44 || die + ;; + *) + die "Unsupported driver: ${1}" + exit + ;; + esac +} + +# @FUNCTION: echo_flag_settings +# @DESCRIPTION: +# This internal function outputs the "disable" actions for a flag +function echo_flag_settings { + # example: + # CPD_DISABLE_${iflag}="action1 action2" + # CPD_DRIVERS_MAKEFILE="flag1 flag1" + # CPD_ATH_MAKEFILE="flag3" + # ... + local iflag=$1 + eval "local disable_list=\"\${CPD_DISABLE_${iflag}}\"" || die + einfo "Disable list for ${iflag}: ${disable_list}" +} + +# ============================================================================== +# EXPORTED FUNCTIONS +# ============================================================================== + +# @FUNCTION: compat-drivers-3.7_src_configure +# @DESCRIPTION: +# This function reads the configuration (disable-actions and filters) for each +# single active flag, then constructs and applies the common configuration set. +compat-drivers-3.7_src_configure() { + # early exit, skip filtering of configuration and build all modules + if use build-all-modules; then + ewarn "You have chosen to build all modules!" + ewarn "The Pentoo team strives to build only the desired modules and the" + ewarn "use flag 'build-all-modules' should only be used when" + ewarn "the desired modules is not available through another flag." + ewarn "Please open an issue at the Pentoo site and let us know which" + ewarn "module was missing!" + return 0 + fi + + # loop over all modules + local use_temp='' + local use_enabled_list='' + for useexp in ${CPD_USE_EXPAND}; do + use_temp="\$CPD_USE_EXPAND_$useexp" || die + for iuse in `eval echo "\$use_temp"`; do + if [ "${iuse:0:1}" = '+' ]; then + local iuse2=${iuse:1} || die + else + local iuse2=${iuse} || die + fi + local iflag="compat_drivers_${useexp}_${iuse2}" || die + # check if it's enabled + if use "${iflag}"; then + use_enabled_list+=" ${iuse2}" || die + # fill the disable/enable lists + # example: + # CPD_DISABLE_${iflag}="action1 action2" + # CPD_DRIVERS_MAKEFILE="flag1 flag1" + # CPD_ATH_MAKEFILE="flag3" + # ... + set_flag "${iuse2}" || die + echo_flag_settings "${iuse2}" || die + fi + done + done + einfo "List of enabled modules: ${use_enabled_list}" + # compose common disable list for all flags + # 1st module/flag + local iuse1="$(echo $use_enabled_list | cut -d ' ' -f 1)" || die + eval "local disable_list=\$CPD_DISABLE_${iuse1}" || die + for iuse in ${use_enabled_list}; do + if [ "${iuse}" != "${iuse1}" ]; then + local disable_list_new='' || die + eval "local disable_list_other=\$CPD_DISABLE_${iuse}" || die + for dis in ${disable_list}; do + has "${dis}" ${disable_list_other} && \ + disable_list_new+=" ${dis}" + done + disable_list="${disable_list_new}" || die + fi + done + # execute all filters for the Makefiles + for file in ${CPD_MAKEFILES}; do + eval "local filter_list=\$CPD_${file}" || die + if [ -n "${filter_list}" ]; then + # einfo "Filtering $(get_makefile ${file}) for: ${filter_list}" + select_drivers_from_makefile "${file}" "${filter_list}" || die + fi + done + # execute common disable list + einfo "Common disable list: ${disable_list}" + for dis in ${disable_list}; do + einfo "Running disable function: disable_${dis}" + eval "disable_${dis}" || die + done +} + +EXPORT_FUNCTIONS src_configure || die diff --git a/eclass/compat-drivers-3.8-r1.eclass b/eclass/compat-drivers-3.8-r1.eclass new file mode 100644 index 00000000..f01faa83 --- /dev/null +++ b/eclass/compat-drivers-3.8-r1.eclass @@ -0,0 +1,104 @@ +# Copyright 1999-2013 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: $ + + +# @ECLASS: compat-drivers-3.8-r1.eclass +# @MAINTAINER: +# wuodan@pentoo.ch +# @BLURB: Implements functionality of driver-select script for several modules +# @DESCRIPTION: +# Implements functionality of driver-select script for several modules +# needs a modified version of the driver-select file! + +# compose IUSE and REQUIRED_USE from the categories +IUSE+=" +build-all-modules" +REQUIRED_USE+=" || (" +for useexp in ${CPD_USE_EXPAND}; do + USE_TEMP="\$CPD_USE_EXPAND_$useexp" + for iuse in `eval echo "\$USE_TEMP"`; do + if [ "${iuse:0:1}" = '+' ]; then + IUSE+=" ${iuse:0:1}compat_drivers_${useexp}_${iuse:1}" || die + REQUIRED_USE+=" compat_drivers_${useexp}_${iuse:1}" || die + else + IUSE+=" compat_drivers_${useexp}_${iuse}" || die + REQUIRED_USE+=" compat_drivers_${useexp}_${iuse} build-all-modules" || die + fi + done +done +REQUIRED_USE+=" )" + +# ============================================================================== +# INTERNAL VARIABLES +# ============================================================================== + +# @VARIABLE: CPD_USE_EXPAND +# @DESCRIPTION: +# This variable needs to be set in the ebuild and contains the categories for +# USE_EXPAND + +# @VARIABLE: CPD_USE_EXPAND_category +# @DESCRIPTION: +# These variables need to be set in the ebuild, one per category in +# CPD_USE_EXPAND. They contain the modules of the categories. + +# @ECLASS-VARIABLE: CPD_MODULE +# @DESCRIPTION: +# This internal variable contains a temporary value, the currently processed +# module. + +# @ECLASS-VARIABLE: CPD_DISABLE_${CPD_MODULE} +# @DESCRIPTION: +# These internal variables contains values, the 'disable-actions' of the +# currently processed module. One variable exists for each active module. + +# ============================================================================== +# INTERNAL FUNCTIONS +# ============================================================================== + +# ============================================================================== +# EXPORTED FUNCTIONS +# ============================================================================== + +# @FUNCTION: compat-drivers-3.8-r1_src_configure +# @DESCRIPTION: +# This function reads the configuration (disable-actions and filters) for each +# single active flag, then constructs and applies the common configuration set. +compat-drivers-3.8-r1_src_configure() { + # early exit, skip filtering of configuration and build all modules + if use build-all-modules; then + ewarn "You have chosen to build all modules!" + ewarn "The Pentoo team strives to build only the desired modules and the" + ewarn "use flag 'build-all-modules' should only be used when" + ewarn "the desired modules is not available through another flag." + ewarn "Please open an issue at the Pentoo site and let us know which" + ewarn "module was missing!" + return 0 + fi + + # loop over all modules + local use_temp='' + local use_enabled_list='' + for useexp in ${CPD_USE_EXPAND}; do + use_temp="\$CPD_USE_EXPAND_$useexp" || die + for iuse in `eval echo "\$use_temp"`; do + if [ "${iuse:0:1}" = '+' ]; then + local iuse2=${iuse:1} || die + else + local iuse2=${iuse} || die + fi + local iflag="compat_drivers_${useexp}_${iuse2}" || die + # check if it's enabled + if use "${iflag}"; then + use_enabled_list+=" ${iuse2}" || die + fi + done + done + einfo "List of enabled modules: ${use_enabled_list}" + + # Call the modified driver-select script + scripts/driver-select -q ${use_enabled_list} || \ + die "driver-select failed. This file was edited by Pentoo" +} + +EXPORT_FUNCTIONS src_configure || die diff --git a/eclass/compat-drivers-3.8.eclass b/eclass/compat-drivers-3.8.eclass new file mode 100644 index 00000000..e517f527 --- /dev/null +++ b/eclass/compat-drivers-3.8.eclass @@ -0,0 +1,560 @@ +# Copyright 1999-2013 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: $ + + +# @ECLASS: compat-drivers-3.8.eclass +# @MAINTAINER: +# wuodan@pentoo.ch +# @BLURB: Implements functionality of driver-select script for several modules +# @DESCRIPTION: +# Implements functionality of driver-select script for several modules + +# compose IUSE and REQUIRED_USE from the categories +IUSE+=" +build-all-modules" +REQUIRED_USE+=" || (" +for useexp in ${CPD_USE_EXPAND}; do + USE_TEMP="\$CPD_USE_EXPAND_$useexp" + for iuse in `eval echo "\$USE_TEMP"`; do + if [ "${iuse:0:1}" = '+' ]; then + IUSE+=" ${iuse:0:1}compat_drivers_${useexp}_${iuse:1}" || die + REQUIRED_USE+=" compat_drivers_${useexp}_${iuse:1}" || die + else + IUSE+=" compat_drivers_${useexp}_${iuse}" || die + REQUIRED_USE+=" compat_drivers_${useexp}_${iuse} build-all-modules" || die + fi + done +done +REQUIRED_USE+=" )" + +# ============================================================================== +# INTERNAL VARIABLES +# ============================================================================== + +# @VARIABLE: CPD_USE_EXPAND +# @DESCRIPTION: +# This variable needs to be set in the ebuild and contains the categories for +# USE_EXPAND + +# @VARIABLE: CPD_USE_EXPAND_category +# @DESCRIPTION: +# These variables need to be set in the ebuild, one per category in +# CPD_USE_EXPAND. They contain the modules of the categories. + +# @ECLASS-VARIABLE: CPD_MODULE +# @DESCRIPTION: +# This internal variable contains a temporary value, the currently processed +# module. + +# @ECLASS-VARIABLE: CPD_DISABLE_${CPD_MODULE} +# @DESCRIPTION: +# These internal variables contains values, the 'disable-actions' of the +# currently processed module. One variable exists for each active module. + +# @ECLASS-VARIABLE: CPD_MAKEFILES +# @DESCRIPTION: +# This internal variable contains a list of all 'Makefile's +CPD_MAKEFILES=" + MAKEFILE + COMPAT_CONFIG_CW + DRIVERS_MAKEFILE + ATH_MAKEFILE + ATH9K_MAKEFILE + BRCM80211_MAKEFILE + RT2X00_MAKEFILE + TI_MAKEFILE + NET_WIRELESS_MAKEFILE + EEPROM_MAKEFILE + DRIVERS_NET_ATHEROS + DRIVERS_NET_BROADCOM + DRIVERS_NET_USB_MAKEFILE + SSB_MAKEFILE + BCMA_MAKEFILE" + +# @ECLASS-VARIABLE: CPD_MAKEFILES_ARRAY +# @DESCRIPTION: +# This internal variable contains an array with paths to all files +CPD_MAKEFILES_ARRAY=( + MAKEFILE=Makefile + COMPAT_CONFIG_CW=config.mk + DRIVERS_MAKEFILE=drivers/net/wireless/Makefile + ATH_MAKEFILE=drivers/net/wireless/ath/Makefile + ATH9K_MAKEFILE=drivers/net/wireless/ath/ath9k/Makefile + BRCM80211_MAKEFILE=drivers/net/wireless/brcm80211/Makefile + RT2X00_MAKEFILE=drivers/net/wireless/rt2x00/Makefile + TI_MAKEFILE=drivers/net/wireless/ti/Makefile + NET_WIRELESS_MAKEFILE=net/wireless/Makefile + EEPROM_MAKEFILE=drivers/misc/eeprom/Makefile + DRIVERS_NET_ATHEROS=drivers/net/ethernet/atheros/Makefile + DRIVERS_NET_BROADCOM=drivers/net/ethernet/broadcom/Makefile + DRIVERS_NET_USB_MAKEFILE=drivers/net/usb/Makefile + SSB_MAKEFILE=drivers/ssb/Makefile + BCMA_MAKEFILE=drivers/bcma/Makefile +) + +# ============================================================================== +# INTERNAL FUNCTIONS +# ============================================================================== + +# @FUNCTION: get_makefile +# @DESCRIPTION: +# This internal function returns the path to a file from CPD_MAKEFILES_ARRAY +function get_makefile { + for file in "${CPD_MAKEFILES_ARRAY[@]}"; do + if [ "${file%%=*}" = "${1}" ]; then + echo "${file#*=}" + return 0 + fi + done + die "Not found" +} + +# @FUNCTION: select_drivers_from_makefile +# @DESCRIPTION: +# This internal function filters a Makefile +# It deletes all non matching lines! +function select_drivers_from_makefile +{ + local makefile=$(get_makefile "$1") + shift + local configs="" + for i in $@; do + [ "${configs}" != '' ] && configs+='|' + configs+="${i}" + done + einfo "Filtering file ${makefile} for: ${configs}" + sed -r "/${configs}/!d" ${makefile} > ${makefile}.tmp || die + mv ${makefile}.tmp ${makefile} || die +} + +# @FUNCTION: disable +# @DESCRIPTION: +# This internal function registers a 'disable' action for a module. +# It writes to a variable CPD_DISABLE_${CPD_MODULE} +function disable { + eval "CPD_DISABLE_${CPD_MODULE}+=\" ${*}\"" || die +} + +# @FUNCTION: disable_makefile +# @DESCRIPTION: +# This internal function clears a Makefile completely. Use with care! +function disable_makefile { + einfo "Clearing entire file: ${1}" + echo > $1 || die +} + +# @FUNCTION: disable_staging +# @DESCRIPTION: +# This internal function disables "staging" +function disable_staging +{ + # perl -i -ne 'print if ! /CONFIG_COMPAT_STAGING/ ' "${MAKEFILE}" + sed -i '/CONFIG_COMPAT_STAGING/d' "$(get_makefile MAKEFILE)" || die +} + +# @FUNCTION: disable_update-initramfs +# @DESCRIPTION: +# This internal function disables "update-initramfs" +function disable_update-initramfs +{ + # perl -i -ne 'print if ! /update-initramfs/' "${MAKEFILE}" + sed -i '/update-initramfs/d' "$(get_makefile MAKEFILE)" || die +} + +# @FUNCTION: disable_lib80211 +# @DESCRIPTION: +# This internal function disables "lib80211" +function disable_lib80211 +{ + # perl -i -ne 'print if ! /LIB80211/ ' $NET_WIRELESS_MAKEFILE + sed -i '/LIB80211/d' "$(get_makefile NET_WIRELESS_MAKEFILE)" || die +} + +# @FUNCTION: disable_b44 +# @DESCRIPTION: +# This internal function disables "b44" +function disable_b44 { + # perl -i -ne 'print if ! /CONFIG_B44/ ' $DRIVERS_NET_BROADCOM + sed -i '/CONFIG_B44/d' "$(get_makefile DRIVERS_NET_BROADCOM)" || die +} + +# @FUNCTION: disable_ssb +# @DESCRIPTION: +# This internal function disables "ssb" +function disable_ssb +{ + disable_makefile "$(get_makefile ${SSB_MAKEFILE})" + # perl -i -ne 'print if ! /drivers\/ssb\//' "${MAKEFILE}" + sed -i '/drivers\/ssb\//d' "$(get_makefile MAKEFILE)" || die +} + +# @FUNCTION: disable_bcma +# @DESCRIPTION: +# This internal function disables "bcma" +function disable_bcma +{ + disable_makefile "$(get_makefile ${BCMA_MAKEFILE})" + # perl -i -ne 'print if ! /drivers\/bcma\//' "${MAKEFILE}" + sed -i '/drivers\/bcma\//d' "$(get_makefile MAKEFILE)" || die +} + +# @FUNCTION: disable_rfkill +# @DESCRIPTION: +# This internal function disables "rfkill" +function disable_rfkill +{ + # perl -i -ne 'print if ! /CONFIG_COMPAT_RFKILL/' "${MAKEFILE}" + sed -i '/CONFIG_COMPAT_RFKILL/d' "$(get_makefile MAKEFILE)" || die +} + +# @FUNCTION: disable_eprom +# @DESCRIPTION: +# This internal function disables "eprom" +function disable_eeprom +{ + disable_makefile "$(get_makefile ${EEPROM_MAKEFILE})" || die + # perl -i -ne 'print if ! /drivers\/misc\/eeprom\//' "${MAKEFILE}" + sed -i '/drivers\/misc\/eeprom\//d' "$(get_makefile MAKEFILE)" || die +} + +# @FUNCTION: disable_usbnet +# @DESCRIPTION: +# This internal function disables "usbnet" +function disable_usbnet +{ + disable_makefile ${DRIVERS_NET_USB_MAKEFILE} || die + # perl -i -ne 'print if ! /drivers\/net\/usb\//' "${MAKEFILE}" + sed -i '/drivers\/net\/usb\//d' "$(get_makefile MAKEFILE)" || die +} + +# @FUNCTION: disable_usbnet +# @DESCRIPTION: +# This internal function disables "usbnet" +# this function is twice in driver-select script!?! +function disable_usbnet { + # perl -i -ne 'print if ! /CONFIG_COMPAT_NET_USB_MODULES/' "${MAKEFILE}" + sed -i '/CONFIG_COMPAT_NET_USB_MODULES/d' "$(get_makefile MAKEFILE)" || die +} + +# @FUNCTION: disable_ethernet +# @DESCRIPTION: +# This internal function disables "ethernet" +function disable_ethernet { + # perl -i -ne 'print if ! /CONFIG_COMPAT_NETWORK_MODULES/' "${MAKEFILE}" + sed -i '/CONFIG_COMPAT_NETWORK_MODULES/d' "$(get_makefile MAKEFILE)" || die +} + +# @FUNCTION: disable_var_03 +# @DESCRIPTION: +# This internal function disables "var_03" +function disable_var_03 { + # perl -i -ne 'print if ! /CONFIG_COMPAT_VAR_MODULES/' "${MAKEFILE}" + sed -i '/CONFIG_COMPAT_VAR_MODULES/d' "$(get_makefile MAKEFILE)" || die +} + +# @FUNCTION: disable_bt +# @DESCRIPTION: +# This internal function disables "bt" +function disable_bt { + # perl -i -ne 'print if ! /CONFIG_COMPAT_BLUETOOTH/' "${MAKEFILE}" + sed -i '/CONFIG_COMPAT_BLUETOOTH/d' "$(get_makefile MAKEFILE)" || die +} + +# @FUNCTION: disable_80211 +# @DESCRIPTION: +# This internal function disables "80211" +function disable_80211 { + # perl -i -ne 'print if ! /CONFIG_COMPAT_WIRELESS/' "${MAKEFILE}" + sed -i '/CONFIG_COMPAT_WIRELESS/d' "$(get_makefile MAKEFILE)" || die +} + +# @FUNCTION: disable_drm +# @DESCRIPTION: +# This internal function disables "drm" +function disable_drm { + # perl -i -ne 'print if ! /CONFIG_COMPAT_VIDEO_MODULES/' "${MAKEFILE}" + sed -i '/CONFIG_COMPAT_VIDEO_MODULES/d' "$(get_makefile MAKEFILE)" || die +} + +# @FUNCTION: disable_ath9k_rate_control +# @DESCRIPTION: +# This internal function disables "ath9k_rate_control" +# new function, not in driver-select +function disable_ath9k_rate_control { + # perl -i -ne 'print if ! /CONFIG_COMPAT_ATH9K_RATE_CONTROL/ ' $COMPAT_CONFIG_CW + sed -i '/CONFIG_COMPAT_ATH9K_RATE_CONTROL/d' "$(get_makefile COMPAT_CONFIG_CW)" || die +} + +# @FUNCTION: select_drivers +# @DESCRIPTION: +# This internal function registers filters for the drivers Makefile +function select_drivers { + eval "CPD_DRIVERS_MAKEFILE+=\" ${*}\"" || die +} + +# @FUNCTION: select_ath_driver +# @DESCRIPTION: +# This internal function registers filters for the ath Makefile +function select_ath_driver { + eval "CPD_ATH_MAKEFILE+=\" ${*}\"" || die +} + +# @FUNCTION: select_ath_driver_common +# @DESCRIPTION: +# This internal function registers common filters for the ath Makefile +function select_ath_driver_common { + # eval "CPD_ATH_MAKEFILE+=\" CONFIG_ATH_ ath-objs regd.o hw.o\"" || die + select_ath_driver CONFIG_ATH_ ath-objs regd.o hw.o key.o || die +} + +# @FUNCTION: select_brcm80211_driver +# @DESCRIPTION: +# This internal function registers filters for the brcm80211 Makefile +function select_brcm80211_driver { + eval "CPD_BRCM80211_MAKEFILE+=\" ${*}\"" || die +} + +# @FUNCTION: select_ti_driver +# @DESCRIPTION: +# This internal function registers filters for the ti Makefile +function select_ti_drivers { + select_drivers CONFIG_WL_TI + eval "CPD_TI_MAKEFILE+=\" ${*}\"" || die +} + +# @FUNCTION: set_flag +# @DESCRIPTION: +# This internal function contains the configuration for each flag/module +function set_flag { + # clear/set global vars + CPD_MODULE=$1 + case $1 in + ath5k) + disable staging usbnet ethernet bt update-initramfs var_03 drm || die + select_drivers CONFIG_ATH_CARDS || die + select_ath_driver CONFIG_ATH5K || die + select_ath_driver_common || die + ;; + ath9k) + disable staging usbnet ethernet bt update-initramfs var_03 drm || die + select_drivers CONFIG_ATH_CARDS || die + select_ath_driver CONFIG_ATH9K_HW || die + select_ath_driver_common || die + ;; + ath9k_ap) + disable staging usbnet ethernet bt update-initramfs var_03 drm || die + select_drivers CONFIG_ATH_CARDS || die + select_ath_driver CONFIG_ATH9K_HW || die + select_ath_driver_common || die + disable ath9k_rate_control || die + ;; + carl9170) + disable staging usbnet ethernet bt update-initramfs var_03 drm || die + select_drivers CONFIG_ATH_CARDS || die + select_ath_driver CONFIG_CARL9170 || die + select_ath_driver_common || die + ;; + ath9k_htc) + disable staging usbnet ethernet bt update-initramfs var_03 drm || die + select_drivers CONFIG_ATH_CARDS || die + select_ath_driver CONFIG_ATH9K_HW || die + select_ath_driver_common || die + ;; + ath6kl) + disable staging usbnet ethernet bt update-initramfs var_03 drm || die + select_drivers CONFIG_ATH_CARDS || die + select_ath_driver CONFIG_ATH6KL || die + select_ath_driver_common || die + ;; + wil6210) + disable staging usbnet ethernet bt update-initramfs var_03 drm || die + select_drivers CONFIG_ATH_CARDS || die + select_ath_driver CONFIG_WIL6210 || die + ;; + brcmsmac) + disable staging usbnet ethernet bt update-initramfs var_03 drm || die + select_drivers CONFIG_BRCMSMAC || die + select_brcm80211_driver CONFIG_BRCMSMAC CONFIG_BRCMUTIL || die + ;; + brcmfmac) + disable staging usbnet ethernet bt update-initramfs var_03 drm || die + select_drivers CONFIG_BRCMFMAC || die + select_brcm80211_driver CONFIG_BRCMSMAC CONFIG_BRCMUTIL || die + ;; + zd1211rw) + select_drivers CONFIG_COMPAT_ZD1211RW || die + disable staging lib80211 ssb bcma usbnet eeprom update-initramfs || die + ;; + b43) + disable staging usbnet ethernet bt update-initramfs || die + disable eeprom lib80211 || die + select_drivers CONFIG_B43 || die + ;; + rt2x00) + select_drivers CONFIG_RT2X00 || die + disable staging usbnet ethernet bt update-initramfs || die + disable lib80211 ssb bcma usbnet update-initramfs || die + ;; + wl1251) + select_ti_drivers CONFIG_WL1251 || die + disable staging lib80211 ssb bcma usbnet eeprom update-initramfs || die + ;; + wl12xx) + select_ti_drivers CONFIG_WL12XX || die + disable staging lib80211 ssb bcma usbnet eeprom update-initramfs || die + ;; + wl18xx) + select_ti_drivers CONFIG_WL18XX || die + disable staging lib80211 ssb bcma usbnet eeprom update-initramfs || die + ;; + # Ethernet and Bluetooth drivers + atl1) + disable staging usbnet var_03 drm bt rfkill 80211 b44 || die + echo -e "obj-\$(CONFIG_ATL1) += atlx/" > "$(get_makefile DRIVERS_NET_ATHEROS)" || die + ;; + atl2) + disable staging usbnet var_03 drm bt rfkill 80211 b44 || die + echo -e "obj-\$(CONFIG_ATL2) += atlx/" > "$(get_makefile DRIVERS_NET_ATHEROS)" || die + ;; + atl1e) + disable staging usbnet var_03 drm bt rfkill 80211 b44 || die + echo -e "obj-\$(CONFIG_ATL1E) += atl1e/" > "$(get_makefile DRIVERS_NET_ATHEROS)" || die + ;; + atl1c) + disable staging usbnet var_03 drm bt rfkill 80211 b44 || die + echo -e "obj-\$(CONFIG_ATL1C) += atl1c/" > "$(get_makefile DRIVERS_NET_ATHEROS)" || die + ;; + alx) + disable staging usbnet var_03 drm bt rfkill 80211 b44 || die + echo -e "obj-\$(CONFIG_ALX) += alx/" > "$(get_makefile DRIVERS_NET_ATHEROS)" || die + ;; + atlxx) + select_drivers CONFIG_ATL1 CONFIG_ATL2 CONFIG_ATL1E CONFIG_ALX || die + disable staging usbnet var_03 drm bt rfkill 80211 b44 update-initramfs || die + ;; + bt) + select_drivers CONFIG_BT || die + disable ssb bcma usbnet eeprom update-initramfs ethernet staging 80211 || die + ;; + i915) + # rfkill may be needed if you enable b44 as you may have b43 + disable ethernet staging usbnet var_03 bt rfkill 80211 || die + ;; + drm) + # rfkill may be needed if you enable b44 as you may have b43 + disable ethernet staging usbnet var_03 bt rfkill 80211 || die + ;; + # Manually added options by pentoo + usbnet) + # disable everything else + disable staging update-initramfs lib80211 b44 ssb bcma rfkill eeprom ethernet var_03 bt 80211 ath9k_rate_control || die + ;; + staging) + # disable everything else + disable usbnet update-initramfs lib80211 b44 ssb bcma rfkill eeprom ethernet var_03 bt 80211 ath9k_rate_control || die + ;; + b44) + disable staging usbnet ethernet bt update-initramfs || die + disable eeprom lib80211 || die + select_drivers CONFIG_B44 || die + ;; + *) + die "Unsupported driver: ${1}" + exit + ;; + esac +} + +# @FUNCTION: echo_flag_settings +# @DESCRIPTION: +# This internal function outputs the "disable" actions for a flag +function echo_flag_settings { + # example: + # CPD_DISABLE_${iflag}="action1 action2" + # CPD_DRIVERS_MAKEFILE="flag1 flag1" + # CPD_ATH_MAKEFILE="flag3" + # ... + local iflag=$1 + eval "local disable_list=\"\${CPD_DISABLE_${iflag}}\"" || die + einfo "Disable list for ${iflag}: ${disable_list}" +} + +# ============================================================================== +# EXPORTED FUNCTIONS +# ============================================================================== + +# @FUNCTION: compat-drivers-3.8_src_configure +# @DESCRIPTION: +# This function reads the configuration (disable-actions and filters) for each +# single active flag, then constructs and applies the common configuration set. +compat-drivers-3.8_src_configure() { + # early exit, skip filtering of configuration and build all modules + if use build-all-modules; then + ewarn "You have chosen to build all modules!" + ewarn "The Pentoo team strives to build only the desired modules and the" + ewarn "use flag 'build-all-modules' should only be used when" + ewarn "the desired modules is not available through another flag." + ewarn "Please open an issue at the Pentoo site and let us know which" + ewarn "module was missing!" + return 0 + fi + + # loop over all modules + local use_temp='' + local use_enabled_list='' + for useexp in ${CPD_USE_EXPAND}; do + use_temp="\$CPD_USE_EXPAND_$useexp" || die + for iuse in `eval echo "\$use_temp"`; do + if [ "${iuse:0:1}" = '+' ]; then + local iuse2=${iuse:1} || die + else + local iuse2=${iuse} || die + fi + local iflag="compat_drivers_${useexp}_${iuse2}" || die + # check if it's enabled + if use "${iflag}"; then + use_enabled_list+=" ${iuse2}" || die + # fill the disable/enable lists + # example: + # CPD_DISABLE_${iflag}="action1 action2" + # CPD_DRIVERS_MAKEFILE="flag1 flag1" + # CPD_ATH_MAKEFILE="flag3" + # ... + set_flag "${iuse2}" || die + echo_flag_settings "${iuse2}" || die + fi + done + done + einfo "List of enabled modules: ${use_enabled_list}" + # compose common disable list for all flags + # 1st module/flag + local iuse1="$(echo $use_enabled_list | cut -d ' ' -f 1)" || die + eval "local disable_list=\$CPD_DISABLE_${iuse1}" || die + for iuse in ${use_enabled_list}; do + if [ "${iuse}" != "${iuse1}" ]; then + local disable_list_new='' || die + eval "local disable_list_other=\$CPD_DISABLE_${iuse}" || die + for dis in ${disable_list}; do + has "${dis}" ${disable_list_other} && \ + disable_list_new+=" ${dis}" + done + disable_list="${disable_list_new}" || die + fi + done + # execute all filters for the Makefiles + for file in ${CPD_MAKEFILES}; do + eval "local filter_list=\$CPD_${file}" || die + if [ -n "${filter_list}" ]; then + # einfo "Filtering $(get_makefile ${file}) for: ${filter_list}" + select_drivers_from_makefile "${file}" "${filter_list}" || die + fi + done + # execute common disable list + einfo "Common disable list: ${disable_list}" + for dis in ${disable_list}; do + einfo "Running disable function: disable_${dis}" + eval "disable_${dis}" || die + done +} + +EXPORT_FUNCTIONS src_configure || die diff --git a/eclass/kde-l10n.eclass b/eclass/kde-l10n.eclass new file mode 100644 index 00000000..100db755 --- /dev/null +++ b/eclass/kde-l10n.eclass @@ -0,0 +1,32 @@ +# Copyright 2004-2012 Sabayon +# Distributed under the terms of the GNU General Public License v2 +# $ + +inherit base kde4-base + +MY_LANG="${PN/kde-l10n-/}" + +# export all the available functions here +EXPORT_FUNCTIONS src_prepare src_configure + +L10N_NAME="${L10N_NAME:-${MY_LANG}}" +DESCRIPTION="KDE4 ${L10N_NAME} localization package" +HOMEPAGE="http://www.kde.org/" +LICENSE="GPL-2" + +KEYWORDS="~amd64 ~x86" +DEPEND=">=sys-devel/gettext-0.15" +RDEPEND="" +IUSE="+handbook" + +kde-l10n_src_prepare() { + # override kde4-base_src_prepare which + # fails at enable_selected_doc_linguas + base_src_prepare +} + +kde-l10n_src_configure() { + mycmakeargs="${mycmakeargs} + $(cmake-utils_use_build handbook docs)" + kde4-base_src_configure +} diff --git a/eclass/kogaion-artwork.eclass b/eclass/kogaion-artwork.eclass new file mode 100644 index 00000000..e537c9e8 --- /dev/null +++ b/eclass/kogaion-artwork.eclass @@ -0,0 +1,62 @@ +# Copyright 2004-2009 Sabayon Project +# Copyright 2012 Rogentos +# Distributed under the terms of the GNU General Public License v2 +# Original Authors: Sabayon Team +# Maintainer BlackNoxis <stefan.cristian at rogentos.ro> +# $ + +inherit eutils + +# @ECLASS-VARIABLE: KERN_INITRAMFS_SEARCH_NAME +# @DESCRIPTION: +# Argument used by `find` to search inside ${ROOT}boot Linux +# Kernel initramfs files to patch +KERN_INITRAMFS_SEARCH_NAME="${KERN_INITRAMFS_SEARCH_NAME:-initramfs-genkernel*}" + +# @ECLASS-VARIABLE: GFX_SPLASH_NAME +# @DESCRIPTION: +# Default splash theme name to use +GFX_SPLASH_NAME="${GFX_SPLASH_NAME:-kogaion}" + +# @FUNCTION: update_kernel_initramfs_splash +# @USAGE: update_kernel_initramfs_splash [splash_theme] [splash_file] +# @RETURN: 1, if something went wrong +# +# @MAINTAINER: +# Brindusa Stefan Cristian +# @AUTHOR: +# Fabio Erculiani +update_kernel_initramfs_splash() { + + [[ -z "${2}" ]] && die "wrong update_kernel_splash arguments" + + if ! has_version "media-gfx/splashutils"; then + ewarn "media-gfx/splashutils not found, cannot update kernel splash" + return 1 + fi + splash_geninitramfs -a "${2}" ${1} + return ${?} + +} + +# @FUNCTION: update_sabayon_kernel_initramfs_splash +# @USAGE: update_sabayon_kernel_initramfs_splash +# +# @AUTHOR: +# Fabio Erculiani +# @MAINTAINER: +# Brindusa Stefan Cristian +update_sabayon_kernel_initramfs_splash() { + local splash_name="${GFX_SPLASH_NAME}" + local override_splash_file="${ROOT}etc/splash_name" + if [ -f "${override_splash_file}" ]; then + found_splash_name=$(cat "${override_splash_file}" | cut -d" " -f 1) + if [ -d "/etc/splash/${found_splash_name}" ]; then + splash_name="${found_splash_name}" + fi + fi + for bootfile in `find ${ROOT}boot -name "${KERN_INITRAMFS_SEARCH_NAME}"`; do + einfo "Updating boot splash for ${bootfile}" + update_kernel_initramfs_splash "${GFX_SPLASH_NAME}" "${bootfile}" + done +} diff --git a/eclass/libreoffice-l10n-2.eclass b/eclass/libreoffice-l10n-2.eclass new file mode 100644 index 00000000..79d74359 --- /dev/null +++ b/eclass/libreoffice-l10n-2.eclass @@ -0,0 +1,139 @@ +# Copyright 2004-2012 Sabayon Linux +# Distributed under the terms of the GNU General Public License v2 +# $ + +OO_EXTENSIONS=( + "472ffb92d82cf502be039203c606643d-Sun-ODF-Template-Pack-en-US_1.0.0.oxt" + "53ca5e56ccd4cab3693ad32c6bd13343-Sun-ODF-Template-Pack-de_1.0.0.oxt" + "4ad003e7bbda5715f5f38fde1f707af2-Sun-ODF-Template-Pack-es_1.0.0.oxt" + "a53080dc876edcddb26eb4c3c7537469-Sun-ODF-Template-Pack-fr_1.0.0.oxt" + "09ec2dac030e1dcd5ef7fa1692691dc0-Sun-ODF-Template-Pack-hu_1.0.0.oxt" + "b33775feda3bcf823cad7ac361fd49a6-Sun-ODF-Template-Pack-it_1.0.0.oxt" +) + +inherit base rpm multilib versionator office-ext + +MY_LANG=${PN/libreoffice-l10n-/} +MY_LANG=${MY_LANG/_/-} + +# export all the available functions here +EXPORT_FUNCTIONS src_unpack src_prepare src_configure src_compile src_install pkg_postinst pkg_prerm + +# @ECLASS-VARIABLE: L10N_LANG +# @DESCRIPTION: +# Localization language name +L10N_LANG="${L10N_LANG:-${MY_LANG}}" + +# @ECLASS-VARIABLE: HELPPACK_AVAIL +# @DESCRIPTION: +# Set this to "0" if help pack package is not available +HELPPACK_AVAIL="${HELPPACK_AVAIL:-1}" + +# @ECLASS-VARIABLE: LANGPACK_AVAIL +# @DESCRIPTION: +# Set this to "0" if lang pack package is not available +LANGPACK_AVAIL="${LANGPACK_AVAIL:-1}" + +DESCRIPTION="LibreOffice.org ${L10N_LANG} localisation" +HOMEPAGE="http://www.documentfoundation.org" +RESTRICT="nomirror" + +L10N_VER="$(get_version_component_range 1-3)" +L10N_RC_VERSION="rc2" +LO_BRANCH=$(get_version_component_range 1-2) + +BASE_SRC_URI="http://download.documentfoundation.org/libreoffice/stable/${L10N_VER}/rpm" +SRC_URI="" +# try guessing +if [ "${LANGPACK_AVAIL}" = "1" ]; then + SRC_URI+="${BASE_SRC_URI}/x86/LibO_${L10N_VER}_Linux_x86_langpack-rpm_${MY_LANG}.tar.gz" +fi +if [ "${HELPPACK_AVAIL}" = "1" ]; then + SRC_URI+=" ${BASE_SRC_URI}/x86/LibO_${L10N_VER}_Linux_x86_helppack-rpm_${MY_LANG}.tar.gz" +fi + +IUSE="" + +EXT_URI="http://ooo.itc.hu/oxygenoffice/download/libreoffice" +TDEPEND="" +if [[ "${MY_LANG}" == "en_US" ]]; then + for i in ${OO_EXTENSIONS[@]}; do + TDEPEND+=" ${EXT_URI}/${i}" + done + SRC_URI+=" templates? ( ${TDEPEND} )" + IUSE+=" templates" +fi + +LICENSE="LGPL-3" +SLOT="0" +KEYWORDS="~amd64 ~x86" + +RDEPEND="=app-office/libreoffice-${LO_BRANCH}*" +DEPEND="dev-util/pkgconfig + dev-util/intltool" + +S="${WORKDIR}" + +OOO_INSTDIR="/usr/$(get_libdir)/libreoffice" + +libreoffice-l10n-2_src_unpack() { + default + + local lang="${MY_LANG}" + local dir=${lang/_/-} + # for english we provide just helppack, as translation is always there + if [[ "${LANGPACK_AVAIL}" == "1" ]]; then + rpmdir="LibO_${L10N_VER}${L10N_RC_VERSION}_Linux_x86_langpack-rpm_${dir}/RPMS/" + [[ -d ${rpmdir} ]] || die "Missing directory: \"${rpmdir}\"" + # First remove dictionaries, we want to use system ones. + rm -rf "${S}/${rpmdir}/"*dict*.rpm + einfo "Unpacking Langpack" + rpm_unpack "./${rpmdir}/"*.rpm + fi + if [[ "${HELPPACK_AVAIL}" == "1" ]]; then + rpmdir="LibO_${L10N_VER}${L10N_RC_VERSION}_Linux_x86_helppack-rpm_${dir}/RPMS/" + [[ -d ${rpmdir} ]] || die "Missing directory: \"${rpmdir}\"" + einfo "Unpacking Helppack" + rpm_unpack ./"${rpmdir}/"*.rpm + fi + if [[ -n "${TDEPEND}" ]]; then + if use templates; then + for i in ${OO_EXTENSIONS[@]}; do + if [[ ! -f "${S}/${i}" ]]; then + cp -v "${DISTDIR}/${i}" "${S}" + ooextused+=( "${i}" ) + fi + done + fi + fi + OO_EXTENSIONS=() + for i in ${ooextused[@]}; do + OO_EXTENSIONS+=( ${i} ) + done +} + +libreoffice-l10n-2_src_prepare() { :; } +libreoffice-l10n-2_src_configure() { :; } +libreoffice-l10n-2_src_compile() { :; } + +libreoffice-l10n-2_src_install() { + local dir="${S}"/opt/libreoffice${LO_BRANCH}/ + # Condition required for people that do not install anything eg no linguas + # or just english with no offlinehelp. + if [[ -d "${dir}" ]] ; then + insinto /usr/$(get_libdir)/libreoffice/ + doins -r "${dir}"/* + fi + # remove extensions that are in the l10n for some weird reason + rm -rf "${ED}"/usr/$(get_libdir)/libreoffice/share/extensions/ + + echo "${OO_EXTENSIONS[@]}" + office-ext_src_install +} + +libreoffice-l10n-2_pkg_postinst() { + office-ext_pkg_postinst +} +libreoffice-l10n-2_pkg_prerm() { + office-ext_pkg_prerm +} diff --git a/eclass/libreoffice-l10n.eclass b/eclass/libreoffice-l10n.eclass new file mode 100644 index 00000000..dc9c85e3 --- /dev/null +++ b/eclass/libreoffice-l10n.eclass @@ -0,0 +1,124 @@ +# Copyright 2004-2010 Sabayon Project +# Distributed under the terms of the GNU General Public License v2 +# $ + +inherit base rpm multilib + +MY_LANG=${PN/libreoffice-l10n-/} +MY_LANG=${MY_LANG/_/-} +PKG_PV="${PV}" + +# export all the available functions here +EXPORT_FUNCTIONS src_unpack src_prepare src_install + +# @ECLASS-VARIABLE: L10N_LANG +# @DESCRIPTION: +# Localization language name +L10N_LANG="${L10N_LANG:-${MY_LANG}}" + +# @ECLASS-VARIABLE: HELPPACK_AVAIL +# @DESCRIPTION: +# Set this to "0" if help pack package is not available +HELPPACK_AVAIL="${HELPPACK_AVAIL:-1}" + +# @ECLASS-VARIABLE: LANGPACK_AVAIL +# @DESCRIPTION: +# Set this to "0" if lang pack package is not available +LANGPACK_AVAIL="${LANGPACK_AVAIL:-1}" + +DESCRIPTION="LibreOffice.org ${L10N_LANG} localisation" +HOMEPAGE="http://www.documentfoundation.org" +RESTRICT="nomirror" +OOVER="${PV}" +OODLVER="${PV}" +if [[ "${PV}" = "3.4.2.3" ]] || [[ "${PV}" = "3.4.3.2" ]]; then + SRC_URI="http://download.documentfoundation.org/libreoffice/stable/3.4.2/rpm/x86/LibO_3.4.2_Linux_x86_langpack-rpm_${MY_LANG}.tar.gz" + if [ "${HELPPACK_AVAIL}" = "1" ]; then + SRC_URI+=" http://download.documentfoundation.org/libreoffice/stable/3.4.2/rpm/x86/LibO_3.4.2_Linux_x86_helppack-rpm_${MY_LANG}.tar.gz" + fi +elif [[ "${PV}" = "3.4.4.2" ]] || [[ "${PV}" = "3.5.0.0" ]]; then + SRC_URI="http://download.documentfoundation.org/libreoffice/stable/3.4.4/rpm/x86/LibO_3.4.4_Linux_x86_langpack-rpm_${MY_LANG}.tar.gz" + if [ "${HELPPACK_AVAIL}" = "1" ]; then + SRC_URI+=" http://download.documentfoundation.org/libreoffice/stable/3.4.4/rpm/x86/LibO_3.4.4_Linux_x86_helppack-rpm_${MY_LANG}.tar.gz" + fi + if [[ "${PV}" = "3.5.0.0" ]]; then + PKG_PV="3.4" + fi +elif [[ "${PV}" = "3.4.5.2" ]]; then + SRC_URI="http://download.documentfoundation.org/libreoffice/stable/3.4.5/rpm/x86/LibO_3.4.5_Linux_x86_langpack-rpm_${MY_LANG}.tar.gz" + if [ "${HELPPACK_AVAIL}" = "1" ]; then + SRC_URI+=" http://download.documentfoundation.org/libreoffice/stable/3.4.5/rpm/x86/LibO_3.4.5_Linux_x86_helppack-rpm_${MY_LANG}.tar.gz" + fi +elif [[ "${PV}" = "3.5.1.2" ]]; then + if [ "${LANGPACK_AVAIL}" = "1" ]; then + SRC_URI="http://download.documentfoundation.org/libreoffice/stable/3.5.1/rpm/x86/LibO_3.5.1_Linux_x86_langpack-rpm_${MY_LANG}.tar.gz" + fi + if [ "${HELPPACK_AVAIL}" = "1" ]; then + SRC_URI+=" http://download.documentfoundation.org/libreoffice/stable/3.5.1/rpm/x86/LibO_3.5.1_Linux_x86_helppack-rpm_${MY_LANG}.tar.gz" + fi +else + die "unsupported libreoffice-l10n ${PV}" +fi + +LICENSE="LGPL-2" +SLOT="0" +KEYWORDS="~amd64 ~x86" +IUSE="" + +RDEPEND="~app-office/libreoffice-${PV}" +DEPEND="dev-util/pkgconfig + dev-util/intltool" + +S="${WORKDIR}/*/RPMS" + +OOO_INSTDIR="/usr/$(get_libdir)/libreoffice" + +libreoffice-l10n_src_unpack() { + cd "${WORKDIR}" + unpack ${A} + mkdir "${WORKDIR}/unpack" + cd "${WORKDIR}/unpack" + rpm_unpack ${S}/*.rpm + + # fix crappy rpms containing + # duplicated dirs + if [ "${PKG_PV:0:3}" = "3.5" ]; then + dict_en_dir="${WORKDIR}/unpack"/opt/libreoffice${PKG_PV:0:3}/share/extensions/dict-en + rm -rf "${dict_en_dir}" + fi +} + +libreoffice-l10n_src_prepare() { + einfo "nothing to prepare" +} + +libreoffice-l10n_src_install() { + dodir "${OOO_INSTDIR}/basis-link" + if [[ "${PKG_PV:0:3}" = "3.3" ]]; then + cp -R "${WORKDIR}"/unpack/opt/libreoffice/basis${PKG_PV:0:3}/* \ + "${ED}${OOO_INSTDIR}/basis-link/" || die "cannot copy" + cp -R "${WORKDIR}"/unpack/opt/libreoffice/{program,readmes} \ + "${ED}${OOO_INSTDIR}/" || die "cannot copy" + elif [[ "${PKG_PV:0:3}" = "3.4" ]]; then + if [[ "${PV:0:3}" = "3.4" ]]; then + cp -R "${WORKDIR}"/unpack/opt/libreoffice${PKG_PV:0:3}/basis${PKG_PV:0:3} \ + "${ED}${OOO_INSTDIR}"/basis${PV:0:3} || die "cannot copy" + else + # 3.5 with old l10ns + cp -R "${WORKDIR}"/unpack/opt/libreoffice${PKG_PV:0:3}/basis${PKG_PV:0:3}/* \ + "${ED}${OOO_INSTDIR}"/ || die "cannot copy" + fi + for source_dir in "${WORKDIR}"/unpack/opt/libreoffice${PKG_PV:0:3}/{program,readmes}; do + if [ -d "${source_dir}" ]; then + cp -R "${source_dir}" "${ED}${OOO_INSTDIR}/" || die "cannot copy" + fi + done + else + for source_dir in "${WORKDIR}"/unpack/opt/libreoffice${PKG_PV:0:3}/{help,program,readmes,share}; do + if [ -d "${source_dir}" ]; then + cp -R "${source_dir}" "${ED}${OOO_INSTDIR}/" || die "cannot copy" + fi + done + fi + chown root:root "${ED}/${OOO_INSTDIR}" -R || die "cannot chown" +} diff --git a/eclass/openoffice-l10n.eclass b/eclass/openoffice-l10n.eclass new file mode 100644 index 00000000..46d15d76 --- /dev/null +++ b/eclass/openoffice-l10n.eclass @@ -0,0 +1,68 @@ +# Copyright 2004-2010 Sabayon Project +# Distributed under the terms of the GNU General Public License v2 +# $ + +EAPI="2" + +inherit base rpm multilib + +MY_LANG=${PN/openoffice-l10n-/} +MY_LANG=${MY_LANG/_/-} +MY_PV="${PV/_/}" + +# export all the available functions here +EXPORT_FUNCTIONS src_unpack src_prepare src_install + +# @ECLASS-VARIABLE: L10N_LANG +# @DESCRIPTION: +# Localization language name +L10N_LANG="${L10N_LANG:-${MY_LANG}}" + +DESCRIPTION="OpenOffice.org ${L10N_LANG} localisation" +HOMEPAGE="http://projects.openoffice.org/native-lang.html" +if [[ "${PV}" = "3.2.0" ]]; then + SRC_URI="mirror://openoffice-extended/${PV}rc5/OOo_${PV}rc5_20100203_LinuxIntel_langpack_${MY_LANG}.tar.gz" +elif [[ "${PV}" = "3.2.1" ]]; then + SRC_URI="mirror://openoffice-extended/${PV}rc2/OOo_${PV}rc2_20100521_Linux_x86_langpack-rpm_${MY_LANG}.tar.gz" +else + SRC_URI="--NOT_SET_SEE_openoffice-l10n.eclass--" +fi + +LICENSE="LGPL-2" +SLOT="0" +KEYWORDS="~amd64 ~x86" +IUSE="" + +RDEPEND="~app-office/openoffice-${PV}" +DEPEND="dev-util/pkgconfig + dev-util/intltool" + +S="${WORKDIR}/*/RPMS" + +OOO_INSTDIR="/usr/$(get_libdir)/openoffice" + +openoffice-l10n_src_unpack() { + cd "${WORKDIR}" + unpack "${A}" + mkdir "${WORKDIR}/unpack" + cd "${WORKDIR}/unpack" + rpm_unpack ${S}/*.rpm +} + +openoffice-l10n_src_prepare() { + einfo "nothing to prepare" +} + +openoffice-l10n_src_install() { + dodir "${OOO_INSTDIR}" + local MY_SRC="${WORKDIR}/unpack/opt/openoffice.org/*" + local MY_SRC2="${WORKDIR}/unpack/opt/openoffice.org3/*" + cp -R ${MY_SRC} "${D}${OOO_INSTDIR}/" || die "cannot copy" + cp -R ${MY_SRC2} "${D}${OOO_INSTDIR}/basis${PV:0:3}/" || die "cannot copy" + # FIXME: upstream bug, localisations listed below try to install the same file + # as ast bg bn dz el eo fi ga gu hi_IN km ku lv mk ml mr my oc om or pa_IN si ta te tr ug uk uz + local dict_file="${D}${OOO_INSTDIR}/basis${PV:0:3}/share/extension/install/dict-en.oxt" + [[ -f "${dict_file}" ]] && ewarn "Removing ${dict_file} due to collisions..." \ + && rm -f "${dict_file}" + chown root:root ${D}/${OOO_INSTDIR} -R +} diff --git a/eclass/rogentos-artwork.eclass b/eclass/rogentos-artwork.eclass new file mode 100644 index 00000000..3f51fef9 --- /dev/null +++ b/eclass/rogentos-artwork.eclass @@ -0,0 +1,62 @@ +# Copyright 2004-2009 Sabayon Project +# Copyright 2012 Rogentos +# Distributed under the terms of the GNU General Public License v2 +# Original Authors: Sabayon Team +# Maintainer BlackNoxis <stefan.cristian at rogentos.ro> +# $ + +inherit eutils + +# @ECLASS-VARIABLE: KERN_INITRAMFS_SEARCH_NAME +# @DESCRIPTION: +# Argument used by `find` to search inside ${ROOT}boot Linux +# Kernel initramfs files to patch +KERN_INITRAMFS_SEARCH_NAME="${KERN_INITRAMFS_SEARCH_NAME:-initramfs-genkernel*}" + +# @ECLASS-VARIABLE: GFX_SPLASH_NAME +# @DESCRIPTION: +# Default splash theme name to use +GFX_SPLASH_NAME="${GFX_SPLASH_NAME:-rogentos}" + +# @FUNCTION: update_kernel_initramfs_splash +# @USAGE: update_kernel_initramfs_splash [splash_theme] [splash_file] +# @RETURN: 1, if something went wrong +# +# @MAINTAINER: +# Brindusa Stefan Cristian +# @AUTHOR: +# Fabio Erculiani +update_kernel_initramfs_splash() { + + [[ -z "${2}" ]] && die "wrong update_kernel_splash arguments" + + if ! has_version "media-gfx/splashutils"; then + ewarn "media-gfx/splashutils not found, cannot update kernel splash" + return 1 + fi + splash_geninitramfs -a "${2}" ${1} + return ${?} + +} + +# @FUNCTION: update_sabayon_kernel_initramfs_splash +# @USAGE: update_sabayon_kernel_initramfs_splash +# +# @AUTHOR: +# Fabio Erculiani +# @MAINTAINER: +# Brindusa Stefan Cristian +update_sabayon_kernel_initramfs_splash() { + local splash_name="${GFX_SPLASH_NAME}" + local override_splash_file="${ROOT}etc/${splash_name}" + if [ -f "${override_splash_file}" ]; then + found_splash_name=$(cat "${override_splash_file}" | cut -d" " -f 1) + if [ -d "/etc/splash/${found_splash_name}" ]; then + splash_name="${found_splash_name}" + fi + fi + for bootfile in `find ${ROOT}boot -name "${KERN_INITRAMFS_SEARCH_NAME}"`; do + einfo "Updating boot splash for ${bootfile}" + update_kernel_initramfs_splash "${GFX_SPLASH_NAME}" "${bootfile}" + done +} diff --git a/eclass/rogentos-kernel.eclass b/eclass/rogentos-kernel.eclass new file mode 100644 index 00000000..7945398e --- /dev/null +++ b/eclass/rogentos-kernel.eclass @@ -0,0 +1,967 @@ +# Copyright 2004-2014 RogentOS Team +# Distributed under the terms of the GNU General Public License v2 +# $ + +# @ECLASS-VARIABLE: K_ROGKERNEL_NAME +# @DESCRIPTION: +# The kernel name used by the ebuild, it should be the ending ${PN} part +# for example, of linux-rogentos it is "${PN/${PN/-*}-}" (rogentos) +K_ROGKERNEL_NAME="${K_ROGKERNEL_NAME:-${PN/${PN/-*}-}}" + +# @ECLASS-VARIABLE: K_ROGKERNEL_SELF_TARBALL_NAME +# @DESCRIPTION: +# If the main kernel sources tarball is generated in-house and available +# on the "rogentos" 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_ROGKERNEL_NAME, +# K_KERNEL_PATCH_VER will be ignored. +# Example: +# K_ROGKERNEL_SELF_TARBALL_NAME="rogentos" +# This would generate: +# SRC_URI="mirror://rogentos/sys-kernel/linux-${PV}+rogentos.tar.${K_TARBALL_EXT}" +K_ROGKERNEL_SELF_TARBALL_NAME="${K_ROGKERNEL_SELF_TARBALL_NAME:-}" + +# @ECLASS-VARIABLE: K_ROGKERNEL_PATCH_UPSTREAM_TARBALL +# @DESCRIPTION: +# If set to 1, the ebuild will fetch the upstream kernel tarball and +# apply the RogentOS patch against it. This strategy avoids the need of +# creating complete kernel source tarballs. The default value is 0. +K_ROGKERNEL_PATCH_UPSTREAM_TARBALL="${K_ROGKERNEL_PATCH_UPSTREAM_TARBALL:-0}" + +# @ECLASS-VARIABLE: K_ROGKERNEL_FORCE_SUBLEVEL +# @DESCRIPTION: +# Force the rewrite of SUBLEVEL in kernel sources Makefile +K_ROGKERNEL_FORCE_SUBLEVEL="${K_ROGKERNEL_FORCE_SUBLEVEL:-}" + +# @ECLASS-VARIABLE: K_ROGKERNEL_RESET_EXTRAVERSION +# @DESCRIPTION: +# Force the rewrite of EXTRAVERSION in kernel sources Makefile (setting it to "") +K_ROGKERNEL_RESET_EXTRAVERSION="${K_ROGKERNEL_RESET_EXTRAVERSION:-}" + +# @ECLASS-VARIABLE: K_ROGKERNEL_LONGTERM +# @DESCRIPTION: +# Consider Kernel stable patchset as longterm (changing URL) +K_ROGKERNEL_LONGTERM="${K_ROGKERNEL_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 +# patch corresponding to patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}.3.${K_TARBALL_EXT} +# @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}" + +# @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_ROGKERNEL_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:-}" + +# @ECLASS-VARIABLE: K_ROGKERNEL_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:-}" + +# @ECLASS-VARIABLE: K_ROGKERNEL_ZFS +# @DESCRIPTION: +# If set, this kernel features ZFS. +K_ROGKERNEL_ZFS="${K_ROGKERNEL_ZFS:-}" + +# @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:-}" + +# @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:-}" + +KERN_INITRAMFS_SEARCH_NAME="${KERN_INITRAMFS_SEARCH_NAME:-initramfs-genkernel*${K_ROGKERNEL_NAME}}" + +# Disable deblobbing feature +K_DEBLOB_AVAILABLE=0 +ETYPE="sources" +K_TARBALL_EXT="${K_TARBALL_EXT:-xz}" + +inherit versionator +if [ "${K_KERNEL_NEW_VERSIONING}" = "1" ]; then + CKV="$(get_version_component_range 1-2)" +fi + +inherit eutils multilib kernel-2 rogentos-artwork mount-boot linux-info + +# from kernel-2 eclass +detect_version +detect_arch + +DESCRIPTION="Kogaion, Argent and ArgOS linux kernel functions and phases" + + +K_LONGTERM_URL_STR="" +if [ -n "${K_ROGKERNEL_LONGTERM}" ]; then + K_LONGTERM_URL_STR="/longterm/v${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}" +fi + +## kernel-2 eclass settings +if [ "${K_ROGKERNEL_PATCH_UPSTREAM_TARBALL}" = "1" ]; then + _patch_name="$(get_version_component_range 1-2)-${K_ROGKERNEL_SELF_TARBALL_NAME}-${PVR}.patch.xz" + SRC_URI="${KERNEL_URI} + mirror://rogentos/${CATEGORY}/${_patch_name} + " + UNIPATCH_LIST="${UNIPATCH_LIST} ${DISTDIR}/${_patch_name}" + unset _patch_name +elif [ -n "${K_ROGKERNEL_SELF_TARBALL_NAME}" ]; then + SRC_URI="mirror://rogentos/${CATEGORY}/linux-${PVR}+${K_ROGKERNEL_SELF_TARBALL_NAME}.tar.${K_TARBALL_EXT}" +else + SRC_URI="${KERNEL_URI}" +fi + +if [ -z "${K_ROGKERNEL_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}.${K_TARBALL_EXT}" + 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="${UNIPATCH_LIST} ${K_KERNEL_PATCH_HOTFIXES}" +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-rogentos + # need to add another final .0 to the version part + echo "${ORIGINAL_KV_FULL/-/.0-}" + else + echo "${ORIGINAL_KV_FULL}" + fi +} + +# replace "linux" with K_ROGKERNEL_NAME, usually replaces +# "linux" with "rogentos" or "server" or "openvz" +KV_FULL="${KV_FULL/${PN/-*}/${K_ROGKERNEL_NAME}}" +EXTRAVERSION="${EXTRAVERSION/${PN/-*}/${K_ROGKERNEL_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 +# sources stuff into /usr/src/linux-3.0.0-rogentos (example) +# 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}" +elif [ "${K_KERNEL_NEW_VERSIONING}" = "1" ]; then + SLOT="$(get_version_component_range 1-2)" +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 +} + +_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 +} + +# provide extra virtual pkg +if _is_kernel_binary; then + PROVIDE="virtual/linux-binary" +# LTS support + if [ "${K_KERNEL_LTS}" = "1" ] || _is_kernel_lts; then + PROVIDE+=" virtual/linux-binary-lts" + fi +fi + +if [ -n "${K_ROGKERNEL_SELF_TARBALL_NAME}" ]; then + HOMEPAGE="https://github.com/Rogentos/kernel" +else + HOMEPAGE="http://www.rogentos.ro" +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}" + 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 + + K_ROGKERNEL_CONFIG_FILES=() + K_ROGKERNEL_CONFIG_FILES+=( "${K_ROGKERNEL_NAME}-${pvr}-$(_get_arch).config" ) + K_ROGKERNEL_CONFIG_FILES+=( "${K_ROGKERNEL_NAME}-${pv}-$(_get_arch).config" ) + K_ROGKERNEL_CONFIG_FILES+=( "${K_ROGKERNEL_NAME}-$(_get_arch).config" ) + + _config_file_set=1 +} + +if [ -n "${K_ONLY_SOURCES}" ] || [ -n "${K_FIRMWARE_PACKAGE}" ]; then + IUSE="${IUSE}" + DEPEND="sys-apps/sed" + RDEPEND="${RDEPEND}" +else + IUSE="dmraid dracut iscsi luks lvm mdadm plymouth splash" + if [ -n "${K_ROGKERNEL_ZFS}" ]; then + IUSE="${IUSE} zfs" + fi + DEPEND="app-arch/xz-utils + sys-apps/sed + sys-devel/autoconf + sys-devel/make + || ( >=sys-kernel/genkernel-next-5 >=sys-kernel/genkernel-3.4.45-r2 ) + arm? ( dev-embedded/u-boot-tools ) + amd64? ( sys-apps/v86d ) + x86? ( sys-apps/v86d ) + splash? ( x11-themes/rogentos-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" + 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 +} + +rogentos-kernel_pkg_setup() { + if [ -n "${K_FIRMWARE_PACKAGE}" ]; then + einfo "Preparing kernel firmwares" + else + einfo "Preparing kernel and its modules" + fi +} + +rogentos-kernel_src_unpack() { + local okv="${OKV}" + if [ -n "${K_ROGKERNEL_SELF_TARBALL_NAME}" ] && [ "${K_ROGKERNEL_PATCH_UPSTREAM_TARBALL}" != "1" ]; then + OKV="${PVR}+${K_ROGKERNEL_SELF_TARBALL_NAME}" + 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 + if [ -n "${K_ROGKERNEL_FORCE_SUBLEVEL}" ]; then + # patch out Makefile with proper sublevel + sed -i "s:^SUBLEVEL = .*:SUBLEVEL = ${K_ROGKERNEL_FORCE_SUBLEVEL}:" \ + "${S}/Makefile" || die + fi + if [ -n "${K_ROGKERNEL_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 + 0|1) rogentos-kernel_src_prepare ;; + esac +} + +rogentos-kernel_src_prepare() { + _set_config_file_vars +} + +rogentos-kernel_src_compile() { + 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 \ + || die "Kernel configuration file not set. Was rogentos-kernel_src_prepare() called?" + + local base_path="${DISTDIR}" + if [ -n "${K_ROGKERNEL_SELF_TARBALL_NAME}" ]; then + base_path="${S}/rogentos/config" + fi + + local found= cfg= + for cfg in "${K_ROGKERNEL_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 + fi + done + [[ -z "${found}" ]] && die "cannot find kernel configs among: ${K_ROGKERNEL_CONFIG_FILES[*]}" +} + +_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 + mkdir -p "${WORKDIR}"/boot + 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 + local GKARGS=() + GKARGS+=( "--no-save-config" "--e2fsprogs" "--udev" ) + use splash && GKARGS+=( "--splash=rogentos" ) + use plymouth && GKARGS+=( "--plymouth" "--plymouth-theme=${PLYMOUTH_THEME}" ) + use dmraid && GKARGS+=( "--dmraid" ) + use iscsi && GKARGS+=( "--iscsi" ) + use mdadm && GKARGS+=( "--mdadm" ) + use luks && GKARGS+=( "--luks" ) + use lvm && GKARGS+=( "--lvm" ) + if [ -n "${K_ROGKERNEL_ZFS}" ]; then + use zfs && GKARGS+=( "--zfs" ) + fi + + 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" + + 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" ) + 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" ) + 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 + 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 + OLDARCH="${ARCH}" + unset ARCH + unset LDFLAGS + DEFAULT_KERNEL_SOURCE="${S}" CMD_KERNEL_DIR="${S}" genkernel "${GKARGS[@]}" ${K_GENKERNEL_ARGS} \ + --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 \ + all || die "genkernel failed" + + if [ -n "${K_MKIMAGE_KERNEL_ADDRESS}" ]; then + unset LOADADDR + fi + + ARCH=${OLDARCH} +} + +_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!" + elif [ "${K_MKIMAGE_WRAP_INITRAMFS}" = "1" ]; then + einfo "Setting up u-boot initramfs for: ${initramfs}" + mkimage -A arm -O linux -T ramdisk -C none -a \ + "${K_MKIMAGE_RAMDISK_ADDRESS}" \ + -e "${K_MKIMAGE_RAMDISK_ENTRYPOINT}" -d "${initramfs}" \ + "${initramfs}.u-boot" || return 1 + mv "${initramfs}.u-boot" "${initramfs}" || return 1 + else + einfo "mkimage won't be called for: ${initramfs}" + fi + return 0 +} + +rogentos-kernel_src_install() { + if [ -n "${K_FIRMWARE_PACKAGE}" ]; then + _firmwares_src_install + elif [ -n "${K_ONLY_SOURCES}" ]; then + _kernel_sources_src_install + else + _kernel_src_install + fi + # File collisions between slots, debug stuff + # not really needed for a kernel + rm -rf "${D}/usr/lib/debug" +} + +_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" + rm -f include/linux/version.h + rm -f include/generated/uapi/linux/version.h + fi + ARCH="${oldarch}" +} + +_kernel_src_install() { + if use arm; then + _setup_mkimage_ramdisk || die "cannot setup mkimage" + fi + + 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 + 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 + + # 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 + + insinto "/boot" + doins "${WORKDIR}"/boot/* || die "cannot copy /boot over" + cp -Rp "${WORKDIR}"/lib/* "${D}/" || die "cannot copy /lib over" + + # 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 + + # 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 + # 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}" +} + +rogentos-kernel_pkg_preinst() { + if _is_kernel_binary; then + mount-boot_pkg_preinst + fi +} +rogentos-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" + 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 + # Linux 3.x support, KV_FULL is set to: 3.0-rogentos + # need to add another final .0 to the version part + echo "${KV_FULL/-/.0-}" + else + echo "${KV_FULL}" + fi +} + +rogentos-kernel_uimage_config() { + # 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 + elog "If you use eselect-bzimage, you are currently booting with kernel:" + elog "${uimage_file}" + elog + elog "Use 'eselect uimage' in order to switch between the available ones" + echo + fi +} + +rogentos-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 +} + +_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}" +} + +rogentos-kernel_pkg_postinst() { + 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 + + # Update kernel initramfs to match user customizations + update_rogentos_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 + + rogentos-kernel_grub2_mkconfig + fi + + # Setup newly installed kernel on ARM + if use arm; then + rogentos-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 + rogentos-kernel_bzimage_config + fi + + kernel-2_pkg_postinst + local depmod_r=$(_get_release_level) + _update_depmod "${depmod_r}" + + elog "Please report kernel bugs at:" + elog "http://bugs.rogentos.ro" + + elog "The source code of this kernel is located at" + elog "=${K_KERNEL_SOURCES_PKG}." + elog "RogentOS Team 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...)." + else + kernel-2_pkg_postinst + fi +} + +rogentos-kernel_pkg_prerm() { + if _is_kernel_binary; then + mount-boot_pkg_prerm + fi +} + +rogentos-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 + + rogentos-kernel_grub2_mkconfig + fi + + # Setup newly installed kernel on ARM + if use arm; then + rogentos-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 + rogentos-kernel_bzimage_config + 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 diff --git a/eclass/sabayon-artwork.eclass b/eclass/sabayon-artwork.eclass new file mode 100644 index 00000000..59d11cca --- /dev/null +++ b/eclass/sabayon-artwork.eclass @@ -0,0 +1,55 @@ +# Copyright 2004-2009 Sabayon Project +# Distributed under the terms of the GNU General Public License v2 +# $ + +inherit eutils + +# @ECLASS-VARIABLE: KERN_INITRAMFS_SEARCH_NAME +# @DESCRIPTION: +# Argument used by `find` to search inside ${ROOT}boot Linux +# Kernel initramfs files to patch +KERN_INITRAMFS_SEARCH_NAME="${KERN_INITRAMFS_SEARCH_NAME:-initramfs-genkernel*}" + +# @ECLASS-VARIABLE: GFX_SPLASH_NAME +# @DESCRIPTION: +# Default splash theme name to use +GFX_SPLASH_NAME="${GFX_SPLASH_NAME:-sabayon}" + +# @FUNCTION: update_kernel_initramfs_splash +# @USAGE: update_kernel_initramfs_splash [splash_theme] [splash_file] +# @RETURN: 1, if something went wrong +# +# @MAINTAINER: +# Fabio Erculiani +update_kernel_initramfs_splash() { + + [[ -z "${2}" ]] && die "wrong update_kernel_splash arguments" + + if ! has_version "media-gfx/splashutils"; then + ewarn "media-gfx/splashutils not found, cannot update kernel splash" + return 1 + fi + splash_geninitramfs -a "${2}" ${1} + return ${?} + +} + +# @FUNCTION: update_sabayon_kernel_initramfs_splash +# @USAGE: update_sabayon_kernel_initramfs_splash +# +# @MAINTAINER: +# Fabio Erculiani +update_sabayon_kernel_initramfs_splash() { + local splash_name="${GFX_SPLASH_NAME}" + local override_splash_file="${ROOT}etc/oem/splash_name" + if [ -f "${override_splash_file}" ]; then + found_splash_name=$(cat "${override_splash_file}" | cut -d" " -f 1) + if [ -d "/etc/splash/${found_splash_name}" ]; then + splash_name="${found_splash_name}" + fi + fi + for bootfile in `find ${ROOT}boot -name "${KERN_INITRAMFS_SEARCH_NAME}"`; do + einfo "Updating boot splash for ${bootfile}" + update_kernel_initramfs_splash "${GFX_SPLASH_NAME}" "${bootfile}" + done +} diff --git a/eclass/sabayon-kernel.eclass b/eclass/sabayon-kernel.eclass new file mode 100644 index 00000000..4c6235d9 --- /dev/null +++ b/eclass/sabayon-kernel.eclass @@ -0,0 +1,967 @@ +# Copyright 2004-2010 Sabayon Project +# Distributed under the terms of the GNU General Public License v2 +# $ + +# @ECLASS-VARIABLE: K_SABKERNEL_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/-*}-}}" + +# @ECLASS-VARIABLE: K_SABKERNEL_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 +# 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. +# Example: +# K_SABKERNEL_SELF_TARBALL_NAME="sabayon" +# This would generate: +# SRC_URI="mirror://sabayon/sys-kernel/linux-${PV}+sabayon.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 Sabayon 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 +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 +# patch corresponding to patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}.3.${K_TARBALL_EXT} +# @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}" + +# @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:-}" + +# @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:-}" + +# @ECLASS-VARIABLE: K_SABKERNEL_ZFS +# @DESCRIPTION: +# If set, this kernel features ZFS. +K_SABKERNEL_ZFS="${K_SABKERNEL_ZFS:-}" + +# @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:-}" + +# @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:-}" + +KERN_INITRAMFS_SEARCH_NAME="${KERN_INITRAMFS_SEARCH_NAME:-initramfs-genkernel*${K_SABKERNEL_NAME}}" + +# Disable deblobbing feature +K_DEBLOB_AVAILABLE=0 +ETYPE="sources" +K_TARBALL_EXT="${K_TARBALL_EXT:-xz}" + +inherit versionator +if [ "${K_KERNEL_NEW_VERSIONING}" = "1" ]; then + CKV="$(get_version_component_range 1-2)" +fi + +inherit eutils multilib kernel-2 sabayon-artwork mount-boot linux-info + +# from kernel-2 eclass +detect_version +detect_arch + +DESCRIPTION="Sabayon Linux kernel functions and phases" + + +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 [ "${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://sabayon/${CATEGORY}/${_patch_name} + " + UNIPATCH_LIST="${UNIPATCH_LIST} ${DISTDIR}/${_patch_name}" + unset _patch_name +elif [ -n "${K_SABKERNEL_SELF_TARBALL_NAME}" ]; then + SRC_URI="mirror://sabayon/${CATEGORY}/linux-${PVR}+${K_SABKERNEL_SELF_TARBALL_NAME}.tar.${K_TARBALL_EXT}" +else + SRC_URI="${KERNEL_URI}" +fi + +if [ -z "${K_SABKERNEL_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}.${K_TARBALL_EXT}" + 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="${UNIPATCH_LIST} ${K_KERNEL_PATCH_HOTFIXES}" +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 + # need to add another final .0 to the version part + echo "${ORIGINAL_KV_FULL/-/.0-}" + 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}}" +# 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 +# sources stuff into /usr/src/linux-3.0.0-sabayon (example) +# 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}" +elif [ "${K_KERNEL_NEW_VERSIONING}" = "1" ]; then + SLOT="$(get_version_component_range 1-2)" +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 +} + +_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 +} + +# provide extra virtual pkg +if _is_kernel_binary; then + PROVIDE="virtual/linux-binary" +# LTS support + if [ "${K_KERNEL_LTS}" = "1" ] || _is_kernel_lts; then + PROVIDE+=" virtual/linux-binary-lts" + fi +fi + +if [ -n "${K_SABKERNEL_SELF_TARBALL_NAME}" ]; then + HOMEPAGE="https://github.com/Sabayon/kernel" +else + HOMEPAGE="http://www.sabayon.org" +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}" + 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 + + 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" ) + + _config_file_set=1 +} + +if [ -n "${K_ONLY_SOURCES}" ] || [ -n "${K_FIRMWARE_PACKAGE}" ]; then + IUSE="${IUSE}" + DEPEND="sys-apps/sed" + RDEPEND="${RDEPEND}" +else + IUSE="dmraid dracut iscsi luks lvm mdadm plymouth splash" + if [ -n "${K_SABKERNEL_ZFS}" ]; then + IUSE="${IUSE} zfs" + fi + DEPEND="app-arch/xz-utils + sys-apps/sed + sys-devel/autoconf + sys-devel/make + || ( >=sys-kernel/genkernel-next-5 >=sys-kernel/genkernel-3.4.45-r2 ) + arm? ( dev-embedded/u-boot-tools ) + amd64? ( sys-apps/v86d ) + x86? ( sys-apps/v86d ) + splash? ( x11-themes/sabayon-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" + 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 +} + +sabayon-kernel_pkg_setup() { + if [ -n "${K_FIRMWARE_PACKAGE}" ]; then + einfo "Preparing kernel firmwares" + else + einfo "Preparing kernel and its modules" + fi +} + +sabayon-kernel_src_unpack() { + local okv="${OKV}" + if [ -n "${K_SABKERNEL_SELF_TARBALL_NAME}" ] && [ "${K_SABKERNEL_PATCH_UPSTREAM_TARBALL}" != "1" ]; then + OKV="${PVR}+${K_SABKERNEL_SELF_TARBALL_NAME}" + 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 + 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 + 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 + 0|1) sabayon-kernel_src_prepare ;; + esac +} + +sabayon-kernel_src_prepare() { + _set_config_file_vars +} + +sabayon-kernel_src_compile() { + 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 \ + || die "Kernel configuration file not set. Was sabayon-kernel_src_prepare() called?" + + local base_path="${DISTDIR}" + if [ -n "${K_SABKERNEL_SELF_TARBALL_NAME}" ]; then + base_path="${S}/sabayon/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 + fi + done + [[ -z "${found}" ]] && die "cannot find kernel configs among: ${K_SABKERNEL_CONFIG_FILES[*]}" +} + +_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 + mkdir -p "${WORKDIR}"/boot + 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 + local GKARGS=() + GKARGS+=( "--no-save-config" "--e2fsprogs" "--udev" ) + use splash && GKARGS+=( "--splash=sabayon" ) + use plymouth && GKARGS+=( "--plymouth" "--plymouth-theme=${PLYMOUTH_THEME}" ) + 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 + + 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" + + 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" ) + 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" ) + 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 + 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 + OLDARCH="${ARCH}" + unset ARCH + unset LDFLAGS + DEFAULT_KERNEL_SOURCE="${S}" CMD_KERNEL_DIR="${S}" genkernel "${GKARGS[@]}" ${K_GENKERNEL_ARGS} \ + --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 \ + all || die "genkernel failed" + + if [ -n "${K_MKIMAGE_KERNEL_ADDRESS}" ]; then + unset LOADADDR + fi + + ARCH=${OLDARCH} +} + +_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!" + elif [ "${K_MKIMAGE_WRAP_INITRAMFS}" = "1" ]; then + einfo "Setting up u-boot initramfs for: ${initramfs}" + mkimage -A arm -O linux -T ramdisk -C none -a \ + "${K_MKIMAGE_RAMDISK_ADDRESS}" \ + -e "${K_MKIMAGE_RAMDISK_ENTRYPOINT}" -d "${initramfs}" \ + "${initramfs}.u-boot" || return 1 + mv "${initramfs}.u-boot" "${initramfs}" || return 1 + else + einfo "mkimage won't be called for: ${initramfs}" + fi + return 0 +} + +sabayon-kernel_src_install() { + if [ -n "${K_FIRMWARE_PACKAGE}" ]; then + _firmwares_src_install + elif [ -n "${K_ONLY_SOURCES}" ]; then + _kernel_sources_src_install + else + _kernel_src_install + fi + # File collisions between slots, debug stuff + # not really needed for a kernel + rm -rf "${D}/usr/lib/debug" +} + +_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" + rm -f include/linux/version.h + rm -f include/generated/uapi/linux/version.h + fi + ARCH="${oldarch}" +} + +_kernel_src_install() { + if use arm; then + _setup_mkimage_ramdisk || die "cannot setup mkimage" + fi + + 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 + 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 + + # 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 + + insinto "/boot" + doins "${WORKDIR}"/boot/* || die "cannot copy /boot over" + cp -Rp "${WORKDIR}"/lib/* "${D}/" || die "cannot copy /lib over" + + # 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 + + # 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 + # 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}" +} + +sabayon-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" + 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 + # Linux 3.x support, KV_FULL is set to: 3.0-sabayon + # need to add another final .0 to the version part + echo "${KV_FULL/-/.0-}" + else + echo "${KV_FULL}" + fi +} + +sabayon-kernel_uimage_config() { + # 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 + elog "If you use eselect-bzimage, you are currently booting with kernel:" + elog "${uimage_file}" + elog + elog "Use 'eselect uimage' in order to switch between the available ones" + echo + 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 +} + +_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}" +} + +sabayon-kernel_pkg_postinst() { + 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 + + # 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 + fi + + kernel-2_pkg_postinst + local depmod_r=$(_get_release_level) + _update_depmod "${depmod_r}" + + elog "Please report kernel bugs at:" + elog "http://bugs.sabayon.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 "${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...)." + else + kernel-2_pkg_postinst + fi +} + +sabayon-kernel_pkg_prerm() { + if _is_kernel_binary; then + mount-boot_pkg_prerm + fi +} + +sabayon-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 + 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 diff --git a/eclass/spl-zfs-kernel.eclass b/eclass/spl-zfs-kernel.eclass new file mode 100644 index 00000000..74fb8589 --- /dev/null +++ b/eclass/spl-zfs-kernel.eclass @@ -0,0 +1,183 @@ +# Copyright 2004-2012 Sabayon Linux +# Distributed under the terms of the GNU General Public License v2 +# $ + +AT_M4DIR="config" +AUTOTOOLS_AUTORECONF="1" +AUTOTOOLS_IN_SOURCE_BUILD="1" + +inherit eutils flag-o-matic git-2 linux-mod autotools-utils + +# export all the available functions here +EXPORT_FUNCTIONS pkg_setup src_unpack src_prepare src_configure src_compile src_install pkg_preinst pkg_postinst pkg_postrm + +# @ECLASS-VARIABLE: ZFS_GIT_REPO +# @DESCRIPTION: +# Identified the ZFS Git repo from where to pull +ZFS_GIT_REPO="${ZFS_GIT_REPO:-}" + +# @ECLASS-VARIABLE: ZFS_GIT_BRANCH +# @DESCRIPTION: +# Identified the ZFS Git branch from where to pull +ZFS_GIT_BRANCH="${ZFS_GIT_BRANCH:-}" + +# @ECLASS-VARIABLE: ZFS_GIT_COMMIT +# @DESCRIPTION: +# Identified the ZFS Git commit from where to pull +ZFS_GIT_COMMIT="${ZFS_GIT_COMMIT:-}" + +# @ECLASS-VARIABLE: SPL_GIT_REPO +# @DESCRIPTION: +# Identified the SPL Git repo from where to pull +SPL_GIT_REPO="${SPL_GIT_REPO:-}" + +# @ECLASS-VARIABLE: SPL_GIT_BRANCH +# @DESCRIPTION: +# Identified the SPL Git branch from where to pull +SPL_GIT_BRANCH="${SPL_GIT_BRANCH:-}" + +# @ECLASS-VARIABLE: SPL_GIT_COMMIT +# @DESCRIPTION: +# Identified the SPL Git commit from where to pull +SPL_GIT_COMMIT="${SPL_GIT_COMMIT:-}" + +SRC_URI="" + +DESCRIPTION="The Solaris Porting Layer Linux kernel module and ZFS Filesystem" +HOMEPAGE="http://zfsonlinux.org/" + +LICENSE="|| ( GPL-2 GPL-3 ) CDDL" +SLOT="0" +KEYWORDS="~amd64 ~x86" +IUSE="custom-cflags debug" + +RDEPEND+="!sys-devel/spl ~sys-fs/zfs-userspace-${PV}" + +SPL_S="${S}/spl-src" +ZFS_S="${S}/zfs-src" + +spl-zfs-kernel_pkg_setup() { + CONFIG_CHECK=" + !DEBUG_LOCK_ALLOC + BLK_DEV_LOOP + EFI_PARTITION + MODULES + KALLSYMS + ZLIB_DEFLATE + ZLIB_INFLATE" + kernel_is ge 2 6 26 || die "Linux 2.6.26 or newer required" + check_extra_config +} + +spl-zfs-kernel_src_unpack() { + # unpack spl + EGIT_REPO_URI="${SPL_GIT_REPO}" \ + EGIT_BRANCH="${SPL_GIT_BRANCH}" \ + EGIT_COMMIT="${SPL_GIT_COMMIT}" \ + EGIT_SOURCEDIR="${SPL_S}" \ + git-2_src_unpack + + # unpack zfs + EGIT_REPO_URI="${ZFS_GIT_REPO}" \ + EGIT_BRANCH="${ZFS_GIT_BRANCH}" \ + EGIT_COMMIT="${ZFS_GIT_COMMIT}" \ + EGIT_SOURCEDIR="${ZFS_S}" \ + git-2_src_unpack +} + +_zfs_src_prepare() { + # Workaround for hard coded path + sed -i "s|/sbin/lsmod|/bin/lsmod|" "${ZFS_S}"/scripts/common.sh.in || die + # Workaround rename + sed -i "s|/usr/bin/scsi-rescan|/usr/sbin/rescan-scsi-bus|" "${ZFS_S}"/scripts/common.sh.in || die + cd "${ZFS_S}" && ECONF_SOURCE="${ZFS_S}" autotools-utils_src_prepare +} + +_spl_src_prepare() { + # Workaround for hard coded path + sed -i "s|/sbin/lsmod|/bin/lsmod|" "${SPL_S}"/scripts/check.sh || die + cd "${SPL_S}" && ECONF_SOURCE="${SPL_S}" autotools-utils_src_prepare +} + +spl-zfs-kernel_src_prepare() { + _spl_src_prepare + _zfs_src_prepare +} + +_zfs_src_configure() { + use custom-cflags || strip-flags + set_arch_to_kernel + + local myeconfargs=( + --bindir="${EPREFIX}/bin" + --sbindir="${EPREFIX}/sbin" + --with-config=kernel + --with-linux="${KV_DIR}" + --with-linux-obj="${KV_OUT_DIR}" + --with-udevdir="${EPREFIX}/lib/udev" + $(use_enable debug) + --with-spl="${SPL_S}" + ) + cd "${ZFS_S}" && ECONF_SOURCE="${ZFS_S}" autotools-utils_src_configure +} + +_spl_src_configure() { + use custom-cflags || strip-flags + set_arch_to_kernel + + local myeconfargs=( + --bindir="${EPREFIX}/bin" + --sbindir="${EPREFIX}/sbin" + --with-config=all + --with-linux="${KV_DIR}" + --with-linux-obj="${KV_OUT_DIR}" + $(use_enable debug) + --with-config=kernel + ) + cd "${SPL_S}" && ECONF_SOURCE="${SPL_S}" autotools-utils_src_configure +} + +spl-zfs-kernel_src_configure() { + _spl_src_configure + _zfs_src_configure +} + +_zfs_src_compile() { + cd "${ZFS_S}" && ECONF_SOURCE="${ZFS_S}" autotools-utils_src_compile +} + +_spl_src_compile() { + cd "${SPL_S}" && ECONF_SOURCE="${SPL_S}" autotools-utils_src_compile +} + +spl-zfs-kernel_src_compile() { + _spl_src_compile + _zfs_src_compile +} + +_zfs_src_install() { + cd "${ZFS_S}" && ECONF_SOURCE="${ZFS_S}" autotools-utils_src_install + rm -rf "${ED}"/usr # make sure +} + +_spl_src_install() { + cd "${SPL_S}" && ECONF_SOURCE="${SPL_S}" autotools-utils_src_install + rm -rf "${ED}"/usr # make sure +} + +spl-zfs-kernel_src_install() { + _spl_src_install + _zfs_src_install +} + +spl-zfs-kernel_pkg_preinst() { + linux-mod_pkg_preinst +} + +spl-zfs-kernel_pkg_postinst() { + linux-mod_pkg_postinst +} + +spl-zfs-kernel_pkg_postrm() { + linux-mod_pkg_postrm +} diff --git a/eclass/spl-zfs-userspace.eclass b/eclass/spl-zfs-userspace.eclass new file mode 100644 index 00000000..33c211a6 --- /dev/null +++ b/eclass/spl-zfs-userspace.eclass @@ -0,0 +1,218 @@ +# Copyright 2004-2012 Sabayon Linux +# Distributed under the terms of the GNU General Public License v2 +# $ + +AT_M4DIR="config" +AUTOTOOLS_AUTORECONF="1" +AUTOTOOLS_IN_SOURCE_BUILD="1" + +inherit eutils flag-o-matic git-2 linux-mod autotools-utils + +# export all the available functions here +EXPORT_FUNCTIONS pkg_setup src_unpack src_prepare src_configure src_compile src_install src_test + +# @ECLASS-VARIABLE: ZFS_GIT_REPO +# @DESCRIPTION: +# Identified the ZFS Git repo from where to pull +ZFS_GIT_REPO="${ZFS_GIT_REPO:-}" + +# @ECLASS-VARIABLE: ZFS_GIT_BRANCH +# @DESCRIPTION: +# Identified the ZFS Git branch from where to pull +ZFS_GIT_BRANCH="${ZFS_GIT_BRANCH:-}" + +# @ECLASS-VARIABLE: ZFS_GIT_COMMIT +# @DESCRIPTION: +# Identified the ZFS Git commit from where to pull +ZFS_GIT_COMMIT="${ZFS_GIT_COMMIT:-}" + +# @ECLASS-VARIABLE: SPL_GIT_REPO +# @DESCRIPTION: +# Identified the SPL Git repo from where to pull +SPL_GIT_REPO="${SPL_GIT_REPO:-}" + +# @ECLASS-VARIABLE: SPL_GIT_BRANCH +# @DESCRIPTION: +# Identified the SPL Git branch from where to pull +SPL_GIT_BRANCH="${SPL_GIT_BRANCH:-}" + +# @ECLASS-VARIABLE: SPL_GIT_COMMIT +# @DESCRIPTION: +# Identified the SPL Git commit from where to pull +SPL_GIT_COMMIT="${SPL_GIT_COMMIT:-}" + +SRC_URI="" + +DESCRIPTION="The Solaris Porting Layer and ZFS Filesystem userspace utilities" +HOMEPAGE="http://zfsonlinux.org/" + +LICENSE="|| ( GPL-2 GPL-3 ) CDDL" +SLOT="0" +KEYWORDS="~amd64 ~x86" + +IUSE="custom-cflags debug dracut +rootfs test test-suite static-libs" +DEPEND+=" sys-apps/util-linux[static-libs?] + sys-libs/zlib[static-libs(+)?]" +RDEPEND+=" ${DEPEND} + !sys-fs/zfs-fuse + !prefix? ( sys-fs/udev ) + test-suite? ( + sys-apps/gawk + sys-apps/util-linux + sys-devel/bc + sys-block/parted + sys-fs/lsscsi + sys-fs/mdadm + sys-process/procps + virtual/modutils + ) + rootfs? ( + app-arch/cpio + app-misc/pax-utils + )" +DEPEND+=" test? ( sys-fs/mdadm )" + +SPL_S="${S}/spl-src" +ZFS_S="${S}/zfs-src" + +spl-zfs-userspace_pkg_setup() { + CONFIG_CHECK=" + !DEBUG_LOCK_ALLOC + BLK_DEV_LOOP + EFI_PARTITION + MODULES + KALLSYMS + ZLIB_DEFLATE + ZLIB_INFLATE" + kernel_is ge 2 6 26 || die "Linux 2.6.26 or newer required" + check_extra_config +} + +spl-zfs-userspace_src_unpack() { + # unpack spl + EGIT_REPO_URI="${SPL_GIT_REPO}" \ + EGIT_BRANCH="${SPL_GIT_BRANCH}" \ + EGIT_COMMIT="${SPL_GIT_COMMIT}" \ + EGIT_SOURCEDIR="${SPL_S}" \ + git-2_src_unpack + + # unpack zfs + EGIT_REPO_URI="${ZFS_GIT_REPO}" \ + EGIT_BRANCH="${ZFS_GIT_BRANCH}" \ + EGIT_COMMIT="${ZFS_GIT_COMMIT}" \ + EGIT_SOURCEDIR="${ZFS_S}" \ + git-2_src_unpack +} + +_zfs_src_prepare() { + # Workaround for hard coded path + sed -i "s|/sbin/lsmod|/bin/lsmod|" "${ZFS_S}"/scripts/common.sh.in || die + # Workaround rename + sed -i "s|/usr/bin/scsi-rescan|/usr/sbin/rescan-scsi-bus|" "${ZFS_S}"/scripts/common.sh.in || die + cd "${ZFS_S}" && ECONF_SOURCE="${ZFS_S}" autotools-utils_src_prepare +} + +_spl_src_prepare() { + # Workaround for hard coded path + sed -i "s|/sbin/lsmod|/bin/lsmod|" "${SPL_S}"/scripts/check.sh || die + cd "${SPL_S}" && ECONF_SOURCE="${SPL_S}" autotools-utils_src_prepare +} + +spl-zfs-userspace_src_prepare() { + _spl_src_prepare + _zfs_src_prepare +} + +_zfs_src_configure() { + use custom-cflags || strip-flags + set_arch_to_kernel + + local myeconfargs=( + --bindir="${EPREFIX}/bin" + --sbindir="${EPREFIX}/sbin" + --with-config=user + --with-linux="${KV_DIR}" + --with-linux-obj="${KV_OUT_DIR}" + --with-udevdir="${EPREFIX}/lib/udev" + $(use_enable debug) + --with-spl="${SPL_S}" + ) + cd "${ZFS_S}" && ECONF_SOURCE="${ZFS_S}" autotools-utils_src_configure +} + +_spl_src_configure() { + use custom-cflags || strip-flags + set_arch_to_kernel + + local myeconfargs=( + --bindir="${EPREFIX}/bin" + --sbindir="${EPREFIX}/sbin" + --with-config=all + --with-linux="${KV_DIR}" + --with-linux-obj="${KV_OUT_DIR}" + $(use_enable debug) + --with-config=user + ) + cd "${SPL_S}" && ECONF_SOURCE="${SPL_S}" autotools-utils_src_configure +} + +spl-zfs-userspace_src_configure() { + _spl_src_configure + _zfs_src_configure +} + +_zfs_src_compile() { + cd "${ZFS_S}" && ECONF_SOURCE="${ZFS_S}" autotools-utils_src_compile +} + +_spl_src_compile() { + cd "${SPL_S}" && ECONF_SOURCE="${SPL_S}" autotools-utils_src_compile +} + +spl-zfs-userspace_src_compile() { + _spl_src_compile + _zfs_src_compile +} + +_zfs_src_install() { + cd "${ZFS_S}" && ECONF_SOURCE="${ZFS_S}" autotools-utils_src_install + gen_usr_ldscript -a uutil nvpair zpool zfs + use dracut || rm -rf "${ED}usr/share/dracut" + use test-suite || rm -rf "${ED}usr/libexec" + + if use rootfs + then + doinitd "${FILESDIR}/zfs-shutdown" + exeinto /usr/share/zfs + doexe "${FILESDIR}/linuxrc" + fi +} + +_spl_src_install() { + cd "${SPL_S}" && ECONF_SOURCE="${SPL_S}" autotools-utils_src_install + rm -rf "${ED}"/usr # make sure +} + +spl-zfs-userspace_src_install() { + _spl_src_install + _zfs_src_install +} + +spl-zfs-userspace_src_test() { + if [[ ! -e /proc/modules ]] + then + die "Missing /proc/modules" + elif [[ $UID -ne 0 ]] + then + ewarn "Cannot run make check tests with FEATURES=userpriv." + ewarn "Skipping make check tests." + elif grep -q '^spl ' /proc/modules + then + ewarn "Cannot run make check tests with module spl loaded." + ewarn "Skipping make check tests." + else + cd "${SPL_S}" && ECONF_SOURCE="${SPL_S}" autotools-utils_src_test + cd "${ZFS_S}" && ECONF_SOURCE="${ZFS_S}" autotools-utils_src_test + fi +} + diff --git a/eclass/transmission-2.51.eclass b/eclass/transmission-2.51.eclass new file mode 100644 index 00000000..e1e32e02 --- /dev/null +++ b/eclass/transmission-2.51.eclass @@ -0,0 +1,294 @@ +# Copyright 1999-2012 Sabayon +# Distributed under the terms of the GNU General Public License v2 +# $Header: $ + +# @ECLASS: transmission-2.51.eclass +# @MAINTAINER: +# slawomir.nizio@sabayon.org +# @AUTHOR: +# Sławomir Nizio <slawomir.nizio@sabayon.org> +# @BLURB: eclass to ease managing of Sabayon split net-p2p/transmission +# @DESCRIPTION: +# This eclass is to ease managing of split net-p2p/transmission for Sabayon. +# Its name contains a version that corresponds to net-p2p/transmission one, +# because the eclass will change often when needed to follow changes +# in Gentoo ebuild. + +# @ECLASS-VARIABLE: TRANSMISSION_ECLASS_VERSION_OK +# @DESCRIPTION: +# Set this to x.y if you want to use transmission-x.y.eclass from ebuild +# with ${PV} different than x.y. This is to catch bugs. +: ${TRANSMISSION_ECLASS_VERSION_OK:=${PV}} + +# @ECLASS-VARIABLE: E_TRANSM_TAIL +# @DESCRIPTION: +# "Tail" of package name. Can take value gtk, qt4, etc. or can be empty. +# It shouldn't be modified. +E_TRANSM_TAIL=${PN#transmission} +E_TRANSM_TAIL=${E_TRANSM_TAIL#-} + +# @FUNCTION: _transmission_is +# @DESCRIPTION: +# Function used to check which variant of Transmission are we working on. +# Argument should be one of these: (none), gtk, qt4, daemon, cli, base. +# If argument is empty or omitted, true value means that it is +# net-p2p/transmission (metapackage). +# Consider it private. +_transmission_is() { + local what=$1 + [[ ${what} = "${E_TRANSM_TAIL}" ]] +} + +LANGS="en es kk lt pt_BR ru" # used only for -qt + +unset _live_inherits +if [[ ${PV} == *9999* ]]; then + # not tested in the eclass + ESVN_REPO_URI="svn://svn.transmissionbt.com/Transmission/trunk" + _live_inherits=subversion +fi + +MY_ECLASSES="" +_transmission_is gtk && MY_ECLASSES+="fdo-mime gnome2-utils" +_transmission_is qt4 && MY_ECLASSES+="fdo-mime qt4-r2" +_transmission_is "" || MY_ECLASSES+=" autotools" + +inherit eutils multilib ${MY_ECLASSES} ${_live_inherits} + +unset MY_ECLASSES + +case ${EAPI:-0} in + 4|3) EXPORT_FUNCTIONS pkg_setup src_prepare src_configure src_compile \ + pkg_preinst pkg_postinst pkg_postrm ;; + *) die "EAPI=${EAPI} is not supported" ;; +esac + +[[ ${PN} = transmission* ]] || \ + die "This eclass can only be used with net-p2p/transmission* ebuilds!" +# Bug catcher! +if ! [[ ${PV} = *9999* ]] && [[ ${TRANSMISSION_ECLASS_VERSION_OK} != ${ECLASS#*-} ]]; then + eerror "used eclass ${ECLASS}" + eerror "TRANSMISSION_ECLASS_VERSION_OK=${TRANSMISSION_ECLASS_VERSION_OK}" + die "ebuild version ${PV} doesn't match with the eclass" +fi + +MY_PN="transmission" +MY_P="${MY_PN}-${PV}" + +DESCRIPTION="A Fast, Easy and Free BitTorrent client" +HOMEPAGE="http://www.transmissionbt.com/" +SRC_URI="http://download.transmissionbt.com/${MY_PN}/files/${MY_P}.tar.xz" + +LICENSE="GPL-2 MIT" +SLOT="0" +IUSE="" + +# only common dependencies plus blockers +RDEPEND="" +_transmission_is base || RDEPEND+="~net-p2p/transmission-base-${PV}" +if ! _transmission_is ""; then + RDEPEND+=" + >=dev-libs/libevent-2.0.10 + dev-libs/openssl:0 + >=net-libs/miniupnpc-1.6 + >=net-misc/curl-7.16.3[ssl] + net-libs/libnatpmp + sys-libs/zlib" +fi + +DEPEND="${RDEPEND}" +if _transmission_is base; then + RDEPEND+=" !<net-p2p/transmission-gtk-${PV} + !<net-p2p/transmission-qt4-${PV} + !<net-p2p/transmission-daemon-${PV} + !<net-p2p/transmission-cli-${PV}" +fi +if ! _transmission_is ""; then + DEPEND+=" dev-util/intltool + dev-util/pkgconfig + sys-devel/gettext + virtual/os-headers" +fi + +S="${WORKDIR}/${MY_P}" +_transmission_is "" && S="${WORKDIR}" + +transmission-2.51_pkg_setup() { + if _transmission_is base; then + enewgroup transmission + enewuser transmission -1 -1 -1 transmission + fi +} + +transmission-2.51_src_unpack() { + if [[ ${PV} == *9999* ]]; then + subversion_src_unpack + else + default + fi +} + +transmission-2.51_src_prepare() { + _transmission_is "" && return + + if [[ ${PV} == *9999* ]]; then + subversion_src_prepare + ./update-version-h.sh + fi + + sed -i -e '/CFLAGS/s:-ggdb3::' configure.ac || die + + if ! use_if_iuse ayatana; then + sed -i -e '/^LIBAPPINDICATOR_MINIMUM/s:=.*:=9999:' configure.ac || die + fi + + # http://trac.transmissionbt.com/ticket/4324 + sed -i -e 's|noinst\(_PROGRAMS = $(TESTS)\)|check\1|' lib${MY_PN}/Makefile.am || die + + intltoolize --copy --force --automake || die + eautoreconf + + if _transmission_is qt4; then + cat <<-EOF > "${T}"/${MY_PN}-magnet.protocol + [Protocol] + exec=transmission-qt '%u' + protocol=magnet + Icon=transmission + input=none + output=none + helper=true + listing= + reading=false + writing=false + makedir=false + deleting=false + EOF + fi + + if ! _transmission_is base; then + local sedcmd="s:\$(top_builddir)/libtransmission/libtransmission.a:" + sedcmd+="${EROOT}usr/$(get_libdir)/libtransmission.a:" + find . -name Makefile.in -exec sed -i -e "${sedcmd}" {} \; || die + sed -i -e '/libtransmission \\/d' Makefile.in || die + if _transmission_is qt4; then + sedcmd="s:\$\${TRANSMISSION_TOP}/libtransmission/libtransmission.a:" + sedcmd+="${EROOT}usr/$(get_libdir)/libtransmission.a:" + sed -i -e "${sedcmd}" qt/qtr.pro || die + fi + fi +} + +transmission-2.51_src_configure() { + _transmission_is "" && return + + local econfargs=( + --enable-external-natpmp + ) + + if _transmission_is base; then + export ac_cv_header_xfs_xfs_h=$(usex xfs) + econfargs+=( + --disable-cli + --disable-daemon + --without-gtk + $(use_enable lightweight) + ) + elif _transmission_is cli; then + econfargs+=( + --enable-cli + --disable-daemon + --without-gtk + ) + elif _transmission_is daemon; then + econfargs+=( + --disable-cli + --enable-daemon + --without-gtk + ) + elif _transmission_is gtk; then + econfargs+=( + --disable-cli + --disable-daemon + --with-gtk + ) + elif _transmission_is qt4; then + econfargs+=( + --disable-cli + --disable-daemon + --without-gtk + ) + else + die "Something is wrong... (E_TRANSM_TAIL=$E_TRANSM_TAIL)" + fi + + econf "${econfargs[@]}" + if _transmission_is qt4; then + pushd qt >/dev/null + eqmake4 qtr.pro + popd >/dev/null + fi +} + +transmission-2.51_src_compile() { + _transmission_is "" && return + + emake + if _transmission_is qt4; then + pushd qt >/dev/null + emake + + local l + for l in ${LANGS}; do + if use linguas_${l}; then + lrelease translations/${MY_PN}_${l}.ts + fi + done + popd >/dev/null + fi +} + + +# Note: not providing src_install. Too many differences and too much code +# which would only clutter this pretty eclass. + +transmission-2.51_pkg_preinst() { + _transmission_is gtk && gnome2_icon_savelist +} + +transmission-2.51_pkg_postinst() { + if _transmission_is gtk || _transmission_is qt4; then + fdo-mime_desktop_database_update + fi + + _transmission_is gtk && gnome2_icon_cache_update + + if _transmission_is daemon; then + elog "If you use ${MY_PN}-daemon, please, set 'rpc-username' and" + elog "'rpc-password' (in plain text, ${MY_PN}-daemon will hash it on" + elog "start) in settings.json file located at /var/${MY_PN}/config or" + elog "any other appropriate config directory." + fi + + if _transmission_is gtk; then + # in -gtk only? + elog + elog "To enable sound emerge media-libs/libcanberra and check that at least" + elog "some sound them is selected. For this go:" + elog "Gnome/system/preferences/sound themes tab and 'sound theme: default'" + elog + fi + + elog "Since µTP is enabled by default, ${MY_PN} needs large kernel buffers for" + elog "the UDP socket. You can append following lines into /etc/sysctl.conf:" + elog " net.core.rmem_max = 4194304" + elog " net.core.wmem_max = 1048576" + elog "and run sysctl -p" +} + +transmission-2.51_pkg_postrm() { + if _transmission_is gtk || _transmission_is qt4; then + fdo-mime_desktop_database_update + fi + + _transmission_is gtk && gnome2_icon_cache_update +} diff --git a/eclass/transmission-2.52.eclass b/eclass/transmission-2.52.eclass new file mode 100644 index 00000000..17b3aa14 --- /dev/null +++ b/eclass/transmission-2.52.eclass @@ -0,0 +1,295 @@ +# Copyright 1999-2012 Sabayon +# Distributed under the terms of the GNU General Public License v2 +# $Header: $ + +# @ECLASS: transmission-2.52.eclass +# @MAINTAINER: +# slawomir.nizio@sabayon.org +# @AUTHOR: +# Sławomir Nizio <slawomir.nizio@sabayon.org> +# @BLURB: eclass to ease managing of Sabayon split net-p2p/transmission +# @DESCRIPTION: +# This eclass is to ease managing of split net-p2p/transmission for Sabayon. +# Its name contains a version that corresponds to net-p2p/transmission one, +# because the eclass will change often when needed to follow changes +# in Gentoo ebuild. + +# @ECLASS-VARIABLE: TRANSMISSION_ECLASS_VERSION_OK +# @DESCRIPTION: +# Set this to x.y if you want to use transmission-x.y.eclass from ebuild +# with ${PV} different than x.y. This is to catch bugs. +: ${TRANSMISSION_ECLASS_VERSION_OK:=${PV}} + +# @ECLASS-VARIABLE: E_TRANSM_TAIL +# @DESCRIPTION: +# "Tail" of package name. Can take value gtk, qt4, etc. or can be empty. +# It shouldn't be modified. +E_TRANSM_TAIL=${PN#transmission} +E_TRANSM_TAIL=${E_TRANSM_TAIL#-} + +# @FUNCTION: _transmission_is +# @DESCRIPTION: +# Function used to check which variant of Transmission are we working on. +# Argument should be one of these: (none), gtk, qt4, daemon, cli, base. +# If argument is empty or omitted, true value means that it is +# net-p2p/transmission (metapackage). +# Consider it private. +_transmission_is() { + local what=$1 + [[ ${what} = "${E_TRANSM_TAIL}" ]] +} + +LANGS="en es kk lt pt_BR ru" # used only for -qt + +unset _live_inherits +if [[ ${PV} == *9999* ]]; then + # not tested in the eclass + ESVN_REPO_URI="svn://svn.transmissionbt.com/Transmission/trunk" + _live_inherits=subversion +fi + +MY_ECLASSES="" +_transmission_is gtk && MY_ECLASSES+="fdo-mime gnome2-utils" +_transmission_is qt4 && MY_ECLASSES+="fdo-mime qt4-r2" +_transmission_is "" || MY_ECLASSES+=" autotools" + +inherit eutils multilib ${MY_ECLASSES} ${_live_inherits} + +unset MY_ECLASSES + +case ${EAPI:-0} in + 4|3) EXPORT_FUNCTIONS pkg_setup src_prepare src_configure src_compile \ + pkg_preinst pkg_postinst pkg_postrm ;; + *) die "EAPI=${EAPI} is not supported" ;; +esac + +[[ ${PN} = transmission* ]] || \ + die "This eclass can only be used with net-p2p/transmission* ebuilds!" +# Bug catcher! +if ! [[ ${PV} = *9999* ]] && [[ ${TRANSMISSION_ECLASS_VERSION_OK} != ${ECLASS#*-} ]]; then + eerror "used eclass ${ECLASS}" + eerror "TRANSMISSION_ECLASS_VERSION_OK=${TRANSMISSION_ECLASS_VERSION_OK}" + die "ebuild version ${PV} doesn't match with the eclass" +fi + +MY_PN="transmission" +MY_P="${MY_PN}-${PV}" + +DESCRIPTION="A Fast, Easy and Free BitTorrent client" +HOMEPAGE="http://www.transmissionbt.com/" +SRC_URI="http://download.transmissionbt.com/${MY_PN}/files/${MY_P}.tar.xz" + +LICENSE="GPL-2 MIT" +SLOT="0" +IUSE="" + +# only common dependencies plus blockers +RDEPEND="" +_transmission_is base || RDEPEND+="~net-p2p/transmission-base-${PV}" +if ! _transmission_is ""; then + RDEPEND+=" + >=dev-libs/libevent-2.0.10 + dev-libs/openssl:0 + >=net-libs/miniupnpc-1.6.20120509 + >=net-misc/curl-7.16.3[ssl] + net-libs/libnatpmp + sys-libs/zlib" +fi + +DEPEND="${RDEPEND}" +if _transmission_is base; then + RDEPEND+=" !<net-p2p/transmission-gtk-${PV} + !<net-p2p/transmission-qt4-${PV} + !<net-p2p/transmission-daemon-${PV} + !<net-p2p/transmission-cli-${PV}" +fi +if ! _transmission_is ""; then + DEPEND+=" dev-util/intltool + virtual/pkgconfig + sys-devel/gettext + virtual/os-headers" +fi + +S="${WORKDIR}/${MY_P}" +_transmission_is "" && S="${WORKDIR}" + +transmission-2.52_pkg_setup() { + if _transmission_is base; then + enewgroup transmission + enewuser transmission -1 -1 -1 transmission + fi +} + +transmission-2.52_src_unpack() { + if [[ ${PV} == *9999* ]]; then + subversion_src_unpack + else + default + fi +} + +transmission-2.52_src_prepare() { + _transmission_is "" && return + + if [[ ${PV} == *9999* ]]; then + subversion_src_prepare + ./update-version-h.sh + fi + + sed -i -e '/CFLAGS/s:-ggdb3::' configure.ac || die + + if ! use_if_iuse ayatana; then + sed -i -e '/^LIBAPPINDICATOR_MINIMUM/s:=.*:=9999:' configure.ac || die + fi + + # http://trac.transmissionbt.com/ticket/4324 + sed -i -e 's|noinst\(_PROGRAMS = $(TESTS)\)|check\1|' lib${MY_PN}/Makefile.am || die + + # [eclass] patch for FreeBSD skipped + + eautoreconf + + if _transmission_is qt4; then + cat <<-EOF > "${T}"/${MY_PN}-magnet.protocol + [Protocol] + exec=transmission-qt '%u' + protocol=magnet + Icon=transmission + input=none + output=none + helper=true + listing= + reading=false + writing=false + makedir=false + deleting=false + EOF + fi + + if ! _transmission_is base; then + local sedcmd="s:\$(top_builddir)/libtransmission/libtransmission.a:" + sedcmd+="${EROOT}usr/$(get_libdir)/libtransmission.a:" + find . -name Makefile.in -exec sed -i -e "${sedcmd}" {} \; || die + sed -i -e '/libtransmission \\/d' Makefile.in || die + if _transmission_is qt4; then + sedcmd="s:\$\${TRANSMISSION_TOP}/libtransmission/libtransmission.a:" + sedcmd+="${EROOT}usr/$(get_libdir)/libtransmission.a:" + sed -i -e "${sedcmd}" qt/qtr.pro || die + fi + fi +} + +transmission-2.52_src_configure() { + _transmission_is "" && return + + local econfargs=( + --enable-external-natpmp + ) + + if _transmission_is base; then + export ac_cv_header_xfs_xfs_h=$(usex xfs) + econfargs+=( + --disable-cli + --disable-daemon + --without-gtk + $(use_enable lightweight) + ) + elif _transmission_is cli; then + econfargs+=( + --enable-cli + --disable-daemon + --without-gtk + ) + elif _transmission_is daemon; then + econfargs+=( + --disable-cli + --enable-daemon + --without-gtk + ) + elif _transmission_is gtk; then + econfargs+=( + --disable-cli + --disable-daemon + --with-gtk + ) + elif _transmission_is qt4; then + econfargs+=( + --disable-cli + --disable-daemon + --without-gtk + ) + else + die "Something is wrong... (E_TRANSM_TAIL=$E_TRANSM_TAIL)" + fi + + econf "${econfargs[@]}" + if _transmission_is qt4; then + pushd qt >/dev/null + eqmake4 qtr.pro + popd >/dev/null + fi +} + +transmission-2.52_src_compile() { + _transmission_is "" && return + + emake + if _transmission_is qt4; then + pushd qt >/dev/null + emake + + local l + for l in ${LANGS}; do + if use linguas_${l}; then + lrelease translations/${MY_PN}_${l}.ts + fi + done + popd >/dev/null + fi +} + + +# Note: not providing src_install. Too many differences and too much code +# which would only clutter this pretty eclass. + +transmission-2.52_pkg_preinst() { + _transmission_is gtk && gnome2_icon_savelist +} + +transmission-2.52_pkg_postinst() { + if _transmission_is gtk || _transmission_is qt4; then + fdo-mime_desktop_database_update + fi + + _transmission_is gtk && gnome2_icon_cache_update + + if _transmission_is daemon; then + elog "If you use ${MY_PN}-daemon, please, set 'rpc-username' and" + elog "'rpc-password' (in plain text, ${MY_PN}-daemon will hash it on" + elog "start) in settings.json file located at /var/${MY_PN}/config or" + elog "any other appropriate config directory." + fi + + if _transmission_is gtk; then + # in -gtk only? + elog + elog "To enable sound emerge media-libs/libcanberra and check that at least" + elog "some sound them is selected. For this go:" + elog "Gnome/system/preferences/sound themes tab and 'sound theme: default'" + elog + fi + + elog "Since µTP is enabled by default, ${MY_PN} needs large kernel buffers for" + elog "the UDP socket. You can append following lines into /etc/sysctl.conf:" + elog " net.core.rmem_max = 4194304" + elog " net.core.wmem_max = 1048576" + elog "and run sysctl -p" +} + +transmission-2.52_pkg_postrm() { + if _transmission_is gtk || _transmission_is qt4; then + fdo-mime_desktop_database_update + fi + + _transmission_is gtk && gnome2_icon_cache_update +} diff --git a/eclass/webapp.eclass b/eclass/webapp.eclass new file mode 100644 index 00000000..150f7ac3 --- /dev/null +++ b/eclass/webapp.eclass @@ -0,0 +1,575 @@ +# Copyright 1999-2006 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/eclass/webapp.eclass,v 1.66 2011/05/19 12:05:13 scarabeus Exp $ + +# @ECLASS: webapp.eclass +# @MAINTAINER: +# web-apps@gentoo.org +# @BLURB: functions for installing applications to run under a web server +# @DESCRIPTION: +# The webapp eclass contains functions to handle web applications with +# webapp-config. Part of the implementation of GLEP #11 + +# @ECLASS-VARIABLE: WEBAPP_DEPEND +# @DESCRIPTION: +# An ebuild should use WEBAPP_DEPEND if a custom DEPEND needs to be built, most +# notably in combination with WEBAPP_OPTIONAL. +WEBAPP_DEPEND=">=app-admin/webapp-config-1.50.15" + +# @ECLASS-VARIABLE: WEBAPP_NO_AUTO_INSTALL +# @DESCRIPTION: +# An ebuild sets this to `yes' if an automatic installation and/or upgrade is +# not possible. The ebuild should overwrite pkg_postinst() and explain the +# reason for this BEFORE calling webapp_pkg_postinst(). + +# @ECLASS-VARIABLE: WEBAPP_OPTIONAL +# @DESCRIPTION: +# An ebuild sets this to `yes' to make webapp support optional, in which case +# you also need to take care of USE-flags and dependencies. + +if [[ "${WEBAPP_OPTIONAL}" != "yes" ]]; then + [[ "${WEBAPP_NO_AUTO_INSTALL}" == "yes" ]] || IUSE="vhosts" + SLOT="${PVR}" + DEPEND="${WEBAPP_DEPEND}" + RDEPEND="${DEPEND}" +fi + +EXPORT_FUNCTIONS pkg_postinst pkg_setup src_install pkg_prerm + +INSTALL_DIR="/${PN}" +IS_UPGRADE=0 +IS_REPLACE=0 + +INSTALL_CHECK_FILE="installed_by_webapp_eclass" +SETUP_CHECK_FILE="setup_by_webapp_eclass" + +ETC_CONFIG="${ROOT}etc/vhosts/webapp-config" +WEBAPP_CONFIG="${ROOT}usr/sbin/webapp-config" +WEBAPP_CLEANER="${ROOT}usr/sbin/webapp-cleaner" + +# ============================================================================== +# INTERNAL FUNCTIONS +# ============================================================================== + +# Load the config file /etc/vhosts/webapp-config +# Supports both the old bash version, and the new python version +webapp_read_config() { + debug-print-function $FUNCNAME $* + + if has_version '>=app-admin/webapp-config-1.50'; then + ENVVAR=$(${WEBAPP_CONFIG} --query ${PN} ${PVR}) || die "Could not read settings from webapp-config!" + eval ${ENVVAR} + else + . ${ETC_CONFIG} || die "Unable to read ${ETC_CONFIG}" + fi +} + +# Check whether a specified file exists in the given directory (`.' by default) +webapp_checkfileexists() { + debug-print-function $FUNCNAME $* + + local my_prefix=${2:+${2}/} + + if [[ ! -e "${my_prefix}${1}" ]]; then + msg="ebuild fault: file '${1}' not found" + eerror "$msg" + eerror "Please report this as a bug at http://bugs.gentoo.org/" + die "$msg" + fi +} + +webapp_check_installedat() { + debug-print-function $FUNCNAME $* + ${WEBAPP_CONFIG} --show-installed -h localhost -d "${INSTALL_DIR}" 2> /dev/null +} + +webapp_strip_appdir() { + debug-print-function $FUNCNAME $* + echo "${1#${MY_APPDIR}/}" +} + +webapp_strip_d() { + debug-print-function $FUNCNAME $* + echo "${1#${D}}" +} + +webapp_strip_cwd() { + debug-print-function $FUNCNAME $* + echo "${1/#.\///}" +} + +webapp_getinstalltype() { + debug-print-function $FUNCNAME $* + + if ! has vhosts ${IUSE} || use vhosts; then + return + fi + + local my_output + my_output="$(webapp_check_installedat)" + + if [[ $? -eq 0 ]]; then + # something is already installed there + # make sure it isn't the same version + + local my_pn="$(echo ${my_output} | awk '{ print $1 }')" + local my_pvr="$(echo ${my_output} | awk '{ print $2 }')" + + REMOVE_PKG="${my_pn}-${my_pvr}" + + if [[ "${my_pn}" == "${PN}" ]]; then + if [[ "${my_pvr}" != "${PVR}" ]]; then + elog "This is an upgrade" + IS_UPGRADE=1 + # for binpkgs, reset status, var declared in global scope + IS_REPLACE=0 + else + elog "This is a re-installation" + IS_REPLACE=1 + # for binpkgs, reset status, var declared in global scope + IS_UPGRADE=0 + fi + else + elog "${my_output} is installed there" + fi + else + # for binpkgs, reset status, var declared in global scope + IS_REPLACE=0 + IS_UPGRADE=0 + elog "This is an installation" + fi +} + +# ============================================================================== +# PUBLIC FUNCTIONS +# ============================================================================== + +# @FUNCTION: need_httpd +# @DESCRIPTION: +# Call this function AFTER your ebuilds DEPEND line if any of the available +# webservers are able to run this application. +need_httpd() { + DEPEND="${DEPEND} + || ( virtual/httpd-basic virtual/httpd-cgi virtual/httpd-fastcgi )" +} + +# @FUNCTION: need_httpd_cgi +# @DESCRIPTION: +# Call this function AFTER your ebuilds DEPEND line if any of the available +# CGI-capable webservers are able to run this application. +need_httpd_cgi() { + DEPEND="${DEPEND} + || ( virtual/httpd-cgi virtual/httpd-fastcgi )" +} + +# @FUNCTION: need_httpd_fastcgi +# @DESCRIPTION: +# Call this function AFTER your ebuilds DEPEND line if any of the available +# FastCGI-capabale webservers are able to run this application. +need_httpd_fastcgi() { + DEPEND="${DEPEND} + virtual/httpd-fastcgi" +} + +# @FUNCTION: webapp_configfile +# @USAGE: <file> [more files ...] +# @DESCRIPTION: +# Mark a file config-protected for a web-based application. +webapp_configfile() { + debug-print-function $FUNCNAME $* + + local m + for m in "$@"; do + webapp_checkfileexists "${m}" "${D}" + + local my_file="$(webapp_strip_appdir "${m}")" + my_file="$(webapp_strip_cwd "${my_file}")" + + elog "(config) ${my_file}" + echo "${my_file}" >> ${D}/${WA_CONFIGLIST} + done +} + +# @FUNCTION: webapp_hook_script +# @USAGE: <file> +# @DESCRIPTION: +# Install a script that will run after a virtual copy is created, and +# before a virtual copy has been removed. +webapp_hook_script() { + debug-print-function $FUNCNAME $* + + webapp_checkfileexists "${1}" + + elog "(hook) ${1}" + cp "${1}" "${D}/${MY_HOOKSCRIPTSDIR}/$(basename "${1}")" || die "Unable to install ${1} into ${D}/${MY_HOOKSCRIPTSDIR}/" + chmod 555 "${D}/${MY_HOOKSCRIPTSDIR}/$(basename "${1}")" +} + +# @FUNCTION: webapp_postinst_txt +# @USAGE: <lang> <file> +# @DESCRIPTION: +# Install a text file containing post-installation instructions. +webapp_postinst_txt() { + debug-print-function $FUNCNAME $* + + webapp_checkfileexists "${2}" + + elog "(info) ${2} (lang: ${1})" + cp "${2}" "${D}/${MY_APPDIR}/postinst-${1}.txt" +} + +# @FUNCTION: webapp_postupgrade_txt +# @USAGE: <lang> <file> +# @DESCRIPTION: +# Install a text file containing post-upgrade instructions. +webapp_postupgrade_txt() { + debug-print-function $FUNCNAME $* + + webapp_checkfileexists "${2}" + + elog "(info) ${2} (lang: ${1})" + cp "${2}" "${D}/${MY_APPDIR}/postupgrade-${1}.txt" +} + +# helper for webapp_serverowned() +_webapp_serverowned() { + debug-print-function $FUNCNAME $* + + webapp_checkfileexists "${1}" "${D}" + local my_file="$(webapp_strip_appdir "${1}")" + my_file="$(webapp_strip_cwd "${my_file}")" + + elog "(server owned) ${my_file}" + echo "${my_file}" >> "${D}/${WA_SOLIST}" +} + +# @FUNCTION: webapp_serverowned +# @USAGE: [-R] <file> [more files ...] +# @DESCRIPTION: +# Identify a file which must be owned by the webserver's user:group settings. +# The ownership of the file is NOT set until the application is installed using +# the webapp-config tool. If -R is given directories are handled recursively. +webapp_serverowned() { + debug-print-function $FUNCNAME $* + + local a m + if [[ "${1}" == "-R" ]]; then + shift + for m in "$@"; do + find "${D}${m}" | while read a; do + a=$(webapp_strip_d "${a}") + _webapp_serverowned "${a}" + done + done + else + for m in "$@"; do + _webapp_serverowned "${m}" + done + fi +} + +# @FUNCTION: webapp_server_configfile +# @USAGE: <server> <file> [new name] +# @DESCRIPTION: +# Install a configuration file for the webserver. You need to specify a +# webapp-config supported <server>. if no new name is given `basename $2' is +# used by default. Note: this function will automagically prepend $1 to the +# front of your config file's name. +webapp_server_configfile() { + debug-print-function $FUNCNAME $* + + webapp_checkfileexists "${2}" + + # WARNING: + # + # do NOT change the naming convention used here without changing all + # the other scripts that also rely upon these names + + local my_file="${1}-${3:-$(basename "${2}")}" + + elog "(${1}) config file '${my_file}'" + cp "${2}" "${D}/${MY_SERVERCONFIGDIR}/${my_file}" +} + +# @FUNCTION: webapp_sqlscript +# @USAGE: <db> <file> [version] +# @DESCRIPTION: +# Install a SQL script that creates/upgrades a database schema for the web +# application. Currently supported database engines are mysql and postgres. +# If a version is given the script should upgrade the database schema from +# the given version to $PVR. +webapp_sqlscript() { + debug-print-function $FUNCNAME $* + + webapp_checkfileexists "${2}" + + dodir "${MY_SQLSCRIPTSDIR}/${1}" + + # WARNING: + # + # do NOT change the naming convention used here without changing all + # the other scripts that also rely upon these names + + if [[ -n "${3}" ]]; then + elog "(${1}) upgrade script for ${PN}-${3} to ${PVR}" + cp "${2}" "${D}${MY_SQLSCRIPTSDIR}/${1}/${3}_to_${PVR}.sql" + chmod 600 "${D}${MY_SQLSCRIPTSDIR}/${1}/${3}_to_${PVR}.sql" + else + elog "(${1}) create script for ${PN}-${PVR}" + cp "${2}" "${D}/${MY_SQLSCRIPTSDIR}/${1}/${PVR}_create.sql" + chmod 600 "${D}/${MY_SQLSCRIPTSDIR}/${1}/${PVR}_create.sql" + fi +} + +# @FUNCTION: webapp_src_preinst +# @DESCRIPTION: +# You need to call this function in src_install() BEFORE anything else has run. +# For now we just create required webapp-config directories. +webapp_src_preinst() { + debug-print-function $FUNCNAME $* + + # sanity checks, to catch bugs in the ebuild + if [[ ! -f "${T}/${SETUP_CHECK_FILE}" ]]; then + eerror + eerror "This ebuild did not call webapp_pkg_setup() at the beginning" + eerror "of the pkg_setup() function" + eerror + eerror "Please log a bug on http://bugs.gentoo.org" + eerror + eerror "You should use emerge -C to remove this package, as the" + eerror "installation is incomplete" + eerror + die "Ebuild did not call webapp_pkg_setup() - report to http://bugs.gentoo.org" + fi + + # Hint, see the webapp_read_config() function to find where these are + # defined. + dodir "${MY_HTDOCSDIR}" + dodir "${MY_HOSTROOTDIR}" + dodir "${MY_CGIBINDIR}" + dodir "${MY_ICONSDIR}" + dodir "${MY_ERRORSDIR}" + dodir "${MY_SQLSCRIPTSDIR}" + dodir "${MY_HOOKSCRIPTSDIR}" + dodir "${MY_SERVERCONFIGDIR}" +} + +# ============================================================================== +# EXPORTED FUNCTIONS +# ============================================================================== + +# @FUNCTION: webapp_pkg_setup +# @DESCRIPTION: +# The default pkg_setup() for this eclass. This will gather required variables +# from webapp-config and check if there is an application installed to +# `${ROOT}/var/www/localhost/htdocs/${PN}/' if USE=vhosts is not set. +# +# You need to call this function BEFORE anything else has run in your custom +# pkg_setup(). +webapp_pkg_setup() { + debug-print-function $FUNCNAME $* + + # to test whether or not the ebuild has correctly called this function + # we add an empty file to the filesystem + # + # we used to just set a variable in the shell script, but we can + # no longer rely on Portage calling both webapp_pkg_setup() and + # webapp_src_install() within the same shell process + touch "${T}/${SETUP_CHECK_FILE}" + + # special case - some ebuilds *do* need to overwride the SLOT + if [[ "${SLOT}+" != "${PVR}+" && "${WEBAPP_MANUAL_SLOT}" != "yes" ]]; then + die "Set WEBAPP_MANUAL_SLOT=\"yes\" if you need to SLOT manually" + fi + + # pull in the shared configuration file + G_HOSTNAME="localhost" + webapp_read_config + + local my_dir="${ROOT}${VHOST_ROOT}/${MY_HTDOCSBASE}/${PN}" + + # if USE=vhosts is enabled OR no application is installed we're done here + if ! has vhosts ${IUSE} || use vhosts || [[ ! -d "${my_dir}" ]]; then + return + fi + + local my_output + my_output="$(webapp_check_installedat)" + + if [[ $? -ne 0 ]]; then + # okay, whatever is there, it isn't webapp-config-compatible + echo + ewarn + ewarn "You already have something installed in ${my_dir}" + ewarn + ewarn "Whatever is in ${my_dir}, it's not" + ewarn "compatible with webapp-config." + ewarn + ewarn "This ebuild may be overwriting important files." + ewarn + echo + ebeep 10 + elif [[ "$(echo ${my_output} | awk '{ print $1 }')" != "${PN}" ]]; then + echo + eerror "You already have ${my_output} installed in ${my_dir}" + eerror + eerror "I cannot upgrade a different application" + eerror + echo + die "Cannot upgrade contents of ${my_dir}" + fi + +} + +# @FUNCTION: webapp_src_install +# @DESCRIPTION: +# This is the default src_install(). For now, we just make sure that root owns +# everything, and that there are no setuid files. +# +# You need to call this function AFTER everything else has run in your custom +# src_install(). +webapp_src_install() { + debug-print-function $FUNCNAME $* + + # to test whether or not the ebuild has correctly called this function + # we add an empty file to the filesystem + # + # we used to just set a variable in the shell script, but we can + # no longer rely on Portage calling both webapp_src_install() and + # webapp_pkg_postinst() within the same shell process + touch "${D}/${MY_APPDIR}/${INSTALL_CHECK_FILE}" + + chown -R "${VHOST_DEFAULT_UID}:${VHOST_DEFAULT_GID}" "${D}/" + chmod -R u-s "${D}/" + chmod -R g-s "${D}/" + + keepdir "${MY_PERSISTDIR}" + fowners "root:0" "${MY_PERSISTDIR}" + fperms 755 "${MY_PERSISTDIR}" +} + +# @FUNCTION: webapp_pkg_postinst +# @DESCRIPTION: +# The default pkg_postinst() for this eclass. This installs the web application to +# `${ROOT}/var/www/localhost/htdocs/${PN}/' if USE=vhosts is not set. Otherwise +# display a short notice how to install this application with webapp-config. +# +# You need to call this function AFTER everything else has run in your custom +# pkg_postinst(). +webapp_pkg_postinst() { + debug-print-function $FUNCNAME $* + + webapp_read_config + + # sanity checks, to catch bugs in the ebuild + if [[ ! -f "${ROOT}${MY_APPDIR}/${INSTALL_CHECK_FILE}" ]]; then + eerror + eerror "This ebuild did not call webapp_src_install() at the end" + eerror "of the src_install() function" + eerror + eerror "Please log a bug on http://bugs.gentoo.org" + eerror + eerror "You should use emerge -C to remove this package, as the" + eerror "installation is incomplete" + eerror + die "Ebuild did not call webapp_src_install() - report to http://bugs.gentoo.org" + fi + + if has vhosts ${IUSE}; then + if ! use vhosts; then + echo + elog "vhosts USE flag not set - auto-installing using webapp-config" + + G_HOSTNAME="localhost" + webapp_read_config + + local my_mode=-I + webapp_getinstalltype + + if [[ "${IS_REPLACE}" == "1" ]]; then + elog "${PN}-${PVR} is already installed - replacing" + my_mode=-I + elif [[ "${IS_UPGRADE}" == "1" ]]; then + elog "${REMOVE_PKG} is already installed - upgrading" + my_mode=-U + else + elog "${PN}-${PVR} is not installed - using install mode" + fi + + my_cmd="${WEBAPP_CONFIG} ${my_mode} -h localhost -u root -d ${INSTALL_DIR} ${PN} ${PVR}" + elog "Running ${my_cmd}" + ${my_cmd} + + echo + local cleaner="${WEBAPP_CLEANER} -p -C ${PN}" + einfo "Running ${cleaner}" + ${cleaner} + else + elog + elog "The 'vhosts' USE flag is switched ON" + elog "This means that Portage will not automatically run webapp-config to" + elog "complete the installation." + elog + elog "To install ${PN}-${PVR} into a virtual host, run the following command:" + elog + elog " webapp-config -I -h <host> -d ${PN} ${PN} ${PVR}" + elog + elog "For more details, see the webapp-config(8) man page" + fi + else + elog + elog "This ebuild does not support the 'vhosts' USE flag." + elog "This means that Portage will not automatically run webapp-config to" + elog "complete the installation." + elog + elog "To install ${PN}-${PVR} into a virtual host, run the following command:" + elog + elog " webapp-config -I -h <host> -d ${PN} ${PN} ${PVR}" + elog + elog "For more details, see the webapp-config(8) man page" + fi +} + +# @FUNCTION: webapp_pkg_prerm +# @DESCRIPTION: +# This is the default pkg_prerm() for this eclass. If USE=vhosts is not set +# remove all installed copies of this web application. Otherwise instruct the +# user to manually remove those copies. See bug #136959. +webapp_pkg_prerm() { + debug-print-function $FUNCNAME $* + + local my_output= + my_output="$(${WEBAPP_CONFIG} --list-installs ${PN} ${PVR})" + [[ $? -ne 0 ]] && return + + local x + if has vhosts ${IUSE} && ! use vhosts; then + echo "${my_output}" | while read x; do + if [[ -f "${x}"/.webapp ]]; then + . "${x}"/.webapp + if [[ -n "${WEB_HOSTNAME}" && -n "${WEB_INSTALLDIR}" ]]; then + ${WEBAPP_CONFIG} -C -h ${WEB_HOSTNAME} -d ${WEB_INSTALLDIR} ${PN} ${PVR} + fi + else + ewarn "Cannot find file ${x}/.webapp" + fi + done + elif [[ "${my_output}" != "" ]]; then + echo + ewarn + ewarn "Don't forget to use webapp-config to remove any copies of" + ewarn "${PN}-${PVR} installed in" + ewarn + + echo "${my_output}" | while read x; do + if [[ -f "${x}"/.webapp ]]; then + ewarn " ${x}" + else + ewarn "Cannot find file ${x}/.webapp" + fi + done + + ewarn + echo + fi +} |