-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d03f1ea
commit f3bb9ef
Showing
1 changed file
with
43 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,76 +1,95 @@ | ||
#!/bin/bash | ||
#!/bin/sh | ||
|
||
set -e | ||
|
||
function _die() | ||
_die() | ||
{ | ||
echo "$*" >&2 | ||
kill -s TERM "$$" | ||
} | ||
|
||
function _requires() | ||
_requires() | ||
{ | ||
for i; do | ||
command -v "$i" &>/dev/null || _die "Dependency '$i' not found, please install it separately" | ||
command -v "$i" 1>/dev/null 2>/dev/null || _die "Dependency '$i' not found, please install it separately" | ||
done | ||
} | ||
|
||
function _main() | ||
_main() | ||
{ | ||
_requires "tar" "wget" "xz" | ||
_requires "wget" | ||
|
||
mkdir -p build && cd build | ||
|
||
# Use jq to fetch latest flatimage version from github | ||
mkdir -p bin | ||
export PATH="$(pwd)/bin:$PATH" | ||
wget -q --show-progress --progress=dot:binary -O bin/jq "https://github.com/jqlang/jq/releases/download/jq-1.7/jq-linux-amd64" | ||
[ -f "bin/jq" ] || wget -O bin/jq "https://github.com/jqlang/jq/releases/download/jq-1.7/jq-linux-amd64" | ||
[ -f "bin/xz" ] || wget -O bin/xz "https://github.com/ruanformigoni/xz-static-musl/releases/download/fec8a15/xz" | ||
[ -f "bin/busybox" ] || wget -O bin/busybox "https://github.com/ruanformigoni/busybox-static-musl/releases/download/7e2c5b6/busybox-x86_64" | ||
ln -sf busybox bin/tar | ||
chmod +x ./bin/* | ||
export PATH="$(pwd)/bin:$PATH" | ||
|
||
# Download flatimage | ||
local image="./bin/arch.flatimage" | ||
wget -q --show-progress --progress=dot:mega -O "$image" "https://github.com/ruanformigoni/flatimage/releases/download/v1.0.2/arch.flatimage" | ||
chmod +x "$image" | ||
IMAGE="./bin/arch.flatimage" | ||
[ -f "$IMAGE" ] || wget -O "$IMAGE" "https://github.com/ruanformigoni/flatimage/releases/download/v1.0.2/arch.flatimage" | ||
chmod +x "$IMAGE" | ||
|
||
# Enable network | ||
"$image" fim-perms set network | ||
"$IMAGE" fim-perms set network | ||
|
||
# Update image | ||
"$image" fim-root pacman -Syu --noconfirm | ||
"$IMAGE" fim-root pacman -Syu --noconfirm | ||
|
||
# Install dependencies | ||
## General | ||
"$image" fim-root pacman -S --noconfirm xorg-server mesa lib32-mesa glxinfo lib32-gcc-libs \ | ||
"$IMAGE" fim-root pacman -S --noconfirm xorg-server mesa lib32-mesa glxinfo lib32-gcc-libs \ | ||
gcc-libs pcre freetype2 lib32-freetype2 | ||
## Video AMD/Intel | ||
"$image" fim-root pacman -S --noconfirm xf86-video-amdgpu vulkan-radeon lib32-vulkan-radeon vulkan-tools | ||
"$image" fim-root pacman -S --noconfirm xf86-video-intel vulkan-intel lib32-vulkan-intel vulkan-tools | ||
"$IMAGE" fim-root pacman -S --noconfirm xf86-video-amdgpu vulkan-radeon lib32-vulkan-radeon vulkan-tools | ||
"$IMAGE" fim-root pacman -S --noconfirm xf86-video-intel vulkan-intel lib32-vulkan-intel vulkan-tools | ||
|
||
# Install steam | ||
## Select the appropriated drivers for your GPU when asked | ||
"$image" fim-root pacman -S --noconfirm steam | ||
"$IMAGE" fim-root pacman -S --noconfirm steam | ||
|
||
# Clear cache | ||
"$image" fim-root pacman -Scc --noconfirm | ||
"$IMAGE" fim-root pacman -Scc --noconfirm | ||
|
||
# Set permissions | ||
"$image" fim-perms set media,audio,wayland,xorg,udev,dbus_user,usb,input,gpu,network | ||
"$IMAGE" fim-perms set media,audio,wayland,xorg,udev,dbus_user,usb,input,gpu,network | ||
|
||
# Configure user name and home directory | ||
"$image" fim-exec mkdir -p /home/steam | ||
"$image" fim-env add 'USER=steam' \ | ||
"$IMAGE" fim-exec mkdir -p /home/steam | ||
"$IMAGE" fim-env add 'USER=steam' \ | ||
'HOME=/home/steam' \ | ||
'XDG_CONFIG_HOME=/home/steam/.config' \ | ||
'XDG_DATA_HOME=/home/steam/.local/share' | ||
|
||
# Set command to run by default | ||
"$image" fim-boot /usr/bin/steam | ||
"$IMAGE" fim-boot /usr/bin/steam | ||
|
||
# Configure desktop integration | ||
wget -O steam.svg https://upload.wikimedia.org/wikipedia/commons/8/83/Steam_icon_logo.svg | ||
tee steam.json <<-EOF | ||
{ | ||
"name": "Steam", | ||
"icon": "./steam.svg", | ||
"categories": ["Game"] | ||
} | ||
EOF | ||
"$IMAGE" fim-desktop setup ./steam.json | ||
"$IMAGE" fim-desktop enable icon,mimetype,entry | ||
|
||
# Notify the application has started | ||
"$IMAGE" fim-notify on | ||
|
||
# Compress | ||
"$image" fim-commit | ||
"$IMAGE" fim-commit | ||
|
||
# Copy | ||
cp "$image" ../steam.flatimage | ||
rm -rf ../steam.flatimage | ||
mv "$IMAGE" ../steam.flatimage | ||
} | ||
|
||
_main "$@" |