source: freewrt/scripts/split-cfg.sh@ f855d85

Last change on this file since f855d85 was 9d67aa5, checked in by Thorsten Glaser <tg@…>, 19 years ago

even more speedup ☻

git-svn-id: svn://www.freewrt.org/trunk/freewrt@2496 afb5a338-a214-0410-bd46-81f09a774fd1

  • Property mode set to 100644
File size: 2.1 KB
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
10TOPDIR=$1
11
12[[ -n $BASH_VERSION ]] && shopt -s extglob
13
14mkdir -p $TOPDIR/.cfg
15cd $TOPDIR/.cfg
16
17oldfiles=$(echo *)
18newfiles=:
19
20echo -n 'autosplitting main config...'
21while 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
56done <$TOPDIR/.config
57
58# now handle the case of removals
59echo -n ' removals...'
60for oldfile in $oldfiles; do
61 [[ $newfiles = *:$oldfile:* ]] || rm -f $oldfile
62done
63printf '\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
71cd $TOPDIR/.cfg
72rm -f $TOPDIR/package/*/info.mk
73for option in *; do
74 echo -n "$option ..."
75 ao=:
76 fgrep -l $option $TOPDIR/package/*/{Makefile,Config.in} 2>&- | \
77 while read line; do
78 echo ${line%/*}/info.mk
79 done | while read fname; do
80 [[ $ao = *:$fname:* ]] && continue
81 ao=$ao$fname:
82 echo "\${_IPKGS_COOKIE}: \${TOPDIR}/.cfg/$option" >>$fname
83 done
84 printf '\033[M\r'
85done
86
87exit 0
Note: See TracBrowser for help on using the repository browser.