2 ###############################################################################
3 # IPFire.org - An Open Source Firewall Solution #
4 # Copyright (C) - IPFire Development Team <info@ipfire.org> #
5 ###############################################################################
7 BASEDIR
=$
(dirname ${0})
10 CONFIGS
="x86_64:default i686:legacy i686:default"
11 CONFIGS
="${CONFIGS} armv7hl:omap armv5tel:versatile armv5tel:kirkwood"
13 function merge_config
() {
20 for arg
in arch flavour output
; do
21 if [ -z "${!arg}" ]; then
22 echo >&2 "merge usage: <arch> <flavour> <output filename>"
27 local config_mode
="oldnoconfig"
29 while [ $# -gt 0 ]; do
32 config_mode
=${1#--mode=}
36 echo >&2 "Unknown option: ${1}"
39 extra_configs
="${extra_configs} ${1}"
45 local configs
="${extra_configs} config-generic"
47 case "${arch}:${flavour}" in
50 configs
="${configs} config-x86-generic config-x86_64-default"
53 configs
="${configs} config-x86-generic config-i686-default"
56 configs
="${configs} config-x86-generic config-i686-default"
57 configs
="${configs} config-i686-legacy"
62 configs
="${configs} config-arm-generic"
65 configs
="${configs} config-arm-generic config-armv5tel-kirkwood"
68 configs
="${configs} config-arm-generic config-armv7hl-omap"
71 echo >&2 "ERROR: Invalid parameters given: $@"
76 # Determine the kernel arch.
87 # Merge the configuration files from its elementary configuration
89 local tmp_out
=$
(mktemp
)
90 local tmp_in
=$
(mktemp
)
93 for config
in ${configs}; do
94 cat ${tmp_out} > ${tmp_in}
95 perl
${SCRIPTS_DIR}/merge.pl \
96 ${config} ${tmp_in} > ${tmp_out}
99 if [ "${config_mode}" != "none" ]; then
100 echo "Running 'make oldnoconfig' for ${arch} (${flavour})..."
103 cat ${tmp_out} > .config
104 make ARCH
="${kernel_arch}" ${config_mode}
105 cat .config
> ${tmp_out}
109 cat ${tmp_out} > ${output}
110 rm -f ${tmp_in} ${tmp_out}
113 # This function runs an interactive "make oldconfig".
114 function make_oldconfig
() {
116 local kernel_arch
="x86"
117 local flavour
="default"
119 local config_in
=$
(mktemp
)
120 local config_out
=$
(mktemp
)
121 local diff_out
=$
(mktemp
)
123 merge_config
${arch} ${flavour} ${config_in} --mode=none
127 cat ${config_in} > .config
129 echo "You may now edit the configuration..."
132 select option
in oldconfig menuconfig oldnoconfig startover quit
; do
134 oldconfig|menuconfig|oldnoconfig
)
135 make ARCH
=${kernel_arch} ${option}
138 cat ${config_in} > .config
146 cat .config
> ${config_out}
149 ${SCRIPTS_DIR}/configdiff.py ${config_in} ${config_out} > ${diff_out}
151 # Update the rest of the configurations.
152 diff_configs
${diff_out} --mode=oldconfig
154 rm -f ${config_in} ${config_out} ${diff_out}
158 # Intersection of all files.
160 # Diff of (intersection of (i686-{default,legacy} and x86_64-default)
161 # against config-generic).
163 # Diff against merge of (config-generic and config-x86-generic).
165 function diff_configs
() {
166 local extra_configs
="$@"
168 declare -A arch_configs
172 for config
in ${CONFIGS}; do
176 filename
=${tmpdir}/config-${arch}-${flavour}
178 merge_config
${arch} ${flavour} ${filename} ${extra_configs}
180 # Do not include i686 legacy.
194 arch_configs
[x86
]="${arch_configs[x86]} ${filename}"
197 arch_configs
[arm
]="${arch_configs[arm]} ${filename}"
200 echo >&2 "ERROR: Invalid architecture: ${arch}"
206 for arch
in x86 arm
; do
207 filename
="${tmpdir}/config-${arch}-common"
208 ${SCRIPTS_DIR}/configcommon.py ${arch_configs[${arch}]} \
211 common_configs
="${common_configs} ${filename}"
214 ${SCRIPTS_DIR}/configcommon.py ${common_configs} > ${tmpdir}/config-generic
216 ${SCRIPTS_DIR}/configdiff.py ${tmpdir}/config-generic ${tmpdir}/config-arm-common \
217 > ${tmpdir}/config-arm-generic
219 ${SCRIPTS_DIR}/configdiff.py ${tmpdir}/config-generic ${tmpdir}/config-x86-common \
220 > ${tmpdir}/config-x86-generic
222 for config
in ${CONFIGS}; do
234 filename
=${tmpdir}/config-${arch}-${flavour}
238 # Legacy depends directly on the default configuration.
239 ${SCRIPTS_DIR}/configdiff.py
${tmpdir}/config-i686-default \
240 ${filename} > ${filename}.tmp
247 ${SCRIPTS_DIR}/configdiff.py ${tmpdir}/config-${suparch}-common \
248 ${filename} > ${filename}.tmp
251 mv ${filename}{.tmp
,}
253 rm -f ${tmpdir}/config-
*-common
255 for config
in ${tmpdir}/*; do
256 if ! cmp $
(basename ${config}) ${config} &>/dev
/null
; then
257 echo "$(basename ${config}) has changed."
259 cat ${config} > $
(basename ${config})
268 while [ $# -gt 0 ]; do
272 KERNEL_DIR
=${arg#--kernel-dir=}
275 echo "${0} - available commands:"
276 echo " * merge <arch> <flavour> <output filename>"
280 echo " You must always set --kernel-dir=..."
283 merge|oldconfig|update
)
290 if [ -z "${KERNEL_DIR}" ]; then
291 echo >&2 "--kernel-dir=... was not set!"
295 if [ -z "${action}" ]; then
296 echo >&2 "No action given... Try ${0} help."