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