From f0b05dd384cff4879fa33038460cdd42fe8b5b86 Mon Sep 17 00:00:00 2001 From: John Levon Date: Mon, 23 Aug 2021 23:00:01 +0100 Subject: [PATCH] scripts/pkgdep: respect $ID_LIKE As per os-release(5), if $ID is not recognised, $ID_LIKE can be used to identify similar systems in preference order. Modify the script to try both variables. Also do the same for the RPM build scripts. Signed-off-by: John Levon Change-Id: I4ed924df01ec678aab232e114d8c9980463c38e0 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/9260 Community-CI: Mellanox Build Bot Community-CI: Broadcom CI Tested-by: SPDK CI Jenkins Reviewed-by: Jim Harris Reviewed-by: Karol Latecki Reviewed-by: Tomasz Zawadzki Reviewed-by: Dong Yi --- rpmbuild/rpm-deps.sh | 11 ++++++++++- rpmbuild/rpm.sh | 8 +++++++- scripts/pkgdep.sh | 16 ++++++++++------ 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/rpmbuild/rpm-deps.sh b/rpmbuild/rpm-deps.sh index 41092bacd..5ef12a3d5 100755 --- a/rpmbuild/rpm-deps.sh +++ b/rpmbuild/rpm-deps.sh @@ -16,7 +16,16 @@ bins=("$rootdir/"build/{bin,examples}/*) ((${#bins[@]} > 0)) || exit 0 source /etc/os-release -[[ $ID == fedora || $ID == centos || $ID == rhel ]] || exit 0 + +id_ok=no + +for id in $ID $ID_LIKE; do + [[ "$id" =~ ^(fedora|centos|rhel) ]] && id_ok=yes +done + +if [[ "$id_ok" != "yes" ]]; then + exit 0 +fi declare -A deps=() for bin in "${bins[@]}"; do diff --git a/rpmbuild/rpm.sh b/rpmbuild/rpm.sh index 8cb92d4af..9f1ec0401 100755 --- a/rpmbuild/rpm.sh +++ b/rpmbuild/rpm.sh @@ -8,7 +8,13 @@ rootdir=$(readlink -f "$specdir/../") [[ -e /etc/os-release ]] source /etc/os-release -if [[ $ID != fedora && $ID != centos && $ID != rhel ]]; then +id_ok=no + +for id in $ID $ID_LIKE; do + [[ "$id" =~ ^(fedora|centos|rhel) ]] && id_ok=yes +done + +if [[ "$id_ok" != "yes" ]]; then printf '%s not supported\n' "$ID" >&2 exit 1 fi diff --git a/scripts/pkgdep.sh b/scripts/pkgdep.sh index 459cd7985..9e13d98b0 100755 --- a/scripts/pkgdep.sh +++ b/scripts/pkgdep.sh @@ -89,9 +89,13 @@ if [[ ${ID,,} == *"suse"* ]]; then ID="sles" fi -if [[ -e $scriptsdir/pkgdep/$ID.sh ]]; then - source "$scriptsdir/pkgdep/$ID.sh" - source "$scriptsdir/pkgdep/common.sh" -else - printf 'Not supported platform detected (%s), aborting\n' "$ID" >&2 -fi +for id in $ID $ID_LIKE; do + if [[ -e $scriptsdir/pkgdep/$id.sh ]]; then + source "$scriptsdir/pkgdep/$id.sh" + source "$scriptsdir/pkgdep/common.sh" + exit 0 + fi +done + +printf 'Not supported platform detected (%s), aborting\n' "$ID" >&2 +exit 1