-
Notifications
You must be signed in to change notification settings - Fork 4
/
genconfig.oldversion
executable file
·126 lines (117 loc) · 3.11 KB
/
genconfig.oldversion
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!/bin/bash
export CLEAN=0
export IMPORT=0
export OPEN=0
export FILEDIR="files/"
export CONFIGPATH="configs"
export CUSTCONF="customerconfigs"
export VERBOSE=0
export TMPDIR="/tmp/builder/"
v() {
[ "$VERBOSE" -ge 1 ] && echo "$@"
}
usage() {
echo
echo 1>&2 "Usage: [OPTION] $0 BoardConfig Customerconfig"
echo
echo " -c, remove all files under ./files and import from config "
echo " -v, verbose"
echo " -o, use openbroadcom kernel"
echo " -u, Update customer config before applying"
echo
echo "BoardConfig ex "
ls -1 configs
if [ -d "$CUSTCONF/$1" ]; then
echo "Customerconfig ex"
ls $CUSTCONF/*
fi
echo
echo "Example ./genconfig vg50 TELIA"
echo "(if no customerconfig is chosen the Inteno Config will be used)"
echo
exit 127
}
generate_config()
{
DIFFFILE="$1"
MASTERFILE="$2"
while read p; do
v "$p"
sed -r -i "$p" $MASTERFILE
done < $DIFFFILE
}
create_and_copy_files()
{
local BOARDTYPE=$1
local CUSTOMER=$2
v "cp $CONFIGPATH/MASTER/config .config"
cp $CONFIGPATH/MASTER/config .config
if [ $OPEN -eq 0 ]; then
if [ ! -d "$CUSTCONF" ]; then
git clone [email protected]:customerconfigs
elif [ $IMPORT -eq 1 ]; then
cd customerconfigs
v "git pull"
git pull
cd ..
fi
fi
if [ ! -d "$CONFIGPATH/$BOARDTYPE" ]; then
echo "Hardware profile does not exist"
exit 0
elif [ ! -d "$CUSTCONF/$BOARDTYPE/$CUSTOMER/" -a $OPEN -eq 0 ]; then
echo "Customer profile does not exist"
exit 0
fi
v "Config $BOARDTYPE selected"
if [ ! -d "$FILEDIR" ]; then
mkdir $FILEDIR
elif [ -d "$FILEDIR" -a $CLEAN -eq 1 ]; then
v "rm -rf $FILEDIR*"
rm -rf $FILEDIR*
fi
# first build config based on boardid
v "cp -r $CONFIGPATH/$BOARDTYPE/fs/* $FILEDIR"
cp -rL $CONFIGPATH/$BOARDTYPE/fs/* $FILEDIR 2>/dev/null
v "cp -r $CONFIGPATH/$BOARDTYPE/* $FILEDIR"
[ -e "$CONFIGPATH/$BOARDTYPE/$BOARDTYPE.diff" ] && generate_config $CONFIGPATH/$BOARDTYPE/$BOARDTYPE.diff .config
echo $BOARDTYPE > .current_config_file
# second add diff for customer config if if customer code
if [ -n "$CUSTOMER" ]; then
v "cp -r $CUSTCONF/$BOARDTYPE/$CUSTOMER/fs/* $FILEDIR"
cp -rL $CUSTCONF/$BOARDTYPE/$CUSTOMER/fs/* $FILEDIR
echo "$BOARDTYPE $CUSTOMER" > .current_config_file
[ -e "$CUSTCONF/$BOARDTYPE/$CUSTOMER/$BOARDTYPE.diff" ] && generate_config $CUSTCONF/$BOARDTYPE/$CUSTOMER/$BOARDTYPE.diff .config
fi
##### if open change to open kernel and remove building of nand tool
if [ $OPEN -eq 1 ]; then
[ -e "$CONFIGPATH/OPEN/open.diff" ] && generate_config $CONFIGPATH/OPEN/open.diff .config
fi
}
####### main #####
if [ $# -eq 0 ]; then
echo Current profile:
cat .current_config_file
echo "Try ./iop_get_config.sh -h' to get instructions if you want to change current config"
exit 0
else
while [ -n "$1" ]; do
case "$1" in
-c) export CLEAN=1;;
-u) export IMPORT=1;;
-o) export OPEN=1;;
-v) export VERBOSE="$(($VERBOSE + 1))";;
-h) usage;;
-*)
echo "Invalid option: $1 "
echo "Try -h' for more information."
exit 1
;;
*) break;;
esac
shift;
done
[ -d $TMPDIR ] || mkdir $TMPDIR
create_and_copy_files "$1" "$2"
[ -d $TMPDIR ] && rm -rf $TMPDIR
fi