# Copyright 1999-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: $ # @ECLASS: games-bin.eclass # @MAINTAINER: # Julian Ospald # games herd # @BLURB: games eclass for binary games such as humble bundle sales # @DESCRIPTION: # RESTRICT, GAMES_DIR, QA_PREBUILT and S are preset, but can be overridden # as usual when set after the inherit line (see "ECLASS DEFAULTS"). # E.g. GAMES_DIR var is preset to ${GAMES_PREFIX_OPT}/${PN} and can be used # in src_install. # # remove_bundled_libs is executed automatically in games-bin_src_prepare # if IUSE="bundled-libs" is present and if the user has disabled it. # Use GAMES_PRESERVE_BUNDLED_LIBS array to always preserve particular # libraries, e.g. when they are not in the tree. inherit unpacker games EXPORT_FUNCTIONS pkg_nofetch src_unpack src_prepare # ECLASS DEFAULTS RESTRICT="bindist fetch" GAMES_DIR="${GAMES_PREFIX_OPT}/${PN}" QA_PREBUILT="${GAMES_DIR#/}/*}" S=${WORKDIR} # @ECLASS-VARIABLE: GAMES_DIR # @DESCRIPTION: # Install dir to be used with insinto/doins, # default is: ${GAMES_PREFIX_OPT}/${PN}. # @ECLASS-VARIABLE: GAMES_PRESERVE_BUNDLED_LIBS # @DESCRIPTION: # Preserve list for bundled libraries, must be a bash ARRAY! # Supports wildcard (libGLEW.so*), but only filenames, not paths. # Supports _$ARCH suffix for the var (GAMES_PRESERVE_BUNDLED_LIBS_amd64). # @FUNCTION: remove_bundled_libs # @USAGE: [] # @DESCRIPTION: # Looks recursively for libraries and symlinks matching # lib*.so* in (default is ${S}) and removes them. remove_bundled_libs() { local p i x local dir=${1:-${S}} # default search pattern for "find" local search_pattern=(-name "lib*.so*") einfo "Removing bundled libraries" for p in GAMES_PRESERVE_BUNDLED_LIBS{,_${ARCH}} ; do if [[ "$(declare -p ${p} 2>/dev/null 2>&1)" == "declare -a"* ]]; then x=${p}[@] # preserve the array for i in "${!x}" ; do # no paths, use ${1} instead for micro-management [[ ${i} == */* ]] && die "GAMES_PRESERVE_BUNDLED_LIBS must not contain paths" # add exclusions to the search pattern search_pattern+=( -a \! -name "${i}") done fi done find "${dir}" \( -type f -o -type l \) \( "${search_pattern[@]}" \) -print -delete || die } games-bin_pkg_nofetch() { einfo einfo "Please buy & download ${SRC_URI} from:" einfo " ${HOMEPAGE}" einfo "and move it to ${DISTDIR}" einfo } games-bin_src_unpack() { unpacker_src_unpack } games-bin_src_prepare() { if has bundled-libs ${IUSE} ; then use bundled-libs || remove_bundled_libs fi }