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} aarch64:default"
20 CONFIGS
="${CONFIGS} armv7hl:default"
23 declare -A SUBPLATFORMS
28 function get_platform
() {
44 function get_subplatform
() {
60 function get_kernel_arch
() {
76 function merge_config
() {
83 for arg
in arch flavour output
; do
84 if [ -z "${!arg}" ]; then
85 echo >&2 "merge usage: <arch> <flavour> <output filename>"
90 local config_mode
="oldnoconfig"
92 while [ $# -gt 0 ]; do
95 config_mode
=${1#--mode=}
99 echo >&2 "Unknown option: ${1}"
102 extra_configs
="${extra_configs} ${1}"
108 local configs
="${extra_configs} config-generic"
110 case "${arch}:${flavour}" in
113 configs
="${configs} config-x86-generic config-x86_64-default"
116 configs
="${configs} config-x86-generic config-i686-default"
119 configs
="${configs} config-x86-generic config-i686-default"
120 configs
="${configs} config-i686-legacy"
125 configs
="${configs} config-arm-generic config-arm64-generic"
130 configs
="${configs} config-arm-generic config-arm32-generic"
133 echo >&2 "ERROR: Invalid parameters given: $@"
138 # Merge the configuration files from its elementary configuration
140 local tmp_out
=$
(mktemp
)
141 local tmp_in
=$
(mktemp
)
144 for config
in ${configs}; do
145 cat ${tmp_out} > ${tmp_in}
146 perl
${SCRIPTS_DIR}/merge.pl \
147 ${config} ${tmp_in} > ${tmp_out}
150 if [ "${config_mode}" != "none" ]; then
151 echo "Running 'make oldnoconfig' for ${arch} (${flavour})..."
152 local kernel_arch
="$(get_kernel_arch "${arch}")"
155 cat ${tmp_out} > .config
156 make ARCH
="${kernel_arch}" ${config_mode}
157 cat .config
> ${tmp_out}
161 cat ${tmp_out} > ${output}
162 rm -f ${tmp_in} ${tmp_out}
165 # This function runs an interactive "make oldconfig".
166 function make_oldconfig
() {
168 local kernel_arch
="x86"
169 local flavour
="default"
171 local config_in
=$
(mktemp
)
172 local config_out
=$
(mktemp
)
173 local diff_out
=$
(mktemp
)
175 merge_config
${arch} ${flavour} ${config_in} --mode=none
179 cat ${config_in} > .config
181 echo "You may now edit the configuration..."
184 select option
in oldconfig menuconfig oldnoconfig startover quit
; do
186 oldconfig|menuconfig|oldnoconfig
)
187 make ARCH
=${kernel_arch} ${option}
190 cat ${config_in} > .config
198 cat .config
> ${config_out}
201 ${SCRIPTS_DIR}/configdiff.py ${config_in} ${config_out} > ${diff_out}
203 # Update the rest of the configurations.
204 diff_configs
${diff_out} --mode=oldconfig
206 rm -f ${config_in} ${config_out} ${diff_out}
210 # Intersection of all files.
212 # Diff of (intersection of (i686-{default,legacy} and x86_64-default)
213 # against config-generic).
215 # Diff against merge of (config-generic and config-x86-generic).
217 function diff_configs
() {
218 local extra_configs
="$@"
224 declare -A platform_configs
225 declare -A subplatform_configs
229 for config
in ${CONFIGS}; do
233 filename
=${tmpdir}/config-${arch}-${flavour}
235 merge_config
${arch} ${flavour} ${filename} ${extra_configs}
237 # Do not include leaf configuration.
244 platform
="$(get_platform "${arch}")"
245 subplatform
="$(get_subplatform "${arch}")"
247 if [ -n "${subplatform}" ]; then
248 subplatform_configs
[${subplatform}]="${subplatform_configs[${subplatform}]} ${filename}"
250 platform_configs[${platform}]="${platform_configs[${platform}]} ${filename}"
255 for platform
in ${PLATFORMS}; do
256 for subplatform
in ${SUBPLATFORMS[${platform}]}; do
257 filename
="${tmpdir}/config-${subplatform}-common"
258 ${SCRIPTS_DIR}/configcommon.py ${subplatform_configs[${subplatform}]} \
261 platform_configs
[${platform}]="${platform_configs[${platform}]} ${filename}"
264 filename="${tmpdir}/config-
${platform}-common"
265 ${SCRIPTS_DIR}/configcommon.py ${platform_configs[${platform}]} \
268 common_configs="${common_configs} ${filename}"
271 ${SCRIPTS_DIR}/configcommon.py ${common_configs} > ${tmpdir}/config-generic
273 for platform in ${PLATFORMS}; do
274 for subplatform in ${SUBPLATFORMS[${platform}]}; do
275 ${SCRIPTS_DIR}/configdiff.py \
276 ${tmpdir}/config-${platform}-common \
277 ${tmpdir}/config-${subplatform}-common \
278 > ${tmpdir}/config-${subplatform}-generic
281 ${SCRIPTS_DIR}/configdiff.py \
282 ${tmpdir}/config-generic \
283 ${tmpdir}/config-${platform}-common \
284 > ${tmpdir}/config-${platform}-generic
287 for config in ${CONFIGS}; do
291 filename=${tmpdir}/config-${arch}-${flavour}
294 aarch64:default|armv7hl:default)
295 # Virtual configuration
300 # Legacy depends directly on the default configuration.
301 ${SCRIPTS_DIR}/configdiff.py ${tmpdir}/config-${arch}-default \
302 ${filename} > ${filename}.tmp
305 platform="$
(get_subplatform
"${arch}" || get_platform
"${arch}")"
306 ${SCRIPTS_DIR}/configdiff.py ${tmpdir}/config-${platform}-common \
307 ${filename} > ${filename}.tmp
310 mv ${filename}{.tmp,}
312 rm -f ${tmpdir}/config-*-common
314 for config in ${tmpdir}/*; do
315 if ! cmp $(basename ${config}) ${config} &>/dev/null; then
316 echo "$
(basename ${config}) has changed.
"
318 cat ${config} > $(basename ${config})
327 while [ $# -gt 0 ]; do
331 KERNEL_DIR=${arg#--kernel-dir=}
334 echo "${0} - available commands
:"
335 echo " * merge
<arch
> <flavour
> <output filename
>"
339 echo " You must always
set --kernel-dir=...
"
342 merge|oldconfig|update)
349 if [ -z "${KERNEL_DIR}" ]; then
350 echo >&2 "--kernel-dir=... was not
set!"
354 if [ -z "${action}" ]; then
355 echo >&2 "No action given... Try
${0} help.
"