1From 4143fa0092fe4cafee10b24a97d3ad0b41ab7a30 Mon Sep 17 00:00:00 2001
2From: Zang Ruochen <zangrc.fnst@cn.fujitsu.com>
3Date: Wed, 7 Aug 2019 03:24:39 +0900
4Subject: [PATCH] kpatch-build: allow overriding of distro name
5
6It is sometimes useful to have ability to override
7distro name, for example during cross-compilation
8build when livepatch modules will be ran on the
9target which differs from host.
10
11This patch adds a new --distro option which
12implements all needed functionality
13
14Upstream-Status: Pending
15
16Signed-off-by: Ruslan Bilovol <rbilovol@cisco.com>
17---
18 kpatch-build/kpatch-build | 9 +++++++--
19 1 file changed, 7 insertions(+), 2 deletions(-)
20
21diff --git a/kpatch-build/kpatch-build b/kpatch-build/kpatch-build
22index 39933fc..c0258a2 100755
23--- a/kpatch-build/kpatch-build
24+++ b/kpatch-build/kpatch-build
25@@ -413,12 +413,13 @@ usage() {
26 	echo "		                   specify current version of module" >&2
27 	echo "		--cross-compile    Specify the prefix used for all executables" >&2
28 	echo "		                   used during compilation" >&2
29+	echo "		--distro           Override distro name" >&2
30 	echo "		--skip-cleanup     Skip post-build cleanup" >&2
31 	echo "		--skip-gcc-check   Skip gcc version matching check" >&2
32 	echo "		                   (not recommended)" >&2
33 }
34
35-options="$(getopt -o ha:r:s:c:v:j:t:n:o:de: -l "help,archversion:,sourcerpm:,sourcedir:,config:,vmlinux:,jobs:,target:,name:,output:,oot-module:,debug,cross-compile:,skip-gcc-check,skip-cleanup" -- "$@")" || die "getopt failed"
36+options="$(getopt -o ha:r:s:c:v:j:t:n:o:de: -l "help,archversion:,sourcerpm:,sourcedir:,config:,vmlinux:,jobs:,target:,name:,output:,oot-module:,debug,cross-compile:,distro:,skip-gcc-check,skip-cleanup" -- "$@")" || die "getopt failed"
37
38 eval set -- "$options"
39
40@@ -485,6 +486,10 @@ while [[ $# -gt 0 ]]; do
41 		KPATCH_CROSS_COMPILE="$2"
42 		shift
43 		;;
44+	--distro)
45+		DISTRO="$2"
46+		shift
47+		;;
48 	--skip-cleanup)
49 		echo "Skipping cleanup"
50 		SKIPCLEANUP=1
51@@ -613,7 +613,7 @@ fi
52 # Don't check external file.
53 # shellcheck disable=SC1090
54 [[ -f "$RELEASE_FILE" ]] && source "$RELEASE_FILE"
55-DISTRO="$ID"
56+DISTRO="${DISTRO:-${ID}}"
57 if [[ "$DISTRO" = fedora ]] || [[ "$DISTRO" = rhel ]] || [[ "$DISTRO" = ol ]] || [[ "$DISTRO" = centos ]]; then
58 	[[ -z "$VMLINUX" ]] && VMLINUX="/usr/lib/debug/lib/modules/$ARCHVERSION/vmlinux"
59 	[[ -e "$VMLINUX" ]] || die "kernel-debuginfo-$ARCHVERSION not installed"
60--
612.7.4
62
63