This is a small script updating the stored busybox config files from an extracted source tree. Basically it copies the the files keeping directory hierarchy intact, adjusts contained 'source' calls for the new path (relative to $TOPDIR) and prefixes all defined (and referenced) symbols with 'BUSYBOX_'.
Signed-off-by: Phil Sutter phil@nwl.cc --- Changes since v1: - Fix last-minute change in sed argument prep breaking functionality - Also replace default install prefix by '@IDIR@' --- package/busybox/extract_config.sh | 56 +++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100755 package/busybox/extract_config.sh
diff --git a/package/busybox/extract_config.sh b/package/busybox/extract_config.sh new file mode 100755 index 0000000000000..1d2b08f0f7c0c --- /dev/null +++ b/package/busybox/extract_config.sh @@ -0,0 +1,56 @@ +#!/bin/bash + +[[ -d "$1" ]] || { + echo "Usage: $(basename $0) <busybox_sourcedir>" + exit 1 +} + +bbsrc="$(realpath $1)" +cd $(dirname $0) + +[[ -e config.new ]] && { + echo -n "config.new exists already. delete? [y|n] " + read ans + case "$ans" in + y|Y) + rm -rf config.new + ;; + n|N) + ;; + *) + echo "what is '$ans'?" + exit 1 + esac +} +mkdir -p config.new + +# store config paths relative to $bbsrc into an array +readarray -t configs <<< $(cd "$bbsrc"; find . -type f -name Config.in) + +# copy each config into config.new +for config in "${configs[@]}"; do + mkdir -p config.new/$(dirname $config) + cp "$bbsrc/$config" "config.new/$config" +done + +# store defined config symbols into an array +readarray -t symbols <<< $(grep -hr '^config ' config.new | cut -d' ' -f2) + +### customize busybox config system for OpenADK + +cd config.new + +# no extra mainmenu, allow replacing PREFIX +sed -i -e 's/^mainmenu/# mainmenu/' -e 's,./_install,@IDIR@,' Config.in + +# prefix all symbols with BUSYBOX_ to create a namespace +# limit replacement to lines containing given keywords to +# not mess up help texts and prompts too much +keywords='(config|depends|range|select|default|^if )' +sympipe=$(IFS='|'; echo "${symbols[*]}" | sed -e 's/|/\|/g') +sympipe_s='/'$keywords'/s/\b('$sympipe')\b/BUSYBOX_\1/g' + +# fix path of all sourced files +source_s='s,^(source *)([^ ]*)$,\1package/busybox/config/\2,' + +sed -i -e "$sympipe_s" -e "$source_s" "${configs[@]}"