summaryrefslogtreecommitdiff
path: root/sys-boot/linux/files/config_prepare.sh
blob: 729e53cbf4965d56fc920d5e4604cc7b89a6b762 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/sh
set -e

CNF="$(dirname $0)/configs"

CONFS="base gentoo"

while [ $# -gt 0 ]; do
	case "$1" in
		--help|-h)
			echo "Usage: $0 [OPTION]... CONFIG..."
			echo "Combine configurations and esure that we have corrent ones."
			exit
			;;
		--repeat|-r)
			shift
			REPEAT="$1"
			;;
		-*)
			echo "Warning: ignoring uknown option: $1" >&2
			;;
		*)
			if [ -f "$CNF/$1" ]; then
				CONFS="$CONFS $1"
			else
				echo "Warning: ignoring requested missing configuration: $1" >&2
			fi
			;;
	esac
	shift
done

if [ -z "$ARCH" ]; then
	CONFS="$CONFS $(uname -m)"
elif [ "$ARCH" = "x86_64" ]; then
	CONFS="$CONFS x86_64"
fi

for C in $CONFS; do
	while read L; do
		echo "$L" | grep -qE "^[[:space:]]*$" && continue # ignore empty lines
		echo "$L" | grep -qE "#.*" && continue # Ignore comments
		# Remove lines with changed settings
		OPTION="$(echo "$L" | grep -oE '^CONFIG_.*=')"
		sed -i "#^$OPTION#d" .config
		# Put config
		echo "$L" >> .config
	done < "$CNF/$C"
done
# Append small version
#sed  -i "#^CONFIG_LOCALVERSION=#g" .config
#echo "CONFIG_LOCALVERSION=\".$VERSION\"" >> .config