2 ###############################################################################
3 # IPFire.org - An Open Source Firewall Solution #
4 # Copyright (C) - IPFire Development Team <info@ipfire.org> #
5 ###############################################################################
7 BASEDIR
=$
(dirname ${0})
11 CONFIGS
="x86_64:default"
14 CONFIGS
="${CONFIGS} i686:legacy i686:default"
17 CONFIGS
="${CONFIGS} armv7hl:exynos armv7hl:default"
20 CONFIGS
="${CONFIGS} armv5tel:versatile armv5tel:kirkwood"
22 function merge_config
() {
29 for arg
in arch flavour output
; do
30 if [ -z "${!arg}" ]; then
31 echo >&2 "merge usage: <arch> <flavour> <output filename>"
36 local config_mode
="oldnoconfig"
38 while [ $# -gt 0 ]; do
41 config_mode
=${1#--mode=}
45 echo >&2 "Unknown option: ${1}"
48 extra_configs
="${extra_configs} ${1}"
54 local configs
="${extra_configs} config-generic"
56 case "${arch}:${flavour}" in
59 configs
="${configs} config-x86-generic config-x86_64-default"
62 configs
="${configs} config-x86-generic config-i686-default"
65 configs
="${configs} config-x86-generic config-i686-default"
66 configs
="${configs} config-i686-legacy"
71 configs
="${configs} config-arm-generic"
74 configs
="${configs} config-arm-generic config-armv5tel-kirkwood"
77 configs
="${configs} config-arm-generic config-armv7hl-default"
80 configs
="${configs} config-arm-generic config-armv7hl-default"
81 configs
="${configs} config-armv7hl-exynos"
84 echo >&2 "ERROR: Invalid parameters given: $@"
89 # Determine the kernel arch.
100 # Merge the configuration files from its elementary configuration
102 local tmp_out
=$
(mktemp
)
103 local tmp_in
=$
(mktemp
)
106 for config
in ${configs}; do
107 cat ${tmp_out} > ${tmp_in}
108 perl
${SCRIPTS_DIR}/merge.pl \
109 ${config} ${tmp_in} > ${tmp_out}
112 if [ "${config_mode}" != "none" ]; then
113 echo "Running 'make oldnoconfig' for ${arch} (${flavour})..."
116 cat ${tmp_out} > .config
117 make ARCH
="${kernel_arch}" ${config_mode}
118 cat .config
> ${tmp_out}
122 cat ${tmp_out} > ${output}
123 rm -f ${tmp_in} ${tmp_out}
126 # This function runs an interactive "make oldconfig".
127 function make_oldconfig
() {
129 local kernel_arch
="x86"
130 local flavour
="default"
132 local config_in
=$
(mktemp
)
133 local config_out
=$
(mktemp
)
134 local diff_out
=$
(mktemp
)
136 merge_config
${arch} ${flavour} ${config_in} --mode=none
140 cat ${config_in} > .config
142 echo "You may now edit the configuration..."
145 select option
in oldconfig menuconfig oldnoconfig startover quit
; do
147 oldconfig|menuconfig|oldnoconfig
)
148 make ARCH
=${kernel_arch} ${option}
151 cat ${config_in} > .config
159 cat .config
> ${config_out}
162 ${SCRIPTS_DIR}/configdiff.py ${config_in} ${config_out} > ${diff_out}
164 # Update the rest of the configurations.
165 diff_configs
${diff_out} --mode=oldconfig
167 rm -f ${config_in} ${config_out} ${diff_out}
171 # Intersection of all files.
173 # Diff of (intersection of (i686-{default,legacy} and x86_64-default)
174 # against config-generic).
176 # Diff against merge of (config-generic and config-x86-generic).
178 function diff_configs
() {
179 local extra_configs
="$@"
181 declare -A arch_configs
185 for config
in ${CONFIGS}; do
189 filename
=${tmpdir}/config-${arch}-${flavour}
191 merge_config
${arch} ${flavour} ${filename} ${extra_configs}
193 # Do not include i686 legacy.
207 arch_configs
[x86
]="${arch_configs[x86]} ${filename}"
210 arch_configs
[arm
]="${arch_configs[arm]} ${filename}"
213 echo >&2 "ERROR: Invalid architecture: ${arch}"
219 for arch
in x86 arm
; do
220 filename
="${tmpdir}/config-${arch}-common"
221 ${SCRIPTS_DIR}/configcommon.py ${arch_configs[${arch}]} \
224 common_configs
="${common_configs} ${filename}"
227 ${SCRIPTS_DIR}/configcommon.py ${common_configs} > ${tmpdir}/config-generic
229 ${SCRIPTS_DIR}/configdiff.py ${tmpdir}/config-generic ${tmpdir}/config-arm-common \
230 > ${tmpdir}/config-arm-generic
232 ${SCRIPTS_DIR}/configdiff.py ${tmpdir}/config-generic ${tmpdir}/config-x86-common \
233 > ${tmpdir}/config-x86-generic
235 for config
in ${CONFIGS}; do
247 filename
=${tmpdir}/config-${arch}-${flavour}
251 # Legacy depends directly on the default configuration.
252 ${SCRIPTS_DIR}/configdiff.py
${tmpdir}/config-i686-default \
253 ${filename} > ${filename}.tmp
256 # Exynos depends directly on the default configuration.
257 ${SCRIPTS_DIR}/configdiff.py
${tmpdir}/config-armv7hl-default \
258 ${filename} > ${filename}.tmp
265 ${SCRIPTS_DIR}/configdiff.py ${tmpdir}/config-${suparch}-common \
266 ${filename} > ${filename}.tmp
269 mv ${filename}{.tmp
,}
271 rm -f ${tmpdir}/config-
*-common
273 for config
in ${tmpdir}/*; do
274 if ! cmp $
(basename ${config}) ${config} &>/dev
/null
; then
275 echo "$(basename ${config}) has changed."
277 cat ${config} > $
(basename ${config})
286 while [ $# -gt 0 ]; do
290 KERNEL_DIR
=${arg#--kernel-dir=}
293 echo "${0} - available commands:"
294 echo " * merge <arch> <flavour> <output filename>"
298 echo " You must always set --kernel-dir=..."
301 merge|oldconfig|update
)
308 if [ -z "${KERNEL_DIR}" ]; then
309 echo >&2 "--kernel-dir=... was not set!"
313 if [ -z "${action}" ]; then
314 echo >&2 "No action given... Try ${0} help."