split-cfg.sh 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. TARGET=$2
  7. LIBC=$3
  8. (( x_cols = (COLUMNS > 10) ? COLUMNS - 2 : 80 ))
  9. typeset -L$x_cols pbar
  10. grep -v '^BUSYBOX\|^# BUSYBOX' $TOPDIR/.config > $TOPDIR/.config.split
  11. mkdir -p $TOPDIR/.cfg_${TARGET}_${LIBC}
  12. cd $TOPDIR/.cfg_${TARGET}_${LIBC}
  13. oldfiles=$(print -r -- *)
  14. newfiles=:
  15. print -nu2 '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. print -u2 "\nWarning: line '$oline' invalid!"
  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 ]] || print -r -- "$oline" >$line
  45. if [[ $newfiles = *:$line:* ]]; then
  46. print -u2 "\nError: duplicate Config.in option '$line'!"
  47. exit 1
  48. fi
  49. newfiles=$newfiles$line:
  50. fi
  51. done <$TOPDIR/.config.split
  52. # now handle the case of removals
  53. print -nu2 ' removals...'
  54. for oldfile in $oldfiles; do
  55. [[ $newfiles = *:$oldfile:* ]] || rm -f $oldfile
  56. done
  57. print -nu2 '\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_${TARGET}_${LIBC}
  65. rm -f $TOPDIR/package/*/info.mk
  66. for option in *; do
  67. pbar="$option ..."
  68. print -nu2 "$pbar\r"
  69. ao=:
  70. fgrep -l $option $TOPDIR/package/*/{Makefile,Config.*} 2>&- | \
  71. while read line; do
  72. print -r -- ${line%/*}/info.mk
  73. done | while read fname; do
  74. [[ $ao = *:$fname:* ]] && continue
  75. ao=$ao$fname:
  76. echo "\${_IPKGS_COOKIE}: \${TOPDIR}/.cfg_${TARGET}_${LIBC}/$option" >>$fname
  77. done
  78. done
  79. pbar=done
  80. print -u2 "$pbar"
  81. exit 0