From 058aacf196630c99e6becd6b1e459ef132950c63 Mon Sep 17 00:00:00 2001 From: Joseph Jezak Date: Fri, 24 Mar 2017 16:17:36 +0000 Subject: [PATCH] Gentoo: Support use expand variables for simultaneous xiwi and xorg. --- installer/gentoo/prepare | 22 ++++++++++++++++++++-- targets/xiwi | 17 ++++++++++------- targets/xorg | 23 +++++++++++------------ 3 files changed, 41 insertions(+), 21 deletions(-) diff --git a/installer/gentoo/prepare b/installer/gentoo/prepare index 23ddda26c..9ba8e722b 100644 --- a/installer/gentoo/prepare +++ b/installer/gentoo/prepare @@ -7,12 +7,12 @@ DISTROAKA='gentoo' -# Set use flags, separated by a space +# Set global use flags, separated by a space set_flags() { while [ "$#" != 0 ]; do local flag=`euse -a $1 | cut -d\[ -f1`; # If don't already have the flag - if [ -z ${flag} ]; then + if [ -z "${flag}" ]; then euse -E $1 1> /dev/null fi shift @@ -88,6 +88,24 @@ By installing $3, the license $2 has been enabled. " } +# Set a use expand flag +# Usage: set_use_expand +set_use_expand() { + # Check if the variable is already present + EXPAND=`grep "$1" /etc/portage/make.conf | cut -f2 -d\"` + # If not, add it with the desired flag + if [ -z "$EXPAND" ]; then + echo "$1=\"$2\"" >> /etc/portage/make.conf + # If the variable is already present, check if the flag is already set + else + FLAG_SET=`echo $EXPAND | grep $2 | cut -f1 -d\"` + # Add the flag + if [ -z "$FLAG_SET" ]; then + sed -i -e "s|$1=\"\(.*\)\"|$1=\"\1 $2\"|" /etc/portage/make.conf + fi + fi +} + # install_dist: see install() in prepare.sh for details. install_dist() { local pkgs='' diff --git a/targets/xiwi b/targets/xiwi index 5a055fe62..b131cc492 100755 --- a/targets/xiwi +++ b/targets/xiwi @@ -29,17 +29,20 @@ if [ "${DISTROAKA:-"$DISTRO"}" = 'debian' ]; then fi if [ "${DISTROAKA:-"$DISTRO"}" = 'gentoo' ]; then - VIDEO_CARDS=`grep VIDEO_CARDS /etc/portage/make.conf | cut -d= -f1` - if [ -z ${VIDEO_CARDS} ]; then - echo "VIDEO_CARDS=\"dummy\"" >> /etc/portage/make.conf - echo "INPUT_DEVICES=\"keyboard libinput mouse evdev\"" >> /etc/portage/make.conf - fi + # Set video card and input devices + set_use_expand VIDEO_CARDS dummy + set_use_expand INPUT_DEVICES keyboard + set_use_expand INPUT_DEVICES libinput + set_use_expand INPUT_DEVICES mouse + set_use_expand INPUT_DEVICES evdev + # Set use flags for X + set_flags X dbus # We remove the suid bit because it breaks LD_PRELOAD'ing libcroutonfreon.so set_package_flag x11-base/xorg-server -suid xorg - - set_flags X dbus + # Install xorg install xorg-x11 xorg-server + # Set the flags for i3 and install it set_flags xcb xkb install i3 else diff --git a/targets/xorg b/targets/xorg index 2c294f5ca..391093eb3 100644 --- a/targets/xorg +++ b/targets/xorg @@ -17,18 +17,17 @@ rm -f '/etc/crouton/xserverrc-x11' # Set the use flags on gentoo that we'll need for X if [ "${DISTROAKA:-"$DISTRO"}" = 'gentoo' ]; then - set_flags libkms uxa dri3 xvmc opengl - - # We remove the suid bit because it breaks LD_PRELOAD'ing libcroutonfreon.so - set_package_flag x11-base/xorg-server -suid xorg - - # Set VIDEO_CARDS and INPUT_DEVICES - # FIXME: Perhaps make this more flexible, right now just pick all of them - VIDEO_CARDS=`grep VIDEO_CARDS /etc/portage/make.conf | cut -d= -f1` - if [ -z ${VIDEO_CARDS} ]; then - echo "VIDEO_CARDS=\"intel fbdev vesa dummy\"" >> /etc/portage/make.conf - echo "INPUT_DEVICES=\"keyboard libinput mouse evdev\"" >> /etc/portage/make.conf - fi + set_flags libkms uxa dri3 xvmc opengl + # We remove the suid bit because it breaks LD_PRELOAD'ing libcroutonfreon.so + set_package_flag x11-base/xorg-server -suid xorg + # Set video card and input devices + # FIXME: ARM, non-intel? + set_use_expand VIDEO_CARDS intel + set_use_expand INPUT_DEVICES keyboard + set_use_expand INPUT_DEVICES libinput + set_use_expand INPUT_DEVICES mouse + set_use_expand INPUT_DEVICES evdev + set_use_expand INPUT_DEVICES synaptics fi # Figure out what we need on this system