split-cfg.sh 2.2 KB

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