Skip to content

Commit b46be97

Browse files
Fix BBG host header generation on legacy builds
1 parent 66f50d4 commit b46be97

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

.github/workflows/build.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1442,6 +1442,45 @@ jobs:
14421442
working-directory: ${{ env.KERNEL_ROOT }}
14431443
run: |
14441444
wget -O- https://github.com/vc-teahouse/Baseband-guard/raw/main/setup.sh | bash
1445+
BBG_MAKEFILE="Baseband-guard/Makefile"
1446+
if [ -f "$BBG_MAKEFILE" ]; then
1447+
python3 - "$BBG_MAKEFILE" <<'PY'
1448+
import sys
1449+
from pathlib import Path
1450+
1451+
path = Path(sys.argv[1])
1452+
text = path.read_text(encoding="utf-8")
1453+
1454+
if "BBG_HOSTCC :=" not in text:
1455+
text = text.replace(
1456+
"obj-$(CONFIG_BBG) += bbg.o\n\n",
1457+
"obj-$(CONFIG_BBG) += bbg.o\n\n"
1458+
"BBG_HOSTCC := $(shell if [ -x /usr/bin/gcc ]; then "
1459+
"printf '%s\\n' /usr/bin/gcc; elif [ -x /usr/bin/cc ]; then "
1460+
"printf '%s\\n' /usr/bin/cc; else command -v gcc 2>/dev/null || "
1461+
"command -v cc 2>/dev/null || printf '%s\\n' \"$(HOSTCC)\"; fi)\n"
1462+
"BBG_SKIP_GENHEADERS := $(filter clean mrproper distclean,$(MAKECMDGOALS))\n\n",
1463+
1,
1464+
)
1465+
1466+
text = text.replace(
1467+
"$(shell $(HOSTCC) -I$(srctree)/scripts/selinux/genheaders",
1468+
"$(shell $(BBG_HOSTCC) -I$(srctree)/scripts/selinux/genheaders",
1469+
1,
1470+
)
1471+
1472+
if "ifeq ($(BBG_SKIP_GENHEADERS),)\nifneq ($(wildcard $(objtree)/security/selinux/flask.h),)" not in text:
1473+
text = text.replace(
1474+
"ifneq ($(wildcard $(objtree)/security/selinux/flask.h),)\n",
1475+
"ifeq ($(BBG_SKIP_GENHEADERS),)\n"
1476+
"ifneq ($(wildcard $(objtree)/security/selinux/flask.h),)\n",
1477+
1,
1478+
)
1479+
text = text.replace("\nendif\n\nGIT_BIN :=", "\nendif\nendif\n\nGIT_BIN :=", 1)
1480+
1481+
path.write_text(text, encoding="utf-8")
1482+
PY
1483+
fi
14451484
echo "CONFIG_BBG=y" >> common/arch/arm64/configs/gki_defconfig
14461485
sed -i '/^config LSM$/,/^help$/{ /^[[:space:]]*default/ { /baseband_guard/! s/selinux/selinux,baseband_guard/ } }' common/security/Kconfig
14471486

0 commit comments

Comments
 (0)