#/bin/bash # Yocto ADT Installer # # Copyright 2010-2011 by Intel Corp. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. usage () { INST_ARCH=`uname -m` INST_OS=`uname -o| tr '[A-Z]' '[a-z]'` INST_KR=`uname -r| tr '[A-Z]' '[a-z]'` echo_info "#########################################################################" echo_info "# Welcome to Yocto Application Developement Tools (ADT) Installer" echo_info "# " echo_info "# Host Machine:\t\t\t\t"$INST_ARCH echo_info "# OS info:\t\t\t\t$INST_KR" echo_info "# Yocto ADT version to be installed:\t$YOCTOADT_VERSION" echo_info "# supported target architectures:\t$YOCTOADT_SUPPORTED_TARGETS" echo_info "# supported target root_fs images:\t$YOCTOADT_SUPPORTED_ROOTFS" echo_info "#########################################################################\n" echo_info "Systemwide installation. Installation will occur under $INSTALL_FOLDER\n" echo_info "############################################################################" echo_info "# Your system installation configurations from adt_installer.conf" echo_info "############################################################################" echo_info "# Cross toolchains:\t\t$YOCTOADT_TARGETS" echo_info "# Install Qemu:\t\t\t$YOCTOADT_QEMU" echo_info "# Install NFS utilities:\t$YOCTOADT_NFS_UTIL" #echo_info "# Install bitbake + UI:\t\t$YOCTOADT_BITBAKE" #echo_info "# Install poky metadata:\t$YOCTOADT_METADATA" #echo_info "############################################################################\n" echo_info "\n##############################################################################" echo_info "# Your rootfs image(s) and target sysroot selections from adt_installer.conf" echo_info "##############################################################################" prompt=1 for arch_type in $YOCTOADT_SUPPORTED_TARGETS; do download_images $arch_type $prompt done echo_info "############################################################################\n" select_install_type } validate_config() { for selected_arch_type in $YOCTOADT_TARGETS; do found=0 for supported_arch_type in $YOCTOADT_SUPPORTED_TARGETS; do if [ "$selected_arch_type" == "$supported_arch_type" ]; then found=1 break fi done if [ $found == 0 ]; then echo_info "[ADT_INST] Error: YOCTADT_TARGETS in adt_installer.conf contains invalid entries: $YOCTOADT_TARGETS. Valid values are: $YOCTOADT_SUPPORTED_TARGETS" echo -e "\n#############################################################################" echo -e "# Meet error(s) when installing Yocto ADT! Please check log file for details. " echo -e "#############################################################################\n" exit -1 fi done for arch_type in $YOCTOADT_SUPPORTED_TARGETS; do #select_target_var="\$YOCTOADT_TARGET_$arch_type" #select_target=`eval echo $select_target_var` #if [ "$select_target" != "Y" ] || [ "$selected_target" != "y" ]; then # continue; #fi target_sysroot_image_var="\$YOCTOADT_TARGET_SYSROOT_IMAGE_$arch_type" target_sysroot_image=`eval echo $target_sysroot_image_var` select_rootfs_var="\$YOCTOADT_ROOTFS_$arch_type" select_rootfs=`eval echo $select_rootfs_var` if [ "$select_rootfs" == "" ] && [ "$target_sysroot_image" == "" ]; then continue; fi for image_type in $select_rootfs; do #validate rootfs type defined in YOCTOADT_ROOTFS_{ARCH} is valid and in YOCTOADT_SUPPORTED_ROOTFS found=0 for supported_rootfs_type in $YOCTOADT_SUPPORTED_ROOTFS; do if [ "$image_type" == "$supported_rootfs_type" ]; then found=1 break fi done if [ $found == 0 ]; then #the rootfs type listed for downloading is not valid echo_info "[ADT_INST] Error: Selected YOCTOADT_ROOTFS_$arch_type value: $image_type, is not valid! Valid values are: $YOCTOADT_SUPPORTED_ROOTFS " echo -e "\n#############################################################################" echo -e "# Meet error(s) when installing Yocto ADT! Please check log file for details. " echo -e "#############################################################################\n" exit -1 fi done found=0 for image_type in $select_rootfs; do #validate that rootfs to be extracted must be in the item: YOCTOADT_ROOTFS_${ARCH} if [ "$target_sysroot_image" == "$image_type" ]; then found=1 break fi done # the rootfs image to be extracted is not selected if [ $found == 0 ]; then echo_info "[ADT_INST] Error: YOCTOADT_TARGET_SYSROOT_IMAGE_$arch_type selection: $target_sysroot_image is not included in YOCTOADT_ROOTFS_$arch_type selections: $select_rootfs" echo -e "\n#############################################################################" echo -e "# Meet error(s) when installing Yocto ADT! Please check log file for details. " echo -e "#############################################################################\n" exit -1 fi done } #detect opkg installed or not, for installing sdk, we will use #this installed local opkg install_opkg() { if [ ! -x "$LOCAL_OPKG_LOC/bin/opkg-cl" ]; then echo_info "OPKG is not setup, setting up opkg in local, which is required for installing yocto ADT...\n" if [ -d $LOCAL_OPKG_LOC ]; then echo_info "Deleting old OPKG folder, which doesn't contain executables... " rm -rf $LOCAL_OPKG_LOC fi parent_folder=`pwd` cd $LOCAL_OPKG_FOLDER check_result opkg_source_dir=`ls -d opkg-*` if [ $opkg_source_dir == "" ]; then echo_info "[ADT_INST] Error: OPKG source directory is not found!" echo -e "\n#############################################################################" echo -e "# Meet error(s) when installing Yocto ADT! Please check log file for details. " echo -e "#############################################################################\n" exit -1 fi cd $opkg_source_dir check_result echo_info "Configure opkg ...\n" ./autogen.sh --prefix=$parent_folder/$LOCAL_OPKG_LOC --with-opkglibdir=$OPKG_LIBDIR --disable-curl --disable-ssl-curl --disable-gpg --disable-shave >> $parent_folder/$YOCTOADT_INSTALL_LOG_FILE check_result echo_info "Make opkg ...\n" make &>> $parent_folder/$YOCTOADT_INSTALL_LOG_FILE check_result echo_info "Make Install opkg ...\n" make install &>> $parent_folder/$YOCTOADT_INSTALL_LOG_FILE #if meet error when installing opkg, cancel the installation check_result cd $parent_folder echo_info "Successfully installed OPKG.\n" fi } confirm_download() { #avoid repeated reminding if [ "$override_oldfile" == 1 ]; then return $pre_result else override_oldfile=1 fi while true; do #echo_info "[ADT_INST] Files [$1] already exists. If you continue downloading, old files will be overrided." #echo_info "[ADT_INST] Further prompts will not be given if there're more existing files to be downloaded." #echo_info "[ADT_INST] Do you want to continue downloading? Please enter Y/N:" echo_info "\nFile [$1] already exists, which means you've downloaded the qemu kernel and rootfs file(s) before. If you choose continue downloading, old files will be overridden." echo_info "[ADT_INST] Do you want to continue downloading? Please enter Y/N:" read YOCTOADT_INSTALL YOCTOADT_INSTALL=`tr '[a-z]' '[A-Z]'<<<"$YOCTOADT_INSTALL"` if [ "$YOCTOADT_INSTALL" == "Y" ]; then pre_result=0 return 0 elif [ "$YOCTOADT_INSTALL" == "N" ]; then pre_result=1 return 1 fi done } download_file() { local filename=`echo ${1##*/}` if [ -f "$LOCAL_DOWNLOAD/$filename" ]; then confirm_download $filename result="$?" if [ ! "$result" == "0" ]; then return else echo "Removing old file [$1]" rm -rf "$LOCAL_DOWNLOAD/$filename" fi fi echo_info "Downloading file: $filename..." wget "$YOCTOADT_IPKG_REPO/$1" -P $LOCAL_DOWNLOAD --progress=bar:force 2>&1 | tee -a "$YOCTOADT_INSTALL_LOG_FILE" } #Need two input params, $1 -- arch_type(arm powerpc x86 mips) $2 rootfs_image_type (a list of sdk sato minimal lsb) get_qemu_image() { local target=`echo "$1" | sed -e 's/x86_64/x86-64/'` if [ "$1" == "x86" ] || [ "$1" == "x86_64" ]; then qemu_kernel="bzImage-qemu$target.bin" elif [ "$1" == "mips" ]; then qemu_kernel="vmlinux-qemu$target.bin" else qemu_kernel="zImage-qemu$target.bin" fi #echo_info "[ADT_INST] Downloading qemu kernel binary: $qemu_kernel" download_file qemu$1/$qemu_kernel check_result for image_type in $select_rootfs; do #echo_info "[ADT_INST] Downloading rootfs file: poky-image-$image_type-qemu$1.tar.bz2" filename="poky-image-$image_type-qemu$target.tar.bz2" download_file qemu$1/$filename check_result done } download_images() { #select_target_var="\$YOCTOADT_TARGET_$1" #select_target=`eval echo $select_target_var` #if [ "$select_target" == "Y" ]; then select_rootfs_var="\$YOCTOADT_ROOTFS_$1" select_sysroot_image_var="\$YOCTOADT_TARGET_SYSROOT_IMAGE_$1" select_sysroot_var="\$YOCTOADT_TARGET_SYSROOT_LOC_$1" select_rootfs=`eval echo $select_rootfs_var` select_sysroot_image=`eval echo $select_sysroot_image_var` select_sysroot=`eval echo $select_sysroot_var` if [ "$select_rootfs" != "" ]; then if [ $2 ]; then #echo_info "\n############################################################################" #echo_info "# To be downloaded rootfs image details defined in adt_installer.conf" #echo_info "############################################################################" echo_info "# Target architecture:\t\t$1" echo_info "# Root_fs images:\t\t$select_rootfs" echo_info "# Target sysroot image:\t\t$select_sysroot_image" echo_info "# Target sysroot loc:\t\t$select_sysroot" echo_info "\n" #echo_info "############################################################################\n" else get_qemu_image $1 $select_rootfs fi fi } #Main body of installer clear run_path=`dirname $0` cd $run_path if [ ! -f "scripts/util" ]; then echo -e "[ADT_INST] Error: Script file: util, can't be found under: $run_path!" echo -e "\n#############################################################################" echo -e "# Meet error(s) when installing Yocto ADT! Please check log file for details. " echo -e "#############################################################################\n" exit -1 fi if [ ! -f "scripts/adt_installer_internal" ]; then echo -e "[ADT_INST] Error: Script file: adt_installer_internal, can't be found under: $run_path!" echo -e "\n#############################################################################" echo -e "# Meet error(s) when installing Yocto ADT! Please check log file for details. " echo -e "#############################################################################\n" exit -1 fi config_file="adt_installer.conf" if [ ! -f "$config_file" ]; then echo_info "[ADT_INST] Error: Installation configuration file: adt_installer.conf is not found!\n" echo_info "\n##################################################################################" echo_info "# Meet error(s) when installing Yocto ADT. Please check log file for details. " echo_info "##################################################################################\n" exit -1 fi . scripts/data_define . scripts/util if [ -f "$YOCTOADT_INSTALL_LOG_FILE" ]; then rm $YOCTOADT_INSTALL_LOG_FILE fi usage user_inst_type="$?" validate_config check_result #firstly we need to install opkg host install_opkg #Create folders for holding rootfs/qemu images if [ ! -d "$LOCAL_DOWNLOAD" ]; then echo_info "Creating new images downloading folder: $LOCAL_DOWNLOAD ..." mkdir -p $LOCAL_DOWNLOAD fi #downloading required qemu images/rootfs if [ "$user_inst_type" == "0" ]; then override_oldfile=1 else override_oldfile=0 fi for arch_type in $YOCTOADT_SUPPORTED_TARGETS; do download_images $arch_type done scripts/adt_installer_internal $user_inst_type result="$?" #echo_info "\n############################################################" if [ "$result" == "0" ]; then echo_info "\n############################################################" echo_info "# Yocto ADT has been successfully installed." echo_info "############################################################\n" fi 8 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137