util 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. #!/bin/bash
  2. # Yocto ADT Installer
  3. #
  4. # Copyright 2010-2011 by Intel Corp.
  5. #
  6. # Permission is hereby granted, free of charge, to any person obtaining a copy
  7. # of this software and associated documentation files (the "Software"), to deal
  8. # in the Software without restriction, including without limitation the rights
  9. # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10. # copies of the Software, and to permit persons to whom the Software is
  11. # furnished to do so, subject to the following conditions:
  12. # The above copyright notice and this permission notice shall be included in
  13. # all copies or substantial portions of the Software.
  14. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. # THE SOFTWARE.
  21. echo_info()
  22. {
  23. echo -e $1 | tee -a $YOCTOADT_INSTALL_LOG_FILE
  24. }
  25. select_install_type()
  26. {
  27. # If choosing silent install, all older installation data will be
  28. # overriden without user's interaction
  29. while true; do
  30. #echo_info "[ADT_INST] Silent install means overrides all existing older"
  31. #echo_info "[ADT_INST] data and the installation needs least user interaction"
  32. #echo_info "[ADT_INST] If you want to use silent installation, please enter S:"
  33. #echo_info "[ADT_INST] If you want to customize installation, please enter C:"
  34. #echo_info "[ADT_INST} If you want to exit current installation, please enter X:"
  35. echo_info "There're two ways you can do installation: silent mode or interactive mode. To choose silent mode, which means you opt for the system to override the existing data under the specified installation directories without prompting for your confirmation. Please be cautious with this selection which may trigger your losing data. With the interactive mode, you have to closely monitor the installation process, since it will prompt you each step it needs to override some existing data. To choose silent mode, please enter [S], for interactive mode, please enter [I] or [X] to exit the installation."
  36. echo_info "[ADT_INST] Please enter your selections here:"
  37. read YOCTOADT_SEL
  38. YOCTOADT_SEL=`tr '[a-z]' '[A-Z]'<<<"$YOCTOADT_SEL"`
  39. if [ "$YOCTOADT_SEL" == "S" ]; then
  40. return "0"
  41. elif [ "$YOCTOADT_SEL" == "I" ]; then
  42. return "1"
  43. elif [ "$YOCTOADT_SEL" == "X" ]; then
  44. echo_info "\n############################################################"
  45. echo_info "# User cancelled installation!"
  46. echo_info "############################################################\n"
  47. exit 1
  48. fi
  49. done
  50. }
  51. confirm_install()
  52. {
  53. # below are prompt, make sure user still want to install even meet
  54. # some prompts
  55. #User likes to enjoy silent installation, we will not break his
  56. #installation process here
  57. if [ "$1" == "0" ]; then
  58. return
  59. fi
  60. while true; do
  61. echo_info "[ADT_INST] Do you want to continue installation? Please enter Y/N:"
  62. read YOCTOADT_INSTALL
  63. YOCTOADT_INSTALL=`tr '[a-z]' '[A-Z]'<<<"$YOCTOADT_INSTALL"`
  64. if [ "$YOCTOADT_INSTALL" == "Y" ]; then
  65. break
  66. elif [ "$YOCTOADT_INSTALL" == "N" ]; then
  67. echo_info "\n############################################################"
  68. echo_info "# User cancelled installation!"
  69. echo_info "############################################################\n"
  70. exit 1
  71. fi
  72. done
  73. }
  74. check_result()
  75. {
  76. result=$?
  77. if [ $result -eq 1 ]; then
  78. exit -1
  79. elif [ $result -ne 0 ]; then
  80. echo_info "\n#############################################################################"
  81. echo_info "# Meet error(s) when installing Yocto ADT! Please check log file for details. "
  82. echo_info "#############################################################################\n"
  83. exit -1
  84. fi
  85. }
  86. # yocto adt installation log file
  87. YOCTOADT_INSTALL_LOG_FILE="adt_installer.log"
  88. # Temp folders holding qemu/rootfs downloaded images
  89. # It will be put into the installation folder
  90. LOCAL_DOWNLOAD="./download_image"