]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - wilink8-wlan/build-utilites.git/blob - build_wl18xx.sh
wlconf : install path update
[wilink8-wlan/build-utilites.git] / build_wl18xx.sh
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 build all/one of the relevent wl18xx software package."
23     echo "A web guide can be found here : http://processors.wiki.ti.com/index.php/WL18xx_System_Build_Scripts"
24     echo ""
25     echo "Usage : "
26     echo ""
27     echo "Building full package : "
28     echo "        ./build_wl18xx.sh init         <head|TAG>  [ Download and Update w/o build  ] "
29     echo "                          update       <head|TAG>  [ Update to specific TAG & Build ] "
30     echo "                          clean                    [ Clean & Build                  ] "
31     echo "                          <empty>                  [ Build w/o update               ] "
32     echo "                          check_updates            [ Check for build script updates ] "
33     echo ""
34     echo "Building specific component :"
35     echo "                          hostapd                  [ Clean & Build hostapd          ] "
36     echo "                          wpa_supplicant           [ Clean & Build wpa_supplicant   ] "
37     echo "                          modules                  [ Clean & Build driver modules   ] "
38     echo "                          firmware                 [ Install firmware file          ] "
39     echo "                          scripts                  [ Install scripts                ] "
40     echo "                          utils                    [ Clean & Build scripts          ] "
41     echo "                          iw                       [ Clean & Build iw               ] "
42     echo "                          openssl                  [ Clean & Build openssll         ] "
43     echo "                          libnl                    [ Clean & Build libnl            ] "
44     echo "                          crda                     [ Clean & Build crda             ] "
46     exit 1
47 }
49 function assert_no_error()
50 {
51         if [ $? -ne 0 ]; then
52                 echo "****** ERROR $? $@*******"
53                 exit 1
54         fi
55         echo "****** $1 *******"
56 }
58 function repo_id()
59 {
60         i="0"
61         while [ $i -lt ${#repositories[@]} ]; do
62                 [ $1 == "${repositories[i]}" ] && echo $i
63                 i=$[$i + 3]
64         done
65 }
67 function repo_url()
68 {
69         echo "${repositories[`repo_id $1` + 1]}"
70 }
72 function repo_branch()
73 {
74         echo "${repositories[`repo_id $1` + 2]}"
75 }
77 function path()
78 {
79         i="0"
80         while [ $i -lt "${#paths[@]}" ]; do
81                 [ $1 == "${paths[i]}" ] && echo "${paths[i + 1]}"
82                 i=$[$i + 2]
83         done
84 }
86 function set_path()
87 {
88         i="0"    
89         while [ $i -lt "${#paths[@]}" ]; do
90                 [ $1 == "${paths[i]}" ] && paths[i+1]=$2    
91                 i=$[$i + 2]
92         done
93 }
95 function repo_path()
96 {
97         echo `path src`/$1
98 }
100 function cd_path()
102         cd `path $1`
105 function cd_repo()
107         cd `repo_path $1`
110 function cd_back()
112         cd - > /dev/null
115 function check_for_build_updates()
117         git fetch
118         count=`git status -uno | grep behind | wc -l`
119         if [ $count -ne 0 ]
120         then
121                 echo ""
122                 echo "*** Please note, there is an updated build script avilalable ***"
123                 echo "*** Use 'git pull' to get the latest update. ***" 
124                 echo ""
125                 sleep 5
126         fi
129 function read_kernel_version()
131         filename=$KERNEL_PATH/Makefile
133         if [ ! -f $filename ]
134         then
135             KERNEL_VERSION=0
136             KERNEL_PATCHLEVEL=0
137             KERNEL_SUBLEVEL=0
138             echo "No Makefile was found. Kernel version was set to default." 
139         else 
140             exec 6< $filename
141             read version <&6
142             read patchlevel <&6
143             read sublevel <&6
144             exec 6<&-
146             KERNEL_VERSION=$(echo $version|sed 's/[^0-9]//g')
147             KERNEL_PATCHLEVEL=$(echo $patchlevel|sed 's/[^0-9]//g')
148             KERNEL_SUBLEVEL=$(echo $sublevel|sed 's/[^0-9]//g')
149             echo "Makefile was found. Kernel version was set to $KERNEL_VERSION.$KERNEL_PATCHLEVEL.$KERNEL_SUBLEVEL." 
150         fi
153 #----------------------------------------------------------j
154 function setup_environment()
156     if [ ! -e setup-env ]
157     then
158         echo "No setup-env"
159         exit 1
160     fi
161     
162     #if a rootfs path is set - replace the default.
163     if [[ "$ROOTFS" != "DEFAULT" ]]
164     then            
165         echo " Changing ROOTFS path to $ROOTFS"
166         set_path filesystem $ROOTFS
167         [ ! -d $ROOTFS ] && echo "Error ROOTFS: $ROOTFS dir does not exist" && exit 1
168     fi   
169     #if no toolchain path is set - download it.
170     if [[ "$TOOLCHAIN_PATH" == "DEFAULT" ]]
171     then            
172         echo " Setting TOOLCHAIN_PATH path to default"
173         export TOOLCHAIN_PATH=`path toolchain`/arm/bin
174         DEFAULT_TOOLCHAIN=1
175     fi   
177     #if no kernel path is set - download it.
178     if [[ "$KERNEL_PATH" == "DEFAULT" ]]
179     then            
180         echo " Setting KERNEL_PATH path to default"
181         export KERNEL_PATH=`repo_path kernel`
182         DEFAULT_KERNEL=1
183     else 
184         echo " Using user defined kernel"                        
185         [ ! -d $KERNEL_PATH ] && echo "Error KERNEL_PATH: $KERNEL_PATH dir does not exist" && exit 1
186     fi  
187     
188         export PROCESSORS_NUMBER=$(egrep '^processor' /proc/cpuinfo | wc -l)
189         export PKG_CONFIG_PATH=`path filesystem`/lib/pkgconfig
190         export INSTALL_PREFIX=`path filesystem`
191         export LIBNL_PATH=`repo_path libnl`
192         export KLIB=`path filesystem`
193         export KLIB_BUILD=${KERNEL_PATH}
194     export GIT_TREE=`repo_path driver`
195     export PATH=$TOOLCHAIN_PATH:$PATH
198 function setup_filesystem_skeleton()
200         mkdir -p `path filesystem`/usr/bin
201         mkdir -p `path filesystem`/etc
202         mkdir -p `path filesystem`/usr/lib/crda
203         mkdir -p `path filesystem`/lib/firmware/ti-connectivity
204         mkdir -p `path filesystem`/usr/share/wl18xx
205         mkdir -p `path filesystem`/usr/bin/wlconf
206         mkdir -p `path filesystem`/usr/bin/wlconf/official_inis
207         mkdir -p `path filesystem`/etc/wireless-regdb/pubkeys
210 function setup_directories()
212         i="0"
213         while [ $i -lt ${#paths[@]} ]; do
214                 mkdir -p ${paths[i + 1]}
215                 i=$[$i + 2]
216         done
217         setup_filesystem_skeleton
221 function setup_repositories()
223         i="0"
224         while [ $i -lt ${#repositories[@]} ]; do
225                 url=${repositories[$i + 1]}
226                 name=${repositories[$i]}
227         echo -e "${NORMAL}Cloning into: ${GREEN} $name ${NORMAL}"        
228         #Skip kernel clone if it was user defined 
229                 [ "$name" != "kernel" -o "$DEFAULT_KERNEL" ] && [ ! -d `repo_path $name` ] && git clone $url `repo_path $name`
230                 i=$[$i + 3]
231         done        
234 function setup_branches()
236         i="0"    
237         while [ $i -lt ${#repositories[@]} ]; do
238                 name=${repositories[$i]}
239                 url=${repositories[$i + 1]}
240         branch=${repositories[$i + 2]}   
241         checkout_type="branch"       
242         #for all the openlink repo. we use a tag if provided.               
243         [ "$name" == "kernel" ] && [ -z "$DEFAULT_KERNEL" ] && i=$[$i + 3] && continue
244         cd_repo $name   
245         echo -e "\n${NORMAL}Checking out branch ${GREEN}$branch  ${NORMAL}in repo ${GREEN}$name ${NORMAL} "
246                 git checkout $branch        
247         git fetch origin
248         git fetch origin --tags  
249         if [[ "$url" == *git.ti.com* ]]
250         then            
251            [[ -n $RESET ]] && echo -e "${PURPLE}Reset to latest in repo ${GREEN}$name ${NORMAL} branch  ${GREEN}$branch ${NORMAL}"  && git reset --hard origin/$branch
252            [[ -n $USE_TAG ]] && git reset --hard $USE_TAG  && echo -e "${NORMAL}Reset to tag ${GREEN}$USE_TAG   ${NORMAL}in repo ${GREEN}$name ${NORMAL} "            
253         fi        
254                 cd_back
255                 i=$[$i + 3]
256         done
259 function setup_toolchain()
261         if [ ! -f `path downloads`/arm-toolchain.tar.bz2 ]; then
262         echo "Setting toolchain"
263                 wget ${toolchain[0]} -O `path downloads`/arm-toolchain.tar.bz2
264                 tar -xjf `path downloads`/arm-toolchain.tar.bz2 -C `path toolchain`
265                 mv `path toolchain`/* `path toolchain`/arm
266         fi
269 function build_uimage()
271     cd_repo kernel
272         [ -z $NO_CONFIG ] && cp `path configuration`/kernel_$KERNEL_VERSION.$KERNEL_PATCHLEVEL.config `repo_path kernel`/.config
273         [ -z $NO_CLEAN ] && make clean
274         [ -z $NO_CLEAN ] && assert_no_error
276     if [ "$KERNEL_VERSION" -eq 3 ] && [ "$KERNEL_PATCHLEVEL" -eq 2 ]
277     then
278         make -j${PROCESSORS_NUMBER} uImage
279         cp `repo_path kernel`/arch/arm/boot/uImage `path tftp`/uImage
280     else
281         if [ -z $NO_DTB ] 
282         then
283             make -j${PROCESSORS_NUMBER} zImage
284             make -j${PROCESSORS_NUMBER} am335x-evm.dtb
285             make -j${PROCESSORS_NUMBER} am335x-bone.dtb
286             make -j${PROCESSORS_NUMBER} am335x-boneblack.dtb
287             make -j${PROCESSORS_NUMBER} modules
288             INSTALL_MOD_PATH=`path filesystem` make -j${PROCESSORS_NUMBER} modules_install
289             cp `repo_path kernel`/arch/arm/boot/zImage `path tftp`/zImage
290             cp `repo_path kernel`/arch/arm/boot/dts/am335x-*.dtb `path tftp`/
291         else
292             LOADADDR=0x80008000 make -j${PROCESSORS_NUMBER} uImage.am335x-evm 
293             cp `repo_path kernel`/arch/arm/boot/uImage.am335x-evm `path tftp`/uImage
294         fi
295     fi
296         assert_no_error
297         cd_back
300 function generate_compat()
302         cd_repo backports
303         python ./gentree.py --clean `repo_path driver` `path compat_wireless`
304         cd_back
307 function build_modules()
309         generate_compat
310         cd_repo compat_wireless
311         if [ -z $NO_CLEAN ]; then
312                 make clean
313         fi
314         make defconfig-wl18xx
315         make -j${PROCESSORS_NUMBER}
316         assert_no_error
317         #find . -name \*.ko -exec cp {} `path debugging`/ \;
318         find . -name \*.ko -exec ${CROSS_COMPILE}strip -g {} \;
319     
320         make  modules_install
321         assert_no_error
322         cd_back
325 function build_openssl()
327         cd_repo openssl
328         [ -z $NO_CONFIG ] && ./Configure linux-generic32
329         [ -z $NO_CLEAN ] && make clean
330         [ -z $NO_CLEAN ] && assert_no_error
331         make
332         assert_no_error
333         make install_sw
334         assert_no_error
335         cd_back
339 function build_iw()
341         cd_repo iw
342         [ -z $NO_CLEAN ] && make clean
343         [ -z $NO_CLEAN ] && assert_no_error
344         CC=${CROSS_COMPILE}gcc LIBS+=" -lpthread -lm" make V=1
345         assert_no_error
346         DESTDIR=`path filesystem` make install
347         assert_no_error
348         cd_back
350 function build_libnl()
352         cd_repo libnl
353         [ -z $NO_CONFIG ] && ./autogen.sh
354         [ -z $NO_CONFIG ] && ./configure --prefix=`path filesystem` --host=${ARCH} CC=${CROSS_COMPILE}gcc AR=${CROSS_COMPILE}ar
355         ([ -z $NO_CONFIG ] || [ -z $NO_CLEAN ]) && make clean
356         [ -z $NO_CLEAN ] && assert_no_error
357         make
358         assert_no_error
359         make install
360         assert_no_error
361         cd_back
364 function build_wpa_supplicant()
366         cd `repo_path hostap`/wpa_supplicant
367         [ -z $NO_CONFIG ] && cp android.config .config
368     [ -n "$SYSLOG_EN" ] && echo "Enable DEBUG_SYSLOG config" && sed -i "/#CONFIG_DEBUG_SYSLOG=y/ s/# *//" .config
369         CONFIG_LIBNL32=y DESTDIR=`path filesystem` make clean
370         assert_no_error
371         CONFIG_LIBNL32=y DESTDIR=`path filesystem` CFLAGS+="-I`path filesystem`/usr/local/ssl/include -I`repo_path libnl`/include" LIBS+="-L`path filesystem`/lib -L`path filesystem`/usr/local/ssl/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
372         assert_no_error
373         CONFIG_LIBNL32=y DESTDIR=`path filesystem` make install
374         assert_no_error
375         cd_back    
376     cp `repo_path scripts_download`/conf/*_supplicant.conf  `path filesystem`/etc/
379 function build_hostapd()
381     cd `repo_path hostap`/hostapd
382         [ -z $NO_CONFIG ] && cp android.config .config
383         [ -n "$UPNP_EN" ] && echo "Enable UPNP config" && sed -i "/#CONFIG_WPS_UPNP=y/ s/# *//" .config
384         CONFIG_LIBNL32=y DESTDIR=`path filesystem` make clean
385         assert_no_error
386         CONFIG_LIBNL32=y DESTDIR=`path filesystem` CFLAGS+="-I`path filesystem`/usr/local/ssl/include -I`repo_path libnl`/include" LIBS+="-L`path filesystem`/lib -L`path filesystem`/usr/local/ssl/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
387         assert_no_error
388         CONFIG_LIBNL32=y DESTDIR=`path filesystem` make install
389         assert_no_error
390         cd_back
391     cp `repo_path scripts_download`/conf/hostapd.conf  `path filesystem`/etc/    
394 function build_crda()
395 {       
396         cp `repo_path wireless_regdb`/regulatory.bin `path filesystem`/usr/lib/crda/regulatory.bin
397         cp `repo_path wireless_regdb`/linville.key.pub.pem `path filesystem`/etc/wireless-regdb/pubkeys/
398     cd_repo crda
399         
400         [ -z $NO_CLEAN ] && DESTDIR=`path filesystem` make clean
401         [ -z $NO_CLEAN ] && assert_no_error
402         PKG_CONFIG_LIBDIR="`path filesystem`/lib/pkgconfig" PKG_CONFIG_PATH="`path filesystem`/usr/local/ssl/lib/pkgconfig" DESTDIR=`path filesystem` CFLAGS+="-I`path filesystem`/usr/local/ssl/include -I`path filesystem`/include -L`path filesystem`/usr/local/ssl/lib -L`path filesystem`/lib" LDLIBS+=-lpthread V=1 USE_OPENSSL=1 make -j${PROCESSORS_NUMBER} all_noverify CC=${CROSS_COMPILE}gcc LD=${CROSS_COMPILE}ld AR=${CROSS_COMPILE}ar
403         assert_no_error
404         DESTDIR=`path filesystem` make install
405         assert_no_error
406         cd_back
409 function build_calibrator()
411         cd_repo ti_utils
412         [ -z $NO_CLEAN ] && NFSROOT=`path filesystem` make clean
413         [ -z $NO_CLEAN ] && assert_no_error
414         NLVER=3 NLROOT=`repo_path libnl`/include NFSROOT=`path filesystem` LIBS+=-lpthread make
415         assert_no_error
416         NFSROOT=`path filesystem` make install
417         #assert_no_error
418         cd_back
421 function build_wlconf()
423         files_to_copy="dictionary.txt struct.bin default.conf wl18xx-conf-default.bin README example.conf example.ini configure-device.sh"
424         cd `repo_path ti_utils`/wlconf
425         if [ -z $NO_CLEAN ]; then
426                 NFSROOT=`path filesystem` make clean
427                 assert_no_error
428                 for file_to_copy in $files_to_copy; do
429                         rm -f `path filesstem`/usr/bin/wlconf/$file_to_copy
430                 done
431                 rm -f `path filesystem`/usr/bin/wlconf/official_inis/*
432         fi
433         NFSROOT=`path filesystem` make CC=${CROSS_COMPILE}gcc LD=${CROSS_COMPILE}ld
434         assert_no_error
436         # install
437         cp -f `repo_path ti_utils`/wlconf/wlconf `path filesystem`/usr/bin/wlconf
438         chmod 755 `path filesystem`/usr/bin/wlconf
439         for file_to_copy in $files_to_copy; do
440                 cp $file_to_copy `path filesystem`/usr/bin/wlconf/$file_to_copy
441                 echo "echoying files $file_to_copy"
442         done
443         cp official_inis/* `path filesystem`/usr/bin/wlconf/official_inis/
444         cd_back
447 function build_fw_download()
449         cp `repo_path fw_download`/*.bin `path filesystem`/lib/firmware/ti-connectivity
453 function build_scripts_download()
455         cd_repo scripts_download
456         echo "Copying scripts"
457         scripts_download_path=`repo_path scripts_download`
458         for script_dir in `ls $scripts_download_path`
459         do
460                 echo "Copying everything from ${script_dir} to `path filesystem`/usr/share/wl18xx directory"
461                 cp -rf `repo_path scripts_download`/${script_dir}/* `path filesystem`/usr/share/wl18xx
462         done
463         cd_back
466 function clean_kernel()
468         [ "$DEFAULT_KERNEL" ] && echo "Cleaning kernel folder"
469         [ "$DEFAULT_KERNEL" ] && cd_repo kernel
470         [ "$DEFAULT_KERNEL" ] && git clean -fdx > /dev/null
473 function clean_outputs()
475     if [[ "$ROOTFS" == "DEFAULT" ]]
476     then
477         echo "Cleaning outputs"
478         rm -rf `path filesystem`/*
479         rm -f `path outputs`/*
480    fi
483 function build_outputs()
485         if [[ "$ROOTFS" == "DEFAULT" ]]
486     then  
487         echo "Building outputs"    
488         cd_path filesystem
489         tar cpjf `path outputs`/${tar_filesystem[0]} .
490         cd_back
491                 
492                 # Copy kernel files only if default kernel is used(for now)
493                 if [ "$DEFAULT_KERNEL" -eq 1 ]
494                 then
495                         if [ "$KERNEL_VERSION" -eq 3 ] && [ "$KERNEL_PATCHLEVEL" -eq 2 ]
496                         then
497                                 cp `path tftp`/uImage `path outputs`/uImage
498                         else
499                                 if [ -z $NO_DTB ]
500                                 then
501                                         cp `path tftp`/zImage `path outputs`/zImage
502                                         cp `path tftp`/*.dtb `path outputs`/
503                                 else
504                                         cp `path tftp`/uImage `path outputs`/uImage
505                                 fi
506                         fi
507                 fi
508     fi
511 function install_outputs()
513     echo "Installing outputs"
514         tftp_path=${setup[2]}
515         sitara_left_path=${setup[5]}
516         sitara_right_path=${setup[8]}
518         cp `path outputs`/uImage ${tftp_path}
519         cp `path outputs`/${tar_filesystem[0]} $sitara_left_path
520         cp `path outputs`/${tar_filesystem[0]} $sitara_right_path
522         cd $sitara_left_path
523         tar xjf ${tar_filesystem[0]}
524         cd_back
526         cd $sitara_right_path
527         tar xjf ${tar_filesystem[0]}
528         cd_back
531 function set_files_to_verify()
533         files_to_verify=(
534         # skeleton path
535         # source path
536         # pattern in output of file
538         `path filesystem`/usr/local/sbin/wpa_supplicant
539         `repo_path hostap`/wpa_supplicant/wpa_supplicant
540         "ELF 32-bit LSB executable, ARM"
542         `path filesystem`/usr/local/bin/hostapd
543         `repo_path hostap`/hostapd/hostapd
544         "ELF 32-bit LSB executable, ARM"
546         `path filesystem`/sbin/crda
547         `repo_path crda`/crda
548         "ELF 32-bit LSB executable, ARM"
550         `path filesystem`/usr/lib/crda/regulatory.bin
551         `repo_path wireless_regdb`/regulatory.bin
552         "CRDA wireless regulatory database file"
554         `path filesystem`/lib/firmware/ti-connectivity/wl18xx-fw-4.bin
555         `repo_path fw_download`/wl18xx-fw-4.bin
556         "data"
558         `path filesystem`/lib/modules/$KERNEL_VERSION.$KERNEL_PATCHLEVEL.*/updates/drivers/net/wireless/ti/wl18xx/wl18xx.ko
559         `path compat_wireless`/drivers/net/wireless/ti/wl18xx/wl18xx.ko
560         "ELF 32-bit LSB relocatable, ARM"
562         `path filesystem`/lib/modules/$KERNEL_VERSION.$KERNEL_PATCHLEVEL.*/updates/drivers/net/wireless/ti/wlcore/wlcore.ko
563         `path compat_wireless`/drivers/net/wireless/ti/wlcore/wlcore.ko
564         "ELF 32-bit LSB relocatable, ARM"
566         #`path filesystem`/usr/bin/calibrator
567         #`repo_path ti_utils`/calibrator
568         #"ELF 32-bit LSB executable, ARM"
570         `path filesystem`/usr/bin/wlconf/wlconf
571         `repo_path ti_utils`/wlconf/wlconf
572         "ELF 32-bit LSB executable, ARM"
573         )
576 function get_tag()
578        i="0"
579        while [ $i -lt ${#repositories[@]} ]; do
580                name=${repositories[$i]}
581                url=${repositories[$i + 1]}
582         branch=${repositories[$i + 2]}
583         checkout_type="branch"
584         cd_repo $name
585         if [[ "$url" == *git.ti.com* ]]
586         then
587                 echo -e "${PURPLE}Describe of ${NORMAL} repo : ${GREEN}$name ${NORMAL} "  ;
588                 git describe
589         fi
590                cd_back
591                i=$[$i + 3]
592        done
597 function admin_tag()
599         i="0"    
600         while [ $i -lt ${#repositories[@]} ]; do
601                 name=${repositories[$i]}
602                 url=${repositories[$i + 1]}
603         branch=${repositories[$i + 2]}   
604         checkout_type="branch"              
605         cd_repo $name    
606         if [[ "$url" == *git.ti.com* ]]
607         then                                   
608                 echo -e "${PURPLE}Adding tag ${GREEN} $1 ${NORMAL} to repo : ${GREEN}$name ${NORMAL} "  ;
609                 git show --summary        
610                 read -p "Do you want to tag this commit ?" yn
611                 case $yn in
612                     [Yy]* )  git tag -a $1 -m "$1" ;
613                              git push --tags ;;
614                     [Nn]* ) echo -e "${PURPLE}Tag was not applied ${NORMAL} " ;;
615                     
616                     * ) echo "Please answer yes or no.";;
617                 esac
618            
619         fi        
620                 cd_back
621                 i=$[$i + 3]
622         done
626 function verify_skeleton()
628         echo "Verifying filesystem skeleton..."
630         set_files_to_verify
632         i="0"
633         while [ $i -lt ${#files_to_verify[@]} ]; do
634                 skeleton_path=${files_to_verify[i]}
635                 source_path=${files_to_verify[i + 1]}
636                 file_pattern=${files_to_verify[i + 2]}
637                 file $skeleton_path | grep "${file_pattern}" >/dev/null
638         if [ $? -eq 1 ]; then
639         echo -e "${RED}ERROR " $skeleton_path " Not found ! ${NORMAL}"
640         #exit
641         fi
643                 md5_skeleton=$(md5sum $skeleton_path | awk '{print $1}')
644                 md5_source=$(md5sum $source_path     | awk '{print $1}')
645                 if [ $md5_skeleton != $md5_source ]; then
646                         echo "ERROR: file mismatch"
647                         echo $skeleton_path
648                         exit 1
649                 fi
650                 i=$[$i + 3]
651         done
653         which regdbdump > /dev/null
654         if [ $? -eq 0 ]; then
655                 regdbdump `path filesystem`/usr/lib/crda/regulatory.bin > /dev/null
656                 assert_no_error
657         fi
660 function verify_installs()
662     apps_to_verify=(
663      libtool     
664      python-m2crypto
665      bison
666      flex
667     )
669     i="0"
670         while [ $i -lt ${#apps_to_verify[@]} ]; do
671         if !( dpkg-query -s ${apps_to_verify[i]} 2>/dev/null | grep -q ^"Status: install ok installed"$ )then
672             echo  "${apps_to_verify[i]} is missing"
673             echo  "Please use 'sudo apt-get install ${apps_to_verify[i]}'"
674             read -p "Do you want to install it now [y/n] ? (requires sudo) " yn
675             case $yn in
676                 [Yy]* )  sudo apt-get install ${apps_to_verify[i]} ;;
677                 [Nn]* ) echo -e "${PURPLE}${apps_to_verify[i]} was not installed. leaving build. ${NORMAL} " ; exit 0 ;;
678                 * ) echo "Please answer y or n.";;
679             esac
680         fi
681         i=$[$i + 1]
682     done
685 function setup_workspace()
687         setup_directories       
688         setup_repositories
689         setup_branches
690     verify_installs
691     #Download toolchain only if it was not set
692     [ DEFAULT_TOOLCHAIN ] && setup_toolchain   
696 function build_all()
698     if [ -z $NO_EXTERNAL ] 
699     then        
700         [ $DEFAULT_KERNEL ] && build_uimage
701         build_openssl
702         build_libnl
703         build_crda
704     fi
705     
706     if [ -z $NO_TI ] 
707     then
708         build_modules
709         build_iw
710         build_wpa_supplicant
711         build_hostapd   
712         build_calibrator
713         build_wlconf
714         build_fw_download
715         build_scripts_download
716     fi
717     
718     [ -z $NO_VERIFY ] && verify_skeleton
721 function setup_and_build()
723     setup_workspace
724     build_all
727 function main()
729         [[ "$1" == "-h" || "$1" == "--help"  ]] && usage
730     setup_environment
731     setup_directories
732     read_kernel_version
733     
734         case "$1" in
735         'init')                
736         print_highlight " initializing workspace (w/o build) "       
737                 [[  -n "$2" ]] && echo "Using tag $2 " && USE_TAG=$2                
738         NO_BUILD=1 
739         setup_workspace
740         read_kernel_version #####read kernel version again after init#####
741                 ;;
742               
743         'clean')        
744         print_highlight " cleaning & building all "       
745         clean_outputs
746         setup_directories
747         build_all        
748                 ;;
750         'update')
751         print_highlight " setting up workspace and building all "
752                 if [  -n "$2" ]
753         then
754             print_highlight "Using tag $2 "
755             USE_TAG=$2
756         else
757             print_highlight "Updating all to head (this will revert local changes)"
758             RESET=1
759         fi
760         #clean_kernel
761         clean_outputs
762         setup_workspace
763         read_kernel_version #####read kernel version again after update#####
764         build_all
765                 ;;
766         
767                 'openlink')
768         print_highlight " building all (w/o clean) "       
769                 NO_EXTERNAL=1 setup_and_build
770                 ;;
772         #################### Building single components #############################
773                 'kernel')
774                 print_highlight " building only Kernel "
775                 #clean_kernel
776                 build_uimage
777                 ;;
778                 
779                 'kernel_modules')
780         print_highlight " building only Driver modules "
781                 build_uimage
782                 build_modules
783                 ;;
784                 'modules')
785         print_highlight " building only Driver modules "
786                 build_modules
787                 ;;
789                 'wpa_supplicant')
790         print_highlight " building only wpa_supplicant "
791                 build_wpa_supplicant      
792                 ;;
794                 'hostapd')
795         print_highlight " building only hostapd "
796                 build_hostapd
797                 ;;
799                 'crda')
800         print_highlight " building only CRDA "
801                 build_crda
802                 ;;
803         
804                 'libnl')
805                 print_highlight " building only libnl"
806                 build_libnl
807                 ;;
809                 'iw')
810                 print_highlight " building only iw"
811                 build_iw
812                 ;;
814                 'openssl')
815                 print_highlight " building only openssl"
816                 build_openssl
817                 ;;
819                 'scripts')
820                 print_highlight " Copying scripts "
821                 build_scripts_download
822                 ;;
823                 
824                 'utils')
825                 print_highlight " building only ti-utils "
826                 build_calibrator
827                 build_wlconf            
828                 ;;        
829                 'firmware')
830                 print_highlight " building only firmware"
831                 build_fw_download
832                 ;;
833         ############################################################
834         'get_tag')
835         get_tag
836         exit
837         ;;
838                 
839         'admin_tag')        
840                 admin_tag $2
841                 ;;
843         'check_updates')
844                 check_for_build_updates
845                 ;;
847         '')
848         print_highlight " building all (No clean & no source code update) "  
849                 #clean_outputs
850         NO_CLEAN=1 build_all
851                 ;;
853         *)
854         echo " "
855         echo "**** Unknown parameter - please see usage below **** "
856         usage
857         ;;
858         esac
859         
860         [[ -z $NO_BUILD ]] && build_outputs
861         [[ -n $INSTALL_NFS ]] && install_outputs
863 main $@