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:lpae armv7hl:default"
23 CONFIGS
="${CONFIGS} armv5tel:default"
26 declare -A SUBPLATFORMS
31 function get_platform
() {
47 function get_subplatform
() {
63 function get_kernel_arch
() {
79 function merge_config
() {
86 for arg
in arch flavour output
; do
87 if [ -z "${!arg}" ]; then
88 echo >&2 "merge usage: <arch> <flavour> <output filename>"
93 local config_mode
="oldnoconfig"
95 while [ $# -gt 0 ]; do
98 config_mode
=${1#--mode=}
102 echo >&2 "Unknown option: ${1}"
105 extra_configs
="${extra_configs} ${1}"
111 local configs
="${extra_configs} config-generic"
113 case "${arch}:${flavour}" in
116 configs
="${configs} config-x86-generic config-x86_64-default"
119 configs
="${configs} config-x86-generic config-i686-default"
122 configs
="${configs} config-x86-generic config-i686-default"
123 configs
="${configs} config-i686-legacy"
128 configs
="${configs} config-arm-generic config-arm64-generic"
133 configs
="${configs} config-arm-generic config-arm32-generic"
134 configs
="${configs} config-armv5tel-default"
137 configs
="${configs} config-arm-generic config-arm32-generic"
138 configs
="${configs} config-armv7hl-default"
141 configs
="${configs} config-arm-generic config-arm32-generic"
142 configs
="${configs} config-armv7hl-default config-armv7hl-lpae"
145 echo >&2 "ERROR: Invalid parameters given: $@"
150 # Merge the configuration files from its elementary configuration
152 local tmp_out
=$
(mktemp
)
153 local tmp_in
=$
(mktemp
)
156 for config
in ${configs}; do
157 cat ${tmp_out} > ${tmp_in}
158 perl
${SCRIPTS_DIR}/merge.pl \
159 ${config} ${tmp_in} > ${tmp_out}
162 if [ "${config_mode}" != "none" ]; then
163 echo "Running 'make oldnoconfig' for ${arch} (${flavour})..."
164 local kernel_arch
="$(get_kernel_arch "${arch}")"
167 cat ${tmp_out} > .config
168 make ARCH
="${kernel_arch}" ${config_mode}
169 cat .config
> ${tmp_out}
173 cat ${tmp_out} > ${output}
174 rm -f ${tmp_in} ${tmp_out}
177 # This function runs an interactive "make oldconfig".
178 function make_oldconfig
() {
180 local kernel_arch
="x86"
181 local flavour
="default"
183 local config_in
=$
(mktemp
)
184 local config_out
=$
(mktemp
)
185 local diff_out
=$
(mktemp
)
187 merge_config
${arch} ${flavour} ${config_in} --mode=none
191 cat ${config_in} > .config
193 echo "You may now edit the configuration..."
196 select option
in oldconfig menuconfig oldnoconfig startover quit
; do
198 oldconfig|menuconfig|oldnoconfig
)
199 make ARCH
=${kernel_arch} ${option}
202 cat ${config_in} > .config
210 cat .config
> ${config_out}
213 ${SCRIPTS_DIR}/configdiff.py ${config_in} ${config_out} > ${diff_out}
215 # Update the rest of the configurations.
216 diff_configs
${diff_out} --mode=oldconfig
218 rm -f ${config_in} ${config_out} ${diff_out}
222 # Intersection of all files.
224 # Diff of (intersection of (i686-{default,legacy} and x86_64-default)
225 # against config-generic).
227 # Diff against merge of (config-generic and config-x86-generic).
229 function diff_configs
() {
230 local extra_configs
="$@"
236 declare -A platform_configs
237 declare -A subplatform_configs
241 for config
in ${CONFIGS}; do
245 filename
=${tmpdir}/config-${arch}-${flavour}
247 merge_config
${arch} ${flavour} ${filename} ${extra_configs}
249 # Do not include leaf configuration.
259 platform
="$(get_platform "${arch}")"
260 subplatform
="$(get_subplatform "${arch}")"
262 if [ -n "${subplatform}" ]; then
263 subplatform_configs
[${subplatform}]="${subplatform_configs[${subplatform}]} ${filename}"
265 platform_configs[${platform}]="${platform_configs[${platform}]} ${filename}"
270 for platform
in ${PLATFORMS}; do
271 for subplatform
in ${SUBPLATFORMS[${platform}]}; do
272 filename
="${tmpdir}/config-${subplatform}-common"
273 ${SCRIPTS_DIR}/configcommon.py ${subplatform_configs[${subplatform}]} \
276 platform_configs
[${platform}]="${platform_configs[${platform}]} ${filename}"
279 filename="${tmpdir}/config-
${platform}-common"
280 ${SCRIPTS_DIR}/configcommon.py ${platform_configs[${platform}]} \
283 common_configs="${common_configs} ${filename}"
286 ${SCRIPTS_DIR}/configcommon.py ${common_configs} > ${tmpdir}/config-generic
288 for platform in ${PLATFORMS}; do
289 for subplatform in ${SUBPLATFORMS[${platform}]}; do
290 ${SCRIPTS_DIR}/configdiff.py \
291 ${tmpdir}/config-${platform}-common \
292 ${tmpdir}/config-${subplatform}-common \
293 > ${tmpdir}/config-${subplatform}-generic
296 ${SCRIPTS_DIR}/configdiff.py \
297 ${tmpdir}/config-generic \
298 ${tmpdir}/config-${platform}-common \
299 > ${tmpdir}/config-${platform}-generic
302 for config in ${CONFIGS}; do
306 filename=${tmpdir}/config-${arch}-${flavour}
310 # Virtual configuration
314 armv7hl:lpae|i686:legacy)
315 # Legacy depends directly on the default configuration.
316 ${SCRIPTS_DIR}/configdiff.py ${tmpdir}/config-${arch}-default \
317 ${filename} > ${filename}.tmp
320 platform="$
(get_subplatform
"${arch}" || get_platform
"${arch}")"
321 ${SCRIPTS_DIR}/configdiff.py ${tmpdir}/config-${platform}-common \
322 ${filename} > ${filename}.tmp
325 mv ${filename}{.tmp,}
327 rm -f ${tmpdir}/config-*-common
329 for config in ${tmpdir}/*; do
330 if ! cmp $(basename ${config}) ${config} &>/dev/null; then
331 echo "$
(basename ${config}) has changed.
"
333 cat ${config} > $(basename ${config})
342 while [ $# -gt 0 ]; do
346 KERNEL_DIR=${arg#--kernel-dir=}
349 echo "${0} - available commands
:"
350 echo " * merge
<arch
> <flavour
> <output filename
>"
354 echo " You must always
set --kernel-dir=...
"
357 merge|oldconfig|update)
364 if [ -z "${KERNEL_DIR}" ]; then
365 echo >&2 "--kernel-dir=... was not
set!"
369 if [ -z "${action}" ]; then
370 echo >&2 "No action given... Try
${0} help.
"