libunwind: update to 1.8.1
[openadk.git] / package / busybox / extract_config.sh
blob1d2b08f0f7c0c1d11326805ce2d018785029eb05
1 #!/bin/bash
3 [[ -d "$1" ]] || {
4 echo "Usage: $(basename $0) <busybox_sourcedir>"
5 exit 1
8 bbsrc="$(realpath $1)"
9 cd $(dirname $0)
11 [[ -e config.new ]] && {
12 echo -n "config.new exists already. delete? [y|n] "
13 read ans
14 case "$ans" in
15 y|Y)
16 rm -rf config.new
18 n|N)
21 echo "what is '$ans'?"
22 exit 1
23 esac
25 mkdir -p config.new
27 # store config paths relative to $bbsrc into an array
28 readarray -t configs <<< $(cd "$bbsrc"; find . -type f -name Config.in)
30 # copy each config into config.new
31 for config in "${configs[@]}"; do
32 mkdir -p config.new/$(dirname $config)
33 cp "$bbsrc/$config" "config.new/$config"
34 done
36 # store defined config symbols into an array
37 readarray -t symbols <<< $(grep -hr '^config ' config.new | cut -d' ' -f2)
39 ### customize busybox config system for OpenADK
41 cd config.new
43 # no extra mainmenu, allow replacing PREFIX
44 sed -i -e 's/^mainmenu/# mainmenu/' -e 's,./_install,@IDIR@,' Config.in
46 # prefix all symbols with BUSYBOX_ to create a namespace
47 # limit replacement to lines containing given keywords to
48 # not mess up help texts and prompts too much
49 keywords='\(config\|depends\|range\|select\|default\|^if \)'
50 sympipe=$(IFS='|'; echo "${symbols[*]}" | sed -e 's/|/\\|/g')
51 sympipe_s='/'$keywords'/s/\b\('$sympipe'\)\b/BUSYBOX_\1/g'
53 # fix path of all sourced files
54 source_s='s,^\(source *\)\([^ ]*\)$,\1package/busybox/config/\2,'
56 sed -i -e "$sympipe_s" -e "$source_s" "${configs[@]}"