@@ -49,11 +49,52 @@ runs:
4949 shell : bash
5050 run : |
5151 set -euo pipefail
52+ echo "::group::Validate inputs"
53+
5254 model='${{ inputs.model }}'
53- if [[ -z "$model" ]]; then
54- echo "Empty model not allowed"; exit 1
55+ soc='${{ inputs.soc }}'
56+ branch='${{ inputs.branch }}'
57+ manifest='${{ inputs.manifest }}'
58+ optimize='${{ inputs.optimize_level }}'
59+
60+ # Non-empty checks
61+ [[ -n "$model" ]] || { echo "Input 'model' cannot be empty"; exit 1; }
62+ [[ -n "$soc" ]] || { echo "Input 'soc' cannot be empty"; exit 1; }
63+ [[ -n "$branch" ]] || { echo "Input 'branch' cannot be empty"; exit 1; }
64+ [[ -n "$manifest" ]] || { echo "Input 'manifest' cannot be empty"; exit 1; }
65+
66+ # Basic format checks
67+ # soc: allow letters, digits, underscores, dashes (e.g., sm8650)
68+ if ! [[ "$soc" =~ ^[A-Za-z0-9_-]+$ ]]; then
69+ echo "Input 'soc' contains invalid characters. Allowed : letters, digits, underscore, dash"; exit 1
70+ fi
71+ # branch: allow common ref patterns; spaces not allowed
72+ if ! [[ "$branch" =~ ^[A-Za-z0-9._/-]+$ ]]; then
73+ echo "Input 'branch' contains invalid characters. Allowed : letters, digits, ., _, -, /"; exit 1
74+ fi
75+ # manifest: either HTTPS URL ending with .xml, or a filename ending with .xml (no spaces)
76+ if [[ "$manifest" == http*://* ]]; then
77+ if ! [[ "$manifest" =~ ^https:// ]]; then
78+ echo "Manifest URL must be HTTPS"; exit 1
79+ fi
80+ if ! [[ "$manifest" =~ \.xml($|\?) ]]; then
81+ echo "Manifest URL should point to an XML file (.xml)"; exit 1
82+ fi
83+ else
84+ if ! [[ "$manifest" =~ \.xml$ ]]; then
85+ echo "Manifest filename must end with .xml"; exit 1
86+ fi
87+ if [[ "$manifest" =~ [[:space:]] ]]; then
88+ echo "Manifest filename cannot contain spaces"; exit 1
89+ fi
5590 fi
91+ # Optimize level validation
92+ case "$optimize" in
93+ O2|O3) ;;
94+ *) echo "optimize_level must be O2 or O3; got '$optimize'"; exit 1 ;;
95+ esac
5696 echo "Input validation OK."
97+ echo "::endgroup::"
5798
5899 - name : Install Minimal Dependencies
59100 shell : bash
@@ -402,12 +443,19 @@ runs:
402443
403444 - name : Build Kernel
404445 shell : bash
446+ env :
447+ PYTHONWARNINGS : " ignore:invalid escape sequence"
405448 run : |
406449 set -euo pipefail
450+ echo "::group::Build kernel"
407451 KERNEL_PATH="$GITHUB_WORKSPACE/$CONFIG/kernel_platform"
408452 COMMON="$KERNEL_PATH/common"
409453 cd "$COMMON"
410454 : > "$COMMON/.scmversion"
455+
456+ # Ensure Python warnings are suppressed for scripts invoked by make
457+ export PYTHONWARNINGS="${PYTHONWARNINGS}"
458+
411459 if [ -n "${CLANG_BIN_PATH:-}" ] && [ -x "${CLANG_BIN_PATH}/clang" ]; then
412460 export PATH="${CLANG_BIN_PATH}:$PATH"
413461 fi
@@ -420,30 +468,43 @@ runs:
420468 OUT=out
421469 mkdir -p "$OUT"
422470 make O="$OUT" gki_defconfig
471+
472+ # LOCALVERSION branding
423473 if [ -n "${CUSTOM_LOCALVERSION:-}" ]; then
424474 scripts/config --file "$OUT/.config" --set-str LOCALVERSION "${CUSTOM_LOCALVERSION}"
425475 scripts/config --file "$OUT/.config" -d LOCALVERSION_AUTO || true
426476 sed -i 's/scm_version="$(scm_version --short)"/scm_version=""/' scripts/setlocalversion
427477 fi
478+
479+ # Optimize level config and flags
428480 if [ "${{ inputs.optimize_level }}" = "O3" ]; then
429481 scripts/config --file "$OUT/.config" -d CC_OPTIMIZE_FOR_PERFORMANCE
430482 scripts/config --file "$OUT/.config" -e CC_OPTIMIZE_FOR_PERFORMANCE_O3
431- export KCFLAGS ="-Wno-error -pipe -O3 -fno-stack-protector "
483+ KCFLAGS_EXTRA ="-O3 "
432484 else
433485 scripts/config --file "$OUT/.config" -e CC_OPTIMIZE_FOR_PERFORMANCE
434486 scripts/config --file "$OUT/.config" -d CC_OPTIMIZE_FOR_PERFORMANCE_O3
435- export KCFLAGS ="-Wno-error -pipe -O2 -fno-stack-protector "
487+ KCFLAGS_EXTRA ="-O2 "
436488 fi
437- export KCPPFLAGS="-DCONFIG_OPTIMIZE_INLINING"
489+
490+ # Consistent flags; include -pipe and disable stack protector
491+ KCFLAGS="-Wno-error -pipe -fno-stack-protector ${KCFLAGS_EXTRA}"
492+ KCPPFLAGS="-DCONFIG_OPTIMIZE_INLINING"
493+
494+ # Regenerate defaults after config edits
438495 make O="$OUT" olddefconfig
496+
439497 echo "Starting build with $(nproc --all) threads..."
440498 set -o pipefail
441- make -j"$(nproc --all)" O="$OUT" 2>&1 | tee build.log
499+ make -j"$(nproc --all)" O="$OUT" KCFLAGS="$KCFLAGS" KCPPFLAGS="$KCPPFLAGS" 2>&1 | tee build.log
500+
442501 IMG="$OUT/arch/arm64/boot/Image"
443502 if [ ! -f "$IMG" ]; then
444- echo "Kernel Image missing"; exit 1
503+ echo "Kernel Image missing"
504+ exit 1
445505 fi
446506 sha256sum "$IMG" | tee "$OUT/Image.sha256"
507+ echo "::endgroup::"
447508
448509 - name : Collect Build Stats / Validate Image
449510 id : collect_stats
@@ -551,4 +612,3 @@ runs:
551612 with :
552613 name : kernel-${{ env.CONFIG }}
553614 path : ${{ env.CONFIG }}/artifacts/
554-
0 commit comments