blob: 956610e9f1fdc037ba04a7a8bbda29ece73b5d0b (
plain)
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
|
#!/bin/bash
#
# defconfig_builder.sh
#
# This will perform a merged based on a file that contains information in the
# repos to be merged.
#
# For more information type defconfig_builder.sh -h
#
# Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/
# ALL RIGHTS RESERVED
PROCESSOR_TAG="processor:"
BUILD_TYPE_TAG="type:"
CONFIG_FRAGMENT_TAG="config-fragment="
set_working_directory()
{
# Sanity checkup kernel build location.
if [ ! -d "$WORKING_PATH" ]; then
echo "Kernel working dir $WORKING_PATH is not a directory/ does not exist! exiting.."
exit 1
fi
ORIGINAL_DIR=$(pwd)
if [ "$ORIGINAL_DIR" != "$WORKING_PATH" ]; then
cd "$WORKING_PATH"
WORKING_PATH=$(pwd)
fi
TI_WORKING_PATH="$WORKING_PATH/ti_config_fragments"
DEFCONFIG_KERNEL_PATH="$WORKING_PATH/arch/arm/configs"
DEFCONFIG_MAP_FILE="$TI_WORKING_PATH/defconfig_map.txt"
}
prepare_for_exit() {
rm -f "$PROCESSOR_FILE"
rm -f "$BUILD_TYPE_FILE"
exit
}
get_processors() {
TEMP_PROC_FILE=$(mktemp)
cat "$DEFCONFIG_MAP_FILE" > "$TEMP_PROC_FILE"
y=0
while true;
do
PROCESSOR_TEMP=$(grep "$PROCESSOR_TAG" "$TEMP_PROC_FILE" | awk '{print$2}' | head -n 1)
if [ -z "$PROCESSOR_TEMP" ]; then
break
fi
if ! grep -qc "$PROCESSOR_TEMP" "$PROCESSOR_FILE"; then
y=$((y+1))
echo -e '\t'"$y". "$PROCESSOR_TEMP" >> "$PROCESSOR_FILE"
fi
sed -i "1d" "$TEMP_PROC_FILE"
done
rm "$TEMP_PROC_FILE"
}
choose_processor() {
get_processors
NUM_OF_PROC=$(wc -l "$PROCESSOR_FILE" | awk '{print$1}')
# Force the user to answer. Maybe the user does not want to continue
while true;
do
cat "$PROCESSOR_FILE"
read -p "Please choose which processor to build for: " REPLY
if [ "$REPLY" -gt '0' -a "$REPLY" -le "$NUM_OF_PROC" ]; then
CHOOSEN_PROCESSOR=$(grep -w "$REPLY" "$PROCESSOR_FILE" | awk '{print$2}')
break
else
echo -e "\nThis is not a choice try again!\n"
fi
done
}
choose_build_type() {
TEMP_BT_FILE=$(mktemp)
TEMP_BUILD_FILE=$(mktemp)
grep "$CHOOSEN_PROCESSOR" "$DEFCONFIG_MAP_FILE" | grep "$BUILD_TYPE_TAG" | awk '{print$4}' > "$TEMP_BUILD_FILE"
y=0
while true;
do
CONFIG_FILE=
CONFIG_FRAGMENTS=
BT_TEMP=$(head -n 1 "$TEMP_BUILD_FILE")
if [ -z "$BT_TEMP" ]; then
break
fi
BUILD_DETAILS=$(grep -w "$BT_TEMP" "$DEFCONFIG_MAP_FILE")
# Check to make sure that the config fragments exist
TEMP_EXTRA_CONFIG_FILE=$(echo "$BUILD_DETAILS" | cut -d: -f6)
if [ -z "$TEMP_EXTRA_CONFIG_FILE" ]; then
CONFIG_FRAGMENTS=
else
for CONFIG_FRAG in $TEMP_EXTRA_CONFIG_FILE;
do
if [ ! -e "$CONFIG_FRAG" ]; then
CONFIG_FRAGMENTS="N/A"
fi
done
fi
if ! grep -qc "$BT_TEMP" "$BUILD_TYPE_FILE"; then
# If the config file and config fragments are available
# add it to the list.
CONFIG_FILE=$(echo "$BUILD_DETAILS" | awk '{print$8}')
if [ "$CONFIG_FILE" = "None" ]; then
CONFIG_FILE=
else
if [ -e "$TI_WORKING_PATH""/""$CONFIG_FILE" ]; then
CONFIG_FILE=
fi
fi
# If the check for the config file and the config fragments
# pass then these two variables should be empty. If
# they fail then they should be N/A.
if [ -z "$CONFIG_FILE" -a -z "$CONFIG_FRAGMENTS" ]; then
y=$((y+1))
echo -e '\t'"$y". "$BT_TEMP" >> "$BUILD_TYPE_FILE"
fi
fi
sed -i "1d" "$TEMP_BUILD_FILE"
done
NUM_OF_BUILDS=$(wc -l "$BUILD_TYPE_FILE" | awk '{print$1}')
# Force the user to answer. Maybe the user does not want to continue
while true;
do
cat "$BUILD_TYPE_FILE"
read -p "Please choose which build: " REPLY
if [ "$REPLY" -gt '0' -a "$REPLY" -le "$NUM_OF_BUILDS" ]; then
CHOOSEN_BUILD_TYPE=$(grep -w "$REPLY" "$BUILD_TYPE_FILE" | awk '{print$2}')
break
else
echo -e "\nThis is not a choice try again!\n"
fi
done
rm "$TEMP_BT_FILE"
rm "$TEMP_BUILD_FILE"
}
get_build_details() {
BUILD_DETAILS=$(grep -w "$CHOOSEN_BUILD_TYPE" "$DEFCONFIG_MAP_FILE")
DEFCONFIG=$(echo "$BUILD_DETAILS" | awk '{print$6}')
DEFCONFIG="$DEFCONFIG_KERNEL_PATH""/""$DEFCONFIG"
CONFIG_FILE=$(echo "$BUILD_DETAILS" | awk '{print$8}')
# There may be a need to just build with the config fragments themselves
if [ "$CONFIG_FILE" = "None" ]; then
CONFIG_FILE=
fi
TEMP_EXTRA_CONFIG_FILE=$(echo "$BUILD_DETAILS" | cut -d: -f6)
for CONFIG_FRAG in $TEMP_EXTRA_CONFIG_FILE;
do
if [ -e "$CONFIG_FRAG" ]; then
EXTRA_CONFIG_FILE="$EXTRA_CONFIG_FILE $CONFIG_FRAG"
else
echo "$CONFIG_FRAG" does not exist
fi
done
}
usage()
{
cat << EOF
This script utilizes a map file to create defconfigs for multiple TI
platforms.
There is only one option for this script. This option defines the working
path to where the Linux kernel resides.
-w - Location of the TI Linux kernel
Command line Example if building from the working Linux kernel
top level directory:
ti_config_fragments/defconfig_builder.sh -w .
Command line Example if building from the ti_config_fragments directory:
defconfig_builder.sh -w ../.
EOF
}
#########################################
# Script Start
#########################################
while getopts "w:" OPTION
do
case $OPTION in
w)
WORKING_PATH=$OPTARG;;
?)
usage
exit;;
esac
done
trap prepare_for_exit EXIT SIGINT SIGTERM
set_working_directory
if [ ! -e "$DEFCONFIG_MAP_FILE" ]; then
echo "No defconfig map file found"
exit 1
fi
PROCESSOR_FILE=$(mktemp)
BUILD_TYPE_FILE=$(mktemp)
choose_processor
choose_build_type
get_build_details
if [ ! -z "$CONFIG_FILE" -a -e "$TI_WORKING_PATH/$CONFIG_FILE" ]; then
CONFIGS=$(grep "$CONFIG_FRAGMENT_TAG" "$TI_WORKING_PATH/$CONFIG_FILE" | cut -d= -f2)
fi
STATUS=$("$WORKING_PATH"/scripts/kconfig/merge_config.sh -m -r "$DEFCONFIG" "$CONFIGS" "$EXTRA_CONFIG_FILE")
if [ "$?" = "0" ];then
echo "Creating defconfig file ""$WORKING_PATH""/arch/arm/configs/""$CHOOSEN_BUILD_TYPE"_defconfig
cp .config "$DEFCONFIG_KERNEL_PATH"/"$CHOOSEN_BUILD_TYPE"_defconfig
else
echo "Defconfig creation failed"
fi
|