split-cfg.sh 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. # This file is part of the OpenADK project. OpenADK is copyrighted
  2. # material, please see the LICENCE file in the top-level directory.
  3. # Note: this is slow, but it's not the "progress stuff" which cau-
  4. # ses the slow-down.
  5. TOPDIR=$1
  6. [[ -n $BASH_VERSION ]] && shopt -s extglob
  7. grep -v '^BUSYBOX\|^# BUSYBOX' $TOPDIR/.config > $TOPDIR/.config.split
  8. mkdir -p $TOPDIR/.cfg
  9. cd $TOPDIR/.cfg
  10. oldfiles=$(echo *)
  11. newfiles=:
  12. echo -n 'autosplitting main config...'
  13. while read line; do
  14. oline=$line
  15. [[ -n $line ]] && if [[ $line = @(# [A-Z])* ]]; then
  16. line=${line#? }
  17. if [[ $line = *@( is not set) ]]; then
  18. line=${line% is not set}
  19. else
  20. # some kind of comment
  21. line=
  22. fi
  23. elif [[ $line = @([A-Z])*@(=)* ]]; then
  24. line=${line%%=*}
  25. elif [[ $line = @(#)* ]]; then
  26. # valid comment
  27. line=
  28. else
  29. # invalid non-comment
  30. echo "Warning: line '$oline' invalid!" >&2
  31. line=
  32. fi
  33. # if the line is a valid yes/no/whatever, write it
  34. # unless the file already exists and has same content
  35. if [[ -n $line ]]; then
  36. if [[ $line != ADK_HAVE_DOT_CONFIG && -s $line ]]; then
  37. fline=$(<$line)
  38. else
  39. fline=
  40. fi
  41. [[ $oline = $fline ]] || echo "$oline" >$line
  42. if [[ $newfiles = *:$line:* ]]; then
  43. echo "Error: duplicate Config.in option '$line'!" >&2
  44. exit 1
  45. fi
  46. newfiles=$newfiles$line:
  47. fi
  48. done <$TOPDIR/.config.split
  49. # now handle the case of removals
  50. echo -n ' removals...'
  51. for oldfile in $oldfiles; do
  52. [[ $newfiles = *:$oldfile:* ]] || rm -f $oldfile
  53. done
  54. printf '\r%60s\r' ''
  55. # now scan for dependencies of packages; the information
  56. # should probably be in build_mipsel because it's generated
  57. # at build time, but OTOH, soon enough, parts of Makefile
  58. # and the entire Config.in will be auto-generated anyway,
  59. # so we're better off placing it here
  60. #XXX this is too slow @868 configure options
  61. cd $TOPDIR/.cfg
  62. rm -f $TOPDIR/package/*/info.mk
  63. for option in *; do
  64. echo -n "$option ..."
  65. x=$(( ${#option} + 4 ))
  66. ao=:
  67. fgrep -l $option $TOPDIR/package/*/{Makefile,Config.*} 2>&- | \
  68. while read line; do
  69. echo ${line%/*}/info.mk
  70. done | while read fname; do
  71. [[ $ao = *:$fname:* ]] && continue
  72. ao=$ao$fname:
  73. echo "\${_IPKGS_COOKIE}: \${TOPDIR}/.cfg/$option" >>$fname
  74. done
  75. printf '\r%'$x's\r' ''
  76. done
  77. exit 0