From 4da829792f35892cc1fd41f5958dc9deb14f33d4 Mon Sep 17 00:00:00 2001 From: weishu Date: Fri, 3 Feb 2023 23:00:59 +0700 Subject: [PATCH] kernel: unify version --- kernel/Makefile | 6 ++++++ kernel/ksu.h | 6 +++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/kernel/Makefile b/kernel/Makefile index 28abb795..caf7910c 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -12,6 +12,12 @@ obj-y += embed_ksud.o obj-y += kernel_compat.o obj-y += selinux/ +# We must use the absolute path to git, otherwise the build will fail if git is not in the PATH +KSU_GIT_VERSION := $(shell cd $(srctree)/$(src);/usr/bin/git rev-list --count HEAD) +ifeq ($(KSU_GIT_VERSION),) +$(error Get git version failed, please make sure git is installed in /usr/bin/git) +endif +ccflags-y += -DKSU_GIT_VERSION=$(KSU_GIT_VERSION) ifndef EXPECTED_SIZE EXPECTED_SIZE := 0x033b diff --git a/kernel/ksu.h b/kernel/ksu.h index b650cdc0..3c2d0dd1 100644 --- a/kernel/ksu.h +++ b/kernel/ksu.h @@ -3,7 +3,11 @@ #include "linux/workqueue.h" -#define KERNEL_SU_VERSION 15 +#ifndef KSU_GIT_VERSION +#error "KSU_GIT_VERSION not defined! Please check Makefile." +#else +#define KERNEL_SU_VERSION (10000 + KSU_GIT_VERSION + 200) // major * 10000 + git version + 200 for historical reasons +#endif #define KERNEL_SU_OPTION 0xDEADBEEF