From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id D74701389AA for ; Mon, 11 Feb 2013 22:15:21 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 55C9221C061; Mon, 11 Feb 2013 22:14:47 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id EB79F21C03E for ; Mon, 11 Feb 2013 22:14:45 +0000 (UTC) Received: from pomiocik.lan (77-253-151-121.adsl.inetia.pl [77.253.151.121]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: mgorny) by smtp.gentoo.org (Postfix) with ESMTPSA id 249D633E67B; Mon, 11 Feb 2013 22:14:43 +0000 (UTC) From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= To: gentoo-dev@lists.gentoo.org Cc: x11@gentoo.org, =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Subject: [gentoo-dev] [PATCH virtualx.eclass 1/5] Introduce a cleaner alternative to VIRTUALX_COMMAND="" virtualmake. Date: Mon, 11 Feb 2013 23:14:39 +0100 Message-Id: <1360620883-22562-2-git-send-email-mgorny@gentoo.org> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1360620883-22562-1-git-send-email-mgorny@gentoo.org> References: <1360620883-22562-1-git-send-email-mgorny@gentoo.org> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@lists.gentoo.org Reply-to: gentoo-dev@lists.gentoo.org X-Archives-Salt: 3c8f76d8-a557-4265-b3c1-91113c452322 X-Archives-Hash: 3e3d992da3d688f62ea6f5da4571ce4d Let's get this straight: VIRTUALX_COMMAND="foo" virtualmake --bar --baz is just ugly. Instead, introduce a function which can be used as: virtualx foo --bar -baz --- gx86/eclass/virtualx.eclass | 45 ++++++++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/gx86/eclass/virtualx.eclass b/gx86/eclass/virtualx.eclass index 0621b18..47116fd 100644 --- a/gx86/eclass/virtualx.eclass +++ b/gx86/eclass/virtualx.eclass @@ -1,4 +1,4 @@ -# Copyright 1999-2012 Gentoo Foundation +# Copyright 1999-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: /var/cvsroot/gentoo-x86/eclass/virtualx.eclass,v 1.43 2012/10/03 22:47:12 chithanh Exp $ @@ -69,11 +69,12 @@ case ${VIRTUALX_REQUIRED} in ;; esac -# @FUNCTION: virtualmake +# @FUNCTION: virtualx +# @USAGE: ... # @DESCRIPTION: -# Function which attach to running X session or start new Xvfb session -# where the VIRTUALX_COMMAND variable content gets executed. -virtualmake() { +# Attach to a running X session or start a new Xvfb session, then run +# the command passed as arguments. +virtualx() { debug-print-function ${FUNCNAME} "$@" local i=0 @@ -83,14 +84,6 @@ virtualmake() { local XHOST=$(type -p xhost) local xvfbargs="-screen 0 1280x1024x24" - # backcompat for maketype - if [[ -n ${maketype} ]]; then - ewarn "QA: ebuild is exporting \$maketype=${maketype}" - ewarn "QA: Ebuild should be migrated to use VIRTUALX_COMMAND=${maketype} instead." - ewarn "QA: Setting VIRTUALX_COMMAND to \$maketype conveniently for now." - VIRTUALX_COMMAND=${maketype} - fi - # If $DISPLAY is not set, or xhost cannot connect to an X # display, then do the Xvfb hack. if [[ -n ${XVFB} && -n ${XHOST} ]] && \ @@ -145,10 +138,10 @@ virtualmake() { # to kill Xvfb debug-print "${FUNCNAME}: ${VIRTUALX_COMMAND} \"$@\"" if has "${EAPI}" 2 3; then - ${VIRTUALX_COMMAND} "$@" + "$@" retval=$? else - nonfatal ${VIRTUALX_COMMAND} "$@" + nonfatal "$@" retval=$? fi @@ -158,16 +151,34 @@ virtualmake() { debug-print "${FUNCNAME}: attaching to running X display" # Normal make if we can connect to an X display debug-print "${FUNCNAME}: ${VIRTUALX_COMMAND} \"$@\"" - ${VIRTUALX_COMMAND} "$@" + "$@" retval=$? fi # die if our command failed - [[ ${retval} -ne 0 ]] && die "${FUNCNAME}: the ${VIRTUALX_COMMAND} failed." + [[ ${retval} -ne 0 ]] && die "${FUNCNAME}: ${1} failed." return 0 # always return 0, it can be altered by failed kill for Xvfb } +# @FUNCTION: virtualmake +# @DESCRIPTION: +# Function which attach to running X session or start new Xvfb session +# where the VIRTUALX_COMMAND variable content gets executed. +virtualmake() { + debug-print-function ${FUNCNAME} "$@" + + # backcompat for maketype + if [[ -n ${maketype} ]]; then + ewarn "QA: ebuild is exporting \$maketype=${maketype}" + ewarn "QA: Ebuild should be migrated to use VIRTUALX_COMMAND=${maketype} instead." + ewarn "QA: Setting VIRTUALX_COMMAND to \$maketype conveniently for now." + VIRTUALX_COMMAND=${maketype} + fi + + virtualx ${VIRTUALX_COMMAND} "$@" +} + # @FUNCTION: Xmake # @DESCRIPTION: # Same as "make", but set up the Xvfb hack if needed. -- 1.8.1.2