| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- # .github/actions/set-kernel-config/action.yml
- name: Set Kernel Config
- description: Enables kernel configs — handles =y, =n, "not set", missing, and arbitrary values
- inputs:
- configs:
- description: |
- Newline-separated list of configs to set.
- Plain name defaults to =y. Supply a value for anything else.
- Examples:
- CONFIG_PID_NS
- CONFIG_IP_SET_MAX=65534
- CONFIG_LOG_BUF_SHIFT=17
- required: true
- defconfig:
- description: Path to the defconfig file
- required: true
- fragment:
- description: Path to the .config fragment file (missing configs land here)
- required: true
- runs:
- using: composite
- steps:
- - name: Apply configs
- shell: bash
- run: |
- DEFCONFIG="${{ inputs.defconfig }}"
- FRAGMENT="${{ inputs.fragment }}"
- touch "${FRAGMENT}"
- set_config() {
- local input="$1"
- # Split name=value — default to =y if no value supplied
- if [[ "$input" == *"="* ]]; then
- local config="${input%%=*}"
- local value="${input#*=}"
- else
- local config="$input"
- local value="y"
- fi
- if grep -q "^${config}=${value}$" "${DEFCONFIG}"; then
- echo "[SKIP] ${config} already =${value} in defconfig"
- elif grep -q "^${config}=" "${DEFCONFIG}"; then
- # Present but wrong value — replace it
- sed -i "s/^${config}=.*/${config}=${value}/" "${DEFCONFIG}"
- echo "[FIX] ${config} had wrong value → updated to =${value} in defconfig"
- elif grep -q "# ${config} is not set" "${DEFCONFIG}"; then
- sed -i "s/# ${config} is not set/${config}=${value}/" "${DEFCONFIG}"
- echo "[FIX] ${config} was 'not set' → set to =${value} in defconfig"
- else
- if ! grep -q "^${config}=${value}$" "${FRAGMENT}"; then
- echo "${config}=${value}" >> "${FRAGMENT}"
- echo "[FRAG] ${config} not found → added =${value} to fragment"
- else
- echo "[SKIP] ${config} already =${value} in fragment"
- fi
- fi
- }
- while IFS= read -r line; do
- # Strip whitespace, skip blanks and comments
- line="$(echo "$line" | tr -d '[:space:]')"
- [[ -z "$line" || "$line" == \#* ]] && continue
- set_config "$line"
- done <<< "${{ inputs.configs }}"
|