From 3cbddb561b9678a7867d93b9e7994418d6858b86 Mon Sep 17 00:00:00 2001
From: Markus Frosch <markus.frosch@icinga.com>
Date: Thu, 2 Apr 2020 14:33:56 +0200
Subject: [PATCH] rpm: Fix hard requirement for os-release

---
 functions-rpm.sh        | 8 ++++++--
 icinga-build-rpm-binary | 4 +++-
 icinga-build-rpm-source | 4 +++-
 3 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/functions-rpm.sh b/functions-rpm.sh
index affa55c..7ba8101 100644
--- a/functions-rpm.sh
+++ b/functions-rpm.sh
@@ -119,7 +119,9 @@ get_rpmbuild() {
         "$@"
     )
 
-    source /etc/os-release
+    if [ -f /etc/os-release ]; then
+      source /etc/os-release
+    fi
     if [ "$ID" != sles ] && [[ "$VERSION" != 11.* ]]; then
       RPMBUILD+=(
         --define "_buildrootdir %{_topdir}/BUILDROOT" \
@@ -212,7 +214,9 @@ setup_extra_repository() {
         ) | sudo bash -c "cat >'/etc/zypp/credentials.d/${extra_name}'"
       fi
       (
-        source /etc/os-release
+        if [ -f /etc/os-release ]; then
+          source /etc/os-release
+        fi
         opt=()
         if [ "$ID" != sles ] && [[ "$VERSION" != 11.* ]]; then
           opt+=(--priority 50)
diff --git a/icinga-build-rpm-binary b/icinga-build-rpm-binary
index edff8f2..bc343aa 100755
--- a/icinga-build-rpm-binary
+++ b/icinga-build-rpm-binary
@@ -103,7 +103,9 @@ fi
 
 echo "[ Running rpmlint ]"
 (
-  source /etc/os-release
+  if [ -f /etc/os-release ]; then
+    source /etc/os-release
+  fi
   if [ "$ID" = sles ] && [[ "$VERSION" = 11.* ]]; then
     echo "Skip rpmlint..."
     exit 0
diff --git a/icinga-build-rpm-source b/icinga-build-rpm-source
index e9aae4f..19beae9 100755
--- a/icinga-build-rpm-source
+++ b/icinga-build-rpm-source
@@ -92,7 +92,9 @@ if [ -e "rpmlint/${ICINGA_BUILD_PROJECT}.conf" ]; then
   lintconf+=("-f" "rpmlint/${ICINGA_BUILD_PROJECT}.conf")
 fi
 (
-  source /etc/os-release
+  if [ -f /etc/os-release ]; then
+    source /etc/os-release
+  fi
   if [ "$ID" = sles ] && [[ "$VERSION" = 11.* ]]; then
     echo "Skip rpmlint..."
     exit 0
-- 
GitLab