tiann / KernelSU

A Kernel based root solution for Android
https://kernelsu.org
GNU General Public License v3.0
9.93k stars 1.61k forks source link

当前KernelSU版本16过低 #912

Closed DZ-IO closed 1 year ago

DZ-IO commented 1 year ago

Describe the bug 官方命令自编译KSU显示版本过低

To Reproduce

  1. 按照官方教程编译KernelSU
  2. 从编译好的镜像启动
  3. 打开KernelSU APP
  4. See the error

Expected behaviour kernelSU管理器正常工作

Screenshots Screenshot_2023-08-29-14-57-11-369_me weishu kernelsu

Smartphone (please complete the following information):

Additional context 使用的是官方main分支

Bot-wxt1221 commented 1 year ago

@DZ-IO 麻烦发一下编译时的日志,集成ksu时采用的命令行就是有 curl 那段

Bot-wxt1221 commented 1 year ago

主要是这一段:

-- KernelSU version: 
-- KernelSU Manager signature size: 
-- KernelSU Manager signature hash: 
DZ-IO commented 1 year ago

@DZ-IO 麻烦发一下编译时的日志,集成ksu时采用的命令行就是有 curl 那段

日志:

/root/kbuild/out/bazel/output_user_root/91d2da69fc50ccf8a24cebdd0d91e1f4/sandbox/processwrapper-sandbox/11/execroot/__main__/common/drivers/kernelsu/Makefile:23: "KSU_GIT_VERSION not defined! It is better to make KernelSU a git submodule!"
-- KernelSU Manager signature size: 0x033b
-- KernelSU Manager signature hash: 0xb0b91415

命令行:

curl -LSs "https://raw.githubusercontent.com/tiann/KernelSU/main/kernel/setup.sh" | bash -s main
Bot-wxt1221 commented 1 year ago

@DZ-IO 删除KernelSU文件夹然后重新执行一下命令行

Bot-wxt1221 commented 1 year ago

观察一下是否还有"KSU_GIT_VERSION not defined!之类的报错

Bot-wxt1221 commented 1 year ago

ksu的版本依赖于git的commit数量

DZ-IO commented 1 year ago

试了一下,还是有报错

然后顺着这个思路去找了一下Makefile,感觉是这里判断不出来是否在git仓库里导致的(没写过Makefile,只是个人理解,如果有误见谅)

# .git is a text file while the module is imported by 'git submodule add'.
ifeq ($(shell test -e $(srctree)/$(src)/../.git; echo $$?),0)
KSU_GIT_VERSION := $(shell cd $(srctree)/$(src); /usr/bin/env PATH="$$PATH":/usr/bin:/usr/local/bin git rev-list --count HEAD)
# ksu_version: major * 10000 + git version + 200 for historical reasons
$(eval KSU_VERSION=$(shell expr 10000 + $(KSU_GIT_VERSION) + 200))
$(info -- KernelSU version: $(KSU_VERSION))
ccflags-y += -DKSU_VERSION=$(KSU_VERSION)
else # If there is no .git file, the default version will be passed.
$(warning "KSU_GIT_VERSION not defined! It is better to make KernelSU a git submodule!")
ccflags-y += -DKSU_VERSION=16
endif
Bot-wxt1221 commented 1 year ago

你的KernelSU目录下是否有.git 文件夹 检查一下你的系统的git在哪里,是否在PATH里面

Bot-wxt1221 commented 1 year ago

看得出来调用了git是从系统的PATH里去找的

Bot-wxt1221 commented 1 year ago

跑一下:

whereis git
echo $PATH

看一下

DZ-IO commented 1 year ago

你的KernelSU目录下是否有.git 文件夹 检查一下你的系统的git在哪里,是否在PATH里面

有.git文件夹,git也在$PATH里 但是它找的那个目录下没有.git

Bot-wxt1221 commented 1 year ago

他在读/drivers/kernelsu的内容,我看了一下这个目录也是个单独的git仓库,你看一下呢

Bot-wxt1221 commented 1 year ago

应该是软连接过去的

Bot-wxt1221 commented 1 year ago

image

DZ-IO commented 1 year ago

他在读/drivers/kernelsu的内容,我看了一下这个目录也是个单独的git仓库,你看一下呢

那个drivers不是git仓库,所以问题出在这了

Bot-wxt1221 commented 1 year ago

你把/drivers/kernelsu/Makefile改成这样算了,估计是make版本的问题,回头提个PR:

obj-y += ksu.o
obj-y += allowlist.o
kernelsu-objs := apk_sign.o
obj-y += kernelsu.o
obj-y += module_api.o
obj-y += sucompat.o
obj-y += uid_observer.o
obj-y += manager.o
obj-y += core_hook.o
obj-y += ksud.o
obj-y += embed_ksud.o
obj-y += kernel_compat.o

obj-y += selinux/
# .git is a text file while the module is imported by 'git submodule add'.
$(info "$(srctree)")
$(info "$(src)")
ifeq ($(shell test -e $(srctree)/KernelSU/.git; echo $$?),0)
KSU_GIT_VERSION := $(shell cd $(srctree)/$(src); /usr/bin/env PATH="$$PATH":/usr/bin:/usr/local/bin git rev-list --count HEAD)
# ksu_version: major * 10000 + git version + 200 for historical reasons
$(eval KSU_VERSION=$(shell expr 10000 + $(KSU_GIT_VERSION) + 200))
$(info -- KernelSU version: $(KSU_VERSION))
ccflags-y += -DKSU_VERSION=$(KSU_VERSION)
else # If there is no .git file, the default version will be passed.
$(warning "KSU_GIT_VERSION not defined! It is better to make KernelSU a git submodule!")
ccflags-y += -DKSU_VERSION=16
endif

ifndef KSU_EXPECTED_SIZE
KSU_EXPECTED_SIZE := 0x033b
endif

ifndef KSU_EXPECTED_HASH
KSU_EXPECTED_HASH := 0xb0b91415
endif

$(info -- KernelSU Manager signature size: $(KSU_EXPECTED_SIZE))
$(info -- KernelSU Manager signature hash: $(KSU_EXPECTED_HASH))

ccflags-y += -DEXPECTED_SIZE=$(KSU_EXPECTED_SIZE)
ccflags-y += -DEXPECTED_HASH=$(KSU_EXPECTED_HASH)
ccflags-y += -Wno-implicit-function-declaration -Wno-strict-prototypes -Wno-int-conversion -Wno-gcc-compat
ccflags-y += -Wno-declaration-after-statement

感觉是make不同版本对软链接目录处理不同

如果还不行请附上KernelSU那段编译日志,KernelSU Version前面有两行一起复制上来。 并且在/drivers/kernelsu目录下执行

git rev-list --count HEAD
make -v
git -v

把输出复制出来

tiann commented 1 year ago

$(warning "KSU_GIT_VERSION not defined! It is better to make KernelSU a git submodule!")

需要确保,在 kernel 源码树的 KernelSU 目录中,执行 git 命令可以正常输出 KernelSU 仓库的相关信息,请你自行检查一下。

General110 commented 1 year ago

用bazel 构建就KSU_GIT_VERSION not defined! It is better to make KernelSU a git submodule!。用build/build.sh