split-cfg.sh 2.1 KB

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