root/trunk/freewrt/scripts/split-cfg.sh

Revision 2953, 2.2 kB (checked in by tg, 1 year ago)

• scan Config.* not just Config.in, because wbx doesn't believe

in keeping things simple and in one place (KISS)

• fix perms *sigh* if I get the person who commits these files

as executables…

Line 
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 [[ -n $BASH_VERSION ]] && 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 '\r%60s\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         x=$(( ${#option} + 4 ))
76         ao=:
77         fgrep -l $option $TOPDIR/package/*/{Makefile,Config.*} 2>&- | \
78             while read line; do
79                 echo ${line%/*}/info.mk
80         done | while read fname; do
81                 [[ $ao = *:$fname:* ]] && continue
82                 ao=$ao$fname:
83                 echo "\${_IPKGS_COOKIE}: \${TOPDIR}/.cfg/$option" >>$fname
84         done
85         printf '\r%'$x's\r' ''
86 done
87
88 exit 0
Note: See TracBrowser for help on using the browser.