split-cfg.sh 2.2 KB

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