1
0

split-cfg.sh 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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 handle package dependencies
  59. cd $TOPDIR/.cfg_${TARGET}_${LIBC}
  60. rm -f $TOPDIR/package/*/info.mk
  61. for option in *; do
  62. pbar="$option ..."
  63. print -nu2 "$pbar\r"
  64. ao=:
  65. fgrep -l $option $TOPDIR/package/*/Config.* 2>&- | \
  66. while read line; do
  67. print -r -- ${line%/*}/info.mk
  68. done | while read fname; do
  69. [[ $ao = *:$fname:* ]] && continue
  70. ao=$ao$fname:
  71. if [ "$option" != "ADK_HAVE_DOT_CONFIG" ];then
  72. echo "\${_IPKGS_COOKIE}: \${TOPDIR}/.cfg_${TARGET}_${LIBC}/$option" >>$fname
  73. fi
  74. done
  75. done
  76. exit 0