1 export PATH__ROOT=`pwd`
2 . configuration.sh
3 . setup-env
4 # Pretty colors
5 GREEN="\033[01;32m"
6 YELLOW="\033[01;33m"
7 NORMAL="\033[00m"
8 BLUE="\033[34m"
9 RED="\033[31m"
10 PURPLE="\033[35m"
11 CYAN="\033[36m"
12 UNDERLINE="\033[02m"
14 function print_highlight()
15 {
16 echo -e " ${YELLOW}***** $1 ***** ${NORMAL} "
17 }
19 function usage ()
20 {
21 echo ""
22 echo "This script builds all/one of the relevent wl18xx software package."
23 echo ""
24 echo "Usage : "
25 echo ""
26 echo "Building full package : Build all components except kernel,dtb "
27 echo " ./build_wl18xx.sh init [ Download and Update w/o build ] "
28 echo " update R8.8 [ Update to specific TAG & Build ] "
29 echo " clean [ Clean & Build ] "
30 echo " check_updates [ Check for build script updates ] "
31 echo ""
32 echo "Building specific component :"
33 echo " hostapd [ Clean & Build hostapd ] "
34 echo " wpa_supplicant [ Clean & Build wpa_supplicant ] "
35 echo " modules [ Clean & Build driver modules ] "
36 echo " firmware [ Install firmware binary ] "
37 echo " scripts [ Install scripts ] "
38 echo " utils [ Clean & Build scripts ] "
39 echo " iw [ Clean & Build iw ] "
40 echo " openssl [ Clean & Build openssll ] "
41 echo " libnl [ Clean & Build libnl ] "
42 echo " wireless-regdb [ Install wireless regdb ] "
43 echo " patch_kernel [ Apply provided kernel patches ] "
44 echo " kernel <defconfig filename> [ Clean & Build Kernel ] "
45 echo " kernel_noclean <defconfig_filename> [ Build Kernel w/o clean ] "
46 echo " patch_bbbe14_dts [Patch bbb black dts file to add e14 cape support] "
47 echo " bbbe14_dtb [Build bbb device tree file with e14 cape support] "
52 exit 1
53 }
55 function assert_no_error()
56 {
57 if [ $? -ne 0 ]; then
58 echo "****** ERROR $? $@*******"
59 exit 1
60 fi
61 echo "****** $1 *******"
62 }
64 function repo_id()
65 {
66 i="0"
67 while [ $i -lt ${#repositories[@]} ]; do
68 [ $1 == "${repositories[i]}" ] && echo $i
69 i=$[$i + 3]
70 done
71 }
73 function repo_url()
74 {
75 echo "${repositories[`repo_id $1` + 1]}"
76 }
78 function repo_branch()
79 {
80 echo "${repositories[`repo_id $1` + 2]}"
81 }
83 function path()
84 {
85 i="0"
86 while [ $i -lt "${#paths[@]}" ]; do
87 [ $1 == "${paths[i]}" ] && echo "${paths[i + 1]}"
88 i=$[$i + 2]
89 done
90 }
92 function set_path()
93 {
94 i="0"
95 while [ $i -lt "${#paths[@]}" ]; do
96 [ $1 == "${paths[i]}" ] && paths[i+1]=$2
97 i=$[$i + 2]
98 done
99 }
101 function repo_path()
102 {
103 echo `path src`/$1
104 }
106 function cd_path()
107 {
108 cd `path $1`
109 }
111 function cd_repo()
112 {
113 cd `repo_path $1`
114 }
116 function cd_back()
117 {
118 cd - > /dev/null
119 }
121 function check_for_build_updates()
122 {
123 git fetch
124 count=`git status -uno | grep behind | wc -l`
125 if [ $count -ne 0 ]
126 then
127 echo ""
128 echo "*** Please note, there is an updated build script avilalable ***"
129 echo "*** Use 'git pull' to get the latest update. ***"
130 echo ""
131 sleep 5
132 fi
133 }
135 function read_kernel_version()
136 {
137 filename=$KERNEL_PATH/Makefile
138 VERSION_STRING="VERSION = "
140 if [ ! -f $filename ]
141 then
142 KERNEL_VERSION=0
143 KERNEL_PATCHLEVEL=0
144 KERNEL_SUBLEVEL=0
145 echo "No Makefile was found. Kernel version was set to default."
146 else
147 exec 6< $filename
148 read VERSION <&6
149 version_parse=$(echo $VERSION|sed 's/[0-9]\+$//')
150 while [ "$version_parse" != "${VERSION_STRING}" ]; do
151 read VERSION <&6
152 version_parse=$(echo $VERSION|sed 's/[0-9]\+$//')
153 done
155 read PATCHLEVEL <&6
156 read SUBLEVEL <&6
157 exec 6<&-
159 KERNEL_VERSION=$(echo $VERSION|sed 's/[^0-9]//g')
160 KERNEL_PATCHLEVEL=$(echo $PATCHLEVEL|sed 's/[^0-9]//g')
161 KERNEL_SUBLEVEL=$(echo $SUBLEVEL|sed 's/[^0-9]//g')
163 echo "Makefile was found. Kernel version was set to $KERNEL_VERSION.$KERNEL_PATCHLEVEL.$KERNEL_SUBLEVEL."
164 fi
165 [ $VERIFY_CONFIG ] && ./verify_kernel_config.sh $KERNEL_PATH/.config
166 }
168 #----------------------------------------------------------j
169 function setup_environment()
170 {
171 print_highlight " *** Entering to create the setup environment based on setup-env file ....."
172 if [ ! -e setup-env ]
173 then
174 echo "******** No setup-env file found !! Exiting the script ***********************"
175 exit 1
176 fi
178 #if a rootfs path is set - replace the default.
179 if [[ "$ROOTFS" != "DEFAULT" ]]
180 then
181 echo " Changing ROOTFS path to $ROOTFS"
182 set_path filesystem $ROOTFS
183 [ ! -d $ROOTFS ] && echo "Error ROOTFS: $ROOTFS dir does not exist" && exit 1
184 fi
186 #if no toolchain path is set - exit
187 if [[ "$TOOLCHAIN_PATH" == "" ]]
188 then
189 echo "Please set TOOLCHAIN_PATH in setupenv. Exiting !"
190 exit
191 fi
194 #if no kernel path is set - exit
195 if [[ "$KERNEL_PATH" == "" ]]
196 then
197 echo "Please set KERNEL_PATH in setupenv. Exiting ! "
198 exit
199 else
200 echo " Using user defined kernel"
201 [ ! -d $KERNEL_PATH ] && echo "Error KERNEL_PATH: $KERNEL_PATH dir does not exist" && exit 1
202 fi
204 export PROCESSORS_NUMBER=$(egrep '^processor' /proc/cpuinfo | wc -l)
205 export PKG_CONFIG_PATH=`path filesystem`/lib/pkgconfig
206 export INSTALL_PREFIX=`path filesystem`
207 export LIBNL_PATH=`repo_path libnl`
208 export KLIB=`path filesystem`
209 export KLIB_BUILD=${KERNEL_PATH}
210 export PATH=$TOOLCHAIN_PATH:$PATH
212 }
214 function setup_filesystem_skeleton()
215 {
216 mkdir -p `path filesystem`/usr/bin
217 mkdir -p `path filesystem`/etc
218 mkdir -p `path filesystem`/etc/init.d
219 mkdir -p `path filesystem`/etc/rcS.d
220 mkdir -p `path filesystem`/usr/lib/crda
221 mkdir -p `path filesystem`/lib/firmware/ti-connectivity
222 mkdir -p `path filesystem`/usr/share/wl18xx
223 mkdir -p `path filesystem`/usr/sbin/wlconf
224 mkdir -p `path filesystem`/usr/sbin/wlconf/official_inis
225 mkdir -p `path filesystem`/etc/wireless-regdb/pubkeys
226 mkdir -p `path filesystem`/boot
227 }
229 function setup_directories()
230 {
231 i="0"
232 while [ $i -lt ${#paths[@]} ]; do
233 mkdir -p ${paths[i + 1]}
234 i=$[$i + 2]
235 done
236 setup_filesystem_skeleton
238 }
240 function setup_repositories()
241 {
242 i="0"
243 while [ $i -lt ${#repositories[@]} ]; do
244 url=${repositories[$i + 1]}
245 name=${repositories[$i]}
246 echo -e "${NORMAL}Cloning into: ${GREEN} $name ${NORMAL}"
247 #Skip kernel clone if it was user defined
248 [ "$name" != "kernel" -o "$DEFAULT_KERNEL" ] && [ ! -d `repo_path $name` ] && git clone $url `repo_path $name`
249 i=$[$i + 3]
250 done
251 }
253 function setup_branches()
254 {
255 i="0"
256 while [ $i -lt ${#repositories[@]} ]; do
257 name=${repositories[$i]}
258 url=${repositories[$i + 1]}
259 branch=${repositories[$i + 2]}
260 checkout_type="branch"
261 #for all the openlink repo. we use a tag if provided.
262 [ "$name" == "kernel" ] && [ -z "$DEFAULT_KERNEL" ] && i=$[$i + 3] && continue
263 cd_repo $name
264 echo -e "\n${NORMAL}Checking out branch ${GREEN}$branch ${NORMAL}in repo ${GREEN}$name ${NORMAL} "
265 git checkout $branch
266 git fetch origin
267 git fetch origin --tags
268 if [[ "$url" == *git.ti.com* ]]
269 then
270 [[ -n $RESET ]] && echo -e "${PURPLE}Reset to latest in repo ${GREEN}$name ${NORMAL} branch ${GREEN}$branch ${NORMAL}" && git reset --hard origin/$branch
271 [[ -n $USE_TAG ]] && git checkout $USE_TAG && echo -e "${NORMAL}Reset to tag ${GREEN}$USE_TAG ${NORMAL}in repo ${GREEN}$name ${NORMAL} "
272 fi
273 cd_back
274 i=$[$i + 3]
275 done
276 }
278 function build_zImage()
279 {
280 if [ "$CLEAN_KERNEL" == "Y" ]|| [ "$CLEAN_KERNEL" == "y" ]
281 then
282 make -C $KERNEL_PATH ARCH=$ARCH CROSS_COMPILE=$CROSS_COMPILE mrproper
283 fi
284 echo "Building Kernel"
285 make -C $KERNEL_PATH ARCH=$ARCH CROSS_COMPILE=$CROSS_COMPILE $1
286 make -j ${PROCESSORS_NUMBER} -C $KERNEL_PATH ARCH=$ARCH CROSS_COMPILE=$CROSS_COMPILE zImage
287 assert_no_error
288 install -d `path filesystem`/boot
289 cp $KERNEL_PATH/arch/arm/boot/zImage `path filesystem`/boot
290 cp $KERNEL_PATH/vmlinux `path filesystem`/boot
291 cp $KERNEL_PATH/System.map `path filesystem`/boot
292 assert_no_error
293 }
295 function patch_bbbe14_dts()
296 {
297 cd $KERNEL_PATH
298 patch -p1 < $PATH__ROOT/patches/kernel_patches/beaglebone-wilink8-capes/Enable-TI-WiFi-Bluetooth-am335x-boneblack-WL1837.patch
299 assert_no_error
300 cd_back
301 }
303 function bbbe14_dtb()
304 {
305 make -C $KERNEL_PATH ARCH=$ARCH CROSS_COMPILE=$CROSS_COMPILE -j${PROCESSORS_NUMBER} am335x-boneblack.dtb
306 cp $KERNEL_PATH/arch/arm/boot/dts/am335x-boneblack.dtb `path filesystem`/boot
307 assert_no_error
309 }
311 function build_modules()
312 {
313 make -j 2 -C $KERNEL_PATH ARCH=$ARCH CROSS_COMPILE=$CROSS_COMPILE modules clean
314 make -j 2 -C $KERNEL_PATH ARCH=$ARCH CROSS_COMPILE=$CROSS_COMPILE modules
315 assert_no_error
316 make -C $KERNEL_PATH ARCH=$ARCH CROSS_COMPILE=$CROSS_COMPILE INSTALL_MOD_PATH=`path filesystem` INSTALL_MOD_STRIP=1 modules_install
317 assert_no_error
318 #cd_back
319 }
321 function build_openssl()
322 {
323 cd_repo openssl
324 [ -z $NO_CONFIG ] && ./Configure linux-generic32 --prefix=`path filesystem`/usr/local
325 [ -z $NO_CLEAN ] && make clean
326 [ -z $NO_CLEAN ] && assert_no_error
327 make
328 assert_no_error
329 DESTDIR=`path filesystem` make install_sw
330 assert_no_error
331 cd_back
332 }
335 function build_iw()
336 {
337 cd_repo iw
338 [ -z $NO_CLEAN ] && make clean
339 [ -z $NO_CLEAN ] && assert_no_error
340 CC=${CROSS_COMPILE}gcc LIBS+=" -lpthread -lm" make V=1
341 assert_no_error
342 DESTDIR=`path filesystem` make install
343 assert_no_error
344 cd_back
345 }
347 function build_wreg()
348 {
349 cd_repo wireless_regdb
350 DESTDIR=`path filesystem` make install
351 assert_no_error
352 cd_back
353 }
356 function build_libnl()
357 {
358 cd_repo libnl
359 [ -z $NO_CONFIG ] && ./autogen.sh
360 [ -z $NO_CONFIG ] && ./configure --prefix=`path filesystem` --host=${ARCH} CC=${CROSS_COMPILE}gcc AR=${CROSS_COMPILE}ar
361 ([ -z $NO_CONFIG ] || [ -z $NO_CLEAN ]) && make clean
362 [ -z $NO_CLEAN ] && assert_no_error
363 make
364 assert_no_error
365 make install
366 assert_no_error
367 cd_back
368 }
370 function build_wpa_supplicant()
371 {
372 cd `repo_path hostap`/wpa_supplicant
373 [ -z $NO_CONFIG ] && cp android.config .config
374 [ -n "$SYSLOG_EN" ] && echo "Enable DEBUG_SYSLOG config" && sed -i "/#CONFIG_DEBUG_SYSLOG=y/ s/# *//" .config
375 CONFIG_LIBNL32=y DESTDIR=`path filesystem` make clean
376 assert_no_error
377 CONFIG_LIBNL32=y DESTDIR=`path filesystem` CFLAGS+="-I`path filesystem`/usr/local/ssl/include -I`path filesystem`/usr/local/include -I`repo_path libnl`/include" LIBS+="-L`path filesystem`/lib -L`path filesystem`/usr/local/lib -lssl -lcrypto -lm -ldl -lpthread" LIBS_p+="-L`path filesystem`/lib -L`path filesystem`/usr/local/ssl/lib -lssl -lcrypto -lm -ldl -lpthread" make -j${PROCESSORS_NUMBER} CC=${CROSS_COMPILE}gcc LD=${CROSS_COMPILE}ld AR=${CROSS_COMPILE}ar
378 assert_no_error
379 CONFIG_LIBNL32=y DESTDIR=`path filesystem` make install
380 assert_no_error
381 cd_back
382 cp `repo_path scripts_download`/conf/*_supplicant.conf `path filesystem`/etc/
383 mv `path filesystem`/usr/local/sbin/wpa* `path filesystem`/usr/sbin
384 }
386 function build_hostapd()
387 {
388 cd `repo_path hostap`/hostapd
389 [ -z $NO_CONFIG ] && cp android.config .config
390 [ -z $NO_UPNP ] && echo "Enable UPNP config" && sed -i "/#CONFIG_WPS_UPNP=y/ s/# *//" .config
391 CONFIG_LIBNL32=y DESTDIR=`path filesystem` make clean
392 assert_no_error
393 CONFIG_LIBNL32=y DESTDIR=`path filesystem` CFLAGS+="-I`path filesystem`/usr/local/ssl/include -I`path filesystem`/usr/local/include -I`repo_path libnl`/include" LIBS+="-L`path filesystem`/lib -L`path filesystem`/usr/local/lib -lssl -lcrypto -lm -ldl -lpthread" LIBS_p+="-L`path filesystem`/lib -L`path filesystem`/usr/local/lib -lssl -lcrypto -lm -ldl -lpthread" make -j${PROCESSORS_NUMBER} CC=${CROSS_COMPILE}gcc LD=${CROSS_COMPILE}ld AR=${CROSS_COMPILE}ar
394 assert_no_error
395 CONFIG_LIBNL32=y DESTDIR=`path filesystem` make install
396 assert_no_error
397 cd_back
398 cp `repo_path scripts_download`/conf/hostapd.conf `path filesystem`/etc/
399 mv `path filesystem`/usr/local/bin/host* `path filesystem`/usr/sbin
400 }
403 function build_wl_logger()
404 {
405 if [ -d "`repo_path ti_utils`/wl_logproxy" ]; then
406 cd `repo_path ti_utils`/wl_logproxy
407 [ -z $NO_CLEAN ] && NFSROOT=`path filesystem` make clean
408 [ -z $NO_CLEAN ] && assert_no_error
409 NLVER=3 NLROOT=`repo_path libnl`/include NFSROOT=`path filesystem` LIBS+=-lpthread make
410 assert_no_error
411 NFSROOT=`path filesystem` make install
412 cd_back
413 fi
414 }
416 function build_calibrator()
417 {
418 cd_repo ti_utils
419 [ -z $NO_CLEAN ] && NFSROOT=`path filesystem` make clean
420 [ -z $NO_CLEAN ] && assert_no_error
421 NLVER=3 NLROOT=`repo_path libnl`/include NFSROOT=`path filesystem` LIBS+=-lpthread make
422 assert_no_error
423 NFSROOT=`path filesystem` make install
424 #assert_no_error
425 cp -f `repo_path ti_utils`/hw/firmware/wl1271-nvs.bin `path filesystem`/lib/firmware/ti-connectivity
426 cd_back
427 }
429 function build_wlconf()
430 {
431 files_to_copy="dictionary.txt struct.bin default.conf wl18xx-conf-default.bin README example.conf example.ini configure-device.sh"
432 cd `repo_path ti_utils`/wlconf
433 if [ -z $NO_CLEAN ]; then
434 NFSROOT=`path filesystem` make clean
435 assert_no_error
436 for file_to_copy in $files_to_copy; do
437 rm -f `path filesystem`/usr/sbin/wlconf/$file_to_copy
438 done
439 rm -f `path filesystem`/usr/sbin/wlconf/official_inis/*
440 fi
441 NFSROOT=`path filesystem` make CC=${CROSS_COMPILE}gcc LD=${CROSS_COMPILE}ld
442 assert_no_error
444 # install
445 cp -f `repo_path ti_utils`/wlconf/wlconf `path filesystem`/usr/sbin/wlconf
446 chmod 755 `path filesystem`/usr/sbin/wlconf
447 for file_to_copy in $files_to_copy; do
448 cp $file_to_copy `path filesystem`/usr/sbin/wlconf/$file_to_copy
449 echo "echoying files $file_to_copy"
450 done
451 cp official_inis/* `path filesystem`/usr/sbin/wlconf/official_inis/
452 cd_back
453 }
455 function build_fw_download()
456 {
457 cp `repo_path fw_download`/*.bin `path filesystem`/lib/firmware/ti-connectivity
458 }
460 function patch_kernel()
461 {
463 [ ! -d $KERNEL_PATH ] && echo "Error KERNEL_PATH: $KERNEL_PATH dir does not exist" && exit 1
464 echo "using kernel: $KERNEL_PATH"
465 read_kernel_version
467 read -p 'Kernel Patches are based on Linux Kernel 4.19.38. Do you want to apply these patches to the Kernel mentioned in setupenv file [y/n] : ' apply_patches
469 case $apply_patches in
470 "n") APPLY_KERNEL_PATCHES=0; echo "Patches NOT Applied, Exiting" ; exit;;
471 "N") APPLY_KERNEL_PATCHES=0; echo "Patches NOT Applied, Exiting" ; exit;;
472 "y") APPLY_KERNEL_PATCHES=1;;
473 "Y") APPLY_KERNEL_PATCHES=1;;
474 *) echo "Wrong Entry.Please enter y or n, Exiting ";APPLY_KERNEL_PATCHES=-1;exit;;
475 esac
476 echo "apply patches $APPLY_KERNEL_PATCHES"
478 echo "$KERNEL_PATH \n $KERNEL_VARIANT \n $PATH__ROOT/patches/kernel_patches/$KERNEL_VARIANT \n "
480 cd $KERNEL_PATH
481 if [ $APPLY_KERNEL_PATCHES -eq 1 ] && [ -d "$PATH__ROOT/patches/kernel_patches/4.19.38" ]; then
482 for i in $PATH__ROOT/patches/kernel_patches/4.19.38/*.patch; do
483 print_highlight "Applying driver patch: $i"
484 patch -p1 -N < $i;
485 assert_no_error
486 done
487 fi
489 assert_no_error
490 cd_back
491 }
493 function build_scripts_download()
494 {
495 cd_repo scripts_download
496 echo "Copying scripts"
497 scripts_download_path=`repo_path scripts_download`
498 for script_dir in `ls -d $scripts_download_path`/*/
499 do
500 echo "Copying everything from ${script_dir} to `path filesystem`/usr/share/wl18xx directory"
501 cp -rf ${script_dir}/* `path filesystem`/usr/share/wl18xx
502 done
503 cd_back
504 }
507 function clean_outputs()
508 {
509 if [[ "$ROOTFS" == "DEFAULT" ]]
510 then
511 echo "Cleaning outputs"
512 cp -r `path filesystem`/boot ./boot_temp
513 rm -rf `path filesystem`/*
514 cp -r ./boot_temp `path filesystem`/boot
515 rm -r boot_temp
517 fi
518 }
521 function set_files_to_verify()
522 {
523 files_to_verify=(
524 # skeleton path
525 # source path
526 # pattern in output of file
528 `path filesystem`/usr/sbin/wpa_supplicant
529 `repo_path hostap`/wpa_supplicant/wpa_supplicant
530 "ELF 32-bit LSB[ ]*executable, ARM"
532 `path filesystem`/usr/sbin/hostapd
533 `repo_path hostap`/hostapd/hostapd
534 "ELF 32-bit LSB[ ]*executable, ARM"
536 `path filesystem`/usr/lib/crda/regulatory.bin
537 `repo_path wireless_regdb`/regulatory.bin
538 "CRDA wireless regulatory database file"
540 `path filesystem`/lib/firmware/ti-connectivity/wl18xx-fw-4.bin
541 `repo_path fw_download`/wl18xx-fw-4.bin
542 "data"
544 `path filesystem`/lib/modules/$KERNEL_VERSION.$KERNEL_PATCHLEVEL.*/kernel/drivers/net/wireless/ti/wl18xx/wl18xx.ko
545 `path filesystem`/lib/modules/$KERNEL_VERSION.$KERNEL_PATCHLEVEL.*/kernel/drivers/net/wireless/ti/wl18xx/wl18xx.ko
547 "ELF 32-bit LSB[ ]*relocatable, ARM"
549 `path filesystem`/lib/modules/$KERNEL_VERSION.$KERNEL_PATCHLEVEL.*/kernel/drivers/net/wireless/ti/wlcore/wlcore.ko
550 `path filesystem`/lib/modules/$KERNEL_VERSION.$KERNEL_PATCHLEVEL.*/kernel/drivers/net/wireless/ti/wlcore/wlcore.ko
552 "ELF 32-bit LSB[ ]*relocatable, ARM"
554 #`path filesystem`/usr/bin/calibrator
555 #`repo_path ti_utils`/calibrator
556 #"ELF 32-bit LSB[ ]*executable, ARM"
558 `path filesystem`/usr/sbin/wlconf/wlconf
559 `repo_path ti_utils`/wlconf/wlconf
560 "ELF 32-bit LSB[ ]*executable, ARM"
561 )
562 }
564 function get_tag()
565 {
566 i="0"
567 while [ $i -lt ${#repositories[@]} ]; do
568 name=${repositories[$i]}
569 url=${repositories[$i + 1]}
570 branch=${repositories[$i + 2]}
571 checkout_type="branch"
572 cd_repo $name
573 if [[ "$url" == *git.ti.com* ]]
574 then
575 echo -e "${PURPLE}Describe of ${NORMAL} repo : ${GREEN}$name ${NORMAL} " ;
576 git describe --tag
577 fi
578 cd_back
579 i=$[$i + 3]
580 done
581 }
585 function admin_tag()
586 {
587 i="0"
588 while [ $i -lt ${#repositories[@]} ]; do
589 name=${repositories[$i]}
590 url=${repositories[$i + 1]}
591 branch=${repositories[$i + 2]}
592 checkout_type="branch"
593 cd_repo $name
594 if [[ "$url" == *git.ti.com* ]]
595 then
596 echo -e "${PURPLE}Adding tag ${GREEN} $1 ${NORMAL} to repo : ${GREEN}$name ${NORMAL} " ;
597 git show --summary
598 read -p "Do you want to tag this commit ?" yn
599 case $yn in
600 [Yy]* ) git tag -a $1 -m "$1" ;
601 git push --tags ;;
602 [Nn]* ) echo -e "${PURPLE}Tag was not applied ${NORMAL} " ;;
604 * ) echo "Please answer yes or no.";;
605 esac
607 fi
608 cd_back
609 i=$[$i + 3]
610 done
611 }
614 function verify_skeleton()
615 {
616 echo "Verifying filesystem skeleton..."
618 set_files_to_verify
620 i="0"
621 while [ $i -lt ${#files_to_verify[@]} ]; do
622 skeleton_path=${files_to_verify[i]}
623 source_path=${files_to_verify[i + 1]}
624 file_pattern=${files_to_verify[i + 2]}
625 file $skeleton_path | grep "${file_pattern}" >/dev/null
626 if [ $? -eq 1 ]; then
627 echo -e "${RED}ERROR " $skeleton_path " Not found ! ${NORMAL}"
628 #exit
629 fi
631 md5_skeleton=$(md5sum $skeleton_path | awk '{print $1}')
632 md5_source=$(md5sum $source_path | awk '{print $1}')
633 if [ $md5_skeleton != $md5_source ]; then
634 echo "ERROR: file mismatch"
635 echo $skeleton_path
636 exit 1
637 fi
638 i=$[$i + 3]
639 done
640 : '
641 which regdbdump > /dev/null
642 if [ $? -eq 0 ]; then
643 regdbdump `path filesystem`/usr/lib/crda/regulatory.bin > /dev/null
644 if [ $? -ne 0 ]; then
645 echo "Please update your public key used to verify the DB"
646 fi
647 fi
648 '
649 }
651 function verify_installs()
652 {
653 apps_to_verify=(
654 libtool
655 python-m2crypto
656 bison
657 flex
658 )
660 i="0"
661 while [ $i -lt ${#apps_to_verify[@]} ]; do
662 if !( dpkg-query -s ${apps_to_verify[i]} 2>/dev/null | grep -q ^"Status: install ok installed"$ )then
663 echo "${apps_to_verify[i]} is missing"
664 echo "Please use 'sudo apt-get install ${apps_to_verify[i]}'"
665 read -p "Do you want to install it now [y/n] ? (requires sudo) " yn
666 case $yn in
667 [Yy]* ) sudo apt-get install ${apps_to_verify[i]} ;;
668 [Nn]* ) echo -e "${PURPLE}${apps_to_verify[i]} was not installed. leaving build. ${NORMAL} " ; exit 0 ;;
669 * ) echo "Please answer y or n.";;
670 esac
671 fi
672 i=$[$i + 1]
673 done
674 }
676 function setup_workspace()
677 {
678 setup_directories
679 setup_repositories
680 setup_branches
681 verify_installs
682 }
685 function build_all()
686 {
687 build_openssl
688 build_libnl
689 build_wreg
690 build_modules
691 build_iw
692 build_wpa_supplicant
693 build_hostapd
694 build_calibrator
695 build_wl_logger
696 build_wlconf
697 build_fw_download
698 build_scripts_download
700 [ -z $NO_VERIFY ] && verify_skeleton
701 }
703 function setup_and_build()
704 {
705 setup_workspace
706 build_all
707 }
709 function main()
710 {
711 [[ "$1" == "-h" || "$1" == "--help" ]] && usage
712 setup_environment
713 setup_directories
714 read_kernel_version
716 case "$1" in
717 'init')
718 print_highlight " initializing workspace (w/o build) "
719 [[ -n "$2" ]] && echo "Using tag $2 " && USE_TAG=$2
720 NO_BUILD=1
721 setup_workspace
722 read_kernel_version #####read kernel version again after init#####
723 ;;
725 'clean')
726 print_highlight " cleaning & building all "
727 clean_outputs
728 setup_directories
729 build_all
730 ;;
732 'update')
733 print_highlight " setting up workspace and building all "
734 if [ -n "$2" ]
735 then
736 print_highlight "Using tag $2 "
737 USE_TAG=$2
738 else
739 print_highlight "Updating all to head (this will revert local changes)"
740 RESET=1
741 fi
742 #clean_kernel
743 clean_outputs
744 setup_workspace
745 read_kernel_version #####read kernel version again after update#####
746 [[ -z $NO_BUILD ]] && build_all
747 ;;
749 #################### Building single components #############################
750 'kernel')
751 print_highlight " building only Kernel "
752 CLEAN_KERNEL="Y"
753 build_zImage $2
754 ;;
756 'kernel_noclean')
757 print_highlight " building kernel without cleaning "
758 CLEAN_KERNEL="N"
759 build_zImage $2
760 ;;
762 'patch_bbbe14_dts')
763 print_highlight " patching beagblebone black dts file to include support for e14 wireless cape"
764 patch_bbbe14_dts
765 ;;
767 'bbbe14_dtb')
768 print_highlight " building beaglebone black device tree file with e14 wireless cape support "
769 bbbe14_dtb
770 ;;
772 'modules')
773 print_highlight " building only Driver modules "
774 build_modules
775 ;;
777 'wpa_supplicant')
778 print_highlight " building only wpa_supplicant "
779 build_wpa_supplicant
780 ;;
782 'hostapd')
783 print_highlight " building only hostapd "
784 build_hostapd
785 ;;
787 'wireless-regdb')
788 print_highlight " building only wireless regulatory database "
789 build_wreg
790 ;;
792 'libnl')
793 print_highlight " building only libnl"
794 build_libnl
795 ;;
797 'iw')
798 print_highlight " building only iw"
799 build_iw
800 ;;
802 'openssl')
803 print_highlight " building only openssl"
804 build_openssl
805 ;;
807 'scripts')
808 print_highlight " Copying scripts "
809 build_scripts_download
810 ;;
812 'utils')
813 print_highlight " building only ti-utils "
814 build_calibrator
815 build_wl_logger
816 build_wlconf
817 ;;
819 'all_hostap')
820 print_highlight " building hostap and dependencies "
821 build_openssl
822 build_libnl
823 build_wpa_supplicant
824 build_hostapd
825 ;;
827 'firmware')
828 print_highlight " building only firmware"
829 build_fw_download
830 ;;
832 'patch_kernel')
833 print_highlight " only patching kernel $2 without performing an actual build!"
834 NO_BUILD=1
835 patch_kernel
836 ;;
838 ############################################################
839 'get_tag')
840 get_tag
841 exit
842 ;;
844 'admin_tag')
845 admin_tag $2
846 ;;
848 'check_updates')
849 check_for_build_updates
850 ;;
852 *)
853 echo " "
854 echo "**** Unknown parameter - please see usage below **** "
855 usage
856 ;;
857 esac
859 echo "Wifi Package Build Successful"
860 }
861 main $@