diff --git a/sdk_container/src/third_party/coreos-overlay/eclass/appid.eclass b/sdk_container/src/third_party/coreos-overlay/eclass/appid.eclass deleted file mode 100644 index bb05f957c2..0000000000 --- a/sdk_container/src/third_party/coreos-overlay/eclass/appid.eclass +++ /dev/null @@ -1,43 +0,0 @@ -# Copyright (c) 2012 The Chromium OS Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. -# $Header: $ - -# @ECLASS: appid.eclass -# @MAINTAINER: -# ChromiumOS Build Team -# @BUGREPORTS: -# Please report bugs via http://crosbug.com/new (with label Area-Build) -# @VCSURL: http://git.chromium.org/gitweb/?p=chromiumos/overlays/chromiumos-overlay.git;a=blob;f=eclass/@ECLASS@ -# @BLURB: Eclass for setting up the omaha appid field in /etc/lsb-release - -# @FUNCTION: doappid -# @USAGE: -# @DESCRIPTION: -# Initializes /etc/lsb-release with the appid. Note that appid is really -# just a UUID in the canonical {8-4-4-4-12} format (all uppercase). e.g. -# {01234567-89AB-CDEF-0123-456789ABCDEF} -doappid() { - [[ $# -eq 1 && -n $1 ]] || die "Usage: ${FUNCNAME} " - local appid=$1 - - # Validate the UUID is formatted correctly. Except for mario -- - # it was created before we had strict rules, and so it violates :(. - if [[ ${appid} != '{87efface-864d-49a5-9bb3-4b050a7c227a}' ]] ; then - local uuid_regex='[{][0-9A-F]{8}-([0-9A-F]{4}-){3}[0-9A-F]{12}[}]' - local filtered_appid=$(echo "${appid}" | LC_ALL=C sed -r "s:${uuid_regex}::") - if [[ -n ${filtered_appid} ]] ; then - eerror "Invalid appid: ${appid} -> ${filtered_appid}" - eerror " - must start with '{' and end with '}'" - eerror " - must be all upper case" - eerror " - be a valid UUID (8-4-4-4-12 hex digits)" - die "invalid appid: ${appid}" - fi - fi - - dodir /etc - - local lsb="${D}/etc/lsb-release" - [[ -e ${lsb} ]] && die "${lsb} already exists!" - echo "CHROMEOS_RELEASE_APPID=${appid}" > "${lsb}" || die "creating ${lsb} failed!" -} diff --git a/sdk_container/src/third_party/coreos-overlay/eclass/cros-coreboot.eclass b/sdk_container/src/third_party/coreos-overlay/eclass/cros-coreboot.eclass deleted file mode 100644 index 99e8b551da..0000000000 --- a/sdk_container/src/third_party/coreos-overlay/eclass/cros-coreboot.eclass +++ /dev/null @@ -1,92 +0,0 @@ -# Copyright (c) 2012 The Chromium OS Authors. All rights reserved. -# Distributed under the terms of the GNU General Public License v2 - -# @ECLASS: cros-coreboot.eclass -# @MAINTAINER: -# The Chromium OS Authors -# @BLURB: Unifies logic for building coreboot images for Chromium OS. - -[[ ${EAPI} != "4" ]] && die "Only EAPI=4 is supported" - -inherit toolchain-funcs - -DESCRIPTION="coreboot x86 firmware" -HOMEPAGE="http://www.coreboot.org" -LICENSE="GPL-2" -SLOT="0" -IUSE="em100-mode" - - -RDEPEND="!sys-boot/chromeos-coreboot" - -DEPEND="sys-power/iasl - sys-apps/coreboot-utils - sys-boot/chromeos-mrc - " - -# @ECLASS-VARIABLE: COREBOOT_BOARD -# @DESCRIPTION: -# Coreboot Configuration name. -: ${COREBOOT_BOARD:=} - -# @ECLASS-VARIABLE: COREBOOT_BUILD_ROOT -# @DESCRIPTION: -# Build directory root -: ${COREBOOT_BUILD_ROOT:=} - -[[ -z ${COREBOOT_BOARD} ]] && die "COREBOOT_BOARD must be set" -[[ -z ${COREBOOT_BUILD_ROOT} ]] && die "COREBOOT_BUILD_ROOT must be set" - -cros-coreboot_pre_src_prepare() { - cp configs/config.${COREBOOT_BOARD} .config -} - -cros-coreboot_src_compile() { - tc-export CC - local board="${COREBOOT_BOARD}" - local build_root="${COREBOOT_BUILD_ROOT}" - - # Set KERNELREVISION (really coreboot revision) to the ebuild revision - # number followed by a dot and the first seven characters of the git - # hash. The name is confusing but consistent with the coreboot - # Makefile. - local sha1v="${VCSID/*-/}" - export KERNELREVISION=".${PV}.${sha1v:0:7}" - - # Firmware related binaries are compiled with a 32-bit toolchain - # on 64-bit platforms - if use amd64 ; then - export CROSS_COMPILE="i686-pc-linux-gnu-" - export CC="${CROSS_COMPILE}-gcc" - else - export CROSS_COMPILE=${CHOST}- - fi - - elog "Toolchain:\n$(sh util/xcompile/xcompile)\n" - emake obj="${build_root}" oldconfig - emake obj="${build_root}" - - # Modify firmware descriptor if building for the EM100 emulator. - if use em100-mode; then - ifdtool --em100 "${build_root}/coreboot.rom" || die - mv "${build_root}/coreboot.rom"{.new,} || die - fi - - # Build cbmem for the target - cd util/cbmem - emake clean - CROSS_COMPILE="${CHOST}-" emake -} - -cros-coreboot_src_install() { - dobin util/cbmem/cbmem - insinto /firmware - newins "${COREBOOT_BUILD_ROOT}/coreboot.rom" coreboot.rom - OPROM=$( awk 'BEGIN{FS="\""} /CONFIG_VGA_BIOS_FILE=/ { print $2 }' \ - configs/config.${COREBOOT_BOARD} ) - CBFSOPROM=pci$( awk 'BEGIN{FS="\""} /CONFIG_VGA_BIOS_ID=/ { print $2 }' \ - configs/config.${COREBOOT_BOARD} ).rom - newins ${OPROM} ${CBFSOPROM} -} - -EXPORT_FUNCTIONS src_compile src_install pre_src_prepare diff --git a/sdk_container/src/third_party/coreos-overlay/eclass/cros-serialuser.eclass b/sdk_container/src/third_party/coreos-overlay/eclass/cros-serialuser.eclass deleted file mode 100644 index a19318d022..0000000000 --- a/sdk_container/src/third_party/coreos-overlay/eclass/cros-serialuser.eclass +++ /dev/null @@ -1,31 +0,0 @@ -# Copyright (c) 2012 The Chromium OS Authors. All rights reserved. -# Distributed under the terms of the GNU General Public License v2 - -# -# Original Author: The Chromium OS Authors -# Purpose: Eclass for use by ebuilds that need to know the debug serial port. -# -[[ ${EAPI} != "4" ]] && die "Only EAPI=4 is supported" - -SERIAL_USE_PREFIX="serial_use_" -ALL_SERIALPORTS=( - ttyAMA{0..5} - ttyO{0..5} - ttyS{0..5} - ttySAC{0..5} -) -IUSE=${ALL_SERIALPORTS[@]/#/${SERIAL_USE_PREFIX}} - -# Echo the current serial port name -get_serial_name() { - local item - - for item in "${ALL_SERIALPORTS[@]}"; do - if use ${SERIAL_USE_PREFIX}${item}; then - echo ${item} - return - fi - done - - die "Unable to determine current serial port." -} diff --git a/sdk_container/src/third_party/coreos-overlay/eclass/gobi-firmware.eclass b/sdk_container/src/third_party/coreos-overlay/eclass/gobi-firmware.eclass deleted file mode 100644 index eac2b2dbbd..0000000000 --- a/sdk_container/src/third_party/coreos-overlay/eclass/gobi-firmware.eclass +++ /dev/null @@ -1,305 +0,0 @@ -# Copyright (c) 2012 The Chromium OS Authors. All rights reserved. -# Distributed under the terms of the GNU General Public License v2 - -# -# Original Author: The Chromium OS Authors -# Purpose: Install Gobi firmware for Chromium OS -# - -# @ECLASS-VARIABLE: GOBI_FIRMWARE_OEM -# @DESCRIPTION: -# OEM name for firmware to install -: ${GOBI_FIRMWARE_OEM:=} - -# @ECLASS-VARIABLE: GOBI_FIRMWARE_VID -# @DESCRIPTION: -# OEM Vendor ID -: ${GOBI_FIRMWARE_VID:=} - -# @ECLASS-VARIABLE: GOBI_FIRMWARE_PID -# @DESCRIPTION: -# OEM Product ID -: ${GOBI_FIRMWARE_PID:=} - -# @ECLASS-VARIABLE: GOBI_FIRMWARE_CARRIERS -# @DESCRIPTION: -# Install firmware for this list of carrier numbers -: ${GOBI_FIRMWARE_CARRIERS:=} - -# @ECLASS-VARIABLE: GOBI_FIRMWARE_ZIP_FILE -# @DESCRIPTION: -# Filename of zip file containing firmware -: ${GOBI_FIRMWARE_ZIP_FILE:=} - -# @ECLASS-VARIABLE: GOBI_FIRMWARE_FLAVOR -# @DESCRIPTION: -# The flavor (gps, xtra) to install -: ${GOBI_FIRMWARE_FLAVOR:="gps"} - -# @ECLASS-VARIABLE: GOBI_FIRMWARE_QDL -# @DESCRIPTION: -# Install the qdl program from the firmware zip file -: ${GOBI_FIRMWARE_QDL:="no"} - -# @ECLASS-VARIABLE: GOBI_FIRMWARE_DEFAULT_CARRIER -# @DESCRIPTION: -# Default carrier firmware to load if not set on modem -: ${GOBI_FIRMWARE_DEFAULT_CARRIER:=} - -# @ECLASS-VARIABLE: GOBI_FIRMWARE_APPS_DIR -# @DESCRIPTION: -# directory name for the .apps files -: ${GOBI_FIRMWARE_APPS_DIR:=""} - -GOBI_FIRMWARE_CARRIER_VOD=0 -GOBI_FIRMWARE_CARRIER_VZW=1 -GOBI_FIRMWARE_CARRIER_ATT=2 -GOBI_FIRMWARE_CARRIER_SPRINT=3 -GOBI_FIRMWARE_CARRIER_TMO=4 -GOBI_FIRMWARE_CARRIER_GEN=6 -GOBI_FIRMWARE_CARRIER_TELLFON=7 -GOBI_FIRMWARE_CARRIER_TELITAL=8 -GOBI_FIRMWARE_CARRIER_ORANGE=9 -GOBI_FIRMWARE_CARRIER_DOCO=12 -GOBI_FIRMWARE_CARRIER_DELLX=15 -GOBI_FIRMWARE_CARRIER_OMH=16 - -# Check for EAPI 2+ -case "${EAPI:-0}" in - 4|3|2) ;; - *) die "unsupported EAPI" ;; -esac - -gobi-firmware_install_udev_qcserial_rules() { - local oem=${GOBI_FIRMWARE_OEM} - local vid=${GOBI_FIRMWARE_VID} - local pid=${GOBI_FIRMWARE_PID} - local file=/etc/udev/rules.d/90-ttyusb-qcserial-${oem}.rules - cat > ${D}${file} < ${D}${file} < ${D}${file} < Options2k${oem}.txt < -# @BLURB: Eclass for Python packages -# @DESCRIPTION: -# The python eclass contains miscellaneous, useful functions for Python packages. - -# This file is a snapshot of python.eclass from when it only had support up to EAPI 3. -# It is used only by selected packages that are still unable to migrate to the latest -# python.eclass. This usage is discouraged as much as possible, though. - -inherit multilib - -if ! has "${EAPI:-0}" 0 1 2 3; then - die "API of python.eclass in EAPI=\"${EAPI}\" not established" -fi - -_CPYTHON2_SUPPORTED_ABIS=(2.4 2.5 2.6 2.7) -_CPYTHON3_SUPPORTED_ABIS=(3.0 3.1 3.2) -_JYTHON_SUPPORTED_ABIS=(2.5-jython) - -# @ECLASS-VARIABLE: PYTHON_DEPEND -# @DESCRIPTION: -# Specification of dependency on dev-lang/python. -# Syntax: -# PYTHON_DEPEND: [[!]USE_flag? ][ version_components_group] -# version_components_group: -# major_version: <2|3|*> -# minimal_version: -# maximal_version: - -_parse_PYTHON_DEPEND() { - local major_version maximal_version minimal_version python_all="0" python_maximal_version python_minimal_version python_versions=() python2="0" python2_maximal_version python2_minimal_version python3="0" python3_maximal_version python3_minimal_version USE_flag= version_components_group version_components_group_regex version_components_groups - - version_components_group_regex="(2|3|\*)(:([[:digit:]]+\.[[:digit:]]+)?(:([[:digit:]]+\.[[:digit:]]+)?)?)?" - version_components_groups="${PYTHON_DEPEND}" - - if [[ "${version_components_groups}" =~ ^((\!)?[[:alnum:]_-]+\?\ )?${version_components_group_regex}(\ ${version_components_group_regex})?$ ]]; then - if [[ "${version_components_groups}" =~ ^(\!)?[[:alnum:]_-]+\? ]]; then - USE_flag="${version_components_groups%\? *}" - version_components_groups="${version_components_groups#* }" - fi - if [[ "${version_components_groups}" =~ ("*".*" "|" *"|^2.*\ (2|\*)|^3.*\ (3|\*)) ]]; then - die "Invalid syntax of PYTHON_DEPEND: Incorrectly specified groups of versions" - fi - - version_components_groups="${version_components_groups// /$'\n'}" - while read version_components_group; do - major_version="${version_components_group:0:1}" - minimal_version="${version_components_group:2}" - minimal_version="${minimal_version%:*}" - maximal_version="${version_components_group:$((3 + ${#minimal_version}))}" - - if [[ "${major_version}" =~ ^(2|3)$ ]]; then - if [[ -n "${minimal_version}" && "${major_version}" != "${minimal_version:0:1}" ]]; then - die "Invalid syntax of PYTHON_DEPEND: Minimal version '${minimal_version}' not in specified group of versions" - fi - if [[ -n "${maximal_version}" && "${major_version}" != "${maximal_version:0:1}" ]]; then - die "Invalid syntax of PYTHON_DEPEND: Maximal version '${maximal_version}' not in specified group of versions" - fi - fi - - if [[ "${major_version}" == "2" ]]; then - python2="1" - python_versions=("${_CPYTHON2_SUPPORTED_ABIS[@]}") - python2_minimal_version="${minimal_version}" - python2_maximal_version="${maximal_version}" - elif [[ "${major_version}" == "3" ]]; then - python3="1" - python_versions=("${_CPYTHON3_SUPPORTED_ABIS[@]}") - python3_minimal_version="${minimal_version}" - python3_maximal_version="${maximal_version}" - else - python_all="1" - python_versions=("${_CPYTHON2_SUPPORTED_ABIS[@]}" "${_CPYTHON3_SUPPORTED_ABIS[@]}") - python_minimal_version="${minimal_version}" - python_maximal_version="${maximal_version}" - fi - - if [[ -n "${minimal_version}" ]] && ! has "${minimal_version}" "${python_versions[@]}"; then - die "Invalid syntax of PYTHON_DEPEND: Unrecognized minimal version '${minimal_version}'" - fi - if [[ -n "${maximal_version}" ]] && ! has "${maximal_version}" "${python_versions[@]}"; then - die "Invalid syntax of PYTHON_DEPEND: Unrecognized maximal version '${maximal_version}'" - fi - - if [[ -n "${minimal_version}" && -n "${maximal_version}" && "${minimal_version}" > "${maximal_version}" ]]; then - die "Invalid syntax of PYTHON_DEPEND: Minimal version '${minimal_version}' greater than maximal version '${maximal_version}'" - fi - done <<< "${version_components_groups}" - - _PYTHON_ATOMS=() - - _append_accepted_versions_range() { - local accepted_version="0" i - for ((i = "${#python_versions[@]}"; i >= 0; i--)); do - if [[ "${python_versions[${i}]}" == "${python_maximal_version}" ]]; then - accepted_version="1" - fi - if [[ "${accepted_version}" == "1" ]]; then - _PYTHON_ATOMS+=("=dev-lang/python-${python_versions[${i}]}*") - fi - if [[ "${python_versions[${i}]}" == "${python_minimal_version}" ]]; then - accepted_version="0" - fi - done - } - - if [[ "${python_all}" == "1" ]]; then - if [[ -z "${python_minimal_version}" && -z "${python_maximal_version}" ]]; then - _PYTHON_ATOMS+=("dev-lang/python") - else - python_versions=("${_CPYTHON2_SUPPORTED_ABIS[@]}" "${_CPYTHON3_SUPPORTED_ABIS[@]}") - python_minimal_version="${python_minimal_version:-${python_versions[0]}}" - python_maximal_version="${python_maximal_version:-${python_versions[${#python_versions[@]}-1]}}" - _append_accepted_versions_range - fi - else - if [[ "${python3}" == "1" ]]; then - if [[ -z "${python3_minimal_version}" && -z "${python3_maximal_version}" ]]; then - _PYTHON_ATOMS+=("=dev-lang/python-3*") - else - python_versions=("${_CPYTHON3_SUPPORTED_ABIS[@]}") - python_minimal_version="${python3_minimal_version:-${python_versions[0]}}" - python_maximal_version="${python3_maximal_version:-${python_versions[${#python_versions[@]}-1]}}" - _append_accepted_versions_range - fi - fi - if [[ "${python2}" == "1" ]]; then - if [[ -z "${python2_minimal_version}" && -z "${python2_maximal_version}" ]]; then - _PYTHON_ATOMS+=("=dev-lang/python-2*") - else - python_versions=("${_CPYTHON2_SUPPORTED_ABIS[@]}") - python_minimal_version="${python2_minimal_version:-${python_versions[0]}}" - python_maximal_version="${python2_maximal_version:-${python_versions[${#python_versions[@]}-1]}}" - _append_accepted_versions_range - fi - fi - fi - - unset -f _append_accepted_versions_range - - if [[ "${#_PYTHON_ATOMS[@]}" -gt 1 ]]; then - DEPEND+="${DEPEND:+ }${USE_flag}${USE_flag:+? ( }|| ( ${_PYTHON_ATOMS[@]} )${USE_flag:+ )}" - RDEPEND+="${RDEPEND:+ }${USE_flag}${USE_flag:+? ( }|| ( ${_PYTHON_ATOMS[@]} )${USE_flag:+ )}" - else - DEPEND+="${DEPEND:+ }${USE_flag}${USE_flag:+? ( }${_PYTHON_ATOMS[@]}${USE_flag:+ )}" - RDEPEND+="${RDEPEND:+ }${USE_flag}${USE_flag:+? ( }${_PYTHON_ATOMS[@]}${USE_flag:+ )}" - fi - else - die "Invalid syntax of PYTHON_DEPEND" - fi -} - -DEPEND=">=app-admin/eselect-python-20091230" -RDEPEND="${DEPEND}" - -if [[ -n "${PYTHON_DEPEND}" && -n "${NEED_PYTHON}" ]]; then - die "PYTHON_DEPEND and NEED_PYTHON cannot be set simultaneously" -elif [[ -n "${PYTHON_DEPEND}" ]]; then - _parse_PYTHON_DEPEND -elif [[ -n "${NEED_PYTHON}" ]]; then - if ! has "${EAPI:-0}" 0 1 2; then - eerror "Use PYTHON_DEPEND instead of NEED_PYTHON." - die "NEED_PYTHON cannot be used in this EAPI" - fi - _PYTHON_ATOMS=(">=dev-lang/python-${NEED_PYTHON}") - DEPEND+="${DEPEND:+ }${_PYTHON_ATOMS[@]}" - RDEPEND+="${RDEPEND:+ }${_PYTHON_ATOMS[@]}" -else - _PYTHON_ATOMS=("dev-lang/python") -fi - -# @ECLASS-VARIABLE: PYTHON_USE_WITH -# @DESCRIPTION: -# Set this to a space separated list of USE flags the Python slot in use must be built with. - -# @ECLASS-VARIABLE: PYTHON_USE_WITH_OR -# @DESCRIPTION: -# Set this to a space separated list of USE flags of which one must be turned on for the slot in use. - -# @ECLASS-VARIABLE: PYTHON_USE_WITH_OPT -# @DESCRIPTION: -# Set this to a name of a USE flag if you need to make either PYTHON_USE_WITH or -# PYTHON_USE_WITH_OR atoms conditional under a USE flag. - -# @FUNCTION: python_pkg_setup -# @DESCRIPTION: -# Makes sure PYTHON_USE_WITH or PYTHON_USE_WITH_OR listed use flags -# are respected. Only exported if one of those variables is set. -if ! has "${EAPI:-0}" 0 1 && [[ -n ${PYTHON_USE_WITH} || -n ${PYTHON_USE_WITH_OR} ]]; then - python_pkg_setup() { - # Check if phase is pkg_setup(). - [[ "${EBUILD_PHASE}" != "setup" ]] && die "${FUNCNAME}() can be used only in pkg_setup() phase" - - python_pkg_setup_fail() { - eerror "${1}" - die "${1}" - } - - [[ ${PYTHON_USE_WITH_OPT} ]] && use !${PYTHON_USE_WITH_OPT} && return - - python_pkg_setup_check_USE_flags() { - local pyatom use - pyatom="$(python_get_implementational_package)" - - for use in ${PYTHON_USE_WITH}; do - if ! has_version "${pyatom}[${use}]"; then - python_pkg_setup_fail "Please rebuild ${pyatom} with the following USE flags enabled: ${PYTHON_USE_WITH}" - fi - done - - for use in ${PYTHON_USE_WITH_OR}; do - if has_version "${pyatom}[${use}]"; then - return - fi - done - - if [[ ${PYTHON_USE_WITH_OR} ]]; then - python_pkg_setup_fail "Please rebuild ${pyatom} with at least one of the following USE flags enabled: ${PYTHON_USE_WITH_OR}" - fi - } - - if [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then - python_execute_function -q python_pkg_setup_check_USE_flags - else - python_pkg_setup_check_USE_flags - fi - - unset -f python_pkg_setup_check_USE_flags python_pkg_setup_fail - } - - EXPORT_FUNCTIONS pkg_setup - - _PYTHON_USE_WITH_ATOMS_ARRAY=() - if [[ -n "${PYTHON_USE_WITH}" ]]; then - for _PYTHON_ATOM in "${_PYTHON_ATOMS[@]}"; do - _PYTHON_USE_WITH_ATOMS_ARRAY+=("${_PYTHON_ATOM}[${PYTHON_USE_WITH/ /,}]") - done - elif [[ -n "${PYTHON_USE_WITH_OR}" ]]; then - for _USE_flag in ${PYTHON_USE_WITH_OR}; do - for _PYTHON_ATOM in "${_PYTHON_ATOMS[@]}"; do - _PYTHON_USE_WITH_ATOMS_ARRAY+=("${_PYTHON_ATOM}[${_USE_flag}]") - done - done - unset _USE_flag - fi - if [[ "${#_PYTHON_USE_WITH_ATOMS_ARRAY[@]}" -gt 1 ]]; then - _PYTHON_USE_WITH_ATOMS="|| ( ${_PYTHON_USE_WITH_ATOMS_ARRAY[@]} )" - else - _PYTHON_USE_WITH_ATOMS="${_PYTHON_USE_WITH_ATOMS_ARRAY[@]}" - fi - if [[ -n "${PYTHON_USE_WITH_OPT}" ]]; then - _PYTHON_USE_WITH_ATOMS="${PYTHON_USE_WITH_OPT}? ( ${_PYTHON_USE_WITH_ATOMS} )" - fi - DEPEND+=" ${_PYTHON_USE_WITH_ATOMS}" - RDEPEND+=" ${_PYTHON_USE_WITH_ATOMS}" - unset _PYTHON_ATOM _PYTHON_USE_WITH_ATOMS _PYTHON_USE_WITH_ATOMS_ARRAY -fi - -unset _PYTHON_ATOMS - -# ================================================================================================ -# ======== FUNCTIONS FOR PACKAGES SUPPORTING INSTALLATION FOR MULTIPLE VERSIONS OF PYTHON ======== -# ================================================================================================ - -# @ECLASS-VARIABLE: SUPPORT_PYTHON_ABIS -# @DESCRIPTION: -# Set this in EAPI <= 4 to indicate that current package supports installation for -# multiple versions of Python. - -# @ECLASS-VARIABLE: PYTHON_EXPORT_PHASE_FUNCTIONS -# @DESCRIPTION: -# Set this to export phase functions for the following ebuild phases: -# src_prepare, src_configure, src_compile, src_test, src_install. -if ! has "${EAPI:-0}" 0 1 && [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then - python_src_prepare() { - python_copy_sources - } - - for python_default_function in src_configure src_compile src_test src_install; do - eval "python_${python_default_function}() { python_execute_function -d -s; }" - done - unset python_default_function - - if [[ -n "${PYTHON_EXPORT_PHASE_FUNCTIONS}" ]]; then - EXPORT_FUNCTIONS src_prepare src_configure src_compile src_test src_install - fi -fi - -unset PYTHON_ABIS - -# @FUNCTION: validate_PYTHON_ABIS -# @DESCRIPTION: -# Ensure that PYTHON_ABIS variable has valid value. -# This function usually should not be directly called in ebuilds. -validate_PYTHON_ABIS() { - # Ensure that some functions cannot be accidentally successfully used in EAPI <= 4 without setting SUPPORT_PYTHON_ABIS variable. - if has "${EAPI:-0}" 0 1 2 3 4 && [[ -z "${SUPPORT_PYTHON_ABIS}" ]]; then - die "${FUNCNAME}() cannot be used in this EAPI without setting SUPPORT_PYTHON_ABIS variable" - fi - - _python_initial_sanity_checks - - # USE_${ABI_TYPE^^} and RESTRICT_${ABI_TYPE^^}_ABIS variables hopefully will be included in EAPI >= 5. - if [[ "$(declare -p PYTHON_ABIS 2> /dev/null)" != "declare -x PYTHON_ABIS="* ]] && has "${EAPI:-0}" 0 1 2 3 4; then - local PYTHON_ABI restricted_ABI support_ABI supported_PYTHON_ABIS= - PYTHON_ABI_SUPPORTED_VALUES="${_CPYTHON2_SUPPORTED_ABIS[@]} ${_CPYTHON3_SUPPORTED_ABIS[@]} ${_JYTHON_SUPPORTED_ABIS[@]}" - - if [[ "$(declare -p USE_PYTHON 2> /dev/null)" == "declare -x USE_PYTHON="* ]]; then - local python2_enabled="0" python3_enabled="0" - - if [[ -z "${USE_PYTHON}" ]]; then - die "USE_PYTHON variable is empty" - fi - - for PYTHON_ABI in ${USE_PYTHON}; do - if ! has "${PYTHON_ABI}" ${PYTHON_ABI_SUPPORTED_VALUES}; then - die "USE_PYTHON variable contains invalid value '${PYTHON_ABI}'" - fi - - if has "${PYTHON_ABI}" "${_CPYTHON2_SUPPORTED_ABIS[@]}"; then - python2_enabled="1" - fi - if has "${PYTHON_ABI}" "${_CPYTHON3_SUPPORTED_ABIS[@]}"; then - python3_enabled="1" - fi - - support_ABI="1" - for restricted_ABI in ${RESTRICT_PYTHON_ABIS}; do - if [[ "${PYTHON_ABI}" == ${restricted_ABI} ]]; then - support_ABI="0" - break - fi - done - [[ "${support_ABI}" == "1" ]] && export PYTHON_ABIS+="${PYTHON_ABIS:+ }${PYTHON_ABI}" - done - - if [[ -z "${PYTHON_ABIS//[${IFS}]/}" ]]; then - die "USE_PYTHON variable does not enable any version of Python supported by ${CATEGORY}/${PF}" - fi - - if [[ "${python2_enabled}" == "0" ]]; then - ewarn "USE_PYTHON variable does not enable any version of Python 2. This configuration is unsupported." - fi - if [[ "${python3_enabled}" == "0" ]]; then - ewarn "USE_PYTHON variable does not enable any version of Python 3. This configuration is unsupported." - fi - if [[ "${python2_enabled}" == "0" && "${python3_enabled}" == "0" ]]; then - die "USE_PYTHON variable does not enable any version of CPython" - fi - else - local python_version python2_version= python3_version= support_python_major_version - - python_version="$("${EPREFIX}/usr/bin/python" -c 'from sys import version_info; print(".".join(str(x) for x in version_info[:2]))')" - - if has_version "=dev-lang/python-2*"; then - if [[ "$(readlink "${EPREFIX}/usr/bin/python2")" != "python2."* ]]; then - die "'${EPREFIX}/usr/bin/python2' is not valid symlink" - fi - - python2_version="$("${EPREFIX}/usr/bin/python2" -c 'from sys import version_info; print(".".join(str(x) for x in version_info[:2]))')" - - for PYTHON_ABI in "${_CPYTHON2_SUPPORTED_ABIS[@]}"; do - support_python_major_version="1" - for restricted_ABI in ${RESTRICT_PYTHON_ABIS}; do - if [[ "${PYTHON_ABI}" == ${restricted_ABI} ]]; then - support_python_major_version="0" - fi - done - [[ "${support_python_major_version}" == "1" ]] && break - done - if [[ "${support_python_major_version}" == "1" ]]; then - for restricted_ABI in ${RESTRICT_PYTHON_ABIS}; do - if [[ "${python2_version}" == ${restricted_ABI} ]]; then - die "Active version of Python 2 is not supported by ${CATEGORY}/${PF}" - fi - done - else - python2_version="" - fi - fi - - if has_version "=dev-lang/python-3*"; then - if [[ "$(readlink "${EPREFIX}/usr/bin/python3")" != "python3."* ]]; then - die "'${EPREFIX}/usr/bin/python3' is not valid symlink" - fi - - python3_version="$("${EPREFIX}/usr/bin/python3" -c 'from sys import version_info; print(".".join(str(x) for x in version_info[:2]))')" - - for PYTHON_ABI in "${_CPYTHON3_SUPPORTED_ABIS[@]}"; do - support_python_major_version="1" - for restricted_ABI in ${RESTRICT_PYTHON_ABIS}; do - if [[ "${PYTHON_ABI}" == ${restricted_ABI} ]]; then - support_python_major_version="0" - fi - done - [[ "${support_python_major_version}" == "1" ]] && break - done - if [[ "${support_python_major_version}" == "1" ]]; then - for restricted_ABI in ${RESTRICT_PYTHON_ABIS}; do - if [[ "${python3_version}" == ${restricted_ABI} ]]; then - die "Active version of Python 3 is not supported by ${CATEGORY}/${PF}" - fi - done - else - python3_version="" - fi - fi - - if [[ -n "${python2_version}" && "${python_version}" == "2."* && "${python_version}" != "${python2_version}" ]]; then - eerror "Python wrapper is configured incorrectly or '${EPREFIX}/usr/bin/python2' symlink" - eerror "is set incorrectly. Use \`eselect python\` to fix configuration." - die "Incorrect configuration of Python" - fi - if [[ -n "${python3_version}" && "${python_version}" == "3."* && "${python_version}" != "${python3_version}" ]]; then - eerror "Python wrapper is configured incorrectly or '${EPREFIX}/usr/bin/python3' symlink" - eerror "is set incorrectly. Use \`eselect python\` to fix configuration." - die "Incorrect configuration of Python" - fi - - PYTHON_ABIS="${python2_version} ${python3_version}" - PYTHON_ABIS="${PYTHON_ABIS# }" - export PYTHON_ABIS="${PYTHON_ABIS% }" - fi - fi - - _python_final_sanity_checks -} - -# @FUNCTION: python_execute_function -# @USAGE: [--action-message message] [-d|--default-function] [--failure-message message] [-f|--final-ABI] [--nonfatal] [-q|--quiet] [-s|--separate-build-dirs] [--source-dir source_directory] [--] [arguments] -# @DESCRIPTION: -# Execute specified function for each value of PYTHON_ABIS, optionally passing additional -# arguments. The specified function can use PYTHON_ABI and BUILDDIR variables. -python_execute_function() { - _python_set_color_variables - - local action action_message action_message_template= default_function="0" failure_message failure_message_template= final_ABI="0" function i iterated_PYTHON_ABIS nonfatal="0" previous_directory previous_directory_stack previous_directory_stack_length PYTHON_ABI quiet="0" separate_build_dirs="0" source_dir= - - while (($#)); do - case "$1" in - --action-message) - action_message_template="$2" - shift - ;; - -d|--default-function) - default_function="1" - ;; - --failure-message) - failure_message_template="$2" - shift - ;; - -f|--final-ABI) - final_ABI="1" - ;; - --nonfatal) - nonfatal="1" - ;; - -q|--quiet) - quiet="1" - ;; - -s|--separate-build-dirs) - separate_build_dirs="1" - ;; - --source-dir) - source_dir="$2" - shift - ;; - --) - shift - break - ;; - -*) - die "${FUNCNAME}(): Unrecognized option '$1'" - ;; - *) - break - ;; - esac - shift - done - - if [[ -n "${source_dir}" && "${separate_build_dirs}" == 0 ]]; then - die "${FUNCNAME}(): '--source-dir' option can be specified only with '--separate-build-dirs' option" - fi - - if [[ "${default_function}" == "0" ]]; then - if [[ "$#" -eq 0 ]]; then - die "${FUNCNAME}(): Missing function name" - fi - function="$1" - shift - - if [[ -z "$(type -t "${function}")" ]]; then - die "${FUNCNAME}(): '${function}' function is not defined" - fi - else - if [[ "$#" -ne 0 ]]; then - die "${FUNCNAME}(): '--default-function' option and function name cannot be specified simultaneously" - fi - if has "${EAPI:-0}" 0 1; then - die "${FUNCNAME}(): '--default-function' option cannot be used in this EAPI" - fi - - if [[ "${EBUILD_PHASE}" == "configure" ]]; then - if has "${EAPI}" 2 3; then - python_default_function() { - econf - } - else - python_default_function() { - nonfatal econf - } - fi - elif [[ "${EBUILD_PHASE}" == "compile" ]]; then - python_default_function() { - emake - } - elif [[ "${EBUILD_PHASE}" == "test" ]]; then - python_default_function() { - if emake -j1 -n check &> /dev/null; then - emake -j1 check - elif emake -j1 -n test &> /dev/null; then - emake -j1 test - fi - } - elif [[ "${EBUILD_PHASE}" == "install" ]]; then - python_default_function() { - emake DESTDIR="${D}" install - } - else - die "${FUNCNAME}(): '--default-function' option cannot be used in this ebuild phase" - fi - function="python_default_function" - fi - - for ((i = 1; i < "${#FUNCNAME[@]}"; i++)); do - if [[ "${FUNCNAME[${i}]}" == "${FUNCNAME}" ]]; then - die "${FUNCNAME}(): Invalid call stack" - fi - done - - if [[ "${quiet}" == "0" ]]; then - [[ "${EBUILD_PHASE}" == "setup" ]] && action="Setting up" - [[ "${EBUILD_PHASE}" == "unpack" ]] && action="Unpacking" - [[ "${EBUILD_PHASE}" == "prepare" ]] && action="Preparation" - [[ "${EBUILD_PHASE}" == "configure" ]] && action="Configuration" - [[ "${EBUILD_PHASE}" == "compile" ]] && action="Building" - [[ "${EBUILD_PHASE}" == "test" ]] && action="Testing" - [[ "${EBUILD_PHASE}" == "install" ]] && action="Installation" - [[ "${EBUILD_PHASE}" == "preinst" ]] && action="Preinstallation" - [[ "${EBUILD_PHASE}" == "postinst" ]] && action="Postinstallation" - [[ "${EBUILD_PHASE}" == "prerm" ]] && action="Preuninstallation" - [[ "${EBUILD_PHASE}" == "postrm" ]] && action="Postuninstallation" - fi - - validate_PYTHON_ABIS - if [[ "${final_ABI}" == "1" ]]; then - iterated_PYTHON_ABIS="$(PYTHON -f --ABI)" - else - iterated_PYTHON_ABIS="${PYTHON_ABIS}" - fi - for PYTHON_ABI in ${iterated_PYTHON_ABIS}; do - if [[ "${quiet}" == "0" ]]; then - if [[ -n "${action_message_template}" ]]; then - action_message="$(eval echo -n "${action_message_template}")" - else - action_message="${action} of ${CATEGORY}/${PF} with $(python_get_implementation) $(python_get_version)..." - fi - echo " ${_GREEN}*${_NORMAL} ${_BLUE}${action_message}${_NORMAL}" - fi - - if [[ "${separate_build_dirs}" == "1" ]]; then - if [[ -n "${source_dir}" ]]; then - export BUILDDIR="${S}/${source_dir}-${PYTHON_ABI}" - else - export BUILDDIR="${S}-${PYTHON_ABI}" - fi - pushd "${BUILDDIR}" > /dev/null || die "pushd failed" - else - export BUILDDIR="${S}" - fi - - previous_directory="$(pwd)" - previous_directory_stack="$(dirs -p)" - previous_directory_stack_length="$(dirs -p | wc -l)" - - if ! has "${EAPI}" 0 1 2 3 && has "${PYTHON_ABI}" ${FAILURE_TOLERANT_PYTHON_ABIS}; then - EPYTHON="$(PYTHON)" nonfatal "${function}" "$@" - else - EPYTHON="$(PYTHON)" "${function}" "$@" - fi - - if [[ "$?" != "0" ]]; then - if [[ -n "${failure_message_template}" ]]; then - failure_message="$(eval echo -n "${failure_message_template}")" - else - failure_message="${action} failed with $(python_get_implementation) $(python_get_version) in ${function}() function" - fi - - if [[ "${nonfatal}" == "1" ]]; then - if [[ "${quiet}" == "0" ]]; then - ewarn "${_RED}${failure_message}${_NORMAL}" - fi - elif [[ "${final_ABI}" == "0" ]] && has "${PYTHON_ABI}" ${FAILURE_TOLERANT_PYTHON_ABIS}; then - if [[ "${EBUILD_PHASE}" != "test" ]] || ! has test-fail-continue ${FEATURES}; then - local enabled_PYTHON_ABIS= other_PYTHON_ABI - for other_PYTHON_ABI in ${PYTHON_ABIS}; do - [[ "${other_PYTHON_ABI}" != "${PYTHON_ABI}" ]] && enabled_PYTHON_ABIS+="${enabled_PYTHON_ABIS:+ }${other_PYTHON_ABI}" - done - export PYTHON_ABIS="${enabled_PYTHON_ABIS}" - fi - if [[ "${quiet}" == "0" ]]; then - ewarn "${_RED}${failure_message}${_NORMAL}" - fi - if [[ -z "${PYTHON_ABIS}" ]]; then - die "${function}() function failed with all enabled versions of Python" - fi - else - die "${failure_message}" - fi - fi - - # Ensure that directory stack has not been decreased. - if [[ "$(dirs -p | wc -l)" -lt "${previous_directory_stack_length}" ]]; then - die "Directory stack decreased illegally" - fi - - # Avoid side effects of earlier returning from the specified function. - while [[ "$(dirs -p | wc -l)" -gt "${previous_directory_stack_length}" ]]; do - popd > /dev/null || die "popd failed" - done - - # Ensure that the bottom part of directory stack has not been changed. Restore - # previous directory (from before running of the specified function) before - # comparison of directory stacks to avoid mismatch of directory stacks after - # potential using of 'cd' to change current directory. Restoration of previous - # directory allows to safely use 'cd' to change current directory in the - # specified function without changing it back to original directory. - cd "${previous_directory}" - if [[ "$(dirs -p)" != "${previous_directory_stack}" ]]; then - die "Directory stack changed illegally" - fi - - if [[ "${separate_build_dirs}" == "1" ]]; then - popd > /dev/null || die "popd failed" - fi - unset BUILDDIR - done - - if [[ "${default_function}" == "1" ]]; then - unset -f python_default_function - fi -} - -# @FUNCTION: python_copy_sources -# @USAGE: [directory] -# @DESCRIPTION: -# Copy unpacked sources of current package to separate build directory for each Python ABI. -python_copy_sources() { - local dir dirs=() PYTHON_ABI - - if [[ "$#" -eq 0 ]]; then - if [[ "${WORKDIR}" == "${S}" ]]; then - die "${FUNCNAME}() cannot be used" - fi - dirs=("${S}") - else - dirs=("$@") - fi - - validate_PYTHON_ABIS - for PYTHON_ABI in ${PYTHON_ABIS}; do - for dir in "${dirs[@]}"; do - cp -pr "${dir}" "${dir}-${PYTHON_ABI}" > /dev/null || die "Copying of sources failed" - done - done -} - -# @FUNCTION: python_set_build_dir_symlink -# @USAGE: -# @DESCRIPTION: -# Create build directory symlink. -python_set_build_dir_symlink() { - local dir="$1" - - [[ -z "${PYTHON_ABI}" ]] && die "PYTHON_ABI variable not set" - [[ -z "${dir}" ]] && dir="build" - - # Do not delete preexistent directories. - rm -f "${dir}" || die "Deletion of '${dir}' failed" - ln -s "${dir}-${PYTHON_ABI}" "${dir}" || die "Creation of '${dir}' directory symlink failed" -} - -# @FUNCTION: python_generate_wrapper_scripts -# @USAGE: [-E|--respect-EPYTHON] [-f|--force] [-q|--quiet] [--] [files] -# @DESCRIPTION: -# Generate wrapper scripts. Existing files are overwritten only with --force option. -# If --respect-EPYTHON option is specified, then generated wrapper scripts will -# respect EPYTHON variable at run time. -python_generate_wrapper_scripts() { - _python_initialize_prefix_variables - - local eselect_python_option file force="0" quiet="0" PYTHON_ABI python2_enabled="0" python3_enabled="0" respect_EPYTHON="0" - - while (($#)); do - case "$1" in - -E|--respect-EPYTHON) - respect_EPYTHON="1" - ;; - -f|--force) - force="1" - ;; - -q|--quiet) - quiet="1" - ;; - --) - shift - break - ;; - -*) - die "${FUNCNAME}(): Unrecognized option '$1'" - ;; - *) - break - ;; - esac - shift - done - - if [[ "$#" -eq 0 ]]; then - die "${FUNCNAME}(): Missing arguments" - fi - - validate_PYTHON_ABIS - for PYTHON_ABI in "${_CPYTHON2_SUPPORTED_ABIS[@]}"; do - if has "${PYTHON_ABI}" ${PYTHON_ABIS}; then - python2_enabled="1" - fi - done - for PYTHON_ABI in "${_CPYTHON3_SUPPORTED_ABIS[@]}"; do - if has "${PYTHON_ABI}" ${PYTHON_ABIS}; then - python3_enabled="1" - fi - done - - if [[ "${python2_enabled}" == "1" && "${python3_enabled}" == "1" ]]; then - eselect_python_option= - elif [[ "${python2_enabled}" == "1" && "${python3_enabled}" == "0" ]]; then - eselect_python_option="--python2" - elif [[ "${python2_enabled}" == "0" && "${python3_enabled}" == "1" ]]; then - eselect_python_option="--python3" - else - die "${FUNCNAME}(): Unsupported environment" - fi - - for file in "$@"; do - if [[ -f "${file}" && "${force}" == "0" ]]; then - die "${FUNCNAME}(): '$1' already exists" - fi - - if [[ "${quiet}" == "0" ]]; then - einfo "Generating '${file#${D%/}}' wrapper script" - fi - - cat << EOF > "${file}" -#!/usr/bin/env python -# Gentoo '${file##*/}' wrapper script - -import os -import re -import subprocess -import sys - -EPYTHON_re = re.compile(r"^python(\d+\.\d+)$") - -EOF - if [[ "$?" != "0" ]]; then - die "${FUNCNAME}(): Generation of '$1' failed" - fi - if [[ "${respect_EPYTHON}" == "1" ]]; then - cat << EOF >> "${file}" -EPYTHON = os.environ.get("EPYTHON") -if EPYTHON: - EPYTHON_matched = EPYTHON_re.match(EPYTHON) - if EPYTHON_matched: - PYTHON_ABI = EPYTHON_matched.group(1) - else: - sys.stderr.write("EPYTHON variable has unrecognized value '%s'\n" % EPYTHON) - sys.exit(1) -else: - try: - eselect_process = subprocess.Popen(["${EPREFIX}/usr/bin/eselect", "python", "show"${eselect_python_option:+, $(echo "\"")}${eselect_python_option}${eselect_python_option:+$(echo "\"")}], stdout=subprocess.PIPE) - if eselect_process.wait() != 0: - raise ValueError - except (OSError, ValueError): - sys.stderr.write("Execution of 'eselect python show${eselect_python_option:+ }${eselect_python_option}' failed\n") - sys.exit(1) - - eselect_output = eselect_process.stdout.read() - if not isinstance(eselect_output, str): - # Python 3 - eselect_output = eselect_output.decode() - - EPYTHON_matched = EPYTHON_re.match(eselect_output) - if EPYTHON_matched: - PYTHON_ABI = EPYTHON_matched.group(1) - else: - sys.stderr.write("'eselect python show${eselect_python_option:+ }${eselect_python_option}' printed unrecognized value '%s" % eselect_output) - sys.exit(1) -EOF - if [[ "$?" != "0" ]]; then - die "${FUNCNAME}(): Generation of '$1' failed" - fi - else - cat << EOF >> "${file}" -try: - eselect_process = subprocess.Popen(["${EPREFIX}/usr/bin/eselect", "python", "show"${eselect_python_option:+, $(echo "\"")}${eselect_python_option}${eselect_python_option:+$(echo "\"")}], stdout=subprocess.PIPE) - if eselect_process.wait() != 0: - raise ValueError -except (OSError, ValueError): - sys.stderr.write("Execution of 'eselect python show${eselect_python_option:+ }${eselect_python_option}' failed\n") - sys.exit(1) - -eselect_output = eselect_process.stdout.read() -if not isinstance(eselect_output, str): - # Python 3 - eselect_output = eselect_output.decode() - -EPYTHON_matched = EPYTHON_re.match(eselect_output) -if EPYTHON_matched: - PYTHON_ABI = EPYTHON_matched.group(1) -else: - sys.stderr.write("'eselect python show${eselect_python_option:+ }${eselect_python_option}' printed unrecognized value '%s" % eselect_output) - sys.exit(1) -EOF - if [[ "$?" != "0" ]]; then - die "${FUNCNAME}(): Generation of '$1' failed" - fi - fi - cat << EOF >> "${file}" - -os.environ["PYTHON_SCRIPT_NAME"] = sys.argv[0] -target_executable = "%s-%s" % (os.path.realpath(sys.argv[0]), PYTHON_ABI) -if not os.path.exists(target_executable): - sys.stderr.write("'%s' does not exist\n" % target_executable) - sys.exit(1) - -os.execv(target_executable, sys.argv) -EOF - if [[ "$?" != "0" ]]; then - die "${FUNCNAME}(): Generation of '$1' failed" - fi - fperms +x "${file#${ED%/}}" || die "fperms '${file}' failed" - done -} - -# ================================================================================================ -# ====== FUNCTIONS FOR PACKAGES NOT SUPPORTING INSTALLATION FOR MULTIPLE VERSIONS OF PYTHON ====== -# ================================================================================================ - -# @FUNCTION: python_set_active_version -# @USAGE: -# @DESCRIPTION: -# Set specified version of CPython as active version of Python. -python_set_active_version() { - if [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then - die "${FUNCNAME}() cannot be used in ebuilds of packages supporting installation for multiple versions of Python" - fi - - if [[ "$#" -ne 1 ]]; then - die "${FUNCNAME}() requires 1 argument" - fi - - _python_initial_sanity_checks - - if [[ "$1" =~ ^[[:digit:]]+\.[[:digit:]]+$ ]]; then - if ! _python_implementation && ! has_version "dev-lang/python:$1"; then - die "${FUNCNAME}(): 'dev-lang/python:$1' is not installed" - fi - export EPYTHON="$(PYTHON "$1")" - elif [[ "$1" == "2" ]]; then - if ! _python_implementation && ! has_version "=dev-lang/python-2*"; then - die "${FUNCNAME}(): '=dev-lang/python-2*' is not installed" - fi - export EPYTHON="$(PYTHON -2)" - elif [[ "$1" == "3" ]]; then - if ! _python_implementation && ! has_version "=dev-lang/python-3*"; then - die "${FUNCNAME}(): '=dev-lang/python-3*' is not installed" - fi - export EPYTHON="$(PYTHON -3)" - else - die "${FUNCNAME}(): Unrecognized argument '$1'" - fi - - # PYTHON_ABI variable is intended to be used only in ebuilds/eclasses, - # so it does not need to be exported to subprocesses. - PYTHON_ABI="${EPYTHON#python}" - PYTHON_ABI="${PYTHON_ABI%%-*}" - - _python_final_sanity_checks - - # python-updater checks PYTHON_REQUESTED_ACTIVE_VERSION variable. - PYTHON_REQUESTED_ACTIVE_VERSION="$1" -} - -# @FUNCTION: python_need_rebuild -# @DESCRIPTION: Mark current package for rebuilding by python-updater after -# switching of active version of Python. -python_need_rebuild() { - if [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then - die "${FUNCNAME}() cannot be used in ebuilds of packages supporting installation for multiple versions of Python" - fi - - export PYTHON_NEED_REBUILD="$(PYTHON --ABI)" -} - -# ================================================================================================ -# ======================================= GETTER FUNCTIONS ======================================= -# ================================================================================================ - -_PYTHON_ABI_EXTRACTION_COMMAND='import platform -import sys -sys.stdout.write(".".join(str(x) for x in sys.version_info[:2])) -if platform.system()[:4] == "Java": - sys.stdout.write("-jython")' - -_python_get_implementation() { - if [[ "$#" -ne 1 ]]; then - die "${FUNCNAME}() requires 1 argument" - fi - - if [[ "$1" =~ ^[[:digit:]]+\.[[:digit:]]+$ ]]; then - echo "CPython" - elif [[ "$1" =~ ^[[:digit:]]+\.[[:digit:]]+-jython$ ]]; then - echo "Jython" - else - die "${FUNCNAME}(): Unrecognized Python ABI '$1'" - fi -} - -# @FUNCTION: PYTHON -# @USAGE: [-2] [-3] [--ABI] [-a|--absolute-path] [-f|--final-ABI] [--] -# @DESCRIPTION: -# Print filename of Python interpreter for specified Python ABI. If Python_ABI argument -# is ommitted, then PYTHON_ABI environment variable must be set and is used. -# If -2 option is specified, then active version of Python 2 is used. -# If -3 option is specified, then active version of Python 3 is used. -# If --final-ABI option is specified, then final ABI from the list of enabled ABIs is used. -# -2, -3 and --final-ABI options and Python_ABI argument cannot be specified simultaneously. -# If --ABI option is specified, then only specified Python ABI is printed instead of -# filename of Python interpreter. -# If --absolute-path option is specified, then absolute path to Python interpreter is printed. -# --ABI and --absolute-path options cannot be specified simultaneously. -PYTHON() { - local ABI_output="0" absolute_path_output="0" final_ABI="0" PYTHON_ABI="${PYTHON_ABI}" python_interpreter python2="0" python3="0" - - while (($#)); do - case "$1" in - -2) - python2="1" - ;; - -3) - python3="1" - ;; - --ABI) - ABI_output="1" - ;; - -a|--absolute-path) - absolute_path_output="1" - ;; - -f|--final-ABI) - final_ABI="1" - ;; - --) - shift - break - ;; - -*) - die "${FUNCNAME}(): Unrecognized option '$1'" - ;; - *) - break - ;; - esac - shift - done - - if [[ "${ABI_output}" == "1" && "${absolute_path_output}" == "1" ]]; then - die "${FUNCNAME}(): '--ABI and '--absolute-path' options cannot be specified simultaneously" - fi - - if [[ "$((${python2} + ${python3} + ${final_ABI}))" -gt 1 ]]; then - die "${FUNCNAME}(): '-2', '-3' or '--final-ABI' options cannot be specified simultaneously" - fi - - if [[ "$#" -eq 0 ]]; then - if [[ "${final_ABI}" == "1" ]]; then - if has "${EAPI:-0}" 0 1 2 3 4 && [[ -z "${SUPPORT_PYTHON_ABIS}" ]]; then - die "${FUNCNAME}(): '--final-ABI' option cannot be used in ebuilds of packages not supporting installation for multiple versions of Python" - fi - validate_PYTHON_ABIS - PYTHON_ABI="${PYTHON_ABIS##* }" - elif [[ "${python2}" == "1" ]]; then - PYTHON_ABI="$(eselect python show --python2 --ABI)" - if [[ -z "${PYTHON_ABI}" ]]; then - die "${FUNCNAME}(): Active Python 2 interpreter not set" - elif [[ "${PYTHON_ABI}" != "2."* ]]; then - die "${FUNCNAME}(): Internal error in \`eselect python show --python2\`" - fi - elif [[ "${python3}" == "1" ]]; then - PYTHON_ABI="$(eselect python show --python3 --ABI)" - if [[ -z "${PYTHON_ABI}" ]]; then - die "${FUNCNAME}(): Active Python 3 interpreter not set" - elif [[ "${PYTHON_ABI}" != "3."* ]]; then - die "${FUNCNAME}(): Internal error in \`eselect python show --python3\`" - fi - elif [[ -z "${SUPPORT_PYTHON_ABIS}" ]]; then - PYTHON_ABI="$("${EPREFIX}/usr/bin/python" -c "${_PYTHON_ABI_EXTRACTION_COMMAND}")" - elif [[ -z "${PYTHON_ABI}" ]]; then - die "${FUNCNAME}(): Invalid usage: Python ABI not specified" - fi - elif [[ "$#" -eq 1 ]]; then - if [[ "${final_ABI}" == "1" ]]; then - die "${FUNCNAME}(): '--final-ABI' option and Python ABI cannot be specified simultaneously" - fi - if [[ "${python2}" == "1" ]]; then - die "${FUNCNAME}(): '-2' option and Python ABI cannot be specified simultaneously" - fi - if [[ "${python3}" == "1" ]]; then - die "${FUNCNAME}(): '-3' option and Python ABI cannot be specified simultaneously" - fi - PYTHON_ABI="$1" - else - die "${FUNCNAME}(): Invalid usage" - fi - - if [[ "${ABI_output}" == "1" ]]; then - echo -n "${PYTHON_ABI}" - return - else - if [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "CPython" ]]; then - python_interpreter="python${PYTHON_ABI}" - elif [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "Jython" ]]; then - python_interpreter="jython-${PYTHON_ABI%-jython}" - fi - - if [[ "${absolute_path_output}" == "1" ]]; then - echo -n "${EPREFIX}/usr/bin/${python_interpreter}" - else - echo -n "${python_interpreter}" - fi - fi - - if [[ -n "${ABI}" && "${ABI}" != "${DEFAULT_ABI}" && "${DEFAULT_ABI}" != "default" ]]; then - echo -n "-${ABI}" - fi -} - -# @FUNCTION: python_get_implementation -# @USAGE: [-f|--final-ABI] -# @DESCRIPTION: -# Print name of Python implementation. -# If --final-ABI option is specified, then final ABI from the list of enabled ABIs is used. -python_get_implementation() { - local final_ABI="0" PYTHON_ABI="${PYTHON_ABI}" - - while (($#)); do - case "$1" in - -f|--final-ABI) - final_ABI="1" - ;; - -*) - die "${FUNCNAME}(): Unrecognized option '$1'" - ;; - *) - die "${FUNCNAME}(): Invalid usage" - ;; - esac - shift - done - - if [[ "${final_ABI}" == "1" ]]; then - PYTHON_ABI="$(PYTHON -f --ABI)" - elif [[ -z "${PYTHON_ABI}" ]]; then - PYTHON_ABI="$(PYTHON --ABI)" - fi - - echo "$(_python_get_implementation "${PYTHON_ABI}")" -} - -# @FUNCTION: python_get_implementational_package -# @USAGE: [-f|--final-ABI] -# @DESCRIPTION: -# Print category, name and slot of package providing Python implementation. -# If --final-ABI option is specified, then final ABI from the list of enabled ABIs is used. -python_get_implementational_package() { - local final_ABI="0" PYTHON_ABI="${PYTHON_ABI}" - - while (($#)); do - case "$1" in - -f|--final-ABI) - final_ABI="1" - ;; - -*) - die "${FUNCNAME}(): Unrecognized option '$1'" - ;; - *) - die "${FUNCNAME}(): Invalid usage" - ;; - esac - shift - done - - if [[ "${final_ABI}" == "1" ]]; then - PYTHON_ABI="$(PYTHON -f --ABI)" - elif [[ -z "${PYTHON_ABI}" ]]; then - PYTHON_ABI="$(PYTHON --ABI)" - fi - - if [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "CPython" ]]; then - echo "dev-lang/python:${PYTHON_ABI}" - elif [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "Jython" ]]; then - echo "dev-java/jython:${PYTHON_ABI%-jython}" - fi -} - -# @FUNCTION: python_get_includedir -# @USAGE: [-f|--final-ABI] -# @DESCRIPTION: -# Print path to Python include directory. -# If --final-ABI option is specified, then final ABI from the list of enabled ABIs is used. -python_get_includedir() { - local final_ABI="0" PYTHON_ABI="${PYTHON_ABI}" - - while (($#)); do - case "$1" in - -f|--final-ABI) - final_ABI="1" - ;; - -*) - die "${FUNCNAME}(): Unrecognized option '$1'" - ;; - *) - die "${FUNCNAME}(): Invalid usage" - ;; - esac - shift - done - - if [[ "${final_ABI}" == "1" ]]; then - PYTHON_ABI="$(PYTHON -f --ABI)" - elif [[ -z "${PYTHON_ABI}" ]]; then - PYTHON_ABI="$(PYTHON --ABI)" - fi - - if [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "CPython" ]]; then - echo "/usr/include/python${PYTHON_ABI}" - elif [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "Jython" ]]; then - echo "/usr/share/jython-${PYTHON_ABI%-jython}/Include" - fi -} - -# @FUNCTION: python_get_libdir -# @USAGE: [-f|--final-ABI] -# @DESCRIPTION: -# Print path to Python library directory. -# If --final-ABI option is specified, then final ABI from the list of enabled ABIs is used. -python_get_libdir() { - local final_ABI="0" PYTHON_ABI="${PYTHON_ABI}" - - while (($#)); do - case "$1" in - -f|--final-ABI) - final_ABI="1" - ;; - -*) - die "${FUNCNAME}(): Unrecognized option '$1'" - ;; - *) - die "${FUNCNAME}(): Invalid usage" - ;; - esac - shift - done - - if [[ "${final_ABI}" == "1" ]]; then - PYTHON_ABI="$(PYTHON -f --ABI)" - elif [[ -z "${PYTHON_ABI}" ]]; then - PYTHON_ABI="$(PYTHON --ABI)" - fi - - if [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "CPython" ]]; then - echo "/usr/$(get_libdir)/python${PYTHON_ABI}" - elif [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "Jython" ]]; then - echo "/usr/share/jython-${PYTHON_ABI%-jython}/Lib" - fi -} - -# @FUNCTION: python_get_sitedir -# @USAGE: [-f|--final-ABI] -# @DESCRIPTION: -# Print path to Python site-packages directory. -# If --final-ABI option is specified, then final ABI from the list of enabled ABIs is used. -python_get_sitedir() { - local options=() - - while (($#)); do - case "$1" in - -f|--final-ABI) - options+=("$1") - ;; - -*) - die "${FUNCNAME}(): Unrecognized option '$1'" - ;; - *) - die "${FUNCNAME}(): Invalid usage" - ;; - esac - shift - done - - echo "$(python_get_libdir "${options[@]}")/site-packages" -} - -# @FUNCTION: python_get_library -# @USAGE: [-f|--final-ABI] [-l|--linker-option] -# @DESCRIPTION: -# Print path to Python library. -# If --linker-option is specified, then "-l${library}" linker option is printed. -# If --final-ABI option is specified, then final ABI from the list of enabled ABIs is used. -python_get_library() { - local final_ABI="0" linker_option="0" PYTHON_ABI="${PYTHON_ABI}" - - while (($#)); do - case "$1" in - -f|--final-ABI) - final_ABI="1" - ;; - -l|--linker-option) - linker_option="1" - ;; - -*) - die "${FUNCNAME}(): Unrecognized option '$1'" - ;; - *) - die "${FUNCNAME}(): Invalid usage" - ;; - esac - shift - done - - if [[ "${final_ABI}" == "1" ]]; then - PYTHON_ABI="$(PYTHON -f --ABI)" - elif [[ -z "${PYTHON_ABI}" ]]; then - PYTHON_ABI="$(PYTHON --ABI)" - fi - - if [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "CPython" ]]; then - if [[ "${linker_option}" == "1" ]]; then - echo "-lpython${PYTHON_ABI}" - else - echo "/usr/$(get_libdir)/libpython${PYTHON_ABI}$(get_libname)" - fi - elif [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "Jython" ]]; then - die "${FUNCNAME}(): Jython does not have shared library" - fi -} - -# @FUNCTION: python_get_version -# @USAGE: [-f|--final-ABI] [--full] [--major] [--minor] [--micro] -# @DESCRIPTION: -# Print Python version. -# --full, --major, --minor and --micro options cannot be specified simultaneously. -# If --full, --major, --minor and --micro options are not specified, then "${major_version}.${minor_version}" is printed. -# If --final-ABI option is specified, then final ABI from the list of enabled ABIs is used. -python_get_version() { - local final_ABI="0" full="0" major="0" minor="0" micro="0" python_command - - while (($#)); do - case "$1" in - -f|--final-ABI) - final_ABI="1" - ;; - --full) - full="1" - ;; - --major) - major="1" - ;; - --minor) - minor="1" - ;; - --micro) - micro="1" - ;; - -*) - die "${FUNCNAME}(): Unrecognized option '$1'" - ;; - *) - die "${FUNCNAME}(): Invalid usage" - ;; - esac - shift - done - - if [[ "$((${full} + ${major} + ${minor} + ${micro}))" -gt 1 ]]; then - die "${FUNCNAME}(): '--full', '--major', '--minor' or '--micro' options cannot be specified simultaneously" - fi - - if [[ "${full}" == "1" ]]; then - python_command="from sys import version_info; print('.'.join(str(x) for x in version_info[:3]))" - elif [[ "${major}" == "1" ]]; then - python_command="from sys import version_info; print(version_info[0])" - elif [[ "${minor}" == "1" ]]; then - python_command="from sys import version_info; print(version_info[1])" - elif [[ "${micro}" == "1" ]]; then - python_command="from sys import version_info; print(version_info[2])" - else - if [[ -n "${PYTHON_ABI}" && "${final_ABI}" == "0" ]]; then - if [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "CPython" ]]; then - echo "${PYTHON_ABI}" - elif [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "Jython" ]]; then - echo "${PYTHON_ABI%-jython}" - fi - return - fi - python_command="from sys import version_info; print('.'.join(str(x) for x in version_info[:2]))" - fi - - if [[ "${final_ABI}" == "1" ]]; then - "$(PYTHON -f)" -c "${python_command}" - else - "$(PYTHON ${PYTHON_ABI})" -c "${python_command}" - fi -} - -# ================================================================================================ -# =================================== MISCELLANEOUS FUNCTIONS ==================================== -# ================================================================================================ - -_python_implementation() { - if [[ "${CATEGORY}/${PN}" == "dev-lang/python" ]]; then - return 0 - elif [[ "${CATEGORY}/${PN}" == "dev-java/jython" ]]; then - return 0 - else - return 1 - fi -} - -_python_initialize_prefix_variables() { - if has "${EAPI:-0}" 0 1 2; then - if [[ -n "${ROOT}" && -z "${EROOT}" ]]; then - EROOT="${ROOT%/}${EPREFIX}/" - fi - if [[ -n "${D}" && -z "${ED}" ]]; then - ED="${D%/}${EPREFIX}/" - fi - fi -} - -unset PYTHON_SANITY_CHECKS - -_python_initial_sanity_checks() { - if [[ "$(declare -p PYTHON_SANITY_CHECKS 2> /dev/null)" != "declare -- PYTHON_SANITY_CHECKS="* ]]; then - # Ensure that /usr/bin/python and /usr/bin/python-config are valid. - if [[ "$(readlink "${EPREFIX}/usr/bin/python")" != "python-wrapper" ]]; then - eerror "'${EPREFIX}/usr/bin/python' is not valid symlink." - eerror "Use \`eselect python set \${python_interpreter}\` to fix this problem." - die "'${EPREFIX}/usr/bin/python' is not valid symlink" - fi - if [[ "$(<"${EPREFIX}/usr/bin/python-config")" != *"Gentoo python-config wrapper script"* ]]; then - eerror "'${EPREFIX}/usr/bin/python-config' is not valid script" - eerror "Use \`eselect python set \${python_interpreter}\` to fix this problem." - die "'${EPREFIX}/usr/bin/python-config' is not valid script" - fi - fi -} - -_python_final_sanity_checks() { - if ! _python_implementation && [[ "$(declare -p PYTHON_SANITY_CHECKS 2> /dev/null)" != "declare -- PYTHON_SANITY_CHECKS="* ]]; then - local PYTHON_ABI="${PYTHON_ABI}" - for PYTHON_ABI in ${PYTHON_ABIS-${PYTHON_ABI}}; do - # Ensure that appropriate version of Python is installed. - if ! has_version "$(python_get_implementational_package)"; then - die "$(python_get_implementational_package) is not installed" - fi - - # Ensure that EPYTHON variable is respected. - if [[ "$(EPYTHON="$(PYTHON)" python -c "${_PYTHON_ABI_EXTRACTION_COMMAND}")" != "${PYTHON_ABI}" ]]; then - eerror "python: '$(type -p python)'" - eerror "ABI: '${ABI}'" - eerror "DEFAULT_ABI: '${DEFAULT_ABI}'" - eerror "EPYTHON: '$(PYTHON)'" - eerror "PYTHON_ABI: '${PYTHON_ABI}'" - eerror "Version of enabled Python: '$(EPYTHON="$(PYTHON)" python -c "${_PYTHON_ABI_EXTRACTION_COMMAND}")'" - die "'python' does not respect EPYTHON variable" - fi - done - fi - PYTHON_SANITY_CHECKS="1" -} - -_python_set_color_variables() { - if [[ "${NOCOLOR:-false}" =~ ^(false|no)$ ]]; then - _BOLD=$'\e[1m' - _RED=$'\e[1;31m' - _GREEN=$'\e[1;32m' - _BLUE=$'\e[1;34m' - _CYAN=$'\e[1;36m' - _NORMAL=$'\e[0m' - else - _BOLD= - _RED= - _GREEN= - _BLUE= - _CYAN= - _NORMAL= - fi -} - -# @FUNCTION: python_convert_shebangs -# @USAGE: [-q|--quiet] [-r|--recursive] [-x|--only-executables] [--] [files|directories] -# @DESCRIPTION: -# Convert shebangs in specified files. Directories can be specified only with --recursive option. -python_convert_shebangs() { - local argument file files=() only_executables="0" python_version quiet="0" recursive="0" - - while (($#)); do - case "$1" in - -r|--recursive) - recursive="1" - ;; - -q|--quiet) - quiet="1" - ;; - -x|--only-executables) - only_executables="1" - ;; - --) - shift - break - ;; - -*) - die "${FUNCNAME}(): Unrecognized option '$1'" - ;; - *) - break - ;; - esac - shift - done - - if [[ "$#" -eq 0 ]]; then - die "${FUNCNAME}(): Missing Python version and files or directories" - elif [[ "$#" -eq 1 ]]; then - die "${FUNCNAME}(): Missing files or directories" - fi - - python_version="$1" - shift - - for argument in "$@"; do - if [[ ! -e "${argument}" ]]; then - die "${FUNCNAME}(): '${argument}' does not exist" - elif [[ -f "${argument}" ]]; then - files+=("${argument}") - elif [[ -d "${argument}" ]]; then - if [[ "${recursive}" == "1" ]]; then - if [[ "${only_executables}" == "1" ]]; then - files+=($(find "${argument}" -perm /111 -type f)) - else - files+=($(find "${argument}" -type f)) - fi - else - die "${FUNCNAME}(): '${argument}' is not a regular file" - fi - else - die "${FUNCNAME}(): '${argument}' is not a regular file or a directory" - fi - done - - for file in "${files[@]}"; do - file="${file#./}" - [[ "${only_executables}" == "1" && ! -x "${file}" ]] && continue - - if [[ "$(head -n1 "${file}")" =~ ^'#!'.*python ]]; then - if [[ "${quiet}" == "0" ]]; then - einfo "Converting shebang in '${file}'" - fi - sed -e "1s/python\([[:digit:]]\+\(\.[[:digit:]]\+\)\?\)\?/python${python_version}/" -i "${file}" || die "Conversion of shebang in '${file}' failed" - - # Delete potential whitespace after "#!". - sed -e '1s/\(^#!\)[[:space:]]*/\1/' -i "${file}" || die "sed '${file}' failed" - fi - done -} - -# ================================================================================================ -# ================================ FUNCTIONS FOR RUNNING OF TESTS ================================ -# ================================================================================================ - -# @ECLASS-VARIABLE: PYTHON_TEST_VERBOSITY -# @DESCRIPTION: -# User-configurable verbosity of tests of Python modules. -# Supported values: 0, 1, 2, 3, 4. -PYTHON_TEST_VERBOSITY="${PYTHON_TEST_VERBOSITY:-1}" - -_python_test_hook() { - if [[ "$#" -ne 1 ]]; then - die "${FUNCNAME}() requires 1 argument" - fi - - if [[ -n "${SUPPORT_PYTHON_ABIS}" && "$(type -t "${FUNCNAME[3]}_$1_hook")" == "function" ]]; then - "${FUNCNAME[3]}_$1_hook" - fi -} - -# @FUNCTION: python_execute_nosetests -# @USAGE: [-P|--PYTHONPATH PYTHONPATH] [-s|--separate-build-dirs] [--] [arguments] -# @DESCRIPTION: -# Execute nosetests for all enabled versions of Python. -# In ebuilds of packages supporting installation for multiple versions of Python, this function -# calls python_execute_nosetests_pre_hook() and python_execute_nosetests_post_hook(), if they are defined. -python_execute_nosetests() { - _python_set_color_variables - - local PYTHONPATH_template= separate_build_dirs= - - while (($#)); do - case "$1" in - -P|--PYTHONPATH) - PYTHONPATH_template="$2" - shift - ;; - -s|--separate-build-dirs) - separate_build_dirs="1" - ;; - --) - shift - break - ;; - -*) - die "${FUNCNAME}(): Unrecognized option '$1'" - ;; - *) - break - ;; - esac - shift - done - - python_test_function() { - local evaluated_PYTHONPATH= - - if [[ -n "${PYTHONPATH_template}" ]]; then - evaluated_PYTHONPATH="$(eval echo -n "${PYTHONPATH_template}")" - if [[ ! -e "${evaluated_PYTHONPATH}" ]]; then - unset evaluated_PYTHONPATH - fi - fi - - _python_test_hook pre - - if [[ -n "${evaluated_PYTHONPATH}" ]]; then - echo ${_BOLD}PYTHONPATH="${evaluated_PYTHONPATH}" nosetests --verbosity="${PYTHON_TEST_VERBOSITY}" "$@"${_NORMAL} - PYTHONPATH="${evaluated_PYTHONPATH}" nosetests --verbosity="${PYTHON_TEST_VERBOSITY}" "$@" || return "$?" - else - echo ${_BOLD}nosetests --verbosity="${PYTHON_TEST_VERBOSITY}" "$@"${_NORMAL} - nosetests --verbosity="${PYTHON_TEST_VERBOSITY}" "$@" || return "$?" - fi - - _python_test_hook post - } - if [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then - python_execute_function ${separate_build_dirs:+-s} python_test_function "$@" - else - if [[ -n "${separate_build_dirs}" ]]; then - die "${FUNCNAME}(): Invalid usage" - fi - python_test_function "$@" || die "Testing failed" - fi - - unset -f python_test_function -} - -# @FUNCTION: python_execute_py.test -# @USAGE: [-P|--PYTHONPATH PYTHONPATH] [-s|--separate-build-dirs] [--] [arguments] -# @DESCRIPTION: -# Execute py.test for all enabled versions of Python. -# In ebuilds of packages supporting installation for multiple versions of Python, this function -# calls python_execute_py.test_pre_hook() and python_execute_py.test_post_hook(), if they are defined. -python_execute_py.test() { - _python_set_color_variables - - local PYTHONPATH_template= separate_build_dirs= - - while (($#)); do - case "$1" in - -P|--PYTHONPATH) - PYTHONPATH_template="$2" - shift - ;; - -s|--separate-build-dirs) - separate_build_dirs="1" - ;; - --) - shift - break - ;; - -*) - die "${FUNCNAME}(): Unrecognized option '$1'" - ;; - *) - break - ;; - esac - shift - done - - python_test_function() { - local evaluated_PYTHONPATH= - - if [[ -n "${PYTHONPATH_template}" ]]; then - evaluated_PYTHONPATH="$(eval echo -n "${PYTHONPATH_template}")" - if [[ ! -e "${evaluated_PYTHONPATH}" ]]; then - unset evaluated_PYTHONPATH - fi - fi - - _python_test_hook pre - - if [[ -n "${evaluated_PYTHONPATH}" ]]; then - echo ${_BOLD}PYTHONPATH="${evaluated_PYTHONPATH}" py.test $([[ "${PYTHON_TEST_VERBOSITY}" -ge 2 ]] && echo -v) "$@"${_NORMAL} - PYTHONPATH="${evaluated_PYTHONPATH}" py.test $([[ "${PYTHON_TEST_VERBOSITY}" -ge 2 ]] && echo -v) "$@" || return "$?" - else - echo ${_BOLD}py.test $([[ "${PYTHON_TEST_VERBOSITY}" -gt 1 ]] && echo -v) "$@"${_NORMAL} - py.test $([[ "${PYTHON_TEST_VERBOSITY}" -gt 1 ]] && echo -v) "$@" || return "$?" - fi - - _python_test_hook post - } - if [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then - python_execute_function ${separate_build_dirs:+-s} python_test_function "$@" - else - if [[ -n "${separate_build_dirs}" ]]; then - die "${FUNCNAME}(): Invalid usage" - fi - python_test_function "$@" || die "Testing failed" - fi - - unset -f python_test_function -} - -# @FUNCTION: python_execute_trial -# @USAGE: [-P|--PYTHONPATH PYTHONPATH] [-s|--separate-build-dirs] [--] [arguments] -# @DESCRIPTION: -# Execute trial for all enabled versions of Python. -# In ebuilds of packages supporting installation for multiple versions of Python, this function -# calls python_execute_trial_pre_hook() and python_execute_trial_post_hook(), if they are defined. -python_execute_trial() { - _python_set_color_variables - - local PYTHONPATH_template= separate_build_dirs= - - while (($#)); do - case "$1" in - -P|--PYTHONPATH) - PYTHONPATH_template="$2" - shift - ;; - -s|--separate-build-dirs) - separate_build_dirs="1" - ;; - --) - shift - break - ;; - -*) - die "${FUNCNAME}(): Unrecognized option '$1'" - ;; - *) - break - ;; - esac - shift - done - - python_test_function() { - local evaluated_PYTHONPATH= - - if [[ -n "${PYTHONPATH_template}" ]]; then - evaluated_PYTHONPATH="$(eval echo -n "${PYTHONPATH_template}")" - if [[ ! -e "${evaluated_PYTHONPATH}" ]]; then - unset evaluated_PYTHONPATH - fi - fi - - _python_test_hook pre - - if [[ -n "${evaluated_PYTHONPATH}" ]]; then - echo ${_BOLD}PYTHONPATH="${evaluated_PYTHONPATH}" trial $([[ "${PYTHON_TEST_VERBOSITY}" -ge 4 ]] && echo --spew) "$@"${_NORMAL} - PYTHONPATH="${evaluated_PYTHONPATH}" trial $([[ "${PYTHON_TEST_VERBOSITY}" -ge 4 ]] && echo --spew) "$@" || return "$?" - else - echo ${_BOLD}trial $([[ "${PYTHON_TEST_VERBOSITY}" -ge 4 ]] && echo --spew) "$@"${_NORMAL} - trial $([[ "${PYTHON_TEST_VERBOSITY}" -ge 4 ]] && echo --spew) "$@" || return "$?" - fi - - _python_test_hook post - } - if [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then - python_execute_function ${separate_build_dirs:+-s} python_test_function "$@" - else - if [[ -n "${separate_build_dirs}" ]]; then - die "${FUNCNAME}(): Invalid usage" - fi - python_test_function "$@" || die "Testing failed" - fi - - unset -f python_test_function -} - -# ================================================================================================ -# ======================= FUNCTIONS FOR HANDLING OF BYTE-COMPILED MODULES ======================== -# ================================================================================================ - -# @FUNCTION: python_enable_pyc -# @DESCRIPTION: -# Tell Python to automatically recompile modules to .pyc/.pyo if the -# timestamps/version stamps have changed. -python_enable_pyc() { - unset PYTHONDONTWRITEBYTECODE -} - -# @FUNCTION: python_disable_pyc -# @DESCRIPTION: -# Tell Python not to automatically recompile modules to .pyc/.pyo -# even if the timestamps/version stamps do not match. This is done -# to protect sandbox. -python_disable_pyc() { - export PYTHONDONTWRITEBYTECODE="1" -} - -# @FUNCTION: python_mod_optimize -# @USAGE: [options] [directory|file] -# @DESCRIPTION: -# If no arguments supplied, it will recompile not recursively all modules -# under sys.path (eg. /usr/lib/python2.6, /usr/lib/python2.6/site-packages). -# -# If supplied with arguments, it will recompile all modules recursively -# in the supplied directory. -# -# Options passed to this function are passed to compileall.py. -# -# This function can be used only in pkg_postinst() phase. -python_mod_optimize() { - _python_initialize_prefix_variables - - # Check if phase is pkg_postinst(). - [[ ${EBUILD_PHASE} != "postinst" ]] && die "${FUNCNAME}() can be used only in pkg_postinst() phase" - - if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then - local dir file options=() other_dirs=() other_files=() previous_PYTHON_ABI="${PYTHON_ABI}" PYTHON_ABI="${PYTHON_ABI}" return_code root site_packages_absolute_dirs=() site_packages_dirs=() site_packages_absolute_files=() site_packages_files=() - - # Strip trailing slash from ROOT. - root="${EROOT%/}" - - # Respect ROOT and options passed to compileall.py. - while (($#)); do - case "$1" in - -l|-f|-q) - options+=("$1") - ;; - -d|-x) - options+=("$1" "$2") - shift - ;; - -*) - ewarn "${FUNCNAME}(): Ignoring option '$1'" - ;; - *) - if ! _python_implementation && [[ "$1" =~ ^"${EPREFIX}"/usr/lib(32|64)?/python[[:digit:]]+\.[[:digit:]]+ ]]; then - die "${FUNCNAME}() does not support absolute paths of directories/files in site-packages directories" - elif [[ "$1" =~ ^/ ]]; then - if [[ -d "${root}/$1" ]]; then - other_dirs+=("${root}/$1") - elif [[ -f "${root}/$1" ]]; then - other_files+=("${root}/$1") - elif [[ -e "${root}/$1" ]]; then - ewarn "'${root}/$1' is not a file or a directory!" - else - ewarn "'${root}/$1' does not exist!" - fi - else - for PYTHON_ABI in ${PYTHON_ABIS-${PYTHON_ABI:-$(PYTHON --ABI)}}; do - if [[ -d "${root}$(python_get_sitedir)/$1" ]]; then - site_packages_dirs+=("$1") - break - elif [[ -f "${root}$(python_get_sitedir)/$1" ]]; then - site_packages_files+=("$1") - break - elif [[ -e "${root}$(python_get_sitedir)/$1" ]]; then - ewarn "'$1' is not a file or a directory!" - else - ewarn "'$1' does not exist!" - fi - done - fi - ;; - esac - shift - done - - # Set additional options. - options+=("-q") - - for PYTHON_ABI in ${PYTHON_ABIS-${PYTHON_ABI:-$(PYTHON --ABI)}}; do - if ((${#site_packages_dirs[@]})) || ((${#site_packages_files[@]})); then - return_code="0" - ebegin "Compilation and optimization of Python modules for $(python_get_implementation) $(python_get_version)" - if ((${#site_packages_dirs[@]})); then - for dir in "${site_packages_dirs[@]}"; do - site_packages_absolute_dirs+=("${root}$(python_get_sitedir)/${dir}") - done - "$(PYTHON)" "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${site_packages_absolute_dirs[@]}" || return_code="1" - if [[ "$(_python_get_implementation "${PYTHON_ABI}")" != "Jython" ]]; then - "$(PYTHON)" -O "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${site_packages_absolute_dirs[@]}" &> /dev/null || return_code="1" - fi - fi - if ((${#site_packages_files[@]})); then - for file in "${site_packages_files[@]}"; do - site_packages_absolute_files+=("${root}$(python_get_sitedir)/${file}") - done - "$(PYTHON)" "${root}$(python_get_libdir)/py_compile.py" "${site_packages_absolute_files[@]}" || return_code="1" - if [[ "$(_python_get_implementation "${PYTHON_ABI}")" != "Jython" ]]; then - "$(PYTHON)" -O "${root}$(python_get_libdir)/py_compile.py" "${site_packages_absolute_files[@]}" &> /dev/null || return_code="1" - fi - fi - eend "${return_code}" - fi - unset site_packages_absolute_dirs site_packages_absolute_files - done - - # Restore previous value of PYTHON_ABI. - if [[ -n "${previous_PYTHON_ABI}" ]]; then - PYTHON_ABI="${previous_PYTHON_ABI}" - else - unset PYTHON_ABI - fi - - if ((${#other_dirs[@]})) || ((${#other_files[@]})); then - return_code="0" - ebegin "Compilation and optimization of Python modules placed outside of site-packages directories for $(python_get_implementation) $(python_get_version)" - if ((${#other_dirs[@]})); then - "$(PYTHON ${PYTHON_ABI})" "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${other_dirs[@]}" || return_code="1" - if [[ "$(_python_get_implementation "${PYTHON_ABI-$(PYTHON --ABI)}")" != "Jython" ]]; then - "$(PYTHON ${PYTHON_ABI})" -O "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${other_dirs[@]}" &> /dev/null || return_code="1" - fi - fi - if ((${#other_files[@]})); then - "$(PYTHON ${PYTHON_ABI})" "${root}$(python_get_libdir)/py_compile.py" "${other_files[@]}" || return_code="1" - if [[ "$(_python_get_implementation "${PYTHON_ABI-$(PYTHON --ABI)}")" != "Jython" ]]; then - "$(PYTHON ${PYTHON_ABI})" -O "${root}$(python_get_libdir)/py_compile.py" "${other_files[@]}" &> /dev/null || return_code="1" - fi - fi - eend "${return_code}" - fi - else - local myroot mydirs=() myfiles=() myopts=() return_code="0" - - # strip trailing slash - myroot="${EROOT%/}" - - # respect ROOT and options passed to compileall.py - while (($#)); do - case "$1" in - -l|-f|-q) - myopts+=("$1") - ;; - -d|-x) - myopts+=("$1" "$2") - shift - ;; - -*) - ewarn "${FUNCNAME}(): Ignoring option '$1'" - ;; - *) - if [[ -d "${myroot}"/$1 ]]; then - mydirs+=("${myroot}/$1") - elif [[ -f "${myroot}"/$1 ]]; then - # Files are passed to python_mod_compile which is ROOT-aware - myfiles+=("$1") - elif [[ -e "${myroot}/$1" ]]; then - ewarn "${myroot}/$1 is not a file or directory!" - else - ewarn "${myroot}/$1 does not exist!" - fi - ;; - esac - shift - done - - # set additional opts - myopts+=(-q) - - ebegin "Compilation and optimization of Python modules for $(python_get_implementation) $(python_get_version)" - if ((${#mydirs[@]})); then - "$(PYTHON ${PYTHON_ABI})" "${myroot}$(python_get_libdir)/compileall.py" "${myopts[@]}" "${mydirs[@]}" || return_code="1" - "$(PYTHON ${PYTHON_ABI})" -O "${myroot}$(python_get_libdir)/compileall.py" "${myopts[@]}" "${mydirs[@]}" &> /dev/null || return_code="1" - fi - - if ((${#myfiles[@]})); then - python_mod_compile "${myfiles[@]}" - fi - - eend "${return_code}" - fi -} - -# @FUNCTION: python_mod_cleanup -# @USAGE: [directory|file] -# @DESCRIPTION: -# Run with optional arguments, where arguments are Python modules. If none given, -# it will look in /usr/lib/python[0-9].[0-9]. -# -# It will recursively scan all compiled Python modules in the directories and -# determine if they are orphaned (i.e. their corresponding .py files are missing.) -# If they are, then it will remove their corresponding .pyc and .pyo files. -# -# This function can be used only in pkg_postrm() phase. -python_mod_cleanup() { - _python_initialize_prefix_variables - _python_set_color_variables - - local path py_file PYTHON_ABI="${PYTHON_ABI}" SEARCH_PATH=() root - - # Check if phase is pkg_postrm(). - [[ ${EBUILD_PHASE} != "postrm" ]] && die "${FUNCNAME}() can be used only in pkg_postrm() phase" - - # Strip trailing slash from ROOT. - root="${EROOT%/}" - - if (($#)); then - if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then - while (($#)); do - if ! _python_implementation && [[ "$1" =~ ^"${EPREFIX}"/usr/lib(32|64)?/python[[:digit:]]+\.[[:digit:]]+ ]]; then - die "${FUNCNAME}() does not support absolute paths of directories/files in site-packages directories" - elif [[ "$1" =~ ^/ ]]; then - SEARCH_PATH+=("${root}/${1#/}") - else - for PYTHON_ABI in ${PYTHON_ABIS-${PYTHON_ABI:-$(PYTHON --ABI)}}; do - SEARCH_PATH+=("${root}$(python_get_sitedir)/$1") - done - fi - shift - done - else - SEARCH_PATH=("${@#/}") - SEARCH_PATH=("${SEARCH_PATH[@]/#/${root}/}") - fi - else - local dir sitedir - for dir in "${root}"/usr/lib*; do - if [[ -d "${dir}" && ! -L "${dir}" ]]; then - for sitedir in "${dir}"/python*/site-packages; do - if [[ -d "${sitedir}" ]]; then - SEARCH_PATH+=("${sitedir}") - fi - done - fi - done - for sitedir in "${root}"/usr/share/jython-*/Lib/site-packages; do - if [[ -d "${sitedir}" ]]; then - SEARCH_PATH+=("${sitedir}") - fi - done - fi - - for path in "${SEARCH_PATH[@]}"; do - if [[ -d "${path}" ]]; then - find "${path}" "(" -name "*.py[co]" -o -name "*\$py.class" ")" -print0 | while read -rd ''; do - if [[ "${REPLY}" == *[co] ]]; then - py_file="${REPLY%[co]}" - [[ -f "${py_file}" || (! -f "${py_file}c" && ! -f "${py_file}o") ]] && continue - einfo "${_BLUE}<<< ${py_file}[co]${_NORMAL}" - rm -f "${py_file}"[co] - elif [[ "${REPLY}" == *\$py.class ]]; then - py_file="${REPLY%\$py.class}.py" - [[ -f "${py_file}" || ! -f "${py_file%.py}\$py.class" ]] && continue - einfo "${_BLUE}<<< ${py_file%.py}\$py.class${_NORMAL}" - rm -f "${py_file%.py}\$py.class" - fi - done - - # Attempt to delete directories, which may be empty. - find "${path}" -type d | sort -r | while read -r dir; do - rmdir "${dir}" 2>/dev/null && einfo "${_CYAN}<<< ${dir}${_NORMAL}" - done - elif [[ "${path}" == *.py && ! -f "${path}" ]]; then - if [[ (-f "${path}c" || -f "${path}o") ]]; then - einfo "${_BLUE}<<< ${path}[co]${_NORMAL}" - rm -f "${path}"[co] - fi - if [[ -f "${path%.py}\$py.class" ]]; then - einfo "${_BLUE}<<< ${path%.py}\$py.class${_NORMAL}" - rm -f "${path%.py}\$py.class" - fi - fi - done -} - -# ================================================================================================ -# ===================================== DEPRECATED FUNCTIONS ===================================== -# ================================================================================================ - -# @FUNCTION: python_version -# @DESCRIPTION: -# Run without arguments and it will export the version of python -# currently in use as $PYVER; sets PYVER/PYVER_MAJOR/PYVER_MINOR -python_version() { - if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then - eerror "Use PYTHON() and/or python_get_*() instead of ${FUNCNAME}()." - die "${FUNCNAME}() cannot be used in this EAPI" - fi - - _python_set_color_variables - - if [[ "${FUNCNAME[1]}" != "distutils_python_version" ]]; then - eerror - eerror "${_RED}Deprecation Warning: ${FUNCNAME}() is deprecated and will be banned on 2010-07-01.${_NORMAL}" - eerror "${_RED}Use PYTHON() instead of python variable. Use python_get_*() instead of PYVER* variables.${_NORMAL}" - eerror - fi - - [[ -n "${PYVER}" ]] && return 0 - local tmpstr - python="${python:-${EPREFIX}/usr/bin/python}" - tmpstr="$(EPYTHON= ${python} -V 2>&1 )" - export PYVER_ALL="${tmpstr#Python }" - export PYVER_MAJOR="${PYVER_ALL:0:1}" - export PYVER_MINOR="${PYVER_ALL:2:1}" - if [[ "${PYVER_ALL:3:1}" == "." ]]; then - export PYVER_MICRO="${PYVER_ALL:4}" - fi - export PYVER="${PYVER_MAJOR}.${PYVER_MINOR}" -} - -# @FUNCTION: python_mod_exists -# @USAGE: -# @DESCRIPTION: -# Run with the module name as an argument. It will check if a -# Python module is installed and loadable. It will return -# TRUE(0) if the module exists, and FALSE(1) if the module does -# not exist. -# -# Example: -# if python_mod_exists gtk; then -# echo "gtk support enabled" -# fi -python_mod_exists() { - if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then - eerror "Use USE dependencies and/or has_version() instead of ${FUNCNAME}()." - die "${FUNCNAME}() cannot be used in this EAPI" - fi - - _python_set_color_variables - - eerror - eerror "${_RED}Deprecation Warning: ${FUNCNAME}() is deprecated and will be banned on 2010-07-01.${_NORMAL}" - eerror "${_RED}Use USE dependencies and/or has_version() instead of ${FUNCNAME}().${_NORMAL}" - eerror - - if [[ "$#" -ne 1 ]]; then - die "${FUNCNAME}() requires 1 argument" - fi - "$(PYTHON ${PYTHON_ABI})" -c "import $1" &> /dev/null -} - -# @FUNCTION: python_tkinter_exists -# @DESCRIPTION: -# Run without arguments, checks if Python was compiled with Tkinter -# support. If not, prints an error message and dies. -python_tkinter_exists() { - if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then - eerror "Use PYTHON_USE_WITH=\"xml\" and python_pkg_setup() instead of ${FUNCNAME}()." - die "${FUNCNAME}() cannot be used in this EAPI" - fi - - _python_set_color_variables - - if [[ "${FUNCNAME[1]}" != "distutils_python_tkinter" ]]; then - eerror - eerror "${_RED}Deprecation Warning: ${FUNCNAME}() is deprecated and will be banned on 2010-07-01.${_NORMAL}" - eerror "${_RED}Use PYTHON_USE_WITH=\"xml\" and python_pkg_setup() instead of ${FUNCNAME}().${_NORMAL}" - eerror - fi - - if ! "$(PYTHON ${PYTHON_ABI})" -c "from sys import version_info -if version_info[0] == 3: - import tkinter -else: - import Tkinter" &> /dev/null; then - eerror "Python needs to be rebuilt with tkinter support enabled." - eerror "Add the following line to '${EPREFIX}/etc/portage/package.use' and rebuild Python" - eerror "dev-lang/python tk" - die "Python installed without support for tkinter" - fi -} - -# @FUNCTION: python_mod_compile -# @USAGE: [more files ...] -# @DESCRIPTION: -# Given filenames, it will pre-compile the module's .pyc and .pyo. -# This function can be used only in pkg_postinst() phase. -# -# Example: -# python_mod_compile /usr/lib/python2.3/site-packages/pygoogle.py -# -python_mod_compile() { - if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then - eerror "Use python_mod_optimize() instead of ${FUNCNAME}()." - die "${FUNCNAME}() cannot be used in this EAPI" - fi - - _python_initialize_prefix_variables - - local f myroot myfiles=() - - # Check if phase is pkg_postinst() - [[ ${EBUILD_PHASE} != postinst ]] && die "${FUNCNAME}() can be used only in pkg_postinst() phase" - - # strip trailing slash - myroot="${EROOT%/}" - - # respect ROOT - for f in "$@"; do - [[ -f "${myroot}/${f}" ]] && myfiles+=("${myroot}/${f}") - done - - if ((${#myfiles[@]})); then - "$(PYTHON ${PYTHON_ABI})" "${myroot}$(python_get_libdir)/py_compile.py" "${myfiles[@]}" - "$(PYTHON ${PYTHON_ABI})" -O "${myroot}$(python_get_libdir)/py_compile.py" "${myfiles[@]}" &> /dev/null - else - ewarn "No files to compile!" - fi -} diff --git a/sdk_container/src/third_party/coreos-overlay/eclass/subversion.eclass b/sdk_container/src/third_party/coreos-overlay/eclass/subversion.eclass deleted file mode 100644 index 45783256c8..0000000000 --- a/sdk_container/src/third_party/coreos-overlay/eclass/subversion.eclass +++ /dev/null @@ -1,525 +0,0 @@ -# Copyright 1999-2009 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/eclass/subversion.eclass,v 1.67 2009/05/10 20:33:38 arfrever Exp $ - -# @ECLASS: subversion.eclass -# @MAINTAINER: -# Akinori Hattori -# Bo Ørsted Andresen -# Arfrever Frehtes Taifersar Arahesis -# -# Original Author: Akinori Hattori -# -# @BLURB: The subversion eclass is written to fetch software sources from subversion repositories -# @DESCRIPTION: -# The subversion eclass provides functions to fetch, patch and bootstrap -# software sources from subversion repositories. - -inherit eutils - -ESVN="${ECLASS}" - -case "${EAPI:-0}" in - 0|1) - EXPORT_FUNCTIONS src_unpack pkg_preinst - ;; - *) - EXPORT_FUNCTIONS src_unpack src_prepare pkg_preinst - ;; -esac - -DESCRIPTION="Based on the ${ECLASS} eclass" - -SUBVERSION_DEPEND="dev-vcs/subversion[webdav-neon,webdav-serf] - net-misc/rsync" - -if [[ -z "${ESVN_DISABLE_DEPENDENCIES}" ]]; then - DEPEND="${SUBVERSION_DEPEND}" -fi - -# @ECLASS-VARIABLE: ESVN_STORE_DIR -# @DESCRIPTION: -# subversion sources store directory. Users may override this in /etc/make.conf -if [[ -z ${ESVN_STORE_DIR} ]]; then - ESVN_STORE_DIR="${PORTAGE_ACTUAL_DISTDIR:-${DISTDIR}}/svn-src" - # Pick a directory with the same permissions now and in the future. Note - # that we cannot just use USERNAME because the eventual effective user when - # doing the svn commands may change - PORTAGE_USERNAME has not taken effect - # yet. Further complicating things, if features userpriv is not set, - # PORTAGE_USERNAME is going to be ignored. We assume that if we enable - # userpriv in the future, we will also set PORTAGE_USERNAME to something - # other than "portage". - # TODO: remove this once we are using consistent users and userpriv settings - # for emerge and emerge-${BOARD}. - ESVN_STORE_DIR="${ESVN_STORE_DIR}/${PORTAGE_USERNAME:-portage}" -fi - -# @ECLASS-VARIABLE: ESVN_FETCH_CMD -# @DESCRIPTION: -# subversion checkout command -ESVN_FETCH_CMD="svn checkout" - -# @ECLASS-VARIABLE: ESVN_UPDATE_CMD -# @DESCRIPTION: -# subversion update command -ESVN_UPDATE_CMD="svn update" - -# @ECLASS-VARIABLE: ESVN_SWITCH_CMD -# @DESCRIPTION: -# subversion switch command -ESVN_SWITCH_CMD="svn switch" - -# @ECLASS-VARIABLE: ESVN_OPTIONS -# @DESCRIPTION: -# the options passed to checkout or update. If you want a specific revision see -# ESVN_REPO_URI instead of using -rREV. -ESVN_OPTIONS="${ESVN_OPTIONS:-}" - -# @ECLASS-VARIABLE: ESVN_REPO_URI -# @DESCRIPTION: -# repository uri -# -# e.g. http://foo/trunk, svn://bar/trunk, svn://bar/branch/foo@1234 -# -# supported protocols: -# http:// -# https:// -# svn:// -# svn+ssh:// -# -# to peg to a specific revision, append @REV to the repo's uri -ESVN_REPO_URI="${ESVN_REPO_URI:-}" - -# @ECLASS-VARIABLE: ESVN_REVISION -# @DESCRIPTION: -# User configurable revision checkout or update to from the repository -# -# Useful for live svn or trunk svn ebuilds allowing the user to peg -# to a specific revision -# -# Note: This should never be set in an ebuild! -ESVN_REVISION="${ESVN_REVISION:-}" - -# @ECLASS-VARIABLE: ESVN_USER -# @DESCRIPTION: -# User name -ESVN_USER="${ESVN_USER:-}" - -# @ECLASS-VARIABLE: ESVN_PASSWORD -# @DESCRIPTION: -# Password -ESVN_PASSWORD="${ESVN_PASSWORD:-}" - -# @ECLASS-VARIABLE: ESVN_PROJECT -# @DESCRIPTION: -# project name of your ebuild (= name space) -# -# subversion eclass will check out the subversion repository like: -# -# ${ESVN_STORE_DIR}/${ESVN_PROJECT}/${ESVN_REPO_URI##*/} -# -# so if you define ESVN_REPO_URI as http://svn.collab.net/repo/svn/trunk or -# http://svn.collab.net/repo/svn/trunk/. and PN is subversion-svn. -# it will check out like: -# -# ${ESVN_STORE_DIR}/subversion/trunk -# -# this is not used in order to declare the name of the upstream project. -# so that you can declare this like: -# -# # jakarta commons-loggin -# ESVN_PROJECT=commons/logging -# -# default: ${PN/-svn}. -ESVN_PROJECT="${ESVN_PROJECT:-${PN/-svn}}" - -# @ECLASS-VARIABLE: ESVN_BOOTSTRAP -# @DESCRIPTION: -# bootstrap script or command like autogen.sh or etc.. -ESVN_BOOTSTRAP="${ESVN_BOOTSTRAP:-}" - -# @ECLASS-VARIABLE: ESVN_PATCHES -# @DESCRIPTION: -# subversion eclass can apply patches in subversion_bootstrap(). -# you can use regexp in this variable like *.diff or *.patch or etc. -# NOTE: patches will be applied before ESVN_BOOTSTRAP is processed. -# -# Patches are searched both in ${PWD} and ${FILESDIR}, if not found in either -# location, the installation dies. -ESVN_PATCHES="${ESVN_PATCHES:-}" - -# @ECLASS-VARIABLE: ESVN_RESTRICT -# @DESCRIPTION: -# this should be a space delimited list of subversion eclass features to -# restrict. -# export) -# don't export the working copy to S. -ESVN_RESTRICT="${ESVN_RESTRICT:-}" - -# @ECLASS-VARIABLE: ESVN_DISABLE_DEPENDENCIES -# @DESCRIPTION: -# Set this variable to a non-empty value to disable the automatic inclusion of -# Subversion in dependencies. -ESVN_DISABLE_DEPENDENCIES="${ESVN_DISABLE_DEPENDENCIES:-}" - -# @ECLASS-VARIABLE: ESVN_OFFLINE -# @DESCRIPTION: -# Set this variable to a non-empty value to disable the automatic updating of -# an svn source tree. This is intended to be set outside the subversion source -# tree by users. -ESVN_OFFLINE="${ESVN_OFFLINE:-${ESCM_OFFLINE}}" - -# @ECLASS-VARIABLE: ESVN_UP_FREQ -# @DESCRIPTION: -# Set the minimum number of hours between svn up'ing in any given svn module. This is particularly -# useful for split KDE ebuilds where we want to ensure that all submodules are compiled for the same -# revision. It should also be kept user overrideable. -ESVN_UP_FREQ="${ESVN_UP_FREQ:=}" - -# @ECLASS-VARIABLE: ESCM_LOGDIR -# @DESCRIPTION: -# User configuration variable. If set to a path such as e.g. /var/log/scm any -# package inheriting from subversion.eclass will record svn revision to -# ${CATEGORY}/${PN}.log in that path in pkg_preinst. This is not supposed to be -# set by ebuilds/eclasses. It defaults to empty so users need to opt in. -ESCM_LOGDIR="${ESCM_LOGDIR:=}" - -# @FUNCTION: subversion_fetch -# @USAGE: [repo_uri] [destination] -# @DESCRIPTION: -# Wrapper function to fetch sources from subversion via svn checkout or svn update, -# depending on whether there is an existing working copy in ${ESVN_STORE_DIR}. -# -# Can take two optional parameters: -# repo_uri - a repository URI. default is ESVN_REPO_URI. -# destination - a check out path in S. -subversion_fetch() { - local repo_uri="$(subversion__get_repository_uri "${1:-${ESVN_REPO_URI}}")" - local revision="$(subversion__get_peg_revision "${1:-${ESVN_REPO_URI}}")" - local S_dest="${2}" - - if [[ -z ${repo_uri} ]]; then - die "${ESVN}: ESVN_REPO_URI (or specified URI) is empty." - fi - - [[ -n "${ESVN_REVISION}" ]] && revision="${ESVN_REVISION}" - - # check for the protocol - local protocol="${repo_uri%%:*}" - - case "${protocol}" in - http|https) - ;; - svn|svn+ssh) - ;; - *) - die "${ESVN}: fetch from '${protocol}' is not yet implemented." - ;; - esac - - addread "/etc/subversion" - addwrite "${ESVN_STORE_DIR}" - # Also make the /var/lib/portage/distfiles/svn-src directory writeable in sandbox - # so we can create it if necessary. - addwrite "$(dirname ${ESVN_STORE_DIR})" - - if [[ ! -d ${ESVN_STORE_DIR} ]]; then - debug-print "${FUNCNAME}: initial checkout. creating subversion directory" - mkdir -p "${ESVN_STORE_DIR}" || die "${ESVN}: can't mkdir ${ESVN_STORE_DIR}." - fi - - cd "${ESVN_STORE_DIR}" || die "${ESVN}: can't chdir to ${ESVN_STORE_DIR}" - - local wc_path="$(subversion__get_wc_path "${repo_uri}")" - local options="${ESVN_OPTIONS} --config-dir ${ESVN_STORE_DIR}/.subversion" - - [[ -n "${revision}" ]] && options="${options} -r ${revision}" - - if [[ "${ESVN_OPTIONS}" = *-r* ]]; then - ewarn "\${ESVN_OPTIONS} contains -r, this usage is unsupported. Please" - ewarn "see \${ESVN_REPO_URI}" - fi - - if has_version ">=dev-vcs/subversion-1.6.0"; then - options="${options} --config-option=config:auth:password-stores=" - fi - - debug-print "${FUNCNAME}: wc_path = \"${wc_path}\"" - debug-print "${FUNCNAME}: ESVN_OPTIONS = \"${ESVN_OPTIONS}\"" - debug-print "${FUNCNAME}: options = \"${options}\"" - - if [[ ! -d ${wc_path}/.svn ]]; then - if [[ -n ${ESVN_OFFLINE} ]]; then - ewarn "ESVN_OFFLINE cannot be used when there is no existing checkout." - fi - # first check out - einfo "subversion check out start -->" - einfo " repository: ${repo_uri}${revision:+@}${revision}" - - debug-print "${FUNCNAME}: ${ESVN_FETCH_CMD} ${options} ${repo_uri}" - - mkdir -p "${ESVN_PROJECT}" || die "${ESVN}: can't mkdir ${ESVN_PROJECT}." - cd "${ESVN_PROJECT}" || die "${ESVN}: can't chdir to ${ESVN_PROJECT}" - if [[ -n "${ESVN_USER}" ]]; then - ${ESVN_FETCH_CMD} ${options} --username "${ESVN_USER}" --password "${ESVN_PASSWORD}" "${repo_uri}" || die "${ESVN}: can't fetch to ${wc_path} from ${repo_uri}." - else - ${ESVN_FETCH_CMD} ${options} "${repo_uri}" || die "${ESVN}: can't fetch to ${wc_path} from ${repo_uri}." - fi - - elif [[ -n ${ESVN_OFFLINE} ]]; then - svn upgrade "${wc_path}" &>/dev/null - svn cleanup "${wc_path}" &>/dev/null - subversion_wc_info "${repo_uri}" || die "${ESVN}: unknown problem occurred while accessing working copy." - if [[ -n ${ESVN_REVISION} && ${ESVN_REVISION} != ${ESVN_WC_REVISION} ]]; then - die "${ESVN}: You requested off-line updating and revision ${ESVN_REVISION} but only revision ${ESVN_WC_REVISION} is available locally." - fi - einfo "Fetching disabled: Using existing repository copy at revision ${ESVN_WC_REVISION}." - else - svn upgrade "${wc_path}" &>/dev/null - svn cleanup "${wc_path}" &>/dev/null - subversion_wc_info "${repo_uri}" || die "${ESVN}: unknown problem occurred while accessing working copy." - - local esvn_up_freq= - if [[ -n ${ESVN_UP_FREQ} ]]; then - if [[ -n ${ESVN_UP_FREQ//[[:digit:]]} ]]; then - die "${ESVN}: ESVN_UP_FREQ must be an integer value corresponding to the minimum number of hours between svn up." - elif [[ -z $(find "${wc_path}/.svn/entries" -mmin "+$((ESVN_UP_FREQ*60))") ]]; then - einfo "Fetching disabled since ${ESVN_UP_FREQ} hours has not passed since last update." - einfo "Using existing repository copy at revision ${ESVN_WC_REVISION}." - esvn_up_freq=no_update - fi - fi - - if [[ -z ${esvn_up_freq} ]]; then - if [[ ${ESVN_WC_URL} != $(subversion__get_repository_uri "${repo_uri}") ]]; then - einfo "subversion switch start -->" - einfo " old repository: ${ESVN_WC_URL}@${ESVN_WC_REVISION}" - einfo " new repository: ${repo_uri}${revision:+@}${revision}" - - debug-print "${FUNCNAME}: ${ESVN_SWITCH_CMD} ${options} ${repo_uri}" - - cd "${wc_path}" || die "${ESVN}: can't chdir to ${wc_path}" - if [[ -n "${ESVN_USER}" ]]; then - ${ESVN_SWITCH_CMD} ${options} --username "${ESVN_USER}" --password "${ESVN_PASSWORD}" ${repo_uri} || die "${ESVN}: can't update ${wc_path} from ${repo_uri}." - else - ${ESVN_SWITCH_CMD} ${options} ${repo_uri} || die "${ESVN}: can't update ${wc_path} from ${repo_uri}." - fi - else - # update working copy - einfo "subversion update start -->" - einfo " repository: ${repo_uri}${revision:+@}${revision}" - - debug-print "${FUNCNAME}: ${ESVN_UPDATE_CMD} ${options}" - - cd "${wc_path}" || die "${ESVN}: can't chdir to ${wc_path}" - if [[ -n "${ESVN_USER}" ]]; then - ${ESVN_UPDATE_CMD} ${options} --username "${ESVN_USER}" --password "${ESVN_PASSWORD}" || die "${ESVN}: can't update ${wc_path} from ${repo_uri}." - else - ${ESVN_UPDATE_CMD} ${options} || die "${ESVN}: can't update ${wc_path} from ${repo_uri}." - fi - fi - fi - fi - - einfo " working copy: ${wc_path}" - - if ! has "export" ${ESVN_RESTRICT}; then - cd "${wc_path}" || die "${ESVN}: can't chdir to ${wc_path}" - - local S="${S}/${S_dest}" - mkdir -p "${S}" - - # export to the ${WORKDIR} - #* "svn export" has a bug. see http://bugs.gentoo.org/119236 - #* svn export . "${S}" || die "${ESVN}: can't export to ${S}." - rsync -rlpgo --exclude=".svn/" . "${S}" || die "${ESVN}: can't export to ${S}." - fi - - echo -} - -# @FUNCTION: subversion_bootstrap -# @DESCRIPTION: -# Apply patches in ${ESVN_PATCHES} and run ${ESVN_BOOTSTRAP} if specified. -subversion_bootstrap() { - if has "export" ${ESVN_RESTRICT}; then - return - fi - - cd "${S}" - - if [[ -n ${ESVN_PATCHES} ]]; then - einfo "apply patches -->" - - local patch fpatch - - for patch in ${ESVN_PATCHES}; do - if [[ -f ${patch} ]]; then - epatch "${patch}" - - else - for fpatch in ${FILESDIR}/${patch}; do - if [[ -f ${fpatch} ]]; then - epatch "${fpatch}" - - else - die "${ESVN}: ${patch} not found" - - fi - done - - fi - done - - echo - fi - - if [[ -n ${ESVN_BOOTSTRAP} ]]; then - einfo "begin bootstrap -->" - - if [[ -f ${ESVN_BOOTSTRAP} && -x ${ESVN_BOOTSTRAP} ]]; then - einfo " bootstrap with a file: ${ESVN_BOOTSTRAP}" - eval "./${ESVN_BOOTSTRAP}" || die "${ESVN}: can't execute ESVN_BOOTSTRAP." - - else - einfo " bootstrap with command: ${ESVN_BOOTSTRAP}" - eval "${ESVN_BOOTSTRAP}" || die "${ESVN}: can't eval ESVN_BOOTSTRAP." - - fi - fi -} - -# @FUNCTION: subversion_src_unpack -# @DESCRIPTION: -# Default src_unpack. Fetch and, in older EAPIs, bootstrap. -subversion_src_unpack() { - subversion_fetch || die "${ESVN}: unknown problem occurred in subversion_fetch." - if has "${EAPI:-0}" 0 1; then - subversion_bootstrap || die "${ESVN}: unknown problem occurred in subversion_bootstrap." - fi -} - -# @FUNCTION: subversion_src_prepare -# @DESCRIPTION: -# Default src_prepare. Bootstrap. -subversion_src_prepare() { - subversion_bootstrap || die "${ESVN}: unknown problem occurred in subversion_bootstrap." -} - -# @FUNCTION: subversion_wc_info -# @USAGE: [repo_uri] -# @RETURN: ESVN_WC_URL, ESVN_WC_ROOT, ESVN_WC_UUID, ESVN_WC_REVISION and ESVN_WC_PATH -# @DESCRIPTION: -# Get svn info for the specified repo_uri. The default repo_uri is ESVN_REPO_URI. -# -# The working copy information on the specified repository URI are set to -# ESVN_WC_* variables. -subversion_wc_info() { - local repo_uri="$(subversion__get_repository_uri "${1:-${ESVN_REPO_URI}}")" - local wc_path="$(subversion__get_wc_path "${repo_uri}")" - - debug-print "${FUNCNAME}: repo_uri = ${repo_uri}" - debug-print "${FUNCNAME}: wc_path = ${wc_path}" - - if [[ ! -d ${wc_path} ]]; then - return 1 - fi - - export ESVN_WC_URL="$(subversion__svn_info "${wc_path}" "URL")" - export ESVN_WC_ROOT="$(subversion__svn_info "${wc_path}" "Repository Root")" - export ESVN_WC_UUID="$(subversion__svn_info "${wc_path}" "Repository UUID")" - export ESVN_WC_REVISION="$(subversion__svn_info "${wc_path}" "Revision")" - export ESVN_WC_PATH="${wc_path}" -} - -## -- Private Functions - -## -- subversion__svn_info() ------------------------------------------------- # -# -# param $1 - a target. -# param $2 - a key name. -# -subversion__svn_info() { - local target="${1}" - local key="${2}" - - env LC_ALL=C svn info "${target}" | grep -i "^${key}" | cut -d" " -f2- -} - -## -- subversion__get_repository_uri() --------------------------------------- # -# -# param $1 - a repository URI. -subversion__get_repository_uri() { - local repo_uri="${1}" - - debug-print "${FUNCNAME}: repo_uri = ${repo_uri}" - - if [[ -z ${repo_uri} ]]; then - die "${ESVN}: ESVN_REPO_URI (or specified URI) is empty." - fi - - # delete trailing slash - if [[ -z ${repo_uri##*/} ]]; then - repo_uri="${repo_uri%/}" - fi - - repo_uri="${repo_uri%@*}" - - echo "${repo_uri}" -} - -## -- subversion__get_wc_path() ---------------------------------------------- # -# -# param $1 - a repository URI. -subversion__get_wc_path() { - local repo_uri="$(subversion__get_repository_uri "${1}")" - - debug-print "${FUNCNAME}: repo_uri = ${repo_uri}" - - echo "${ESVN_STORE_DIR}/${ESVN_PROJECT}/${repo_uri##*/}" -} - -## -- subversion__get_peg_revision() ----------------------------------------- # -# -# param $1 - a repository URI. -subversion__get_peg_revision() { - local repo_uri="${1}" - - debug-print "${FUNCNAME}: repo_uri = ${repo_uri}" - - # repo_uri has peg revision ? - if [[ ${repo_uri} != *@* ]]; then - debug-print "${FUNCNAME}: repo_uri does not have a peg revision." - fi - - local peg_rev= - [[ ${repo_uri} = *@* ]] && peg_rev="${repo_uri##*@}" - - debug-print "${FUNCNAME}: peg_rev = ${peg_rev}" - - echo "${peg_rev}" -} - -# @FUNCTION: subversion_pkg_preinst -# @USAGE: [repo_uri] -# @DESCRIPTION: -# Log the svn revision of source code. Doing this in pkg_preinst because we -# want the logs to stick around if packages are uninstalled without messing with -# config protection. -subversion_pkg_preinst() { - local pkgdate=$(date "+%Y%m%d %H:%M:%S") - subversion_wc_info "${1:-${ESVN_REPO_URI}}" - if [[ -n ${ESCM_LOGDIR} ]]; then - local dir="${ROOT}/${ESCM_LOGDIR}/${CATEGORY}" - if [[ ! -d ${dir} ]]; then - mkdir -p "${dir}" || \ - eerror "Failed to create '${dir}' for logging svn revision to '${PORTDIR_SCM}'" - fi - local logmessage="svn: ${pkgdate} - ${PF}:${SLOT} was merged at revision ${ESVN_WC_REVISION}" - if [[ -d ${dir} ]]; then - echo "${logmessage}" >> "${dir}/${PN}.log" - else - eerror "Could not log the message '${logmessage}' to '${dir}/${PN}.log'" - fi - fi -} diff --git a/sdk_container/src/third_party/coreos-overlay/eclass/tegra-bct.eclass b/sdk_container/src/third_party/coreos-overlay/eclass/tegra-bct.eclass deleted file mode 100644 index 1f6eb51d9c..0000000000 --- a/sdk_container/src/third_party/coreos-overlay/eclass/tegra-bct.eclass +++ /dev/null @@ -1,84 +0,0 @@ -# Copyright (c) 2012 The Chromium OS Authors. All rights reserved. -# Distributed under the terms of the GNU General Public License v2 - -# -# Original Author: The Chromium OS Authors -# Purpose: Install Tegra BCT files for firmware construction. -# - -# @ECLASS-VARIABLE: TEGRA_BCT_SDRAM_CONFIG -# @DESCRIPTION: -# SDRAM memory timing configuration file to install -: ${TEGRA_BCT_SDRAM_CONFIG:=} - -# @ECLASS-VARIABLE: TEGRA_BCT_FLASH_CONFIG -# @DESCRIPTION: -# Flash memory configuration file to install -: ${TEGRA_BCT_FLASH_CONFIG:=} - -# @ECLASS-VARIABLE: TEGRA_BCT_CHIP_FAMILY -# @DESCRIPTION: -# Family of Tegra chip (determines BCT configuration) -: ${TEGRA_BCT_CHIP_FAMILY:=t25} - -# Check for EAPI 2+ -case "${EAPI:-0}" in - 4|3|2) ;; - *) die "unsupported EAPI" ;; -esac - -tegra-bct_src_configure() { - local sdram_file=${FILESDIR}/${TEGRA_BCT_SDRAM_CONFIG} - local flash_file=${FILESDIR}/${TEGRA_BCT_FLASH_CONFIG} - - if [ -z "${TEGRA_BCT_SDRAM_CONFIG}" ]; then - die "No SDRAM configuration file selected." - fi - - if [ -z "${TEGRA_BCT_FLASH_CONFIG}" ]; then - die "No flash configuration file selected." - fi - - if [ -z "${TEGRA_BCT_CHIP_FAMILY}" ]; then - die "No chip family selected." - fi - - einfo "Using sdram config file: ${sdram_file}" - einfo "Using flash config file: ${flash_file}" - einfo "Using chip family : ${TEGRA_BCT_CHIP_FAMILY}" - - cat ${flash_file} > board.cfg || - die "Failed to read flash config file." - - cat ${sdram_file} >> board.cfg || - die "Failed to read SDRAM config file." -} - -tegra-bct_src_compile() { - local chip_family="-${TEGRA_BCT_CHIP_FAMILY}" - cbootimage -gbct $chip_family board.cfg board.bct || - die "Failed to generate BCT." -} - -tegra-bct_src_install() { - local sdram_file=${FILESDIR}/${TEGRA_BCT_SDRAM_CONFIG} - local flash_file=${FILESDIR}/${TEGRA_BCT_FLASH_CONFIG} - - insinto /firmware/bct - - doins "${sdram_file}" - doins "${flash_file}" - - if [ "$(basename ${sdram_file})" != "sdram.cfg" ]; then - dosym "$(basename ${sdram_file})" /firmware/bct/sdram.cfg - fi - - if [ "$(basename ${flash_file})" != "flash.cfg" ]; then - dosym "$(basename ${flash_file})" /firmware/bct/flash.cfg - fi - - doins board.cfg - doins board.bct -} - -EXPORT_FUNCTIONS src_configure src_compile src_install diff --git a/sdk_container/src/third_party/coreos-overlay/eclass/tests/appid.sh b/sdk_container/src/third_party/coreos-overlay/eclass/tests/appid.sh deleted file mode 100755 index fab7c00b7b..0000000000 --- a/sdk_container/src/third_party/coreos-overlay/eclass/tests/appid.sh +++ /dev/null @@ -1,50 +0,0 @@ -#!/bin/bash - -source tests-common.sh - -inherit appid - -valid_uuids=( - '{01234567-89AB-CDEF-0123-456789ABCDEF}' - '{11111111-1111-1111-1111-111111111111}' - '{DDDDDDDD-DDDD-DDDD-DDDD-DDDDDDDDDDDD}' - $(grep -hs doappid ../../../../{private-,}overlays/overlay-*/chromeos-base/chromeos-bsp-*/*.ebuild | \ - gawk '{print gensub(/"/, "", "g", $2)}') -) -invalid_uuids=( - '' - '01234567-89AB-CDEF-0123-4567-89ABCDEF0123' - ' {01234567-89AB-CDEF-0123-4567-89ABCDEF0123} ' - ' {01234567-89AB-CDEF-0123-4567-89ABCDEF0123}' - '{01234567-89AB-CDEF-0123-4567-89ABCDEF0123} ' - '{01234567-89AB-CDEF-0123-4567-89abcDEF0123}' - '{GGGGGGGG-GGGG-GGGG-GGGG-GGGG-GGGGGGGGGGGG}' -) - -tbegin "no args" -! (doappid) >&/dev/null -tend $? - -tbegin "too many args" -! (doappid "${valid_uuids[0]}" 1234) >&/dev/null -tend $? - -tbegin "invalid appids" -for uuid in "${invalid_uuids[@]}" ; do - if (doappid "${uuid}") >&/dev/null ; then - tend 1 "not caught: ${uuid}" - fi - rm -rf "${D}" -done -tend $? - -tbegin "valid appids" -for uuid in "${valid_uuids[@]}" ; do - if ! (doappid "${uuid}") ; then - tend 1 "not accepted: ${uuid}" - fi - rm -rf "${D}" -done -tend $? - -texit diff --git a/sdk_container/src/third_party/coreos-overlay/eclass/tests/tests-common.sh b/sdk_container/src/third_party/coreos-overlay/eclass/tests/tests-common.sh deleted file mode 100644 index 2f830cb010..0000000000 --- a/sdk_container/src/third_party/coreos-overlay/eclass/tests/tests-common.sh +++ /dev/null @@ -1 +0,0 @@ -source ../../../portage-stable/eclass/tests/tests-common.sh diff --git a/sdk_container/src/third_party/coreos-overlay/eclass/toolchain-funcs.eclass b/sdk_container/src/third_party/coreos-overlay/eclass/toolchain-funcs.eclass deleted file mode 100644 index 91260744a2..0000000000 --- a/sdk_container/src/third_party/coreos-overlay/eclass/toolchain-funcs.eclass +++ /dev/null @@ -1,787 +0,0 @@ -# Copyright 1999-2012 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/eclass/toolchain-funcs.eclass,v 1.120 2012/12/29 05:08:54 vapier Exp $ - -# @ECLASS: toolchain-funcs.eclass -# @MAINTAINER: -# Toolchain Ninjas -# @BLURB: functions to query common info about the toolchain -# @DESCRIPTION: -# The toolchain-funcs aims to provide a complete suite of functions -# for gleaning useful information about the toolchain and to simplify -# ugly things like cross-compiling and multilib. All of this is done -# in such a way that you can rely on the function always returning -# something sane. - -if [[ ${___ECLASS_ONCE_TOOLCHAIN_FUNCS} != "recur -_+^+_- spank" ]] ; then -___ECLASS_ONCE_TOOLCHAIN_FUNCS="recur -_+^+_- spank" - -inherit multilib binutils-funcs - -# tc-getPROG [tuple] -_tc-getPROG() { - local tuple=$1 - local v var vars=$2 - local prog=$3 - - var=${vars%% *} - for v in ${vars} ; do - if [[ -n ${!v} ]] ; then - export ${var}="${!v}" - echo "${!v}" - return 0 - fi - done - - local search= - [[ -n $4 ]] && search=$(type -p "$4-${prog}") - [[ -z ${search} && -n ${!tuple} ]] && search=$(type -p "${!tuple}-${prog}") - [[ -n ${search} ]] && prog=${search##*/} - - export ${var}=${prog} - echo "${!var}" -} -tc-getBUILD_PROG() { _tc-getPROG CBUILD "BUILD_$1 $1_FOR_BUILD HOST$1" "${@:2}"; } -tc-getPROG() { _tc-getPROG CHOST "$@"; } - -# @FUNCTION: tc-getAR -# @USAGE: [toolchain prefix] -# @RETURN: name of the archiver -tc-getAR() { tc-getPROG AR ar "$@"; } -# @FUNCTION: tc-getAS -# @USAGE: [toolchain prefix] -# @RETURN: name of the assembler -tc-getAS() { tc-getPROG AS as "$@"; } -# @FUNCTION: tc-getCC -# @USAGE: [toolchain prefix] -# @RETURN: name of the C compiler -tc-getCC() { tc-getPROG CC gcc "$@"; } -# @FUNCTION: tc-getCPP -# @USAGE: [toolchain prefix] -# @RETURN: name of the C preprocessor -tc-getCPP() { tc-getPROG CPP cpp "$@"; } -# @FUNCTION: tc-getCXX -# @USAGE: [toolchain prefix] -# @RETURN: name of the C++ compiler -tc-getCXX() { tc-getPROG CXX g++ "$@"; } -# @FUNCTION: tc-getLD -# @USAGE: [toolchain prefix] -# @RETURN: name of the linker -tc-getLD() { tc-getPROG LD ld "$@"; } -# @FUNCTION: tc-getSTRIP -# @USAGE: [toolchain prefix] -# @RETURN: name of the strip program -tc-getSTRIP() { tc-getPROG STRIP strip "$@"; } -# @FUNCTION: tc-getNM -# @USAGE: [toolchain prefix] -# @RETURN: name of the symbol/object thingy -tc-getNM() { tc-getPROG NM nm "$@"; } -# @FUNCTION: tc-getRANLIB -# @USAGE: [toolchain prefix] -# @RETURN: name of the archiver indexer -tc-getRANLIB() { tc-getPROG RANLIB ranlib "$@"; } -# @FUNCTION: tc-getOBJCOPY -# @USAGE: [toolchain prefix] -# @RETURN: name of the object copier -tc-getOBJCOPY() { tc-getPROG OBJCOPY objcopy "$@"; } -# @FUNCTION: tc-getF77 -# @USAGE: [toolchain prefix] -# @RETURN: name of the Fortran 77 compiler -tc-getF77() { tc-getPROG F77 gfortran "$@"; } -# @FUNCTION: tc-getFC -# @USAGE: [toolchain prefix] -# @RETURN: name of the Fortran 90 compiler -tc-getFC() { tc-getPROG FC gfortran "$@"; } -# @FUNCTION: tc-getGCJ -# @USAGE: [toolchain prefix] -# @RETURN: name of the java compiler -tc-getGCJ() { tc-getPROG GCJ gcj "$@"; } -# @FUNCTION: tc-getPKG_CONFIG -# @USAGE: [toolchain prefix] -# @RETURN: name of the pkg-config tool -tc-getPKG_CONFIG() { tc-getPROG PKG_CONFIG pkg-config "$@"; } -# @FUNCTION: tc-getRC -# @USAGE: [toolchain prefix] -# @RETURN: name of the Windows resource compiler -tc-getRC() { tc-getPROG RC windres "$@"; } -# @FUNCTION: tc-getDLLWRAP -# @USAGE: [toolchain prefix] -# @RETURN: name of the Windows dllwrap utility -tc-getDLLWRAP() { tc-getPROG DLLWRAP dllwrap "$@"; } - -# @FUNCTION: tc-getBUILD_AR -# @USAGE: [toolchain prefix] -# @RETURN: name of the archiver for building binaries to run on the build machine -tc-getBUILD_AR() { tc-getBUILD_PROG AR ar "$@"; } -# @FUNCTION: tc-getBUILD_AS -# @USAGE: [toolchain prefix] -# @RETURN: name of the assembler for building binaries to run on the build machine -tc-getBUILD_AS() { tc-getBUILD_PROG AS as "$@"; } -# @FUNCTION: tc-getBUILD_CC -# @USAGE: [toolchain prefix] -# @RETURN: name of the C compiler for building binaries to run on the build machine -tc-getBUILD_CC() { tc-getBUILD_PROG CC gcc "$@"; } -# @FUNCTION: tc-getBUILD_CPP -# @USAGE: [toolchain prefix] -# @RETURN: name of the C preprocessor for building binaries to run on the build machine -tc-getBUILD_CPP() { tc-getBUILD_PROG CPP cpp "$@"; } -# @FUNCTION: tc-getBUILD_CXX -# @USAGE: [toolchain prefix] -# @RETURN: name of the C++ compiler for building binaries to run on the build machine -tc-getBUILD_CXX() { tc-getBUILD_PROG CXX g++ "$@"; } -# @FUNCTION: tc-getBUILD_LD -# @USAGE: [toolchain prefix] -# @RETURN: name of the linker for building binaries to run on the build machine -tc-getBUILD_LD() { tc-getBUILD_PROG LD ld "$@"; } -# @FUNCTION: tc-getBUILD_STRIP -# @USAGE: [toolchain prefix] -# @RETURN: name of the strip program for building binaries to run on the build machine -tc-getBUILD_STRIP() { tc-getBUILD_PROG STRIP strip "$@"; } -# @FUNCTION: tc-getBUILD_NM -# @USAGE: [toolchain prefix] -# @RETURN: name of the symbol/object thingy for building binaries to run on the build machine -tc-getBUILD_NM() { tc-getBUILD_PROG NM nm "$@"; } -# @FUNCTION: tc-getBUILD_RANLIB -# @USAGE: [toolchain prefix] -# @RETURN: name of the archiver indexer for building binaries to run on the build machine -tc-getBUILD_RANLIB() { tc-getBUILD_PROG RANLIB ranlib "$@"; } -# @FUNCTION: tc-getBUILD_OBJCOPY -# @USAGE: [toolchain prefix] -# @RETURN: name of the object copier for building binaries to run on the build machine -tc-getBUILD_OBJCOPY() { tc-getBUILD_PROG OBJCOPY objcopy "$@"; } -# @FUNCTION: tc-getBUILD_PKG_CONFIG -# @USAGE: [toolchain prefix] -# @RETURN: name of the pkg-config tool for building binaries to run on the build machine -tc-getBUILD_PKG_CONFIG() { tc-getBUILD_PROG PKG_CONFIG pkg-config "$@"; } - -# @FUNCTION: tc-export -# @USAGE: -# @DESCRIPTION: -# Quick way to export a bunch of compiler vars at once. -tc-export() { - local var - for var in "$@" ; do - [[ $(type -t tc-get${var}) != "function" ]] && die "tc-export: invalid export variable '${var}'" - eval tc-get${var} > /dev/null - done -} - -# @FUNCTION: tc-is-cross-compiler -# @RETURN: Shell true if we are using a cross-compiler, shell false otherwise -tc-is-cross-compiler() { - return $([[ ${CBUILD:-${CHOST}} != ${CHOST} ]]) -} - -# @FUNCTION: tc-is-softfloat -# @DESCRIPTION: -# See if this toolchain is a softfloat based one. -# @CODE -# The possible return values: -# - only: the target is always softfloat (never had fpu) -# - yes: the target should support softfloat -# - softfp: (arm specific) the target should use hardfloat insns, but softfloat calling convention -# - no: the target doesn't support softfloat -# @CODE -# This allows us to react differently where packages accept -# softfloat flags in the case where support is optional, but -# rejects softfloat flags where the target always lacks an fpu. -tc-is-softfloat() { - local CTARGET=${CTARGET:-${CHOST}} - case ${CTARGET} in - bfin*|h8300*) - echo "only" ;; - *) - if [[ ${CTARGET//_/-} == *-softfloat-* ]] ; then - echo "yes" - elif [[ ${CTARGET//_/-} == *-softfp-* ]] ; then - echo "softfp" - else - echo "no" - fi - ;; - esac -} - -# @FUNCTION: tc-is-static-only -# @DESCRIPTION: -# Return shell true if the target does not support shared libs, shell false -# otherwise. -tc-is-static-only() { - local host=${CTARGET:-${CHOST}} - - # *MiNT doesn't have shared libraries, only platform so far - return $([[ ${host} == *-mint* ]]) -} - -# @FUNCTION: tc-export_build_env -# @USAGE: [compiler variables] -# @DESCRIPTION: -# Export common build related compiler settings. -tc-export_build_env() { - tc-export "$@" - : ${BUILD_CFLAGS:=-O1 -pipe} - : ${BUILD_CXXFLAGS:=-O1 -pipe} - : ${BUILD_CPPFLAGS:=} - : ${BUILD_LDFLAGS:=} - export BUILD_{C,CXX,CPP,LD}FLAGS -} - -# @FUNCTION: tc-env_build -# @USAGE: [command args] -# @INTERNAL -# @DESCRIPTION: -# Setup the compile environment to the build tools and then execute the -# specified command. We use tc-getBUILD_XX here so that we work with -# all of the semi-[non-]standard env vars like $BUILD_CC which often -# the target build system does not check. -tc-env_build() { - tc-export_build_env - CFLAGS=${BUILD_CFLAGS} \ - CXXFLAGS=${BUILD_CXXFLAGS} \ - CPPFLAGS=${BUILD_CPPFLAGS} \ - LDFLAGS=${BUILD_LDFLAGS} \ - AR=$(tc-getBUILD_AR) \ - AS=$(tc-getBUILD_AS) \ - CC=$(tc-getBUILD_CC) \ - CPP=$(tc-getBUILD_CPP) \ - CXX=$(tc-getBUILD_CXX) \ - LD=$(tc-getBUILD_LD) \ - NM=$(tc-getBUILD_NM) \ - PKG_CONFIG=$(tc-getBUILD_PKG_CONFIG) \ - RANLIB=$(tc-getBUILD_RANLIB) \ - "$@" -} - -# @FUNCTION: econf_build -# @USAGE: [econf flags] -# @DESCRIPTION: -# Sometimes we need to locally build up some tools to run on CBUILD because -# the package has helper utils which are compiled+executed when compiling. -# This won't work when cross-compiling as the CHOST is set to a target which -# we cannot natively execute. -# -# For example, the python package will build up a local python binary using -# a portable build system (configure+make), but then use that binary to run -# local python scripts to build up other components of the overall python. -# We cannot rely on the python binary in $PATH as that often times will be -# a different version, or not even installed in the first place. Instead, -# we compile the code in a different directory to run on CBUILD, and then -# use that binary when compiling the main package to run on CHOST. -# -# For example, with newer EAPIs, you'd do something like: -# @CODE -# src_configure() { -# ECONF_SOURCE=${S} -# if tc-is-cross-compiler ; then -# mkdir "${WORKDIR}"/${CBUILD} -# pushd "${WORKDIR}"/${CBUILD} >/dev/null -# econf_build --disable-some-unused-stuff -# popd >/dev/null -# fi -# ... normal build paths ... -# } -# src_compile() { -# if tc-is-cross-compiler ; then -# pushd "${WORKDIR}"/${CBUILD} >/dev/null -# emake one-or-two-build-tools -# ln/mv build-tools to normal build paths in ${S}/ -# popd >/dev/null -# fi -# ... normal build paths ... -# } -# @CODE -econf_build() { - tc-env_build econf --build=${CBUILD:-${CHOST}} "$@" -} - -# @FUNCTION: tc-has-openmp -# @USAGE: [toolchain prefix] -# @DESCRIPTION: -# See if the toolchain supports OpenMP. -tc-has-openmp() { - local base="${T}/test-tc-openmp" - cat <<-EOF > "${base}.c" - #include - int main() { - int nthreads, tid, ret = 0; - #pragma omp parallel private(nthreads, tid) - { - tid = omp_get_thread_num(); - nthreads = omp_get_num_threads(); ret += tid + nthreads; - } - return ret; - } - EOF - $(tc-getCC "$@") -fopenmp "${base}.c" -o "${base}" >&/dev/null - local ret=$? - rm -f "${base}"* - return ${ret} -} - -# @FUNCTION: tc-has-tls -# @USAGE: [-s|-c|-l] [toolchain prefix] -# @DESCRIPTION: -# See if the toolchain supports thread local storage (TLS). Use -s to test the -# compiler, -c to also test the assembler, and -l to also test the C library -# (the default). -tc-has-tls() { - local base="${T}/test-tc-tls" - cat <<-EOF > "${base}.c" - int foo(int *i) { - static __thread int j = 0; - return *i ? j : *i; - } - EOF - local flags - case $1 in - -s) flags="-S";; - -c) flags="-c";; - -l) ;; - -*) die "Usage: tc-has-tls [-c|-l] [toolchain prefix]";; - esac - : ${flags:=-fPIC -shared -Wl,-z,defs} - [[ $1 == -* ]] && shift - $(tc-getCC "$@") ${flags} "${base}.c" -o "${base}" >&/dev/null - local ret=$? - rm -f "${base}"* - return ${ret} -} - - -# Parse information from CBUILD/CHOST/CTARGET rather than -# use external variables from the profile. -tc-ninja_magic_to_arch() { -ninj() { [[ ${type} == "kern" ]] && echo $1 || echo $2 ; } - - local type=$1 - local host=$2 - [[ -z ${host} ]] && host=${CTARGET:-${CHOST}} - - local KV=${KV:-${KV_FULL}} - [[ ${type} == "kern" ]] && [[ -z ${KV} ]] && \ - ewarn "QA: Kernel version could not be determined, please inherit kernel-2 or linux-info" - - case ${host} in - aarch64*) ninj arm64 arm;; - alpha*) echo alpha;; - arm*) echo arm;; - avr*) ninj avr32 avr;; - bfin*) ninj blackfin bfin;; - cris*) echo cris;; - hppa*) ninj parisc hppa;; - i?86*) - # Starting with linux-2.6.24, the 'x86_64' and 'i386' - # trees have been unified into 'x86'. - # FreeBSD still uses i386 - if [[ ${type} == "kern" ]] && [[ $(KV_to_int ${KV}) -lt $(KV_to_int 2.6.24) || ${host} == *freebsd* ]] ; then - echo i386 - else - echo x86 - fi - ;; - ia64*) echo ia64;; - m68*) echo m68k;; - mips*) echo mips;; - nios2*) echo nios2;; - nios*) echo nios;; - powerpc*) - # Starting with linux-2.6.15, the 'ppc' and 'ppc64' trees - # have been unified into simply 'powerpc', but until 2.6.16, - # ppc32 is still using ARCH="ppc" as default - if [[ ${type} == "kern" ]] && [[ $(KV_to_int ${KV}) -ge $(KV_to_int 2.6.16) ]] ; then - echo powerpc - elif [[ ${type} == "kern" ]] && [[ $(KV_to_int ${KV}) -eq $(KV_to_int 2.6.15) ]] ; then - if [[ ${host} == powerpc64* ]] || [[ ${PROFILE_ARCH} == "ppc64" ]] ; then - echo powerpc - else - echo ppc - fi - elif [[ ${host} == powerpc64* ]] ; then - echo ppc64 - elif [[ ${PROFILE_ARCH} == "ppc64" ]] ; then - ninj ppc64 ppc - else - echo ppc - fi - ;; - s390*) echo s390;; - sh64*) ninj sh64 sh;; - sh*) echo sh;; - sparc64*) ninj sparc64 sparc;; - sparc*) [[ ${PROFILE_ARCH} == "sparc64" ]] \ - && ninj sparc64 sparc \ - || echo sparc - ;; - vax*) echo vax;; - x86_64*freebsd*) echo amd64;; - x86_64*) - # Starting with linux-2.6.24, the 'x86_64' and 'i386' - # trees have been unified into 'x86'. - if [[ ${type} == "kern" ]] && [[ $(KV_to_int ${KV}) -ge $(KV_to_int 2.6.24) ]] ; then - echo x86 - else - ninj x86_64 amd64 - fi - ;; - - # since our usage of tc-arch is largely concerned with - # normalizing inputs for testing ${CTARGET}, let's filter - # other cross targets (mingw and such) into the unknown. - *) echo unknown;; - esac -} -# @FUNCTION: tc-arch-kernel -# @USAGE: [toolchain prefix] -# @RETURN: name of the kernel arch according to the compiler target -tc-arch-kernel() { - tc-ninja_magic_to_arch kern "$@" -} -# @FUNCTION: tc-arch -# @USAGE: [toolchain prefix] -# @RETURN: name of the portage arch according to the compiler target -tc-arch() { - tc-ninja_magic_to_arch portage "$@" -} - -tc-endian() { - local host=$1 - [[ -z ${host} ]] && host=${CTARGET:-${CHOST}} - host=${host%%-*} - - case ${host} in - aarch64*be) echo big;; - aarch64) echo little;; - alpha*) echo big;; - arm*b*) echo big;; - arm*) echo little;; - cris*) echo little;; - hppa*) echo big;; - i?86*) echo little;; - ia64*) echo little;; - m68*) echo big;; - mips*l*) echo little;; - mips*) echo big;; - powerpc*) echo big;; - s390*) echo big;; - sh*b*) echo big;; - sh*) echo little;; - sparc*) echo big;; - x86_64*) echo little;; - *) echo wtf;; - esac -} - -# Internal func. The first argument is the version info to expand. -# Query the preprocessor to improve compatibility across different -# compilers rather than maintaining a --version flag matrix. #335943 -_gcc_fullversion() { - local ver="$1"; shift - set -- `$(tc-getCPP "$@") -E -P - <<<"__GNUC__ __GNUC_MINOR__ __GNUC_PATCHLEVEL__"` - eval echo "$ver" -} - -# @FUNCTION: gcc-fullversion -# @RETURN: compiler version (major.minor.micro: [3.4.6]) -gcc-fullversion() { - _gcc_fullversion '$1.$2.$3' "$@" -} -# @FUNCTION: gcc-version -# @RETURN: compiler version (major.minor: [3.4].6) -gcc-version() { - _gcc_fullversion '$1.$2' "$@" -} -# @FUNCTION: gcc-major-version -# @RETURN: major compiler version (major: [3].4.6) -gcc-major-version() { - _gcc_fullversion '$1' "$@" -} -# @FUNCTION: gcc-minor-version -# @RETURN: minor compiler version (minor: 3.[4].6) -gcc-minor-version() { - _gcc_fullversion '$2' "$@" -} -# @FUNCTION: gcc-micro-version -# @RETURN: micro compiler version (micro: 3.4.[6]) -gcc-micro-version() { - _gcc_fullversion '$3' "$@" -} - -# Returns the installation directory - internal toolchain -# function for use by _gcc-specs-exists (for flag-o-matic). -_gcc-install-dir() { - echo "$(LC_ALL=C $(tc-getCC) -print-search-dirs 2> /dev/null |\ - awk '$1=="install:" {print $2}')" -} -# Returns true if the indicated specs file exists - internal toolchain -# function for use by flag-o-matic. -_gcc-specs-exists() { - [[ -f $(_gcc-install-dir)/$1 ]] -} - -# Returns requested gcc specs directive unprocessed - for used by -# gcc-specs-directive() -# Note; later specs normally overwrite earlier ones; however if a later -# spec starts with '+' then it appends. -# gcc -dumpspecs is parsed first, followed by files listed by "gcc -v" -# as "Reading ", in order. Strictly speaking, if there's a -# $(gcc_install_dir)/specs, the built-in specs aren't read, however by -# the same token anything from 'gcc -dumpspecs' is overridden by -# the contents of $(gcc_install_dir)/specs so the result is the -# same either way. -_gcc-specs-directive_raw() { - local cc=$(tc-getCC) - local specfiles=$(LC_ALL=C ${cc} -v 2>&1 | awk '$1=="Reading" {print $NF}') - ${cc} -dumpspecs 2> /dev/null | cat - ${specfiles} | awk -v directive=$1 \ -'BEGIN { pspec=""; spec=""; outside=1 } -$1=="*"directive":" { pspec=spec; spec=""; outside=0; next } - outside || NF==0 || ( substr($1,1,1)=="*" && substr($1,length($1),1)==":" ) { outside=1; next } - spec=="" && substr($0,1,1)=="+" { spec=pspec " " substr($0,2); next } - { spec=spec $0 } -END { print spec }' - return 0 -} - -# Return the requested gcc specs directive, with all included -# specs expanded. -# Note, it does not check for inclusion loops, which cause it -# to never finish - but such loops are invalid for gcc and we're -# assuming gcc is operational. -gcc-specs-directive() { - local directive subdname subdirective - directive="$(_gcc-specs-directive_raw $1)" - while [[ ${directive} == *%\(*\)* ]]; do - subdname=${directive/*%\(} - subdname=${subdname/\)*} - subdirective="$(_gcc-specs-directive_raw ${subdname})" - directive="${directive//\%(${subdname})/${subdirective}}" - done - echo "${directive}" - return 0 -} - -# Returns true if gcc sets relro -gcc-specs-relro() { - local directive - directive=$(gcc-specs-directive link_command) - return $([[ "${directive/\{!norelro:}" != "${directive}" ]]) -} -# Returns true if gcc sets now -gcc-specs-now() { - local directive - directive=$(gcc-specs-directive link_command) - return $([[ "${directive/\{!nonow:}" != "${directive}" ]]) -} -# Returns true if gcc builds PIEs -gcc-specs-pie() { - local directive - directive=$(gcc-specs-directive cc1) - return $([[ "${directive/\{!nopie:}" != "${directive}" ]]) -} -# Returns true if gcc builds with the stack protector -gcc-specs-ssp() { - local directive - directive=$(gcc-specs-directive cc1) - return $([[ "${directive/\{!fno-stack-protector:}" != "${directive}" ]]) -} -# Returns true if gcc upgrades fstack-protector to fstack-protector-all -gcc-specs-ssp-to-all() { - local directive - directive=$(gcc-specs-directive cc1) - return $([[ "${directive/\{!fno-stack-protector-all:}" != "${directive}" ]]) -} -# Returns true if gcc builds with fno-strict-overflow -gcc-specs-nostrict() { - local directive - directive=$(gcc-specs-directive cc1) - return $([[ "${directive/\{!fstrict-overflow:}" != "${directive}" ]]) -} - - -# @FUNCTION: gen_usr_ldscript -# @USAGE: [-a] -# @DESCRIPTION: -# This function generate linker scripts in /usr/lib for dynamic -# libs in /lib. This is to fix linking problems when you have -# the .so in /lib, and the .a in /usr/lib. What happens is that -# in some cases when linking dynamic, the .a in /usr/lib is used -# instead of the .so in /lib due to gcc/libtool tweaking ld's -# library search path. This causes many builds to fail. -# See bug #4411 for more info. -# -# Note that you should in general use the unversioned name of -# the library (libfoo.so), as ldconfig should usually update it -# correctly to point to the latest version of the library present. -gen_usr_ldscript() { - local lib libdir=$(get_libdir) output_format="" auto=false suffix=$(get_libname) - [[ -z ${ED+set} ]] && local ED=${D%/}${EPREFIX}/ - - tc-is-static-only && return - - # Eventually we'd like to get rid of this func completely #417451 - case ${CTARGET:-${CHOST}} in - *-darwin*) ;; - *linux*|*-freebsd*|*-openbsd*|*-netbsd*) - use prefix && return 0 ;; - *) return 0 ;; - esac - - # Just make sure it exists - dodir /usr/${libdir} - - if [[ $1 == "-a" ]] ; then - auto=true - shift - dodir /${libdir} - fi - - # OUTPUT_FORMAT gives hints to the linker as to what binary format - # is referenced ... makes multilib saner - output_format=$($(tc-getCC) ${CFLAGS} ${LDFLAGS} -Wl,--verbose 2>&1 | sed -n 's/^OUTPUT_FORMAT("\([^"]*\)",.*/\1/p') - [[ -n ${output_format} ]] && output_format="OUTPUT_FORMAT ( ${output_format} )" - - for lib in "$@" ; do - local tlib - if ${auto} ; then - lib="lib${lib}${suffix}" - else - # Ensure /lib/${lib} exists to avoid dangling scripts/symlinks. - # This especially is for AIX where $(get_libname) can return ".a", - # so /lib/${lib} might be moved to /usr/lib/${lib} (by accident). - [[ -r ${ED}/${libdir}/${lib} ]] || continue - #TODO: better die here? - fi - - case ${CTARGET:-${CHOST}} in - *-darwin*) - if ${auto} ; then - tlib=$(scanmacho -qF'%S#F' "${ED}"/usr/${libdir}/${lib}) - else - tlib=$(scanmacho -qF'%S#F' "${ED}"/${libdir}/${lib}) - fi - [[ -z ${tlib} ]] && die "unable to read install_name from ${lib}" - tlib=${tlib##*/} - - if ${auto} ; then - mv "${ED}"/usr/${libdir}/${lib%${suffix}}.*${suffix#.} "${ED}"/${libdir}/ || die - # some install_names are funky: they encode a version - if [[ ${tlib} != ${lib%${suffix}}.*${suffix#.} ]] ; then - mv "${ED}"/usr/${libdir}/${tlib%${suffix}}.*${suffix#.} "${ED}"/${libdir}/ || die - fi - rm -f "${ED}"/${libdir}/${lib} - fi - - # Mach-O files have an id, which is like a soname, it tells how - # another object linking against this lib should reference it. - # Since we moved the lib from usr/lib into lib this reference is - # wrong. Hence, we update it here. We don't configure with - # libdir=/lib because that messes up libtool files. - # Make sure we don't lose the specific version, so just modify the - # existing install_name - if [[ ! -w "${ED}/${libdir}/${tlib}" ]] ; then - chmod u+w "${ED}${libdir}/${tlib}" # needed to write to it - local nowrite=yes - fi - install_name_tool \ - -id "${EPREFIX}"/${libdir}/${tlib} \ - "${ED}"/${libdir}/${tlib} || die "install_name_tool failed" - [[ -n ${nowrite} ]] && chmod u-w "${ED}${libdir}/${tlib}" - # Now as we don't use GNU binutils and our linker doesn't - # understand linker scripts, just create a symlink. - pushd "${ED}/usr/${libdir}" > /dev/null - ln -snf "../../${libdir}/${tlib}" "${lib}" - popd > /dev/null - ;; - *) - if ${auto} ; then - tlib=$(scanelf -qF'%S#F' "${ED}"/usr/${libdir}/${lib}) - [[ -z ${tlib} ]] && die "unable to read SONAME from ${lib}" - mv "${ED}"/usr/${libdir}/${lib}* "${ED}"/${libdir}/ || die - # some SONAMEs are funky: they encode a version before the .so - if [[ ${tlib} != ${lib}* ]] ; then - mv "${ED}"/usr/${libdir}/${tlib}* "${ED}"/${libdir}/ || die - fi - rm -f "${ED}"/${libdir}/${lib} - else - tlib=${lib} - fi - cat > "${ED}/usr/${libdir}/${lib}" <<-END_LDSCRIPT - /* GNU ld script - Since Gentoo has critical dynamic libraries in /lib, and the static versions - in /usr/lib, we need to have a "fake" dynamic lib in /usr/lib, otherwise we - run into linking problems. This "fake" dynamic lib is a linker script that - redirects the linker to the real lib. And yes, this works in the cross- - compiling scenario as the sysroot-ed linker will prepend the real path. - - See bug http://bugs.gentoo.org/4411 for more info. - */ - ${output_format} - GROUP ( ${EPREFIX}/${libdir}/${tlib} ) - END_LDSCRIPT - ;; - esac - fperms a+x "/usr/${libdir}/${lib}" || die "could not change perms on ${lib}" - done -} - -# -# ChromiumOS extensions below here. -# - -# Returns true if gcc builds PIEs -# For ARM, readelf -h | grep Type always has REL instead of EXEC. -# That is why we have to read the flags one by one and check them instead -# of test-compiling a small program. -gcc-pie() { - for flag in $(echo "void f(){char a[100];}" | \ - ${CTARGET}-gcc -v -xc -c -o /dev/null - 2>&1 | \ - grep cc1 | \ - tr " " "\n" | \ - tac) - do - if [[ $flag == "-fPIE" || $flag == "-fPIC" ]] - then - return 0 - elif [[ $flag == "-fno-PIE" || $flag == "-fno-PIC" ]] - then - return 1 - fi - done - return 1 -} - -# Returns true if gcc builds with the stack protector -gcc-ssp() { - local obj=$(mktemp) - echo "void f(){char a[100];}" | ${CTARGET}-gcc -xc -c -o ${obj} - - return $(${CTARGET}-readelf -sW ${obj} | grep -q stack_chk_fail) -} - -# Sets up environment variables required to build with Clang -# This should be replaced with a sysroot wrapper ala GCC if/when -# we get serious about building with Clang. -clang-setup-env() { - use clang || return 0 - case ${ARCH} in - amd64|x86) - export CC="clang" CXX="clang++" - - local clang_flags=( - --sysroot="${SYSROOT}" - -B$(get_binutils_path_gold) - $(usex x86 -m32 '') - ) - append-flags "${clang_flags[@]}" - - # Some boards use optimizations (e.g. -mfpmath=sse) that - # clang does not support. - append-flags -Qunused-arguments - ;; - *) die "Clang is not yet supported for ${ARCH}" - esac - - if use asan; then - append-flags -fsanitize=address -fno-omit-frame-pointer - fi -} - -fi diff --git a/sdk_container/src/third_party/coreos-overlay/eclass/toolchain_crosstool.eclass b/sdk_container/src/third_party/coreos-overlay/eclass/toolchain_crosstool.eclass deleted file mode 100644 index 9d4dea6899..0000000000 --- a/sdk_container/src/third_party/coreos-overlay/eclass/toolchain_crosstool.eclass +++ /dev/null @@ -1,2466 +0,0 @@ -# Copyright 1999-2008 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/eclass/toolchain.eclass,v 1.434 2010/07/05 22:25:09 vapier Exp $ -# -# Maintainer: Toolchain Ninjas - -HOMEPAGE="http://gcc.gnu.org/" -LICENSE="GPL-2 LGPL-2.1" -RESTRICT="mirror strip" # cross-compilers need controlled stripping - -#---->> eclass stuff <<---- -inherit eutils versionator libtool toolchain-funcs flag-o-matic gnuconfig multilib fixheadtails - -EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_test pkg_preinst src_install pkg_postinst pkg_prerm pkg_postrm -DESCRIPTION="Based on the ${ECLASS} eclass" - -FEATURES=${FEATURES/multilib-strict/} - -toolchain_crosstool_pkg_setup() { - gcc_pkg_setup -} -toolchain_crosstool_src_unpack() { - gcc_src_unpack -} -toolchain_crosstool_src_compile() { - gcc_src_compile -} -toolchain_crosstool_src_test() { - gcc_src_test -} -toolchain_crosstool_pkg_preinst() { - ${ETYPE}_pkg_preinst -} -toolchain_crosstool_src_install() { - ${ETYPE}_src_install -} -toolchain_crosstool_pkg_postinst() { - ${ETYPE}_pkg_postinst -} -toolchain_crosstool_pkg_prerm() { - ${ETYPE}_pkg_prerm -} -toolchain_crosstool_pkg_postrm() { - ${ETYPE}_pkg_postrm -} -#----<< eclass stuff >>---- - - -#---->> globals <<---- -export CTARGET=${CTARGET:-${CHOST}} -if [[ ${CTARGET} = ${CHOST} ]] ; then - if [[ ${CATEGORY/cross-} != ${CATEGORY} ]] ; then - export CTARGET=${CATEGORY/cross-} - fi -fi -is_crosscompile() { - [[ ${CHOST} != ${CTARGET} ]] -} - -tc_version_is_at_least() { version_is_at_least "$1" "${2:-${GCC_PV}}" ; } - - -GCC_PV=${TOOLCHAIN_GCC_PV:-${PV}} -GCC_PVR=${GCC_PV} -[[ ${PR} != "r0" ]] && GCC_PVR=${GCC_PVR}-${PR} -GCC_RELEASE_VER=$(get_version_component_range 1-3 ${GCC_PV}) -GCC_BRANCH_VER=$(get_version_component_range 1-2 ${GCC_PV}) -GCCMAJOR=$(get_version_component_range 1 ${GCC_PV}) -GCCMINOR=$(get_version_component_range 2 ${GCC_PV}) -GCCMICRO=$(get_version_component_range 3 ${GCC_PV}) -[[ ${BRANCH_UPDATE-notset} == "notset" ]] && BRANCH_UPDATE=$(get_version_component_range 4 ${GCC_PV}) - -# According to gcc/c-cppbuiltin.c, GCC_CONFIG_VER MUST match this regex. -# ([^0-9]*-)?[0-9]+[.][0-9]+([.][0-9]+)?([- ].*)? -GCC_CONFIG_VER=${GCC_CONFIG_VER:-$(replace_version_separator 3 '-' ${GCC_PV})} - -# Pre-release support -if [[ ${GCC_PV} != ${GCC_PV/_pre/-} ]] ; then - PRERELEASE=${GCC_PV/_pre/-} -fi -# make _alpha and _beta ebuilds automatically use a snapshot -if [[ ${GCC_PV} == *_alpha* ]] ; then - SNAPSHOT=${GCC_BRANCH_VER}-${GCC_PV##*_alpha} -elif [[ ${GCC_PV} == *_beta* ]] ; then - SNAPSHOT=${GCC_BRANCH_VER}-${GCC_PV##*_beta} -elif [[ ${GCC_PV} == *_rc* ]] ; then - SNAPSHOT=${GCC_PV%_rc*}-RC-${GCC_PV##*_rc} -fi -export GCC_FILESDIR=${GCC_FILESDIR:-${FILESDIR}} - -if [[ ${ETYPE} == "gcc-library" ]] ; then - GCC_VAR_TYPE=${GCC_VAR_TYPE:-non-versioned} - GCC_LIB_COMPAT_ONLY=${GCC_LIB_COMPAT_ONLY:-true} - GCC_TARGET_NO_MULTILIB=${GCC_TARGET_NO_MULTILIB:-true} -else - GCC_VAR_TYPE=${GCC_VAR_TYPE:-versioned} - GCC_LIB_COMPAT_ONLY="false" - GCC_TARGET_NO_MULTILIB=${GCC_TARGET_NO_MULTILIB:-false} -fi - -PREFIX=${TOOLCHAIN_PREFIX:-/usr} - -if [[ ${GCC_VAR_TYPE} == "versioned" ]] ; then - if tc_version_is_at_least 3.4.0 ; then - LIBPATH=${TOOLCHAIN_LIBPATH:-${PREFIX}/lib/gcc/${CTARGET}/${GCC_CONFIG_VER}} - else - LIBPATH=${TOOLCHAIN_LIBPATH:-${PREFIX}/lib/gcc-lib/${CTARGET}/${GCC_CONFIG_VER}} - fi - INCLUDEPATH=${TOOLCHAIN_INCLUDEPATH:-${LIBPATH}/include} - if is_crosscompile ; then - BINPATH=${TOOLCHAIN_BINPATH:-${PREFIX}/${CHOST}/${CTARGET}/gcc-bin/${GCC_CONFIG_VER}} - else - BINPATH=${TOOLCHAIN_BINPATH:-${PREFIX}/${CTARGET}/gcc-bin/${GCC_CONFIG_VER}} - fi - DATAPATH=${TOOLCHAIN_DATAPATH:-${PREFIX}/share/gcc-data/${CTARGET}/${GCC_CONFIG_VER}} - # Dont install in /usr/include/g++-v3/, but in gcc internal directory. - # We will handle /usr/include/g++-v3/ with gcc-config ... - STDCXX_INCDIR=${TOOLCHAIN_STDCXX_INCDIR:-${LIBPATH}/include/g++-v${GCC_BRANCH_VER/\.*/}} -elif [[ ${GCC_VAR_TYPE} == "non-versioned" ]] ; then - # using non-versioned directories to install gcc, like what is currently - # done for ppc64 and 3.3.3_pre, is a BAD IDEA. DO NOT do it!! However... - # setting up variables for non-versioned directories might be useful for - # specific gcc targets, like libffi. Note that we dont override the value - # returned by get_libdir here. - LIBPATH=${TOOLCHAIN_LIBPATH:-${PREFIX}/$(get_libdir)} - INCLUDEPATH=${TOOLCHAIN_INCLUDEPATH:-${PREFIX}/include} - BINPATH=${TOOLCHAIN_BINPATH:-${PREFIX}/bin} - DATAPATH=${TOOLCHAIN_DATAPATH:-${PREFIX}/share} - STDCXX_INCDIR=${TOOLCHAIN_STDCXX_INCDIR:-${PREFIX}/include/g++-v3} -fi - -#----<< globals >>---- - - -#---->> SLOT+IUSE logic <<---- -if [[ ${ETYPE} == "gcc-library" ]] ; then - IUSE="nls build test" - SLOT="${CTARGET}-${SO_VERSION_SLOT:-5}" -else - IUSE="multislot nptl test" - - if [[ ${PN} != "kgcc64" && ${PN} != gcc-* ]] ; then - IUSE="${IUSE} altivec build fortran nls nocxx" - [[ -n ${PIE_VER} ]] && IUSE="${IUSE} nopie" - [[ -n ${PP_VER} ]] && IUSE="${IUSE} nossp" - [[ -n ${SPECS_VER} ]] && IUSE="${IUSE} nossp" - [[ -n ${HTB_VER} ]] && IUSE="${IUSE} boundschecking" - [[ -n ${D_VER} ]] && IUSE="${IUSE} d" - - if tc_version_is_at_least 3 ; then - IUSE="${IUSE} bootstrap doc gcj gtk hardened libffi multilib objc vanilla" - - # gcc-{nios2,bfin} don't accept these - if [[ ${PN} == "gcc" ]] ; then - IUSE="${IUSE} n32 n64" - fi - - tc_version_is_at_least "4.0" && IUSE="${IUSE} objc-gc mudflap" - tc_version_is_at_least "4.1" && IUSE="${IUSE} objc++" - tc_version_is_at_least "4.2" && IUSE="${IUSE} openmp" - tc_version_is_at_least "4.3" && IUSE="${IUSE} fixed-point" - if tc_version_is_at_least "4.4" ; then - IUSE="${IUSE} graphite" - [[ -n ${SPECS_VER} ]] && IUSE="${IUSE} nossp" - fi - tc_version_is_at_least "4.5" && IUSE="${IUSE} lto" - fi - fi - - # Support upgrade paths here or people get pissed - if use multislot ; then - SLOT="${CTARGET}-${GCC_CONFIG_VER}" - elif is_crosscompile; then - SLOT="${CTARGET}-${GCC_BRANCH_VER}" - else - SLOT="${GCC_BRANCH_VER}" - fi -fi -#----<< SLOT+IUSE logic >>---- - - -#---->> S + SRC_URI essentials <<---- - -# This function sets the source directory depending on whether we're using -# a prerelease, snapshot, or release tarball. To use it, just set S with: -# -# S="$(gcc_get_s_dir)" -# -# Travis Tilley (03 Sep 2004) -# -gcc_get_s_dir() { - local GCC_S - if [[ -n ${PRERELEASE} ]] ; then - GCC_S=${WORKDIR}/gcc-${PRERELEASE} - elif [[ -n ${SNAPSHOT} ]] ; then - GCC_S=${WORKDIR}/gcc-${SNAPSHOT} - else - GCC_S=${WORKDIR}/gcc-${GCC_RELEASE_VER} - fi - echo "${GCC_S}" -} - -# This function handles the basics of setting the SRC_URI for a gcc ebuild. -# To use, set SRC_URI with: -# -# SRC_URI="$(get_gcc_src_uri)" -# -# Other than the variables normally set by portage, this function's behavior -# can be altered by setting the following: -# -# SNAPSHOT -# If set, this variable signals that we should be using a snapshot -# of gcc from ftp://sources.redhat.com/pub/gcc/snapshots/. It is -# expected to be in the format "YYYY-MM-DD". Note that if the ebuild -# has a _pre suffix, this variable is ignored and the prerelease -# tarball is used instead. -# -# BRANCH_UPDATE -# If set, this variable signals that we should be using the main -# release tarball (determined by ebuild version) and applying a -# CVS branch update patch against it. The location of this branch -# update patch is assumed to be in ${GENTOO_TOOLCHAIN_BASE_URI}. -# Just like with SNAPSHOT, this variable is ignored if the ebuild -# has a _pre suffix. -# -# PATCH_VER -# PATCH_GCC_VER -# This should be set to the version of the gentoo patch tarball. -# The resulting filename of this tarball will be: -# gcc-${PATCH_GCC_VER:-${GCC_RELEASE_VER}}-patches-${PATCH_VER}.tar.bz2 -# -# PIE_VER -# PIE_GCC_VER -# obsoleted: PIE_CORE -# These variables control patching in various updates for the logic -# controlling Position Independant Executables. PIE_VER is expected -# to be the version of this patch, PIE_GCC_VER the gcc version of -# the patch, and PIE_CORE (obsoleted) the actual filename of the patch. -# An example: -# PIE_VER="8.7.6.5" -# PIE_GCC_VER="3.4.0" -# The resulting filename of this tarball will be: -# gcc-${PIE_GCC_VER:-${GCC_RELEASE_VER}}-piepatches-v${PIE_VER}.tar.bz2 -# old syntax (do not define PIE_CORE anymore): -# PIE_CORE="gcc-3.4.0-piepatches-v${PIE_VER}.tar.bz2" -# -# SPECS_VER -# SPECS_GCC_VER -# This is for the minispecs files included in the hardened gcc-4.x -# The specs files for hardenedno*, vanilla and for building the "specs" file. -# SPECS_VER is expected to be the version of this patch, SPECS_GCC_VER -# the gcc version of the patch. -# An example: -# SPECS_VER="8.7.6.5" -# SPECS_GCC_VER="3.4.0" -# The resulting filename of this tarball will be: -# gcc-${SPECS_GCC_VER:-${GCC_RELEASE_VER}}-specs-${SPECS_VER}.tar.bz2 -# -# PP_VER -# PP_GCC_VER -# obsoleted: PP_FVER -# These variables control patching in stack smashing protection -# support. They both control the version of ProPolice to download. -# -# PP_VER / PP_GCC_VER -# Used to roll our own custom tarballs of ssp. -# PP_FVER / PP_VER -# Used for mirroring ssp straight from IBM. -# PP_VER sets the version of the directory in which to find the -# patch, and PP_FVER sets the version of the patch itself. For -# example: -# PP_VER="3_4" -# PP_FVER="${PP_VER//_/.}-2" -# would download gcc3_4/protector-3.4-2.tar.gz -# -# HTB_VER -# HTB_GCC_VER -# These variables control whether or not an ebuild supports Herman -# ten Brugge's bounds-checking patches. If you want to use a patch -# for an older gcc version with a new gcc, make sure you set -# HTB_GCC_VER to that version of gcc. -# -# MAN_VER -# The version of gcc for which we will download manpages. This will -# default to ${GCC_RELEASE_VER}, but we may not want to pre-generate man pages -# for prerelease test ebuilds for example. This allows you to -# continue using pre-generated manpages from the last stable release. -# If set to "none", this will prevent the downloading of manpages, -# which is useful for individual library targets. -# -gentoo_urls() { - echo http://commondatastorage.googleapis.com/chromeos-localmirror/distfiles/$1 -} - -get_gcc_src_uri() { - export PATCH_GCC_VER=${PATCH_GCC_VER:-${GCC_RELEASE_VER}} - export UCLIBC_GCC_VER=${UCLIBC_GCC_VER:-${PATCH_GCC_VER}} - export PIE_GCC_VER=${PIE_GCC_VER:-${GCC_RELEASE_VER}} - export PP_GCC_VER=${PP_GCC_VER:-${GCC_RELEASE_VER}} - export HTB_GCC_VER=${HTB_GCC_VER:-${GCC_RELEASE_VER}} - export SPECS_GCC_VER=${SPECS_GCC_VER:-${GCC_RELEASE_VER}} - - # Set where to download gcc itself depending on whether we're using a - # prerelease, snapshot, or release tarball. - # TODO: Add this back in the future to select between snapshot and - # pre-release. -### if [[ -n ${PRERELEASE} ]] ; then -### GCC_SRC_URI="ftp://gcc.gnu.org/pub/gcc/prerelease-${PRERELEASE}/gcc-${PRERELEASE}.tar.bz2" -### elif [[ -n ${SNAPSHOT} ]] ; then -### GCC_SRC_URI="ftp://sources.redhat.com/pub/gcc/snapshots/${SNAPSHOT}/gcc-${SNAPSHOT}.tar.bz2" -### else -### GCC_SRC_URI="mirror://gnu/gcc/gcc-${GCC_PV}/gcc-${GCC_RELEASE_VER}.tar.bz2" -### # we want all branch updates to be against the main release -### [[ -n ${BRANCH_UPDATE} ]] && \ -### GCC_SRC_URI="${GCC_SRC_URI} $(gentoo_urls gcc-${GCC_RELEASE_VER}-branch-update-${BRANCH_UPDATE}.patch.bz2)" -### fi - GCC_SRC_URI="$(gentoo_urls ${COST_PKG_VERSION}.tar.bz2)" - - # propolice aka stack smashing protection - if [[ -n ${PP_VER} ]] ; then - if [[ -n ${PP_FVER} ]] ; then - GCC_SRC_URI="${GCC_SRC_URI} - !nossp? ( - http://www.research.ibm.com/trl/projects/security/ssp/gcc${PP_VER}/protector-${PP_FVER}.tar.gz - $(gentoo_urls protector-${PP_FVER}.tar.gz) - )" - else - GCC_SRC_URI="${GCC_SRC_URI} $(gentoo_urls gcc-${PP_GCC_VER}-ssp-${PP_VER}.tar.bz2)" - fi - fi - - # uclibc lovin - [[ -n ${UCLIBC_VER} ]] && \ - GCC_SRC_URI="${GCC_SRC_URI} $(gentoo_urls gcc-${UCLIBC_GCC_VER}-uclibc-patches-${UCLIBC_VER}_${COST_SUFFIX}.tar.bz2)" - - # PERL cannot be present at bootstrap, and is used to build the man pages. - # So... lets include some pre-generated ones, shall we? - [[ -n ${MAN_VER} ]] && \ - GCC_SRC_URI="${GCC_SRC_URI} $(gentoo_urls gcc-${MAN_VER}-manpages.tar.bz2)" - - # various gentoo patches - [[ -n ${PATCH_VER} ]] && \ - GCC_SRC_URI="${GCC_SRC_URI} $(gentoo_urls gcc-${PATCH_GCC_VER}-patches-${PATCH_VER}_${COST_SUFFIX}.tar.bz2)" - - # strawberry pie, Cappuccino and a Gauloises (it's a good thing) - [[ -n ${PIE_VER} ]] && \ - PIE_CORE=${PIE_CORE:-gcc-${PIE_GCC_VER}-piepatches-v${PIE_VER}_${COST_SUFFIX}.tar.bz2} && \ - GCC_SRC_URI="${GCC_SRC_URI} $(gentoo_urls ${PIE_CORE})" - - # gcc minispec for the hardened gcc 4 compiler - [[ -n ${SPECS_VER} ]] && \ - GCC_SRC_URI="${GCC_SRC_URI} $(gentoo_urls gcc-${SPECS_GCC_VER}-specs-${SPECS_VER}.tar.bz2)" - - # gcc bounds checking patch - if [[ -n ${HTB_VER} ]] ; then - local HTBFILE="bounds-checking-gcc-${HTB_GCC_VER}-${HTB_VER}.patch.bz2" - GCC_SRC_URI="${GCC_SRC_URI} - boundschecking? ( - mirror://sourceforge/boundschecking/${HTBFILE} - $(gentoo_urls ${HTBFILE}) - )" - fi - - # support for the D language - [[ -n ${D_VER} ]] && \ - GCC_SRC_URI="${GCC_SRC_URI} d? ( mirror://sourceforge/dgcc/gdc-${D_VER}-src.tar.bz2 )" - - # >= gcc-4.3 uses ecj.jar and we only add gcj as a use flag under certain - # conditions - if [[ ${PN} != "kgcc64" && ${PN} != gcc-* ]] ; then - tc_version_is_at_least "4.3" && \ - GCC_SRC_URI="${GCC_SRC_URI} - gcj? ( ftp://sourceware.org/pub/java/ecj-4.3.jar )" - fi - - echo "${GCC_SRC_URI}" -} -S=$(gcc_get_s_dir) -SRC_URI=$(get_gcc_src_uri) -#---->> S + SRC_URI essentials >>---- - - -#---->> support checks <<---- - -# Grab a variable from the build system (taken from linux-info.eclass) -get_make_var() { - local var=$1 makefile=${2:-${WORKDIR}/build/Makefile} - echo -e "e:\\n\\t@echo \$(${var})\\ninclude ${makefile}" | \ - r=${makefile%/*} emake --no-print-directory -s -f - 2>/dev/null -} -XGCC() { get_make_var GCC_FOR_TARGET ; } - -# The gentoo piessp patches allow for 3 configurations: -# 1) PIE+SSP by default -# 2) PIE by default -# 3) SSP by default -hardened_gcc_works() { - if [[ $1 == "pie" ]] ; then - # $gcc_cv_ld_pie is unreliable as it simply take the output of - # `ld --help | grep -- -pie`, that reports the option in all cases, also if - # the loader doesn't actually load the resulting executables. - # To avoid breakage, blacklist FreeBSD here at least - [[ ${CTARGET} == *-freebsd* ]] && return 1 - - want_pie || return 1 - tc_version_is_at_least 4.3.2 && use nopie && return 1 - hardened_gcc_is_stable pie && return 0 - if has "~$(tc-arch)" ${ACCEPT_KEYWORDS} ; then - hardened_gcc_check_unsupported pie && return 1 - ewarn "Allowing pie-by-default for an unstable arch ($(tc-arch))" - return 0 - fi - return 1 - elif [[ $1 == "ssp" ]] ; then - [[ -n ${PP_VER} ]] || [[ -n ${SPECS_VER} ]] || return 1 - tc_version_is_at_least 4.3.2 && use nossp && return 1 - hardened_gcc_is_stable ssp && return 0 - if has "~$(tc-arch)" ${ACCEPT_KEYWORDS} ; then - hardened_gcc_check_unsupported ssp && return 1 - ewarn "Allowing ssp-by-default for an unstable arch ($(tc-arch))" - return 0 - fi - return 1 - else - # laziness ;) - hardened_gcc_works pie || return 1 - hardened_gcc_works ssp || return 1 - return 0 - fi -} - -hardened_gcc_is_stable() { - if [[ $1 == "pie" ]] ; then - # HARDENED_* variables are deprecated and here for compatibility - local tocheck="${HARDENED_PIE_WORKS} ${HARDENED_GCC_WORKS}" - if [[ ${CTARGET} == *-uclibc* ]] ; then - tocheck="${tocheck} ${PIE_UCLIBC_STABLE}" - else - tocheck="${tocheck} ${PIE_GLIBC_STABLE}" - fi - elif [[ $1 == "ssp" ]] ; then - # ditto - local tocheck="${HARDENED_SSP_WORKS} ${HARDENED_GCC_WORKS}" - if [[ ${CTARGET} == *-uclibc* ]] ; then - tocheck="${tocheck} ${SSP_UCLIBC_STABLE}" - else - tocheck="${tocheck} ${SSP_STABLE}" - fi - else - die "hardened_gcc_stable needs to be called with pie or ssp" - fi - - has $(tc-arch) ${tocheck} && return 0 - return 1 -} - -hardened_gcc_check_unsupported() { - local tocheck="" - # if a variable is unset, we assume that all archs are unsupported. since - # this function is never called if hardened_gcc_is_stable returns true, - # this shouldn't cause problems... however, allowing this logic to work - # even with the variables unset will break older ebuilds that dont use them. - if [[ $1 == "pie" ]] ; then - if [[ ${CTARGET} == *-uclibc* ]] ; then - [[ -z ${PIE_UCLIBC_UNSUPPORTED} ]] && return 0 - tocheck="${tocheck} ${PIE_UCLIBC_UNSUPPORTED}" - else - [[ -z ${PIE_GLIBC_UNSUPPORTED} ]] && return 0 - tocheck="${tocheck} ${PIE_GLIBC_UNSUPPORTED}" - fi - elif [[ $1 == "ssp" ]] ; then - if [[ ${CTARGET} == *-uclibc* ]] ; then - [[ -z ${SSP_UCLIBC_UNSUPPORTED} ]] && return 0 - tocheck="${tocheck} ${SSP_UCLIBC_UNSUPPORTED}" - else - [[ -z ${SSP_UNSUPPORTED} ]] && return 0 - tocheck="${tocheck} ${SSP_UNSUPPORTED}" - fi - else - die "hardened_gcc_check_unsupported needs to be called with pie or ssp" - fi - - has $(tc-arch) ${tocheck} && return 0 - return 1 -} - -has_libssp() { - [[ -e /$(get_libdir)/libssp.so ]] && return 0 - return 1 -} - -want_libssp() { - [[ ${GCC_LIBSSP_SUPPORT} == "true" ]] || return 1 - has_libssp || return 1 - [[ -n ${PP_VER} ]] || return 1 - return 0 -} - -_want_stuff() { - local var=$1 flag=$2 - [[ -z ${!var} ]] && return 1 - use ${flag} && return 0 - return 1 -} -want_boundschecking() { _want_stuff HTB_VER boundschecking ; } -want_pie() { - ! use hardened && [[ -n ${PIE_VER} ]] && use nopie && return 1 - [[ -n ${PIE_VER} ]] && [[ -n ${SPECS_VER} ]] && return 0 - tc_version_is_at_least 4.3.2 && return 1 - _want_stuff PIE_VER !nopie -} -want_ssp() { _want_stuff PP_VER !nossp ; } - -# SPLIT_SPECS are deprecated for >=GCC 4.4 -want_split_specs() { - tc_version_is_at_least 4.4 && return 1 - [[ ${SPLIT_SPECS} == "true" ]] && want_pie -} -want_minispecs() { - if tc_version_is_at_least 4.3.2 && use hardened ; then - if ! want_pie ; then - ewarn "PIE_VER or SPECS_VER is not defiend in the GCC ebuild." - elif use vanilla ; then - ewarn "You will not get hardened features if you have the vanilla USE-flag." - elif use nopie && use nossp ; then - ewarn "You will not get hardened features if you have the nopie and nossp USE-flag." - elif ! hardened_gcc_works pie && ! hardened_gcc_works ssp && ! use nopie ; then - ewarn "Your $(tc-arch) arch is not supported." - else - return 0 - fi - ewarn "Hope you know what you are doing. Hardened will not work." - return 0 - fi - return 1 -} -# This function checks whether or not glibc has the support required to build -# Position Independant Executables with gcc. -glibc_have_pie() { - if [[ ! -f ${ROOT}/usr/$(get_libdir)/Scrt1.o ]] ; then - echo - ewarn "Your glibc does not have support for pie, the file Scrt1.o is missing" - ewarn "Please update your glibc to a proper version or disable hardened" - echo - return 1 - fi -} - -# This function determines whether or not libc has been patched with stack -# smashing protection support. -libc_has_ssp() { - [[ ${ROOT} != "/" ]] && return 0 - - # lib hacks taken from sandbox configure - echo 'int main(){}' > "${T}"/libctest.c - LC_ALL=C gcc "${T}"/libctest.c -lc -o libctest -Wl,-verbose &> "${T}"/libctest.log || return 1 - local libc_file=$(awk '/attempt to open/ { if (($4 ~ /\/libc\.so/) && ($5 == "succeeded")) LIBC = $4; }; END {print LIBC}' "${T}"/libctest.log) - - [[ -z ${libc_file} ]] && die "Unable to find a libc !?" - - # Check for gcc-4.x style ssp support - if [[ -n $(readelf -s "${libc_file}" 2>/dev/null | \ - grep 'FUNC.*GLOBAL.*__stack_chk_fail') ]] - then - return 0 - else - # Check for gcc-3.x style ssp support - if [[ -n $(readelf -s "${libc_file}" 2>/dev/null | \ - grep 'OBJECT.*GLOBAL.*__guard') ]] && \ - [[ -n $(readelf -s "${libc_file}" 2>/dev/null | \ - grep 'FUNC.*GLOBAL.*__stack_smash_handler') ]] - then - return 0 - elif is_crosscompile ; then - die "'${libc_file}' was detected w/out ssp, that sucks (a lot)" - else - return 1 - fi - fi -} - -# This is to make sure we don't accidentally try to enable support for a -# language that doesnt exist. GCC 3.4 supports f77, while 4.0 supports f95, etc. -# -# Also add a hook so special ebuilds (kgcc64) can control which languages -# exactly get enabled -gcc-lang-supported() { - grep ^language=\"${1}\" "${S}"/gcc/*/config-lang.in > /dev/null || return 1 - [[ -z ${TOOLCHAIN_ALLOWED_LANGS} ]] && return 0 - has $1 ${TOOLCHAIN_ALLOWED_LANGS} -} - -#----<< support checks >>---- - -#---->> specs + env.d logic <<---- - -# defaults to enable for all hardened toolchains -gcc_common_hard="-DEFAULT_RELRO -DEFAULT_BIND_NOW" - -# configure to build with the hardened GCC specs as the default -make_gcc_hard() { - if hardened_gcc_works ; then - einfo "Updating gcc to use automatic PIE + SSP building ..." - sed -e "s|^HARD_CFLAGS = |HARD_CFLAGS = -DEFAULT_PIE_SSP ${gcc_common_hard} |" \ - -i "${S}"/gcc/Makefile.in || die "Failed to update gcc!" - elif hardened_gcc_works pie ; then - einfo "Updating gcc to use automatic PIE building ..." - ewarn "SSP has not been enabled by default" - sed -e "s|^HARD_CFLAGS = |HARD_CFLAGS = -DEFAULT_PIE ${gcc_common_hard} |" \ - -i "${S}"/gcc/Makefile.in || die "Failed to update gcc!" - elif hardened_gcc_works ssp ; then - einfo "Updating gcc to use automatic SSP building ..." - ewarn "PIE has not been enabled by default" - sed -e "s|^HARD_CFLAGS = |HARD_CFLAGS = -DEFAULT_SSP ${gcc_common_hard} |" \ - -i "${S}"/gcc/Makefile.in || die "Failed to update gcc!" - else - # do nothing if hardened isnt supported, but dont die either - ewarn "hardened is not supported for this arch in this gcc version" - ebeep - return 0 - fi - - # rebrand to make bug reports easier - BRANDING_GCC_PKGVERSION=${BRANDING_GCC_PKGVERSION/Gentoo/Gentoo Hardened} -} - -# now we generate different spec files so that the user can select a compiler -# that enforces certain features in gcc itself and so we don't have to worry -# about a certain package ignoring CFLAGS/LDFLAGS -_create_specs_file() { - # Usage: _create_specs_file - local uflag=$1 name=$2 flags=${*:3} - ebegin "Creating a ${name} gcc specs file" - pushd "${WORKDIR}"/build/gcc > /dev/null - if [[ -z ${uflag} ]] || use ${uflag} ; then - # backup the compiler first - cp Makefile Makefile.orig - sed -i -e '/^HARD_CFLAGS/s:=.*:='"${flags}"':' Makefile - mv xgcc xgcc.foo - mv gcc.o gcc.o.foo - emake -s xgcc - $(XGCC) -dumpspecs > "${WORKDIR}"/build/${name}.specs - # restore everything to normal - mv gcc.o.foo gcc.o - mv xgcc.foo xgcc - mv Makefile.orig Makefile - else - $(XGCC) -dumpspecs > "${WORKDIR}"/build/${name}.specs - fi - popd > /dev/null - eend $([[ -s ${WORKDIR}/build/${name}.specs ]] ; echo $?) -} -create_vanilla_specs_file() { _create_specs_file hardened vanilla ; } -create_hardened_specs_file() { _create_specs_file !hardened hardened ${gcc_common_hard} -DEFAULT_PIE_SSP ; } -create_hardenednossp_specs_file() { _create_specs_file "" hardenednossp ${gcc_common_hard} -DEFAULT_PIE ; } -create_hardenednopie_specs_file() { _create_specs_file "" hardenednopie ${gcc_common_hard} -DEFAULT_SSP ; } -create_hardenednopiessp_specs_file() { _create_specs_file "" hardenednopiessp ${gcc_common_hard} ; } - -split_out_specs_files() { - local s spec_list="hardenednopiessp vanilla" - if hardened_gcc_works ; then - spec_list="${spec_list} hardened hardenednossp hardenednopie" - elif hardened_gcc_works pie ; then - spec_list="${spec_list} hardenednossp" - elif hardened_gcc_works ssp ; then - spec_list="${spec_list} hardenednopie" - fi - for s in ${spec_list} ; do - create_${s}_specs_file || return 1 - done -} - -create_gcc_env_entry() { - dodir /etc/env.d/gcc - local gcc_envd_base="/etc/env.d/gcc/${CTARGET}-${GCC_CONFIG_VER}" - - if [[ -z $1 ]] ; then - gcc_envd_file="${D}${gcc_envd_base}" - # I'm leaving the following commented out to remind me that it - # was an insanely -bad- idea. Stuff broke. GCC_SPECS isnt unset - # on chroot or in non-toolchain.eclass gcc ebuilds! - #gcc_specs_file="${LIBPATH}/specs" - gcc_specs_file="" - else - gcc_envd_file="${D}${gcc_envd_base}-$1" - gcc_specs_file="${LIBPATH}/$1.specs" - fi - - # phase PATH/ROOTPATH out ... - echo "PATH=\"${BINPATH}\"" > ${gcc_envd_file} - echo "ROOTPATH=\"${BINPATH}\"" >> ${gcc_envd_file} - echo "GCC_PATH=\"${BINPATH}\"" >> ${gcc_envd_file} - - if use multilib && ! has_multilib_profile; then - LDPATH="${LIBPATH}" - for path in 32 64 ; do - [[ -d ${LIBPATH}/${path} ]] && LDPATH="${LDPATH}:${LIBPATH}/${path}" - done - else - local MULTIDIR - LDPATH="${LIBPATH}" - - # We want to list the default ABI's LIBPATH first so libtool - # searches that directory first. This is a temporary - # workaround for libtool being stupid and using .la's from - # conflicting ABIs by using the first one in the search path - - local abi=${DEFAULT_ABI} - local MULTIDIR=$($(XGCC) $(get_abi_CFLAGS ${abi}) --print-multi-directory) - if [[ ${MULTIDIR} == "." ]] ; then - LDPATH=${LIBPATH} - else - LDPATH=${LIBPATH}/${MULTIDIR} - fi - - for abi in $(get_all_abis) ; do - [[ ${abi} == ${DEFAULT_ABI} ]] && continue - - MULTIDIR=$($(XGCC) $(get_abi_CFLAGS ${abi}) --print-multi-directory) - if [[ ${MULTIDIR} == "." ]] ; then - LDPATH=${LDPATH}:${LIBPATH} - else - LDPATH=${LDPATH}:${LIBPATH}/${MULTIDIR} - fi - done - fi - - echo "LDPATH=\"${LDPATH}\"" >> ${gcc_envd_file} - echo "MANPATH=\"${DATAPATH}/man\"" >> ${gcc_envd_file} - echo "INFOPATH=\"${DATAPATH}/info\"" >> ${gcc_envd_file} - echo "STDCXX_INCDIR=\"${STDCXX_INCDIR##*/}\"" >> ${gcc_envd_file} - - is_crosscompile && echo "CTARGET=${CTARGET}" >> ${gcc_envd_file} - - # Set which specs file to use - [[ -n ${gcc_specs_file} ]] && echo "GCC_SPECS=\"${gcc_specs_file}\"" >> ${gcc_envd_file} -} -setup_minispecs_gcc_build_specs() { - # Setup the "build.specs" file for gcc 4.3 to use when building. - if hardened_gcc_works pie ; then - cat "${WORKDIR}"/specs/pie.specs >> "${WORKDIR}"/build.specs - fi - if hardened_gcc_works ssp ; then - for s in ssp sspall ; do - cat "${WORKDIR}"/specs/${s}.specs >> "${WORKDIR}"/build.specs - done - fi - for s in nostrict znow ; do - cat "${WORKDIR}"/specs/${s}.specs >> "${WORKDIR}"/build.specs - done - export GCC_SPECS="${WORKDIR}"/build.specs -} -copy_minispecs_gcc_specs() { - # setup the hardenedno* specs files and the vanilla specs file. - if hardened_gcc_works ; then - create_gcc_env_entry hardenednopiessp - fi - if hardened_gcc_works pie ; then - create_gcc_env_entry hardenednopie - fi - if hardened_gcc_works ssp ; then - create_gcc_env_entry hardenednossp - fi - create_gcc_env_entry vanilla - insinto ${LIBPATH} - doins "${WORKDIR}"/specs/*.specs || die "failed to install specs" - # Build system specs file which, if it exists, must be a complete set of - # specs as it completely and unconditionally overrides the builtin specs. - # For gcc 4.3 - if ! tc_version_is_at_least 4.4 ; then - $(XGCC) -dumpspecs > "${WORKDIR}"/specs/specs - cat "${WORKDIR}"/build.specs >> "${WORKDIR}"/specs/specs - doins "${WORKDIR}"/specs/specs || die "failed to install the specs file" - fi -} - -#----<< specs + env.d logic >>---- - -#---->> pkg_* <<---- -gcc_pkg_setup() { - [[ -z ${ETYPE} ]] && die "Your ebuild needs to set the ETYPE variable" - - if [[ ( $(tc-arch) == "amd64" || $(tc-arch) == "ppc64" ) && ( ${LD_PRELOAD} == "/lib/libsandbox.so" || ${LD_PRELOAD} == "/usr/lib/libsandbox.so" ) ]] && is_multilib ; then - eerror "Sandbox in your installed portage does not support compilation." - eerror "of a multilib gcc. Please set FEATURES=-sandbox and try again." - eerror "After you have a multilib gcc, re-emerge portage to have a working sandbox." - die "No 32bit sandbox. Retry with FEATURES=-sandbox." - fi - - if [[ ${ETYPE} == "gcc-compiler" ]] ; then - case $(tc-arch) in - mips) - # Must compile for mips64-linux target if we want n32/n64 support - case "${CTARGET}" in - mips64*) ;; - *) - if use n32 || use n64; then - eerror "n32/n64 can only be used when target host is mips64*-*-linux-*"; - die "Invalid USE flags for CTARGET ($CTARGET)"; - fi - ;; - esac - - #cannot have both n32 & n64 without multilib - if use n32 && use n64 && ! is_multilib; then - eerror "Please enable multilib if you want to use both n32 & n64"; - die "Invalid USE flag combination"; - fi - ;; - esac - - # Setup variables which would normally be in the profile - if is_crosscompile ; then - multilib_env ${CTARGET} - if ! use multilib ; then - MULTILIB_ABIS=${DEFAULT_ABI} - fi - fi - - # we dont want to use the installed compiler's specs to build gcc! - unset GCC_SPECS - fi - - want_libssp && libc_has_ssp && \ - die "libssp cannot be used with a glibc that has been patched to provide ssp symbols" - want_minispecs - - unset LANGUAGES #265283 -} - -gcc-compiler_pkg_preinst() { - : -} - -gcc-compiler_pkg_postinst() { - do_gcc_config - - if ! is_crosscompile ; then - echo - ewarn "If you have issues with packages unable to locate libstdc++.la," - ewarn "then try running 'fix_libtool_files.sh' on the old gcc versions." - echo - fi - - # If our gcc-config version doesn't like '-' in it's version string, - # tell our users that gcc-config will yell at them, but it's all good. - if ! has_version '>=sys-devel/gcc-config-1.3.10-r1' && [[ ${GCC_CONFIG_VER/-/} != ${GCC_CONFIG_VER} ]] ; then - ewarn "Your version of gcc-config will issue about having an invalid profile" - ewarn "when switching to this profile. It is safe to ignore this warning," - ewarn "and this problem has been corrected in >=sys-devel/gcc-config-1.3.10-r1." - fi - - if ! is_crosscompile && ! use multislot && [[ ${GCCMAJOR}.${GCCMINOR} == 3.4 ]] ; then - echo - ewarn "You should make sure to rebuild all your C++ packages when" - ewarn "upgrading between different versions of gcc. For example," - ewarn "when moving to gcc-3.4 from gcc-3.3, emerge gentoolkit and run:" - ewarn " # revdep-rebuild --library libstdc++.so.5" - echo - ewarn "For more information on the steps to take when upgrading " - ewarn "from gcc-3.3 please refer to: " - ewarn "http://www.gentoo.org/doc/en/gcc-upgrading.xml" - echo - fi - - if ! is_crosscompile ; then - # hack to prevent collisions between SLOT - [[ ! -d ${ROOT}/lib/rcscripts/awk ]] \ - && mkdir -p "${ROOT}"/lib/rcscripts/awk - [[ ! -d ${ROOT}/sbin ]] \ - && mkdir -p "${ROOT}"/sbin - cp "${ROOT}/${DATAPATH}"/fixlafiles.awk "${ROOT}"/lib/rcscripts/awk/ || die "installing fixlafiles.awk" - cp "${ROOT}/${DATAPATH}"/fix_libtool_files.sh "${ROOT}"/sbin/ || die "installing fix_libtool_files.sh" - - [[ ! -d ${ROOT}/usr/bin ]] \ - && mkdir -p "${ROOT}"/usr/bin - # Since these aren't critical files and portage sucks with - # handling of binpkgs, don't require these to be found - for x in "${ROOT}/${DATAPATH}"/c{89,99} ; do - if [[ -e ${x} ]]; then - cp ${x} "${ROOT}"/usr/bin/ || die "installing c89/c99" - fi - done - fi -} - -gcc-compiler_pkg_prerm() { - # Don't let these files be uninstalled #87647 - touch -c "${ROOT}"/sbin/fix_libtool_files.sh \ - "${ROOT}"/lib/rcscripts/awk/fixlafiles.awk -} - -gcc-compiler_pkg_postrm() { - # to make our lives easier (and saner), we do the fix_libtool stuff here. - # rather than checking SLOT's and trying in upgrade paths, we just see if - # the common libstdc++.la exists in the ${LIBPATH} of the gcc that we are - # unmerging. if it does, that means this was a simple re-emerge. - - # clean up the cruft left behind by cross-compilers - if is_crosscompile ; then - if [[ -z $(ls "${ROOT}"/etc/env.d/gcc/${CTARGET}* 2>/dev/null) ]] ; then - rm -f "${ROOT}"/etc/env.d/gcc/config-${CTARGET} - rm -f "${ROOT}"/etc/env.d/??gcc-${CTARGET} - rm -f "${ROOT}"/usr/bin/${CTARGET}-{gcc,{g,c}++}{,32,64} - fi - return 0 - fi - - # ROOT isnt handled by the script - [[ ${ROOT} != "/" ]] && return 0 - - if [[ ! -e ${LIBPATH}/libstdc++.so ]] ; then - # make sure the profile is sane during same-slot upgrade #289403 - do_gcc_config - - einfo "Running 'fix_libtool_files.sh ${GCC_RELEASE_VER}'" - /sbin/fix_libtool_files.sh ${GCC_RELEASE_VER} - if [[ -n ${BRANCH_UPDATE} ]] ; then - einfo "Running 'fix_libtool_files.sh ${GCC_RELEASE_VER}-${BRANCH_UPDATE}'" - /sbin/fix_libtool_files.sh ${GCC_RELEASE_VER}-${BRANCH_UPDATE} - fi - fi - - return 0 -} - -#---->> pkg_* <<---- - -#---->> src_* <<---- - -# generic GCC src_unpack, to be called from the ebuild's src_unpack. -# BIG NOTE regarding hardened support: ebuilds with support for hardened are -# expected to export the following variable: -# -# HARDENED_GCC_WORKS -# This variable should be set to the archs on which hardened should -# be allowed. For example: HARDENED_GCC_WORKS="x86 sparc amd64" -# This allows for additional archs to be supported by hardened when -# ready. -# -# Travis Tilley (03 Sep 2004) -# -gcc-compiler_src_unpack() { - # fail if using pie patches, building hardened, and glibc doesnt have - # the necessary support - want_pie && use hardened && glibc_have_pie - - if use hardened ; then - einfo "updating configuration to build hardened GCC" - make_gcc_hard || die "failed to make gcc hard" - fi - - if is_libffi ; then - # move the libffi target out of gcj and into all - sed -i \ - -e '/^libgcj=/s:target-libffi::' \ - -e '/^target_lib/s:=":="target-libffi :' \ - "${S}"/configure || die - fi -} -gcc-library_src_unpack() { - : -} -guess_patch_type_in_dir() { - [[ -n $(ls "$1"/*.bz2 2>/dev/null) ]] \ - && EPATCH_SUFFIX="patch.bz2" \ - || EPATCH_SUFFIX="patch" -} -do_gcc_rename_java_bins() { - # bug #139918 - conflict between gcc and java-config-2 for ownership of - # /usr/bin/rmi{c,registry}. Done with mv & sed rather than a patch - # because patches would be large (thanks to the rename of man files), - # and it's clear from the sed invocations that all that changes is the - # rmi{c,registry} names to grmi{c,registry} names. - # Kevin F. Quinn 2006-07-12 - einfo "Renaming jdk executables rmic and rmiregistry to grmic and grmiregistry." - # 1) Move the man files if present (missing prior to gcc-3.4) - for manfile in rmic rmiregistry; do - [[ -f ${S}/gcc/doc/${manfile}.1 ]] || continue - mv "${S}"/gcc/doc/${manfile}.1 "${S}"/gcc/doc/g${manfile}.1 - done - # 2) Fixup references in the docs if present (mission prior to gcc-3.4) - for jfile in gcc/doc/gcj.info gcc/doc/grmic.1 gcc/doc/grmiregistry.1 gcc/java/gcj.texi; do - [[ -f ${S}/${jfile} ]] || continue - sed -i -e 's:rmiregistry:grmiregistry:g' "${S}"/${jfile} || - die "Failed to fixup file ${jfile} for rename to grmiregistry" - sed -i -e 's:rmic:grmic:g' "${S}"/${jfile} || - die "Failed to fixup file ${jfile} for rename to grmic" - done - # 3) Fixup Makefiles to build the changed executable names - # These are present in all 3.x versions, and are the important bit - # to get gcc to build with the new names. - for jfile in libjava/Makefile.am libjava/Makefile.in gcc/java/Make-lang.in; do - sed -i -e 's:rmiregistry:grmiregistry:g' "${S}"/${jfile} || - die "Failed to fixup file ${jfile} for rename to grmiregistry" - # Careful with rmic on these files; it's also the name of a directory - # which should be left unchanged. Replace occurrences of 'rmic$', - # 'rmic_' and 'rmic '. - sed -i -e 's:rmic\([$_ ]\):grmic\1:g' "${S}"/${jfile} || - die "Failed to fixup file ${jfile} for rename to grmic" - done -} -gcc_src_unpack() { - export BRANDING_GCC_PKGVERSION="Gentoo ${GCC_PVR}" - - [[ -z ${UCLIBC_VER} ]] && [[ ${CTARGET} == *-uclibc* ]] && die "Sorry, this version does not support uClibc" - - gcc_quick_unpack - exclude_gcc_patches - - cd "${S}" - - if ! use vanilla ; then - if [[ -n ${PATCH_VER} ]] ; then - guess_patch_type_in_dir "${WORKDIR}"/patch - EPATCH_MULTI_MSG="Applying Gentoo patches ..." \ - epatch "${WORKDIR}"/patch - BRANDING_GCC_PKGVERSION="${BRANDING_GCC_PKGVERSION} p${PATCH_VER}" - fi - if [[ -n ${UCLIBC_VER} ]] ; then - guess_patch_type_in_dir "${WORKDIR}"/uclibc - EPATCH_MULTI_MSG="Applying uClibc patches ..." \ - epatch "${WORKDIR}"/uclibc - fi - fi - do_gcc_HTB_patches - do_gcc_SSP_patches - do_gcc_PIE_patches - epatch_user - - ${ETYPE}_src_unpack || die "failed to ${ETYPE}_src_unpack" - - # protoize don't build on FreeBSD, skip it - ## removed in 4.5, bug #270558 --de. - if [[ ${GCCMAJOR}.${GCCMINOR} < 4.5 ]]; then - if ! is_crosscompile && ! use elibc_FreeBSD ; then - # enable protoize / unprotoize - sed -i -e '/^LANGUAGES =/s:$: proto:' "${S}"/gcc/Makefile.in - fi - fi - - fix_files="" - for x in contrib/test_summary libstdc++-v3/scripts/check_survey.in ; do - [[ -e ${x} ]] && fix_files="${fix_files} ${x}" - done - ht_fix_file ${fix_files} */configure *.sh */Makefile.in - - if ! is_crosscompile && is_multilib && \ - [[ ( $(tc-arch) == "amd64" || $(tc-arch) == "ppc64" ) && -z ${SKIP_MULTILIB_HACK} ]] ; then - disgusting_gcc_multilib_HACK || die "multilib hack failed" - fi - - gcc_version_patch - if [[ ${GCCMAJOR}.${GCCMINOR} > 4.0 ]] ; then - if [[ -n ${SNAPSHOT} || -n ${PRERELEASE} ]] ; then - echo ${PV/_/-} > "${S}"/gcc/BASE-VER - fi - fi - - # >= gcc-4.3 doesn't bundle ecj.jar, so copy it - if [[ ${GCCMAJOR}.${GCCMINOR} > 4.2 ]] && - use gcj ; then - cp -pPR "${DISTDIR}/ecj-4.3.jar" "${S}/ecj.jar" || die - fi - - # disable --as-needed from being compiled into gcc specs - # natively when using a gcc version < 3.4.4 - # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14992 - if ! tc_version_is_at_least 3.4.4 ; then - sed -i -e s/HAVE_LD_AS_NEEDED/USE_LD_AS_NEEDED/g "${S}"/gcc/config.in - fi - - # In gcc 3.3.x and 3.4.x, rename the java bins to gcc-specific names - # in line with gcc-4. - if [[ ${GCCMAJOR} == 3 ]] && - [[ ${GCCMINOR} -ge 3 ]] - then - do_gcc_rename_java_bins - fi - - # Fixup libtool to correctly generate .la files with portage - cd "${S}" - elibtoolize --portage --shallow --no-uclibc - - gnuconfig_update - - # update configure files - local f - einfo "Fixing misc issues in configure files" - tc_version_is_at_least 4.1 && epatch "${GCC_FILESDIR}"/gcc-configure-texinfo.patch - for f in $(grep -l 'autoconf version 2.13' $(find "${S}" -name configure)) ; do - ebegin " Updating ${f/${S}\/} [LANG]" - patch "${f}" "${GCC_FILESDIR}"/gcc-configure-LANG.patch >& "${T}"/configure-patch.log \ - || eerror "Please file a bug about this" - eend $? - done - sed -i 's|A-Za-z0-9|[:alnum:]|g' "${S}"/gcc/*.awk #215828 - - if [[ -x contrib/gcc_update ]] ; then - einfo "Touching generated files" - ./contrib/gcc_update --touch | \ - while read f ; do - einfo " ${f%%...}" - done - fi - - disable_multilib_libjava || die "failed to disable multilib java" -} - -gcc-library-configure() { - # multilib support - [[ ${GCC_TARGET_NO_MULTILIB} == "true" ]] \ - && confgcc="${confgcc} --disable-multilib" \ - || confgcc="${confgcc} --enable-multilib" -} - -gcc-compiler-configure() { - # multilib support - if is_multilib ; then - confgcc="${confgcc} --enable-multilib" - elif [[ ${CTARGET} == *-linux* ]] ; then - confgcc="${confgcc} --disable-multilib" - fi - - if tc_version_is_at_least "4.0" ; then - if has mudflap ${IUSE} ; then - confgcc="${confgcc} $(use_enable mudflap libmudflap)" - else - confgcc="${confgcc} --disable-libmudflap" - fi - - if want_libssp ; then - confgcc="${confgcc} --enable-libssp" - else - export gcc_cv_libc_provides_ssp=yes - confgcc="${confgcc} --disable-libssp" - fi - - # If we want hardened support with the newer piepatchset for >=gcc 4.4 - if tc_version_is_at_least 4.4 && want_minispecs ; then - confgcc="${confgcc} $(use_enable hardened esp)" - fi - - if tc_version_is_at_least "4.2" ; then - confgcc="${confgcc} $(use_enable openmp libgomp)" - fi - - # enable the cld workaround until we move things to stable. - # by that point, the rest of the software out there should - # have caught up. - if tc_version_is_at_least "4.3" ; then - if ! has ${ARCH} ${KEYWORDS} ; then - confgcc="${confgcc} --enable-cld" - fi - fi - - # Stick the python scripts in their own slotted directory - # bug #279252 - # - # --with-python-dir=DIR - # Specifies where to install the Python modules used for aot-compile. DIR - # should not include the prefix used in installation. For example, if the - # Python modules are to be installed in /usr/lib/python2.5/site-packages, - # then –with-python-dir=/lib/python2.5/site-packages should be passed. - # - # This should translate into "/share/gcc-data/${CTARGET}/${GCC_CONFIG_VER}/python" - if tc_version_is_at_least "4.4" ; then - confgcc="${confgcc} --with-python-dir=${DATAPATH/$PREFIX/}/python" - fi - fi - - # GTK+ is preferred over xlib in 3.4.x (xlib is unmaintained - # right now). Much thanks to for the heads up. - # Travis Tilley (11 Jul 2004) - if ! is_gcj ; then - confgcc="${confgcc} --disable-libgcj" - elif use gtk ; then - confgcc="${confgcc} --enable-java-awt=gtk" - fi - - case $(tc-arch) in - arm) #264534 - local arm_arch="${CTARGET%%-*}" - # Only do this if arm_arch is armv* - if [[ ${arm_arch} == armv* ]] ; then - # Convert armv7{a,r,m} to armv7-{a,r,m} - [[ ${arm_arch} == armv7? ]] && arm_arch=${arm_arch/7/7-} - # Remove endian ('l' / 'eb') - [[ ${arm_arch} == *l ]] && arm_arch=${arm_arch%l} - [[ ${arm_arch} == *eb ]] && arm_arch=${arm_arch%eb} - confgcc="${confgcc} --with-arch=${arm_arch}" - fi - - # Enable hardvfp - if [[ ${CTARGET##*-} == *eabi ]] && [[ $(tc-is-hardfloat) == yes ]] && \ - tc_version_is_at_least "4.5" ; then - confgcc="${confgcc} --with-float=hard" - fi - ;; - # Add --with-abi flags to set default MIPS ABI - mips) - local mips_abi="" - use n64 && mips_abi="--with-abi=64" - use n32 && mips_abi="--with-abi=n32" - [[ -n ${mips_abi} ]] && confgcc="${confgcc} ${mips_abi}" - ;; - # Default arch for x86 is normally i386, lets give it a bump - # since glibc will do so based on CTARGET anyways - x86) - confgcc="${confgcc} --with-arch=${CTARGET%%-*}" - ;; - # Enable sjlj exceptions for backward compatibility on hppa - hppa) - [[ ${GCCMAJOR} == "3" ]] && confgcc="${confgcc} --enable-sjlj-exceptions" - ;; - esac - - GCC_LANG="c" - is_cxx && GCC_LANG="${GCC_LANG},c++" - is_d && GCC_LANG="${GCC_LANG},d" - is_gcj && GCC_LANG="${GCC_LANG},java" - if is_objc || is_objcxx ; then - GCC_LANG="${GCC_LANG},objc" - if tc_version_is_at_least "4.0" ; then - use objc-gc && confgcc="${confgcc} --enable-objc-gc" - fi - is_objcxx && GCC_LANG="${GCC_LANG},obj-c++" - fi - is_treelang && GCC_LANG="${GCC_LANG},treelang" - - # fortran support just got sillier! the lang value can be f77 for - # fortran77, f95 for fortran95, or just plain old fortran for the - # currently supported standard depending on gcc version. - is_fortran && GCC_LANG="${GCC_LANG},fortran" - is_f77 && GCC_LANG="${GCC_LANG},f77" - is_f95 && GCC_LANG="${GCC_LANG},f95" - - # We do NOT want 'ADA support' in here! - # is_ada && GCC_LANG="${GCC_LANG},ada" - - einfo "configuring for GCC_LANG: ${GCC_LANG}" -} - -# Other than the variables described for gcc_setup_variables, the following -# will alter tha behavior of gcc_do_configure: -# -# CTARGET -# CBUILD -# Enable building for a target that differs from CHOST -# -# GCC_TARGET_NO_MULTILIB -# Disable multilib. Useful when building single library targets. -# -# GCC_LANG -# Enable support for ${GCC_LANG} languages. defaults to just "c" -# -# Travis Tilley (04 Sep 2004) -# -gcc_do_configure() { - local confgcc - - # Set configuration based on path variables - confgcc="${confgcc} \ - --prefix=${PREFIX} \ - --bindir=${BINPATH} \ - --includedir=${INCLUDEPATH} \ - --datadir=${DATAPATH} \ - --mandir=${DATAPATH}/man \ - --infodir=${DATAPATH}/info \ - --with-gxx-include-dir=${STDCXX_INCDIR}" - # On Darwin we need libdir to be set in order to get correct install names - # for things like libobjc-gnu, libgcj and libfortran. If we enable it on - # non-Darwin we screw up the behaviour this eclass relies on. We in - # particular need this over --libdir for bug #255315. - [[ ${CHOST} == *-darwin* ]] && \ - confgcc="${confgcc} --enable-version-specific-runtime-libs" - - # All our cross-compile logic goes here ! woo ! - confgcc="${confgcc} --host=${CHOST}" - if is_crosscompile || tc-is-cross-compiler ; then - # Straight from the GCC install doc: - # "GCC has code to correctly determine the correct value for target - # for nearly all native systems. Therefore, we highly recommend you - # not provide a configure target when configuring a native compiler." - confgcc="${confgcc} --target=${CTARGET}" - fi - [[ -n ${CBUILD} ]] && confgcc="${confgcc} --build=${CBUILD}" - - # ppc altivec support - confgcc="${confgcc} $(use_enable altivec)" - - # gcc has fixed-point arithmetic support in 4.3 for mips targets that can - # significantly increase compile time by several hours. This will allow - # users to control this feature in the event they need the support. - tc_version_is_at_least "4.3" && confgcc="${confgcc} $(use_enable fixed-point)" - - # graphite support was added in 4.4, which depends upon external libraries - # for optimizations. This option allows users to determine if they want - # these optimizations and libraries pulled in - tc_version_is_at_least "4.4" && \ - confgcc="${confgcc} $(use_with graphite ppl) $(use_with graphite cloog)" - - # lto support was added in 4.5, which depends upon elfutils. This allows - # users to enable that option, and pull in the additional library - tc_version_is_at_least "4.5" && \ - confgcc="${confgcc} $(use_enable lto)" - - - [[ $(tc-is-softfloat) == "yes" ]] && confgcc="${confgcc} --with-float=soft" - [[ $(tc-is-hardfloat) == "yes" ]] && confgcc="${confgcc} --with-float=hard" - - # Native Language Support - if use nls ; then - confgcc="${confgcc} --enable-nls --without-included-gettext" - else - confgcc="${confgcc} --disable-nls" - fi - - # reasonably sane globals (hopefully) - confgcc="${confgcc} \ - --with-system-zlib \ - --disable-checking \ - --disable-werror \ - --enable-secureplt" - - # etype specific configuration - einfo "running ${ETYPE}-configure" - ${ETYPE}-configure || die - - # if not specified, assume we are building for a target that only - # requires C support - GCC_LANG=${GCC_LANG:-c} - confgcc="${confgcc} --enable-languages=${GCC_LANG}" - - if is_crosscompile ; then - # When building a stage1 cross-compiler (just C compiler), we have to - # disable a bunch of features or gcc goes boom - local needed_libc="" - case ${CTARGET} in - *-linux) needed_libc=no-fucking-clue;; - *-dietlibc) needed_libc=dietlibc;; - *-elf) needed_libc=newlib;; - *-freebsd*) needed_libc=freebsd-lib;; - *-gnu*) needed_libc=glibc;; - *-klibc) needed_libc=klibc;; - *-uclibc*) needed_libc=uclibc;; - *-cygwin) needed_libc=cygwin;; - mingw*|*-mingw*) needed_libc=mingw-runtime;; - avr) confgcc="${confgcc} --enable-shared --disable-threads";; - esac - if [[ -n ${needed_libc} ]] ; then - if ! has_version ${CATEGORY}/${needed_libc} ; then - confgcc="${confgcc} --disable-shared --disable-threads --without-headers" - elif built_with_use --hidden --missing false ${CATEGORY}/${needed_libc} crosscompile_opts_headers-only ; then - confgcc="${confgcc} --disable-shared --with-sysroot=${PREFIX}/${CTARGET}" - else - confgcc="${confgcc} --with-sysroot=${PREFIX}/${CTARGET}" - fi - fi - - if [[ ${GCCMAJOR}.${GCCMINOR} > 4.1 ]] ; then - confgcc="${confgcc} --disable-bootstrap" - fi - else - if tc-is-static-only ; then - confgcc="${confgcc} --disable-shared" - else - confgcc="${confgcc} --enable-shared" - fi - case ${CHOST} in - mingw*|*-mingw*|*-cygwin) - confgcc="${confgcc} --enable-threads=win32" ;; - *-mint*) - confgcc="${confgcc} --disable-threads" ;; - *) - confgcc="${confgcc} --enable-threads=posix" ;; - esac - fi - [[ ${CTARGET} == *-elf ]] && confgcc="${confgcc} --with-newlib" - # __cxa_atexit is "essential for fully standards-compliant handling of - # destructors", but apparently requires glibc. - if [[ ${CTARGET} == *-uclibc* ]] ; then - confgcc="${confgcc} --disable-__cxa_atexit --enable-target-optspace $(use_enable nptl tls)" - [[ ${GCCMAJOR}.${GCCMINOR} == 3.3 ]] && confgcc="${confgcc} --enable-sjlj-exceptions" - if tc_version_is_at_least 3.4 && [[ ${GCCMAJOR}.${GCCMINOR} < 4.3 ]] ; then - confgcc="${confgcc} --enable-clocale=uclibc" - fi - elif [[ ${CTARGET} == *-gnu* ]] ; then - confgcc="${confgcc} --enable-__cxa_atexit" - confgcc="${confgcc} --enable-clocale=gnu" - elif [[ ${CTARGET} == *-freebsd* ]]; then - confgcc="${confgcc} --enable-__cxa_atexit" - elif [[ ${CTARGET} == *-solaris* ]]; then - confgcc="${confgcc} --enable-__cxa_atexit" - fi - [[ ${GCCMAJOR}.${GCCMINOR} < 3.4 ]] && confgcc="${confgcc} --disable-libunwind-exceptions" - - # create a sparc*linux*-{gcc,g++} that can handle -m32 and -m64 (biarch) - if [[ ${CTARGET} == sparc*linux* ]] \ - && is_multilib \ - && ! is_crosscompile \ - && [[ ${GCCMAJOR}.${GCCMINOR} > 4.2 ]] - then - confgcc="${confgcc} --enable-targets=all" - fi - - tc_version_is_at_least 4.3 && set -- "$@" \ - --with-bugurl=http://bugs.gentoo.org/ \ - --with-pkgversion="${BRANDING_GCC_PKGVERSION}" - set -- ${confgcc} "$@" ${EXTRA_ECONF} - - # Nothing wrong with a good dose of verbosity - echo - einfo "PREFIX: ${PREFIX}" - einfo "BINPATH: ${BINPATH}" - einfo "LIBPATH: ${LIBPATH}" - einfo "DATAPATH: ${DATAPATH}" - einfo "STDCXX_INCDIR: ${STDCXX_INCDIR}" - echo - einfo "Configuring GCC with: ${@//--/\n\t--}" - echo - - # Build in a separate build tree - mkdir -p "${WORKDIR}"/build - pushd "${WORKDIR}"/build > /dev/null - - # and now to do the actual configuration - addwrite /dev/zero - echo "${S}"/configure "$@" - "${S}"/configure "$@" || die "failed to run configure" - - # return to whatever directory we were in before - popd > /dev/null -} - -# This function accepts one optional argument, the make target to be used. -# If ommitted, gcc_do_make will try to guess whether it should use all, -# profiledbootstrap, or bootstrap-lean depending on CTARGET and arch. An -# example of how to use this function: -# -# gcc_do_make all-target-libstdc++-v3 -# -# In addition to the target to be used, the following variables alter the -# behavior of this function: -# -# LDFLAGS -# Flags to pass to ld -# -# STAGE1_CFLAGS -# CFLAGS to use during stage1 of a gcc bootstrap -# -# BOOT_CFLAGS -# CFLAGS to use during stages 2+3 of a gcc bootstrap. -# -# Travis Tilley (04 Sep 2004) -# -gcc_do_make() { - # Fix for libtool-portage.patch - local OLDS=${S} - S=${WORKDIR}/build - - # Set make target to $1 if passed - [[ -n $1 ]] && GCC_MAKE_TARGET=$1 - # default target - if is_crosscompile || tc-is-cross-compiler ; then - # 3 stage bootstrapping doesnt quite work when you cant run the - # resulting binaries natively ^^; - GCC_MAKE_TARGET=${GCC_MAKE_TARGET-all} - else - GCC_MAKE_TARGET=${GCC_MAKE_TARGET-bootstrap-lean} - fi - - # the gcc docs state that parallel make isnt supported for the - # profiledbootstrap target, as collisions in profile collecting may occur. - [[ ${GCC_MAKE_TARGET} == "profiledbootstrap" ]] && export MAKEOPTS="${MAKEOPTS} -j1" - - # boundschecking seems to introduce parallel build issues - want_boundschecking && export MAKEOPTS="${MAKEOPTS} -j1" - - if [[ ${GCC_MAKE_TARGET} == "all" ]] ; then - STAGE1_CFLAGS=${STAGE1_CFLAGS-"${CFLAGS}"} - elif [[ $(gcc-version) == "3.4" && ${GCC_BRANCH_VER} == "3.4" ]] && gcc-specs-ssp ; then - # See bug #79852 - STAGE1_CFLAGS=${STAGE1_CFLAGS-"-O2"} - else - STAGE1_CFLAGS=${STAGE1_CFLAGS-"-O"} - fi - - if is_crosscompile; then - # In 3.4, BOOT_CFLAGS is never used on a crosscompile... - # but I'll leave this in anyways as someone might have had - # some reason for putting it in here... --eradicator - BOOT_CFLAGS=${BOOT_CFLAGS-"-O2"} - else - # we only want to use the system's CFLAGS if not building a - # cross-compiler. - BOOT_CFLAGS=${BOOT_CFLAGS-"$(get_abi_CFLAGS) ${CFLAGS}"} - fi - - pushd "${WORKDIR}"/build - - emake \ - LDFLAGS="${LDFLAGS}" \ - STAGE1_CFLAGS="${STAGE1_CFLAGS}" \ - LIBPATH="${LIBPATH}" \ - BOOT_CFLAGS="${BOOT_CFLAGS}" \ - ${GCC_MAKE_TARGET} \ - || die "emake failed with ${GCC_MAKE_TARGET}" - - if ! is_crosscompile && ! use nocxx && use doc ; then - if type -p doxygen > /dev/null ; then - if tc_version_is_at_least 4.3 ; then - cd "${CTARGET}"/libstdc++-v3/doc - emake doc-man-doxygen || ewarn "failed to make docs" - elif tc_version_is_at_least 3.0 ; then - cd "${CTARGET}"/libstdc++-v3 - emake doxygen-man || ewarn "failed to make docs" - fi - else - ewarn "Skipping libstdc++ manpage generation since you don't have doxygen installed" - fi - fi - - popd -} - -# This function will add ${GCC_CONFIG_VER} to the names of all shared libraries in the -# directory specified to avoid filename collisions between multiple slotted -# non-versioned gcc targets. If no directory is specified, it is assumed that -# you want -all- shared objects to have ${GCC_CONFIG_VER} added. Example -# -# add_version_to_shared ${D}/usr/$(get_libdir) -# -# Travis Tilley (05 Sep 2004) -# -add_version_to_shared() { - local sharedlib sharedlibdir - [[ -z $1 ]] \ - && sharedlibdir=${D} \ - || sharedlibdir=$1 - - for sharedlib in $(find ${sharedlibdir} -name *.so.*) ; do - if [[ ! -L ${sharedlib} ]] ; then - einfo "Renaming `basename "${sharedlib}"` to `basename "${sharedlib/.so*/}-${GCC_CONFIG_VER}.so.${sharedlib/*.so./}"`" - mv "${sharedlib}" "${sharedlib/.so*/}-${GCC_CONFIG_VER}.so.${sharedlib/*.so./}" \ - || die - pushd `dirname "${sharedlib}"` > /dev/null || die - ln -sf "`basename "${sharedlib/.so*/}-${GCC_CONFIG_VER}.so.${sharedlib/*.so./}"`" \ - "`basename "${sharedlib}"`" || die - popd > /dev/null || die - fi - done -} - -# This is mostly a stub function to be overwritten in an ebuild -gcc_do_filter_flags() { - strip-flags - - # In general gcc does not like optimization, and add -O2 where - # it is safe. This is especially true for gcc 3.3 + 3.4 - replace-flags -O? -O2 - - # ... sure, why not? - strip-unsupported-flags - - # dont want to funk ourselves - filter-flags '-mabi*' -m31 -m32 -m64 - - case ${GCC_BRANCH_VER} in - 3.2|3.3) - replace-cpu-flags k8 athlon64 opteron i686 x86-64 - replace-cpu-flags pentium-m pentium3m pentium3 - case $(tc-arch) in - amd64|x86) filter-flags '-mtune=*' ;; - # in gcc 3.3 there is a bug on ppc64 where if -mcpu is used, - # the compiler wrongly assumes a 32bit target - ppc64) filter-flags "-mcpu=*";; - esac - case $(tc-arch) in - amd64) replace-cpu-flags core2 nocona;; - x86) replace-cpu-flags core2 prescott;; - esac - - replace-cpu-flags G3 750 - replace-cpu-flags G4 7400 - replace-cpu-flags G5 7400 - - # XXX: should add a sed or something to query all supported flags - # from the gcc source and trim everything else ... - filter-flags -f{no-,}unit-at-a-time -f{no-,}web -mno-tls-direct-seg-refs - filter-flags -f{no-,}stack-protector{,-all} - filter-flags -fvisibility-inlines-hidden -fvisibility=hidden - ;; - 3.4|4.*) - case $(tc-arch) in - x86|amd64) filter-flags '-mcpu=*';; - *-macos) - # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25127 - [[ ${GCC_BRANCH_VER} == 4.0 || ${GCC_BRANCH_VER} == 4.1 ]] && \ - filter-flags '-mcpu=*' '-march=*' '-mtune=*' - ;; - esac - ;; - esac - - # Compile problems with these (bug #6641 among others)... - #filter-flags "-fno-exceptions -fomit-frame-pointer -fforce-addr" - - # CFLAGS logic (verified with 3.4.3): - # CFLAGS: - # This conflicts when creating a crosscompiler, so set to a sane - # default in this case: - # used in ./configure and elsewhere for the native compiler - # used by gcc when creating libiberty.a - # used by xgcc when creating libstdc++ (and probably others)! - # this behavior should be removed... - # - # CXXFLAGS: - # used by xgcc when creating libstdc++ - # - # STAGE1_CFLAGS (not used in creating a crosscompile gcc): - # used by ${CHOST}-gcc for building stage1 compiler - # - # BOOT_CFLAGS (not used in creating a crosscompile gcc): - # used by xgcc for building stage2/3 compiler - - if is_crosscompile ; then - # Set this to something sane for both native and target - CFLAGS="-O2 -pipe" - - local VAR="CFLAGS_"${CTARGET//-/_} - CXXFLAGS=${!VAR} - fi - - export GCJFLAGS=${GCJFLAGS:-${CFLAGS}} -} - -gcc_src_compile() { - gcc_do_filter_flags - einfo "CFLAGS=\"${CFLAGS}\"" - einfo "CXXFLAGS=\"${CXXFLAGS}\"" - - # For hardened gcc 4.3 piepatchset to build the hardened specs - # file (build.specs) to use when building gcc. - if ! tc_version_is_at_least 4.4 && want_minispecs ; then - setup_minispecs_gcc_build_specs - fi - # Build in a separate build tree - mkdir -p "${WORKDIR}"/build - pushd "${WORKDIR}"/build > /dev/null - - # Install our pre generated manpages if we do not have perl ... - [[ ! -x /usr/bin/perl ]] && [[ -n ${MAN_VER} ]] && \ - unpack gcc-${MAN_VER}-manpages.tar.bz2 - - einfo "Configuring ${PN} ..." - gcc_do_configure - - touch "${S}"/gcc/c-gperf.h - - # Do not make manpages if we do not have perl ... - [[ ! -x /usr/bin/perl ]] \ - && find "${WORKDIR}"/build -name '*.[17]' | xargs touch - - einfo "Compiling ${PN} ..." - gcc_do_make ${GCC_MAKE_TARGET} - - # Do not create multiple specs files for PIE+SSP if boundschecking is in - # USE, as we disable PIE+SSP when it is. - if [[ ${ETYPE} == "gcc-compiler" ]] && want_split_specs && ! want_minispecs; then - split_out_specs_files || die "failed to split out specs" - fi - - popd > /dev/null -} - -gcc_src_test() { - cd "${WORKDIR}"/build - emake -j1 -k check || ewarn "check failed and that sucks :(" -} - -gcc-library_src_install() { - # Do the 'make install' from the build directory - cd "${WORKDIR}"/build - S=${WORKDIR}/build \ - emake -j1 \ - DESTDIR="${D}" \ - prefix=${PREFIX} \ - bindir=${BINPATH} \ - includedir=${LIBPATH}/include \ - datadir=${DATAPATH} \ - mandir=${DATAPATH}/man \ - infodir=${DATAPATH}/info \ - LIBPATH="${LIBPATH}" \ - ${GCC_INSTALL_TARGET} || die - - if [[ ${GCC_LIB_COMPAT_ONLY} == "true" ]] ; then - rm -rf "${D}"${INCLUDEPATH} - rm -rf "${D}"${DATAPATH} - pushd "${D}"${LIBPATH}/ - rm *.a *.la *.so - popd - fi - - if [[ -n ${GCC_LIB_USE_SUBDIR} ]] ; then - mkdir -p "${WORKDIR}"/${GCC_LIB_USE_SUBDIR}/ - mv "${D}"${LIBPATH}/* "${WORKDIR}"/${GCC_LIB_USE_SUBDIR}/ - mv "${WORKDIR}"/${GCC_LIB_USE_SUBDIR}/ "${D}"${LIBPATH} - - dodir /etc/env.d - echo "LDPATH=\"${LIBPATH}/${GCC_LIB_USE_SUBDIR}/\"" >> "${D}"/etc/env.d/99${PN} - fi - - if [[ ${GCC_VAR_TYPE} == "non-versioned" ]] ; then - # if we're not using versioned directories, we need to use versioned - # filenames. - add_version_to_shared - fi -} - -gcc-compiler_src_install() { - local x= - - cd "${WORKDIR}"/build - # Do allow symlinks in private gcc include dir as this can break the build - find gcc/include*/ -type l -print0 | xargs -0 rm -f - # Remove generated headers, as they can cause things to break - # (ncurses, openssl, etc). - for x in $(find gcc/include*/ -name '*.h') ; do - grep -q 'It has been auto-edited by fixincludes from' "${x}" \ - && rm -f "${x}" - done - # Do the 'make install' from the build directory - S=${WORKDIR}/build \ - emake -j1 DESTDIR="${D}" install || die - # Punt some tools which are really only useful while building gcc - find "${D}" -name install-tools -prune -type d -exec rm -rf "{}" \; - # This one comes with binutils - find "${D}" -name libiberty.a -exec rm -f "{}" \; - - # Move the libraries to the proper location - gcc_movelibs - - # Basic sanity check - if ! is_crosscompile ; then - local EXEEXT - eval $(grep ^EXEEXT= "${WORKDIR}"/build/gcc/config.log) - [[ -r ${D}${BINPATH}/gcc${EXEEXT} ]] || die "gcc not found in ${D}" - fi - - dodir /etc/env.d/gcc - create_gcc_env_entry - - if want_split_specs ; then - if use hardened ; then - create_gcc_env_entry vanilla - fi - ! use hardened && hardened_gcc_works && create_gcc_env_entry hardened - if hardened_gcc_works || hardened_gcc_works pie ; then - create_gcc_env_entry hardenednossp - fi - if hardened_gcc_works || hardened_gcc_works ssp ; then - create_gcc_env_entry hardenednopie - fi - create_gcc_env_entry hardenednopiessp - - insinto ${LIBPATH} - doins "${WORKDIR}"/build/*.specs || die "failed to install specs" - fi - # Setup the gcc_env_entry for hardened gcc 4 with minispecs - if want_minispecs ; then - copy_minispecs_gcc_specs - fi - # Make sure we dont have stuff lying around that - # can nuke multiple versions of gcc - - gcc_slot_java - - # Move to compiler-specific directories - [[ -f ${D}${STDCXX_INCDIR}/cxxabi.h ]] && \ - mv -f "${D}"${STDCXX_INCDIR}/cxxabi.h "${D}"${LIBPATH}/include/ - - # These should be symlinks - dodir /usr/bin - cd "${D}"${BINPATH} - for x in cpp gcc g++ c++ g77 gcj gcjh gfortran ; do - # For some reason, g77 gets made instead of ${CTARGET}-g77... - # this should take care of that - [[ -f ${x} ]] && mv ${x} ${CTARGET}-${x} - - if [[ -f ${CTARGET}-${x} ]] && ! is_crosscompile ; then - ln -sf ${CTARGET}-${x} ${x} - - # Create version-ed symlinks - dosym ${BINPATH}/${CTARGET}-${x} \ - /usr/bin/${CTARGET}-${x}-${GCC_CONFIG_VER} - dosym ${BINPATH}/${CTARGET}-${x} \ - /usr/bin/${x}-${GCC_CONFIG_VER} - fi - - if [[ -f ${CTARGET}-${x}-${GCC_CONFIG_VER} ]] ; then - rm -f ${CTARGET}-${x}-${GCC_CONFIG_VER} - ln -sf ${CTARGET}-${x} ${CTARGET}-${x}-${GCC_CONFIG_VER} - fi - done - - # I do not know if this will break gcj stuff, so I'll only do it for - # objc for now; basically "ffi.h" is the correct file to include, - # but it gets installed in .../GCCVER/include and yet it does - # "#include " which (correctly, as it's an "extra" file) - # is installed in .../GCCVER/include/libffi; the following fixes - # ffi.'s include of ffitarget.h - Armando Di Cianno - if [[ -d ${D}${LIBPATH}/include/libffi ]] ; then - mv -i "${D}"${LIBPATH}/include/libffi/* "${D}"${LIBPATH}/include || die - rm -r "${D}"${LIBPATH}/include/libffi || die - fi - - # Now do the fun stripping stuff - env RESTRICT="" CHOST=${CHOST} prepstrip "${D}${BINPATH}" - env RESTRICT="" CHOST=${CTARGET} prepstrip "${D}${LIBPATH}" - # gcc used to install helper binaries in lib/ but then moved to libexec/ - [[ -d ${D}${PREFIX}/libexec/gcc ]] && \ - env RESTRICT="" CHOST=${CHOST} prepstrip "${D}${PREFIX}/libexec/gcc/${CTARGET}/${GCC_CONFIG_VER}" - - cd "${S}" - if is_crosscompile; then - rm -rf "${D}"/usr/share/{man,info} - rm -rf "${D}"${DATAPATH}/{man,info} - else - local cxx_mandir=${WORKDIR}/build/${CTARGET}/libstdc++-v3/docs/doxygen/man - if [[ -d ${cxx_mandir} ]] ; then - # clean bogus manpages #113902 - find "${cxx_mandir}" -name '*_build_*' -exec rm {} \; - cp -r "${cxx_mandir}"/man? "${D}/${DATAPATH}"/man/ - fi - has noinfo ${FEATURES} \ - && rm -r "${D}/${DATAPATH}"/info \ - || prepinfo "${DATAPATH}" - has noman ${FEATURES} \ - && rm -r "${D}/${DATAPATH}"/man \ - || prepman "${DATAPATH}" - fi - # prune empty dirs left behind - for x in 1 2 3 4 ; do - find "${D}" -type d -exec rmdir "{}" \; >& /dev/null - done - - # install testsuite results - if use test; then - docinto testsuite - find "${WORKDIR}"/build -type f -name "*.sum" -print0 | xargs -0 dodoc - find "${WORKDIR}"/build -type f -path "*/testsuite/*.log" -print0 \ - | xargs -0 dodoc - fi - - # Rather install the script, else portage with changing $FILESDIR - # between binary and source package borks things .... - if ! is_crosscompile ; then - insinto "${DATAPATH}" - if tc_version_is_at_least 4.0 ; then - newins "${GCC_FILESDIR}"/awk/fixlafiles.awk-no_gcc_la fixlafiles.awk || die - find "${D}/${LIBPATH}" -name libstdc++.la -type f -exec rm "{}" \; - else - doins "${GCC_FILESDIR}"/awk/fixlafiles.awk || die - fi - exeinto "${DATAPATH}" - doexe "${GCC_FILESDIR}"/fix_libtool_files.sh || die - doexe "${GCC_FILESDIR}"/c{89,99} || die - fi - - # use gid of 0 because some stupid ports don't have - # the group 'root' set to gid 0 - chown -R root:0 "${D}"${LIBPATH} - - # Move pretty-printers to gdb datadir to shut ldconfig up - gdbdir=/usr/share/gdb/auto-load - for module in $(find "${D}" -iname "*-gdb.py" -print); do - insinto ${gdbdir}/$(dirname "${module/${D}/}" | \ - sed -e "s:/lib/:/$(get_libdir)/:g") - doins "${module}" - rm "${module}" - done -} - -gcc_slot_java() { - local x - - # Move Java headers to compiler-specific dir - for x in "${D}"${PREFIX}/include/gc*.h "${D}"${PREFIX}/include/j*.h ; do - [[ -f ${x} ]] && mv -f "${x}" "${D}"${LIBPATH}/include/ - done - for x in gcj gnu java javax org ; do - if [[ -d ${D}${PREFIX}/include/${x} ]] ; then - dodir /${LIBPATH}/include/${x} - mv -f "${D}"${PREFIX}/include/${x}/* "${D}"${LIBPATH}/include/${x}/ - rm -rf "${D}"${PREFIX}/include/${x} - fi - done - - if [[ -d ${D}${PREFIX}/lib/security ]] || [[ -d ${D}${PREFIX}/$(get_libdir)/security ]] ; then - dodir /${LIBPATH}/security - mv -f "${D}"${PREFIX}/lib*/security/* "${D}"${LIBPATH}/security - rm -rf "${D}"${PREFIX}/lib*/security - fi - - # Move libgcj.spec to compiler-specific directories - [[ -f ${D}${PREFIX}/lib/libgcj.spec ]] && \ - mv -f "${D}"${PREFIX}/lib/libgcj.spec "${D}"${LIBPATH}/libgcj.spec - - # SLOT up libgcj.pc (and let gcc-config worry about links) - local libgcj=$(find "${D}"${PREFIX}/lib/pkgconfig/ -name 'libgcj*.pc') - if [[ -n ${libgcj} ]] ; then - sed -i "/^libdir=/s:=.*:=${LIBPATH}:" "${libgcj}" - mv "${libgcj}" "${D}"/usr/lib/pkgconfig/libgcj-${GCC_PV}.pc || die - fi - - # Rename jar because it could clash with Kaffe's jar if this gcc is - # primary compiler (aka don't have the - extension) - cd "${D}"${BINPATH} - [[ -f jar ]] && mv -f jar gcj-jar -} - -# Move around the libs to the right location. For some reason, -# when installing gcc, it dumps internal libraries into /usr/lib -# instead of the private gcc lib path -gcc_movelibs() { - # older versions of gcc did not support --print-multi-os-directory - tc_version_is_at_least 3.0 || return 0 - - local multiarg removedirs="" - for multiarg in $($(XGCC) -print-multi-lib) ; do - multiarg=${multiarg#*;} - multiarg=${multiarg//@/ -} - - local OS_MULTIDIR=$($(XGCC) ${multiarg} --print-multi-os-directory) - local MULTIDIR=$($(XGCC) ${multiarg} --print-multi-directory) - local TODIR=${D}${LIBPATH}/${MULTIDIR} - local FROMDIR= - - [[ -d ${TODIR} ]] || mkdir -p ${TODIR} - - for FROMDIR in \ - ${LIBPATH}/${OS_MULTIDIR} \ - ${LIBPATH}/../${MULTIDIR} \ - ${PREFIX}/lib/${OS_MULTIDIR} \ - ${PREFIX}/${CTARGET}/lib/${OS_MULTIDIR} \ - ${PREFIX}/lib/${MULTIDIR} - do - removedirs="${removedirs} ${FROMDIR}" - FROMDIR=${D}${FROMDIR} - if [[ ${FROMDIR} != "${TODIR}" && -d ${FROMDIR} ]] ; then - local files=$(find "${FROMDIR}" -maxdepth 1 ! -type d 2>/dev/null) - if [[ -n ${files} ]] ; then - mv ${files} "${TODIR}" - fi - fi - done - fix_libtool_libdir_paths "${LIBPATH}/${MULTIDIR}" - done - - # We remove directories separately to avoid this case: - # mv SRC/lib/../lib/*.o DEST - # rmdir SRC/lib/../lib/ - # mv SRC/lib/../lib32/*.o DEST # Bork - for FROMDIR in ${removedirs} ; do - rmdir "${D}"${FROMDIR} >& /dev/null - done - find "${D}" -type d | xargs rmdir >& /dev/null -} - -#----<< src_* >>---- - -#---->> unorganized crap in need of refactoring follows - -# gcc_quick_unpack will unpack the gcc tarball and patches in a way that is -# consistant with the behavior of get_gcc_src_uri. The only patch it applies -# itself is the branch update if present. -# -# Travis Tilley (03 Sep 2004) -# -gcc_quick_unpack() { - pushd "${WORKDIR}" > /dev/null - export PATCH_GCC_VER=${PATCH_GCC_VER:-${GCC_RELEASE_VER}} - export UCLIBC_GCC_VER=${UCLIBC_GCC_VER:-${PATCH_GCC_VER}} - export PIE_GCC_VER=${PIE_GCC_VER:-${GCC_RELEASE_VER}} - export PP_GCC_VER=${PP_GCC_VER:-${GCC_RELEASE_VER}} - export HTB_GCC_VER=${HTB_GCC_VER:-${GCC_RELEASE_VER}} - export SPECS_GCC_VER=${SPECS_GCC_VER:-${GCC_RELEASE_VER}} - - if [[ -n ${GCC_A_FAKEIT} ]] ; then - unpack ${GCC_A_FAKEIT} - elif [[ -n ${PRERELEASE} ]] ; then - unpack gcc-${PRERELEASE}.tar.bz2 - elif [[ -n ${SNAPSHOT} ]] ; then - unpack gcc-${SNAPSHOT}.tar.bz2 - else - unpack gcc-${GCC_RELEASE_VER}.tar.bz2 - # We want branch updates to be against a release tarball - if [[ -n ${BRANCH_UPDATE} ]] ; then - pushd "${S}" > /dev/null - epatch "${DISTDIR}"/gcc-${GCC_RELEASE_VER}-branch-update-${BRANCH_UPDATE}.patch.bz2 - popd > /dev/null - fi - fi - - if [[ -n ${D_VER} ]] && use d ; then - pushd "${S}"/gcc > /dev/null - unpack gdc-${D_VER}-src.tar.bz2 - cd .. - ebegin "Adding support for the D language" - ./gcc/d/setup-gcc.sh >& "${T}"/dgcc.log - if ! eend $? ; then - eerror "The D gcc package failed to apply" - eerror "Please include this log file when posting a bug report:" - eerror " ${T}/dgcc.log" - die "failed to include the D language" - fi - popd > /dev/null - fi - - [[ -n ${PATCH_VER} ]] && \ - unpack gcc-${PATCH_GCC_VER}-patches-${PATCH_VER}_${COST_SUFFIX}.tar.bz2 - - [[ -n ${UCLIBC_VER} ]] && \ - unpack gcc-${UCLIBC_GCC_VER}-uclibc-patches-${UCLIBC_VER}_${COST_SUFFIX}.tar.bz2 - - if want_ssp ; then - if [[ -n ${PP_FVER} ]] ; then - # The gcc 3.4 propolice versions are meant to be unpacked to ${S} - pushd "${S}" > /dev/null - unpack protector-${PP_FVER}.tar.gz - popd > /dev/null - else - unpack gcc-${PP_GCC_VER}-ssp-${PP_VER}.tar.bz2 - fi - fi - - if want_pie ; then - if [[ -n ${PIE_CORE} ]] ; then - unpack ${PIE_CORE} - else - unpack gcc-${PIE_GCC_VER}-piepatches-v${PIE_VER}_${COST_SUFFIX}.tar.bz2 - fi - [[ -n ${SPECS_VER} ]] && \ - unpack gcc-${SPECS_GCC_VER}-specs-${SPECS_VER}.tar.bz2 - fi - - want_boundschecking && \ - unpack "bounds-checking-gcc-${HTB_GCC_VER}-${HTB_VER}.patch.bz2" - - popd > /dev/null -} - -# Exclude any unwanted patches, as specified by the following variables: -# -# GENTOO_PATCH_EXCLUDE -# List of filenames, relative to ${WORKDIR}/patch/ -# -# PIEPATCH_EXCLUDE -# List of filenames, relative to ${WORKDIR}/piepatch/ -# -# Travis Tilley (03 Sep 2004) -# -exclude_gcc_patches() { - local i - for i in ${GENTOO_PATCH_EXCLUDE} ; do - if [[ -f ${WORKDIR}/patch/${i} ]] ; then - einfo "Excluding patch ${i}" - rm -f "${WORKDIR}"/patch/${i} || die "failed to delete ${i}" - fi - done - for i in ${PIEPATCH_EXCLUDE} ; do - if [[ -f ${WORKDIR}/piepatch/${i} ]] ; then - einfo "Excluding piepatch ${i}" - rm -f "${WORKDIR}"/piepatch/${i} || die "failed to delete ${i}" - fi - done -} - -# Try to apply some stub patches so that gcc won't error out when -# passed parameters like -fstack-protector but no ssp is found -do_gcc_stub() { - local v stub_patch="" - for v in ${GCC_RELEASE_VER} ${GCC_BRANCH_VER} ; do - stub_patch=${GCC_FILESDIR}/stubs/gcc-${v}-$1-stub.patch - if [[ -e ${stub_patch} ]] && ! use vanilla ; then - EPATCH_SINGLE_MSG="Applying stub patch for $1 ..." \ - epatch "${stub_patch}" - return 0 - fi - done -} - -do_gcc_HTB_patches() { - if ! want_boundschecking || \ - (want_ssp && [[ ${HTB_EXCLUSIVE} == "true" ]]) - then - do_gcc_stub htb - return 0 - fi - - # modify the bounds checking patch with a regression patch - epatch "${WORKDIR}/bounds-checking-gcc-${HTB_GCC_VER}-${HTB_VER}.patch" - BRANDING_GCC_PKGVERSION="${BRANDING_GCC_PKGVERSION}, HTB-${HTB_GCC_VER}-${HTB_VER}" -} - -# patch in ProPolice Stack Smashing protection -do_gcc_SSP_patches() { - # PARISC has no love ... it's our stack :( - if [[ $(tc-arch) == "hppa" ]] || \ - ! want_ssp || \ - (want_boundschecking && [[ ${HTB_EXCLUSIVE} == "true" ]]) - then - do_gcc_stub ssp - return 0 - fi - - local ssppatch - local sspdocs - - if [[ -n ${PP_FVER} ]] ; then - # Etoh keeps changing where files are and what the patch is named - if tc_version_is_at_least 3.4.1 ; then - # >3.4.1 uses version in patch name, and also includes docs - ssppatch="${S}/gcc_${PP_VER}.dif" - sspdocs="yes" - elif tc_version_is_at_least 3.4.0 ; then - # >3.4 put files where they belong and 3_4 uses old patch name - ssppatch="${S}/protector.dif" - sspdocs="no" - elif tc_version_is_at_least 3.2.3 ; then - # earlier versions have no directory structure or docs - mv "${S}"/protector.{c,h} "${S}"/gcc - ssppatch="${S}/protector.dif" - sspdocs="no" - fi - else - # Just start packaging the damn thing ourselves - mv "${WORKDIR}"/ssp/protector.{c,h} "${S}"/gcc/ - ssppatch=${WORKDIR}/ssp/gcc-${PP_GCC_VER}-ssp.patch - # allow boundschecking and ssp to get along - (want_boundschecking && [[ -e ${WORKDIR}/ssp/htb-ssp.patch ]]) \ - && patch -s "${ssppatch}" "${WORKDIR}"/ssp/htb-ssp.patch - fi - - [[ -z ${ssppatch} ]] && die "Sorry, SSP is not supported in this version" - epatch ${ssppatch} - - if [[ ${PN} == "gcc" && ${sspdocs} == "no" ]] ; then - epatch "${GCC_FILESDIR}"/pro-police-docs.patch - fi - - # Don't build crtbegin/end with ssp - sed -e 's|^CRTSTUFF_CFLAGS = |CRTSTUFF_CFLAGS = -fno-stack-protector |'\ - -i gcc/Makefile.in || die "Failed to update crtstuff!" - - # if gcc in a stage3 defaults to ssp, is version 3.4.0 and a stage1 is built - # the build fails building timevar.o w/: - # cc1: stack smashing attack in function ix86_split_to_parts() - if use build && tc_version_is_at_least 3.4.0 ; then - if gcc -dumpspecs | grep -q "fno-stack-protector:" ; then - epatch "${GCC_FILESDIR}"/3.4.0/gcc-3.4.0-cc1-no-stack-protector.patch - fi - fi - - BRANDING_GCC_PKGVERSION="${BRANDING_GCC_PKGVERSION}, ssp-${PP_FVER:-${PP_GCC_VER}-${PP_VER}}" - if want_libssp ; then - update_gcc_for_libssp - else - update_gcc_for_libc_ssp - fi - - # Don't build libgcc with ssp - sed -e 's|^\(LIBGCC2_CFLAGS.*\)$|\1 -fno-stack-protector|' \ - -i gcc/Makefile.in || die "Failed to update gcc!" -} - -# If glibc or uclibc has been patched to provide the necessary symbols itself, -# then lets use those for SSP instead of libgcc. -update_gcc_for_libc_ssp() { - if libc_has_ssp ; then - einfo "Updating gcc to use SSP from libc ..." - sed -e 's|^\(LIBGCC2_CFLAGS.*\)$|\1 -D_LIBC_PROVIDES_SSP_|' \ - -i "${S}"/gcc/Makefile.in || die "Failed to update gcc!" - fi -} - -# a split out non-libc non-libgcc ssp requires additional spec logic changes -update_gcc_for_libssp() { - einfo "Updating gcc to use SSP from libssp..." - sed -e 's|^\(INTERNAL_CFLAGS.*\)$|\1 -D_LIBSSP_PROVIDES_SSP_|' \ - -i "${S}"/gcc/Makefile.in || die "Failed to update gcc!" -} - -# do various updates to PIE logic -do_gcc_PIE_patches() { - if ! want_pie || \ - (want_boundschecking && [[ ${HTB_EXCLUSIVE} == "true" ]]) - then - return 0 - fi - - want_boundschecking \ - && rm -f "${WORKDIR}"/piepatch/*/*-boundschecking-no.patch* \ - || rm -f "${WORKDIR}"/piepatch/*/*-boundschecking-yes.patch* - - use vanilla && return 0 - - if tc_version_is_at_least 4.3.2; then - guess_patch_type_in_dir "${WORKDIR}"/piepatch/ - EPATCH_MULTI_MSG="Applying pie patches ..." \ - epatch "${WORKDIR}"/piepatch/ - else - guess_patch_type_in_dir "${WORKDIR}"/piepatch/upstream - - # corrects startfile/endfile selection and shared/static/pie flag usage - EPATCH_MULTI_MSG="Applying upstream pie patches ..." \ - epatch "${WORKDIR}"/piepatch/upstream - # adds non-default pie support (rs6000) - EPATCH_MULTI_MSG="Applying non-default pie patches ..." \ - epatch "${WORKDIR}"/piepatch/nondef - # adds default pie support (rs6000 too) if DEFAULT_PIE[_SSP] is defined - EPATCH_MULTI_MSG="Applying default pie patches ..." \ - epatch "${WORKDIR}"/piepatch/def - fi - # we want to be able to control the pie patch logic via something other - # than ALL_CFLAGS... - sed -e '/^ALL_CFLAGS/iHARD_CFLAGS = ' \ - -e 's|^ALL_CFLAGS = |ALL_CFLAGS = $(HARD_CFLAGS) |' \ - -i "${S}"/gcc/Makefile.in - - BRANDING_GCC_PKGVERSION="${BRANDING_GCC_PKGVERSION}, pie-${PIE_VER}" -} - -should_we_gcc_config() { - # we always want to run gcc-config if we're bootstrapping, otherwise - # we might get stuck with the c-only stage1 compiler - use bootstrap && return 0 - use build && return 0 - - # if the current config is invalid, we definitely want a new one - # Note: due to bash quirkiness, the following must not be 1 line - local curr_config - curr_config=$(env -i ROOT="${ROOT}" gcc-config -c ${CTARGET} 2>&1) || return 0 - - # if the previously selected config has the same major.minor (branch) as - # the version we are installing, then it will probably be uninstalled - # for being in the same SLOT, make sure we run gcc-config. - local curr_config_ver=$(env -i ROOT="${ROOT}" gcc-config -S ${curr_config} | awk '{print $2}') - - local curr_branch_ver=$(get_version_component_range 1-2 ${curr_config_ver}) - - # If we're using multislot, just run gcc-config if we're installing - # to the same profile as the current one. - use multislot && return $([[ ${curr_config_ver} == ${GCC_CONFIG_VER} ]]) - - if [[ ${curr_branch_ver} == ${GCC_BRANCH_VER} ]] ; then - return 0 - else - # if we're installing a genuinely different compiler version, - # we should probably tell the user -how- to switch to the new - # gcc version, since we're not going to do it for him/her. - # We don't want to switch from say gcc-3.3 to gcc-3.4 right in - # the middle of an emerge operation (like an 'emerge -e world' - # which could install multiple gcc versions). - einfo "The current gcc config appears valid, so it will not be" - einfo "automatically switched for you. If you would like to" - einfo "switch to the newly installed gcc version, do the" - einfo "following:" - echo - einfo "gcc-config ${CTARGET}-${GCC_CONFIG_VER}" - einfo "source /etc/profile" - echo - ebeep - return 1 - fi -} - -do_gcc_config() { - if ! should_we_gcc_config ; then - env -i ROOT="${ROOT}" gcc-config --use-old --force - return 0 - fi - - local current_gcc_config="" current_specs="" use_specs="" - - current_gcc_config=$(env -i ROOT="${ROOT}" gcc-config -c ${CTARGET} 2>/dev/null) - if [[ -n ${current_gcc_config} ]] ; then - # figure out which specs-specific config is active - current_specs=$(gcc-config -S ${current_gcc_config} | awk '{print $3}') - [[ -n ${current_specs} ]] && use_specs=-${current_specs} - fi - if [[ -n ${use_specs} ]] && \ - [[ ! -e ${ROOT}/etc/env.d/gcc/${CTARGET}-${GCC_CONFIG_VER}${use_specs} ]] - then - ewarn "The currently selected specs-specific gcc config," - ewarn "${current_specs}, doesn't exist anymore. This is usually" - ewarn "due to enabling/disabling hardened or switching to a version" - ewarn "of gcc that doesnt create multiple specs files. The default" - ewarn "config will be used, and the previous preference forgotten." - ebeep - epause - use_specs="" - fi - - gcc-config ${CTARGET}-${GCC_CONFIG_VER}${use_specs} -} - -# This function allows us to gentoo-ize gcc's version number and bugzilla -# URL without needing to use patches. -gcc_version_patch() { - # gcc-4.3+ has configure flags (whoo!) - tc_version_is_at_least 4.3 && return 0 - - local version_string=${GCC_CONFIG_VER} - [[ -n ${BRANCH_UPDATE} ]] && version_string="${version_string} ${BRANCH_UPDATE}" - - einfo "patching gcc version: ${version_string} (${BRANDING_GCC_PKGVERSION})" - - if grep -qs VERSUFFIX "${S}"/gcc/version.c ; then - sed -i -e "s~VERSUFFIX \"\"~VERSUFFIX \" (${BRANDING_GCC_PKGVERSION})\"~" \ - "${S}"/gcc/version.c || die "failed to update VERSUFFIX with Gentoo branding" - else - version_string="${version_string} (${BRANDING_GCC_PKGVERSION})" - sed -i -e "s~\(const char version_string\[\] = \"\).*\(\".*\)~\1$version_string\2~" \ - "${S}"/gcc/version.c || die "failed to update version.c with Gentoo branding." - fi - sed -i -e 's~gcc\.gnu\.org\/bugs\.html~bugs\.gentoo\.org\/~' \ - "${S}"/gcc/version.c || die "Failed to change the bug URL" -} - -# The purpose of this DISGUSTING gcc multilib hack is to allow 64bit libs -# to live in lib instead of lib64 where they belong, with 32bit libraries -# in lib32. This hack has been around since the beginning of the amd64 port, -# and we're only now starting to fix everything that's broken. Eventually -# this should go away. -# -# Travis Tilley (03 Sep 2004) -# -disgusting_gcc_multilib_HACK() { - local config - local libdirs - if has_multilib_profile ; then - case $(tc-arch) in - amd64) - config="i386/t-linux64" - libdirs="../$(get_abi_LIBDIR amd64) ../$(get_abi_LIBDIR x86)" \ - ;; - ppc64) - config="rs6000/t-linux64" - libdirs="../$(get_abi_LIBDIR ppc64) ../$(get_abi_LIBDIR ppc)" \ - ;; - esac - else - die "Your profile is no longer supported by portage." - fi - - einfo "updating multilib directories to be: ${libdirs}" - sed -i -e "s:^MULTILIB_OSDIRNAMES.*:MULTILIB_OSDIRNAMES = ${libdirs}:" "${S}"/gcc/config/${config} -} - -disable_multilib_libjava() { - if is_gcj ; then - # We dont want a multilib libjava, so lets use this hack taken from fedora - pushd "${S}" > /dev/null - sed -i -e 's/^all: all-redirect/ifeq (\$(MULTISUBDIR),)\nall: all-redirect\nelse\nall:\n\techo Multilib libjava build disabled\nendif/' libjava/Makefile.in - sed -i -e 's/^install: install-redirect/ifeq (\$(MULTISUBDIR),)\ninstall: install-redirect\nelse\ninstall:\n\techo Multilib libjava install disabled\nendif/' libjava/Makefile.in - sed -i -e 's/^check: check-redirect/ifeq (\$(MULTISUBDIR),)\ncheck: check-redirect\nelse\ncheck:\n\techo Multilib libjava check disabled\nendif/' libjava/Makefile.in - sed -i -e 's/^all: all-recursive/ifeq (\$(MULTISUBDIR),)\nall: all-recursive\nelse\nall:\n\techo Multilib libjava build disabled\nendif/' libjava/Makefile.in - sed -i -e 's/^install: install-recursive/ifeq (\$(MULTISUBDIR),)\ninstall: install-recursive\nelse\ninstall:\n\techo Multilib libjava install disabled\nendif/' libjava/Makefile.in - sed -i -e 's/^check: check-recursive/ifeq (\$(MULTISUBDIR),)\ncheck: check-recursive\nelse\ncheck:\n\techo Multilib libjava check disabled\nendif/' libjava/Makefile.in - popd > /dev/null - fi -} - -# make sure the libtool archives have libdir set to where they actually -# -are-, and not where they -used- to be. also, any dependencies we have -# on our own .la files need to be updated. -fix_libtool_libdir_paths() { - pushd "${D}" >/dev/null - - pushd "./${1}" >/dev/null - local dir="${PWD#${D%/}}" - local allarchives=$(echo *.la) - allarchives="\(${allarchives// /\\|}\)" - popd >/dev/null - - sed -i \ - -e "/^libdir=/s:=.*:='${dir}':" \ - ./${dir}/*.la - sed -i \ - -e "/^dependency_libs=/s:/[^ ]*/${allarchives}:${LIBPATH}/\1:g" \ - $(find ./${PREFIX}/lib* -maxdepth 3 -name '*.la') \ - ./${dir}/*.la - - popd >/dev/null -} - -is_multilib() { - [[ ${GCCMAJOR} < 3 ]] && return 1 - case ${CTARGET} in - mips64*|powerpc64*|s390x*|sparc*|x86_64*) - has_multilib_profile || use multilib ;; - *-*-solaris*|*-apple-darwin*|*-mint*) - use multilib ;; - *) false ;; - esac -} - -is_cxx() { - gcc-lang-supported 'c++' || return 1 - ! use nocxx -} - -is_d() { - gcc-lang-supported d || return 1 - use d -} - -is_f77() { - gcc-lang-supported f77 || return 1 - use fortran -} - -is_f95() { - gcc-lang-supported f95 || return 1 - use fortran -} - -is_fortran() { - gcc-lang-supported fortran || return 1 - use fortran -} - -is_gcj() { - gcc-lang-supported java || return 1 - use gcj -} - -is_libffi() { - has libffi ${IUSE} || return 1 - use libffi -} - -is_objc() { - gcc-lang-supported objc || return 1 - use objc -} - -is_objcxx() { - gcc-lang-supported 'obj-c++' || return 1 - use objc++ -} - -is_ada() { - gcc-lang-supported ada || return 1 - use ada -} - -is_treelang() { - has boundschecking ${IUSE} && use boundschecking && return 1 #260532 - is_crosscompile && return 1 #199924 - gcc-lang-supported treelang || return 1 - #use treelang - return 0 -} diff --git a/sdk_container/src/third_party/coreos-overlay/eclass/useradd.eclass b/sdk_container/src/third_party/coreos-overlay/eclass/useradd.eclass deleted file mode 100644 index c40fa0bf37..0000000000 --- a/sdk_container/src/third_party/coreos-overlay/eclass/useradd.eclass +++ /dev/null @@ -1,132 +0,0 @@ -# Copyright (c) 2009 The Chromium OS Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. -# $Header: $ - -# -# useradd.eclass -# -# Adds a mechanism for adding users/groups into alternate roots. -# -# This will likely go away. -# -# Authors: -# Google, inc. -# - -HOMEPAGE="http://www.chromium.org/" - -# Before we manipulate users at all, we want to make sure that -# passwd/group/shadow is initialized in the first place. That's -# what baselayout does. -if [ "${PN}" != "baselayout" ]; then - DEPEND="sys-apps/baselayout" - RDEPEND="sys-apps/baselayout" -fi - -# Tests if the user already exists in the passwd file. -# -# $1 - Username (e.g. "messagebus") -user_exists() { - grep -e "^$1\:" "${ROOT}/etc/passwd" > /dev/null 2>&1 -} - -# Tests if the group already exists in the group file. -# -# $1 - Groupname (e.g. "messagebus") -group_exists() { - grep -e "^$1\:" "${ROOT}/etc/group" > /dev/null 2>&1 -} - -# Add entry to /etc/passwd -# -# $1 - Username (e.g. "messagebus") -# $2 - "*" to indicate not shadowed, "x" to indicate shadowed -# $3 - UID (e.g. 200) -# $4 - GID (e.g. 200) -# $5 - full name (e.g. "") -# $6 - home dir (e.g. "/home/foo" or "/var/run/dbus") -# $7 - shell (e.g. "/bin/sh" or "/bin/false") -add_user() { - if user_exists "$1"; then - elog "Skipping add_user of existing user: '$1'" - return - fi - - echo "${1}:${2}:${3}:${4}:${5}:${6}:${7}" >> "${ROOT}/etc/passwd" -} - -# Remove entry from /etc/passwd -# -# $1 - Username -remove_user() { - [ -e "${ROOT}/etc/passwd" ] && sed -i -e /^${1}:.\*$/d "${ROOT}/etc/passwd" -} - -# Add entry to /etc/shadow -# -# $1 - Username -# $2 - Crypted password -add_shadow() { - echo "${1}:${2}:14500:0:99999::::" >> "${ROOT}/etc/shadow" -} - -# Remove entry from /etc/shadow -# -# $1 - Username -remove_shadow() { - [ -e "${ROOT}/etc/shadow" ] && sed -i -e /^${1}:.\*$/d "${ROOT}/etc/shadow" -} - -# Add entry to /etc/group -# $1 - Groupname (e.g. "messagebus") -# $2 - GID (e.g. 200) -add_group() { - if group_exists "$1"; then - elog "Skipping add_group of existing group: '$1'" - return - fi - echo "${1}:x:${2}:" >> "${ROOT}/etc/group" -} - -# Copies user entry from host passwd file if it already exists or else -# creates a new user using add_user. -# -# See add_user for argument list. -copy_or_add_user() { - local username="$1" - - if user_exists "$1"; then - elog "Skipping copy_or_add_user of existing user '$1'" - return - fi - - local entry=$(grep -e "^$1\:" /etc/passwd) - if [ -n "$entry" ]; then - elog "Copying existing passwd entry from root: '$entry'" - echo "$entry" >> "${ROOT}/etc/passwd" - else - add_user "$@" - fi -} - -# Copies group entry from host group file if it already exists or else -# creates a new group using add_group. -# -# See add_group for argument list. -copy_or_add_group() { - local groupname="$1" - - if group_exists "$1"; then - elog "Skipping copy_or_add_group of existing group '$1'" - return - fi - - local entry=$(grep -e "^$1\:" /etc/group) - if [ -n "$entry" ]; then - elog "Copying existing group entry from root: '$entry'" - echo "$entry" >> "${ROOT}/etc/group" - else - add_group "$@" - fi -}