public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] New eclass: games-bin (review/comments)
@ 2013-03-23 20:53 hasufell
  2013-03-26 22:15 ` [gentoo-dev] " Richard Yao
  0 siblings, 1 reply; 2+ messages in thread
From: hasufell @ 2013-03-23 20:53 UTC (permalink / raw
  To: gentoo-dev; +Cc: games, mgorny, ryao

[-- 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
}

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [gentoo-dev] Re: New eclass: games-bin (review/comments)
  2013-03-23 20:53 [gentoo-dev] New eclass: games-bin (review/comments) hasufell
@ 2013-03-26 22:15 ` Richard Yao
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Yao @ 2013-03-26 22:15 UTC (permalink / raw
  To: hasufell; +Cc: gentoo-dev, games, mgorny

[-- Attachment #1: Type: text/plain, Size: 1393 bytes --]

On 03/23/2013 04:53 PM, hasufell wrote:
> 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.
> 

If it works, I see no reason not to commit it. It has my okay.


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 901 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-03-26 22:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-23 20:53 [gentoo-dev] New eclass: games-bin (review/comments) hasufell
2013-03-26 22:15 ` [gentoo-dev] " Richard Yao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox