Merge pull request #1 from scoronado12/stefano-tweaks

Portability tweaks
This commit is contained in:
Brandon Rozek 2019-12-29 22:03:59 -05:00 committed by GitHub
commit f97b5d2afa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 62 additions and 12 deletions

View file

@ -26,21 +26,54 @@ xephyrpid=$!
if command -v ratpoison; then
sleep 1
ratpoison -d :$DNum &
else # Use the default x window manager installed
else # Use the default x window manager installed based on lsb_release id
DISPLAY=:$DNum
x-window-manager &
distro_id=$(lsb_release -i | awk '{print($3)}')
if [ "${distro_id}" == "Ubuntu" ] || [ "${distro_id}" == "Debian" ]; then
x-window-manager &
else
if [ "${XDG_SESSION_DESKTOP}" == "KDE" ]; then
startplasma-x11 &
elif [ "${XDG_SESSION_DESKTOP}" == "GNOME" ]; then
mutter &
else
printf "%s\n" "Could not find a suitable Window Manager"
exit 1
fi
fi
fi
windowmanagerpid=$!
docker run --net=host \
--rm \
-e DISPLAY=:$DNum \
-v /tmp/.X11-unix/X$DNum:/tmp/.X11-unix/X$DNum:rw \
--user $(id -u):$(id -g) \
--group-add audio \
--cap-drop=ALL \
--shm-size 2g \
"$@"
#detect podman or docker
if command -v docker; then
engine_of_choice="docker"
elif command -v podman; then
engine_of_choice="podman"
else
printf "%s\n" "Docker/Podman are not installed!"
exit 1
fi
# then run the detected container engine
$engine_of_choice run --net=host \
--rm \
-e DISPLAY=:$DNum \
-v /tmp/.X11-unix/X$DNum:/tmp/.X11-unix/X$DNum:rw \
--user $(id -u):$(id -g) \
--group-add audio \
--cap-drop=ALL \
--shm-size 2g \
"$@"
kill $windowmanagerpid
kill $xephyrpid

View file

@ -3,6 +3,7 @@
from argparse import ArgumentParser
from getpass import getuser
from os import getuid, getgid, getlogin
from shutil import which
import subprocess
parser = ArgumentParser(description="Install AUR packages into a Docker container")
@ -45,4 +46,20 @@ RUN yay -S --noconfirm {package_name}
ENTRYPOINT [\"/usr/bin/env\", \"{command}\"]"
"""
subprocess.run(["docker", "build", "-t", command, "-"], input = dockerfile, encoding = 'UTF-8')
# check if either docker or podman are installed
try:
if which("docker") is None:
print("Docker not installed, building with Podman")
engine = "podman"
elif which("podman") is None:
engine = "docker"
else:
print("Podman/Docker are not installed! Exiting...")
exit(1)
subprocess.run([engine, "build", "-t", command, "-"], input = dockerfile, encoding = 'UTF-8')
except FileNotFoundError:
print("An Error has occured while attempting to build the image.")
exit(1)