From: hasufell <hasufell@gentoo.org>
To: gentoo-dev@lists.gentoo.org
Cc: games@gentoo.org, mgorny@gentoo.org, ryao@gentoo.org
Subject: [gentoo-dev] New eclass: games-bin (review/comments)
Date: Sat, 23 Mar 2013 21:53:59 +0100 [thread overview]
Message-ID: <514E1667.8030604@gentoo.org> (raw)
[-- Attachment #1: Type: text/plain, Size: 1798 bytes --]
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
After packaging the complete humble bundle last time I noticed a bit
of code duplication.
Nothing serious, but I still think there could be a small eclass
making things easier.
Especially the "remove_bundled_libs" function and the is useful IMO
and allows to easily remove those things.
The GAMES_PRESERVE_BUNDLED_LIBS array would allow to preserve libs,
e.g. stuff like "libbass" which is not present in the tree and even
GAMES_PRESERVE_BUNDLED_LIBS_amd64 (in case we have a 32bit only game
and there are no multilib versions for some of those libs).
It also works well with a "bundled-libs" useflag (see
games-bin_src_prepare), because it can happen that binary games break
while the tree is moving forward with library versions, or that system
libraries create weird blockers for the user or even cause runtime
breakage (which happened with the editor of games-rpg/grimrock wrt
#454934).
Most bin games use some functions from unpacker.eclass, so it is
inherited and used in games-bin_src_unpack by default.
I was also thinking about some check-reqs thing, but it's probably
better that is handled explicitly.
If you have suggestions or if you think that approach sucks, please
tell me.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.19 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
iQEcBAEBAgAGBQJRThZnAAoJEFpvPKfnPDWzl8EH/RARdOR2GKicEBGTxO2krO1A
AUcHcUlqjkgwaDmNcJ4HwbEhgVJG6vojNDihKJixlJShkD51tsVP/mhBzReH9zkE
RC7mBCek/uB5NrH5Vm2C1/dtBWAuxjJ2mN3a327a7U2tPcHkgYBGZtiAI7pSS8cl
UCfr315wBYPO95LZDUiuoQHw+ogzDP7RsrNhlJKHgwXJLE2oEUrtoKo3rkDwDZlU
ODVYT95sfZAHkyQDGhTusZB8Go+2+hhUHUua0yG30m4PXiW6j/4kCHYV59HRHYsj
6uEKpX4/h7xU0MZ1bOpqZHK2CoNlL7lPdxOMpQ/rVw8eyRNVuDpkyT1YkD/Rnj4=
=uaH2
-----END PGP SIGNATURE-----
[-- Attachment #2: games-bin.eclass --]
[-- Type: text/plain, Size: 2616 bytes --]
# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
# @ECLASS: games-bin.eclass
# @MAINTAINER:
# Julian Ospald <hasufell@gentoo.org>
# games herd <games@gentoo.org>
# @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: [<searchdir>]
# @DESCRIPTION:
# Looks recursively for libraries and symlinks matching
# lib*.so* in <searchdir> (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
}
next reply other threads:[~2013-03-23 20:54 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-23 20:53 hasufell [this message]
2013-03-26 22:15 ` [gentoo-dev] Re: New eclass: games-bin (review/comments) Richard Yao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=514E1667.8030604@gentoo.org \
--to=hasufell@gentoo.org \
--cc=games@gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
--cc=mgorny@gentoo.org \
--cc=ryao@gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox