#!/bin/sh usage() { cat <<-__EOF__ usage: setup-xorg-base [-h] [PKG..] Set up system to use Xorg options: -h Show this help Installs xorg-server, enables community repository, enable udev and install the pagkages PKG if specified. __EOF__ exit $1 } while getopts "d:n:h" opt; do case $opt in h) usage 0;; '?') usage "1" >&2;; esac done shift $(($OPTIND - 1)) # For every main/ repo, enable corresponding community/ repo orig="$ROOT"/etc/apk/repositories if test -f "$orig"; then echo '>> Enabling community repositories' tmp="$orig".tmp:setup-xorg-base :> "$tmp" while read line ; do echo "$line" nosharp="${line##\#*}" nomain="${line%%/main}" if test "$line" = "$nosharp" && test "$line" != "$nomain"; then echo "$nomain"/community fi done < "$orig" >> "$tmp" mv -f "$tmp" "$orig" $MOCK apk update fi # enable community repo if [ -f "$ROOT"/etc/apk/repositories ] && ! grep -q '^[^#].*/community$' "$ROOT"/etc/apk/repositories; then repo=$(grep '^[^#].*/main$' /etc/apk/repositories | sed 's:/main$:/community:') escaped_repo=$(echo $repo | sed -e 's:/:\\/:g' -e 's:\.:\\.:g') sed -i -e "/^[^#].*\/main$/a $repo" \ -e "/^#${escaped_repo}$/d" \ "$ROOT"/etc/apk/repositories \ && echo ">> Enabling community repository" $MOCK apk update fi $MOCK apk add xorg-server xf86-input-libinput eudev mesa "$@" setup-devd udev