From 93f3c97a63dfd6a1940a4fd08fb74c7f1ea18aac Mon Sep 17 00:00:00 2001 From: Ikey Doherty Date: Mon, 17 Feb 2020 10:16:42 +0000 Subject: [PATCH] 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 --- build.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/build.sh b/build.sh index 7c090498..9eca846d 100755 --- a/build.sh +++ b/build.sh @@ -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() {