kpatch-build: Check if /etc/os-release exists

Not every distro out there supports /etc/os-release file.
This file is useful for obtaining given distro defaults, but not
essential for the script to work (when all parameters are passed
on a command line).

To avoid warnings or unwanted errors, make sourcing of this file
conditional.

Signed-off-by: Pawel Wieczorkiewicz <wipawel@amazon.de>
This commit is contained in:
Pawel Wieczorkiewicz 2019-08-10 13:46:47 +00:00
parent 30a7dd677b
commit ed5091b16f

View File

@ -46,6 +46,7 @@ RPMTOPDIR="$CACHEDIR/buildroot"
VERSIONFILE="$CACHEDIR/version" VERSIONFILE="$CACHEDIR/version"
TEMPDIR="$CACHEDIR/tmp" TEMPDIR="$CACHEDIR/tmp"
LOGFILE="$CACHEDIR/build.log" LOGFILE="$CACHEDIR/build.log"
RELEASE_FILE=/etc/os-release
DEBUG=0 DEBUG=0
SKIPCLEANUP=0 SKIPCLEANUP=0
SKIPGCCCHECK=0 SKIPGCCCHECK=0
@ -569,8 +570,8 @@ fi
[[ -z "$TARGETS" ]] && TARGETS="vmlinux modules" [[ -z "$TARGETS" ]] && TARGETS="vmlinux modules"
# Don't check external file. # Don't check external file.
# shellcheck disable=SC1091 # shellcheck disable=SC1090
source /etc/os-release [[ -f "$RELEASE_FILE" ]] && source "$RELEASE_FILE"
DISTRO="$ID" DISTRO="$ID"
if [[ "$DISTRO" = fedora ]] || [[ "$DISTRO" = rhel ]] || [[ "$DISTRO" = ol ]] || [[ "$DISTRO" = centos ]]; then if [[ "$DISTRO" = fedora ]] || [[ "$DISTRO" = rhel ]] || [[ "$DISTRO" = ol ]] || [[ "$DISTRO" = centos ]]; then
[[ -z "$VMLINUX" ]] && VMLINUX="/usr/lib/debug/lib/modules/$ARCHVERSION/vmlinux" [[ -z "$VMLINUX" ]] && VMLINUX="/usr/lib/debug/lib/modules/$ARCHVERSION/vmlinux"