build.sh: Support multiple locations of the os-release file

In stateless operating systems the os-release file might not exist
in /etc/ unless a compatability link is in place, or the user has
overriden the distro defaults.

A layering approach should instead be used, to read a set of known
paths in priority order. If the /etc/os-release file is not found,
the fallback location of /usr/lib/os-release will be used instead.

Signed-off-by: Ikey Doherty <ikey.doherty@lispysnake.com>
pull/41/head
Ikey Doherty 4 years ago
parent 65b90fc01b
commit 93f3c97a63
No known key found for this signature in database
GPG Key ID: 9EC8151B1F7ADDEA

@ -1,14 +1,21 @@
#!/bin/bash
OS_RELEASE_FILES=("/etc/os-release" "/usr/lib/os-release")
XDG_DATA_HOME="${XDG_DATA_HOME:-$HOME/.local/share}"
XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}"
DATA_DIR="$XDG_DATA_HOME/MangoHud"
LAYER="build/release/usr/share/vulkan/implicit_layer.d/mangohud.json"
INSTALL_DIR="build/package/MangoHud"
IMPLICIT_LAYER_DIR="$XDG_DATA_HOME/vulkan/implicit_layer.d"
DISTRO=$(sed 1q /etc/os-release | sed 's/NAME=//g' | sed 's/"//g')
VERSION=$(git describe --long --tags --always | sed 's/\([^-]*-g\)/r\1/;s/-/./g;s/^v//')
# Correctly identify the os-release file.
for os_release in ${OS_RELEASE_FILES[@]} ; do
if [[ ! -e "${os_release}" ]]; then
continue
fi
DISTRO=$(sed 1q ${os_release} | sed 's/NAME=//g' | sed 's/"//g')
done
dependencies() {
if [[ ! -f build/release/usr/lib64/libMangoHud.so ]]; then
missing_deps() {

Loading…
Cancel
Save