scripts/kconfig/merge_config.sh

Source file repositories/reference/linux-study-clean/scripts/kconfig/merge_config.sh

File Facts

System
Linux kernel
Corpus path
scripts/kconfig/merge_config.sh
Extension
.sh
Size
8959 bytes
Lines
384
Domain
Support Tooling And Documentation
Bucket
scripts
Inferred role
Support Tooling And Documentation: scripts
Status
atlas-only

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

function get_cfg(line) {
		if (match(line, cfg_regex)) {
			return substr(line, RSTART, RLENGTH)
		} else if (match(line, notset_regex)) {
			# Extract CONFIG_FOO from "# CONFIG_FOO is not set"
			sub(/^# /, "", line)
			sub(/ is not set$/, "", line)
			return line
		}
		return ""
	}

	function warn_builtin(cfg, prev, new) {
		if (warnoverride == "true") return
		print cfg ": -y passed, will not demote y to m"
		print "Previous value: " prev
		print "New value: " new
		print ""
	}

	function warn_redefined(cfg, prev, new) {
		if (warnoverride == "true") return
		print "Value of " cfg " is redefined by fragment " mergefile ":"
		print "Previous value: " prev
		print "New value: " new
		print ""
	}

	function warn_redundant(cfg) {
		if (warnredun != "true" || warnoverride == "true") return
		print "Value of " cfg " is redundant by fragment " mergefile ":"
	}

	# First pass: read merge file, store all lines and index
	FILENAME == ARGV[1] {
		mergefile = FILENAME
		merge_lines[FNR] = $0
		merge_total = FNR
		cfg = get_cfg($0)
		if (cfg != "") {
			merge_cfg[cfg] = $0
			merge_cfg_line[cfg] = FNR
		}
		next
	}

	# Second pass: process base file (TMP_FILE)
	FILENAME == ARGV[2] {
		cfg = get_cfg($0)

		# Not a config or not in merge file - keep it
		if (cfg == "" || !(cfg in merge_cfg)) {
			print $0 >> outfile
			next
		}

		prev_val = $0
		new_val = merge_cfg[cfg]

		# BUILTIN: do not demote y to m
		if (builtin == "true" && new_val ~ /=m$/ && prev_val ~ /=y$/) {
			warn_builtin(cfg, prev_val, new_val)
			print $0 >> outfile
			skip_merge[merge_cfg_line[cfg]] = 1
			next
		}

		# Values equal - redundant
		if (prev_val == new_val) {
			warn_redundant(cfg)

Annotation

Implementation Notes