mirror of
https://github.com/flatcar/scripts.git
synced 2025-08-16 09:26:58 +02:00
eclass/virtualx: Sync with gentoo
It's from gentoo commit 3a34d9930357ff882123aa4004ac7f568d2269fd.
This commit is contained in:
parent
77d8fbde2d
commit
eef0962cf6
@ -1,4 +1,4 @@
|
|||||||
# Copyright 1999-2018 Gentoo Foundation
|
# Copyright 1999-2021 Gentoo Authors
|
||||||
# Distributed under the terms of the GNU General Public License v2
|
# Distributed under the terms of the GNU General Public License v2
|
||||||
|
|
||||||
# @ECLASS: virtualx.eclass
|
# @ECLASS: virtualx.eclass
|
||||||
@ -6,25 +6,19 @@
|
|||||||
# x11@gentoo.org
|
# x11@gentoo.org
|
||||||
# @AUTHOR:
|
# @AUTHOR:
|
||||||
# Original author: Martin Schlemmer <azarah@gentoo.org>
|
# Original author: Martin Schlemmer <azarah@gentoo.org>
|
||||||
# @SUPPORTED_EAPIS: 4 5 6 7
|
# @SUPPORTED_EAPIS: 6 7 8
|
||||||
# @BLURB: This eclass can be used for packages that needs a working X environment to build.
|
# @BLURB: This eclass can be used for packages that need a working X environment to build.
|
||||||
|
|
||||||
if [[ ! ${_VIRTUAL_X} ]]; then
|
case ${EAPI} in
|
||||||
|
6|7|8) ;;
|
||||||
case "${EAPI:-0}" in
|
*) die "${ECLASS}: EAPI ${EAPI:-0} is not supported." ;;
|
||||||
0|1|2|3)
|
|
||||||
die "virtualx.eclass: EAPI ${EAPI} is too old."
|
|
||||||
;;
|
|
||||||
4|5|6|7)
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
die "virtualx.eclass: EAPI ${EAPI} is not supported yet."
|
|
||||||
;;
|
|
||||||
esac
|
esac
|
||||||
|
|
||||||
[[ ${EAPI} == [45] ]] && inherit eutils
|
if [[ ! ${_VIRTUALX_ECLASS} ]]; then
|
||||||
|
_VIRTUALX_ECLASS=1
|
||||||
|
|
||||||
# @ECLASS-VARIABLE: VIRTUALX_REQUIRED
|
# @ECLASS-VARIABLE: VIRTUALX_REQUIRED
|
||||||
|
# @PRE_INHERIT
|
||||||
# @DESCRIPTION:
|
# @DESCRIPTION:
|
||||||
# Variable specifying the dependency on xorg-server and xhost.
|
# Variable specifying the dependency on xorg-server and xhost.
|
||||||
# Possible special values are "always" and "manual", which specify
|
# Possible special values are "always" and "manual", which specify
|
||||||
@ -35,83 +29,36 @@ esac
|
|||||||
: ${VIRTUALX_REQUIRED:=test}
|
: ${VIRTUALX_REQUIRED:=test}
|
||||||
|
|
||||||
# @ECLASS-VARIABLE: VIRTUALX_DEPEND
|
# @ECLASS-VARIABLE: VIRTUALX_DEPEND
|
||||||
|
# @OUTPUT_VARIABLE
|
||||||
# @DESCRIPTION:
|
# @DESCRIPTION:
|
||||||
# Dep string available for use outside of eclass, in case a more
|
# Standard dependencies string that is automatically added to BDEPEND
|
||||||
# complicated dep is needed.
|
# (in EAPI-6: DEPEND) unless VIRTUALX_REQUIRED is set to "manual".
|
||||||
# You can specify the variable BEFORE inherit to add more dependencies.
|
# DEPRECATED: Pre-EAPI-8 you can specify the variable BEFORE inherit
|
||||||
VIRTUALX_DEPEND="${VIRTUALX_DEPEND}
|
# to add more dependencies.
|
||||||
!prefix? ( x11-base/xorg-server[xvfb] )
|
[[ ${EAPI} != [67] ]] && VIRTUALX_DEPEND=""
|
||||||
|
VIRTUALX_DEPEND+="
|
||||||
|
x11-base/xorg-server[xvfb]
|
||||||
x11-apps/xhost
|
x11-apps/xhost
|
||||||
"
|
"
|
||||||
|
[[ ${EAPI} != [67] ]] && readonly VIRTUALX_DEPEND
|
||||||
|
|
||||||
# @ECLASS-VARIABLE: VIRTUALX_COMMAND
|
[[ ${VIRTUALX_COMMAND} ]] && die "VIRTUALX_COMMAND has been removed and is a no-op"
|
||||||
# @DESCRIPTION:
|
|
||||||
# Command (or eclass function call) to be run in the X11 environment
|
|
||||||
# (within virtualmake function).
|
|
||||||
: ${VIRTUALX_COMMAND:="emake"}
|
|
||||||
|
|
||||||
case ${VIRTUALX_REQUIRED} in
|
case ${VIRTUALX_REQUIRED} in
|
||||||
manual)
|
manual)
|
||||||
;;
|
;;
|
||||||
always)
|
always)
|
||||||
if [[ ${EAPI:-0} != [0123456] ]]; then
|
|
||||||
BDEPEND="${VIRTUALX_DEPEND}"
|
BDEPEND="${VIRTUALX_DEPEND}"
|
||||||
else
|
|
||||||
DEPEND="${VIRTUALX_DEPEND}"
|
|
||||||
fi
|
|
||||||
RDEPEND=""
|
|
||||||
;;
|
|
||||||
optional|tests)
|
|
||||||
[[ ${EAPI} == [45] ]] \
|
|
||||||
|| die 'Values "optional" and "tests" for VIRTUALX_REQUIRED are banned in EAPI > 5'
|
|
||||||
# deprecated section YAY.
|
|
||||||
eqawarn "VIRTUALX_REQUIRED=optional and VIRTUALX_REQUIRED=tests are deprecated."
|
|
||||||
eqawarn "You can drop the variable definition completely from ebuild,"
|
|
||||||
eqawarn "because it is default behaviour."
|
|
||||||
|
|
||||||
if [[ -n ${VIRTUALX_USE} ]]; then
|
|
||||||
# so they like to specify the useflag
|
|
||||||
eqawarn "VIRTUALX_USE variable is deprecated."
|
|
||||||
eqawarn "Please read eclass manpage to find out how to use VIRTUALX_REQUIRED"
|
|
||||||
eqawarn "to achieve the same behaviour."
|
|
||||||
fi
|
|
||||||
|
|
||||||
[[ -z ${VIRTUALX_USE} ]] && VIRTUALX_USE="test"
|
|
||||||
DEPEND="${VIRTUALX_USE}? ( ${VIRTUALX_DEPEND} )"
|
|
||||||
RDEPEND=""
|
|
||||||
IUSE="${VIRTUALX_USE}"
|
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
if [[ ${EAPI:-0} != [0123456] ]]; then
|
|
||||||
BDEPEND="${VIRTUALX_REQUIRED}? ( ${VIRTUALX_DEPEND} )"
|
BDEPEND="${VIRTUALX_REQUIRED}? ( ${VIRTUALX_DEPEND} )"
|
||||||
else
|
|
||||||
DEPEND="${VIRTUALX_REQUIRED}? ( ${VIRTUALX_DEPEND} )"
|
|
||||||
fi
|
|
||||||
RDEPEND=""
|
|
||||||
IUSE="${VIRTUALX_REQUIRED}"
|
IUSE="${VIRTUALX_REQUIRED}"
|
||||||
|
[[ ${VIRTUALX_REQUIRED} == test ]] &&
|
||||||
|
RESTRICT+=" !test? ( test )"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# @FUNCTION: virtualmake
|
[[ ${EAPI} == 6 ]] && DEPEND="${BDEPEND}"
|
||||||
# @DESCRIPTION:
|
|
||||||
# Function which start new Xvfb session
|
|
||||||
# where the VIRTUALX_COMMAND variable content gets executed.
|
|
||||||
virtualmake() {
|
|
||||||
debug-print-function ${FUNCNAME} "$@"
|
|
||||||
|
|
||||||
[[ ${EAPI} == [45] ]] \
|
|
||||||
|| die "${FUNCNAME} is unsupported in EAPI > 5, please use virtx"
|
|
||||||
|
|
||||||
# backcompat for maketype
|
|
||||||
if [[ -n ${maketype} ]]; then
|
|
||||||
[[ ${EAPI} == [45] ]] || die "maketype is banned in EAPI > 5"
|
|
||||||
eqawarn "ebuild is exporting \$maketype=${maketype}"
|
|
||||||
eqawarn "Ebuild should be migrated to use 'virtx command' instead."
|
|
||||||
VIRTUALX_COMMAND=${maketype}
|
|
||||||
fi
|
|
||||||
|
|
||||||
virtx "${VIRTUALX_COMMAND}" "${@}"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# @FUNCTION: virtx
|
# @FUNCTION: virtx
|
||||||
@ -178,7 +125,10 @@ virtx() {
|
|||||||
# Xvfb is started, else bump the display number
|
# Xvfb is started, else bump the display number
|
||||||
#
|
#
|
||||||
# Azarah - 5 May 2002
|
# Azarah - 5 May 2002
|
||||||
XDISPLAY=$(i=0; while [[ -f /tmp/.X${i}-lock ]] ; do ((i++));done; echo ${i})
|
# GNOME GDM may have started X on DISPLAY :0 with a
|
||||||
|
# lock file /tmp/.X1024-lock, therefore start the search at 1.
|
||||||
|
# Else a leftover /tmp/.X1-lock will prevent finding an available display.
|
||||||
|
XDISPLAY=$(i=1; while [[ -f /tmp/.X${i}-lock ]] ; do ((i++));done; echo ${i})
|
||||||
debug-print "${FUNCNAME}: XDISPLAY=${XDISPLAY}"
|
debug-print "${FUNCNAME}: XDISPLAY=${XDISPLAY}"
|
||||||
|
|
||||||
# We really do not want SANDBOX enabled here
|
# We really do not want SANDBOX enabled here
|
||||||
@ -226,44 +176,4 @@ virtx() {
|
|||||||
return 0 # always return 0, it can be altered by failed kill for Xvfb
|
return 0 # always return 0, it can be altered by failed kill for Xvfb
|
||||||
}
|
}
|
||||||
|
|
||||||
# @FUNCTION: Xmake
|
|
||||||
# @DESCRIPTION:
|
|
||||||
# Same as "make", but set up the Xvfb hack if needed.
|
|
||||||
# Deprecated call.
|
|
||||||
Xmake() {
|
|
||||||
debug-print-function ${FUNCNAME} "$@"
|
|
||||||
|
|
||||||
[[ ${EAPI} == [45] ]] \
|
|
||||||
|| die "${FUNCNAME} is unsupported in EAPI > 5, please use 'virtx emake -j1 ....'"
|
|
||||||
|
|
||||||
eqawarn "you should not execute make directly"
|
|
||||||
eqawarn "rather execute Xemake -j1 if you have issues with parallel make"
|
|
||||||
VIRTUALX_COMMAND="emake -j1" virtualmake "$@"
|
|
||||||
}
|
|
||||||
|
|
||||||
# @FUNCTION: Xemake
|
|
||||||
# @DESCRIPTION:
|
|
||||||
# Same as "emake", but set up the Xvfb hack if needed.
|
|
||||||
Xemake() {
|
|
||||||
debug-print-function ${FUNCNAME} "$@"
|
|
||||||
|
|
||||||
[[ ${EAPI} == [45] ]] \
|
|
||||||
|| die "${FUNCNAME} is unsupported in EAPI > 5, please use 'virtx emake ....'"
|
|
||||||
|
|
||||||
VIRTUALX_COMMAND="emake" virtualmake "$@"
|
|
||||||
}
|
|
||||||
|
|
||||||
# @FUNCTION: Xeconf
|
|
||||||
# @DESCRIPTION:
|
|
||||||
# Same as "econf", but set up the Xvfb hack if needed.
|
|
||||||
Xeconf() {
|
|
||||||
debug-print-function ${FUNCNAME} "$@"
|
|
||||||
|
|
||||||
[[ ${EAPI} == [45] ]] \
|
|
||||||
|| die "${FUNCNAME} is unsupported in EAPI > 5, please use 'virtx econf ....'"
|
|
||||||
|
|
||||||
VIRTUALX_COMMAND="econf" virtualmake "$@"
|
|
||||||
}
|
|
||||||
|
|
||||||
_VIRTUAL_X=1
|
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user