setup.sh 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. #!/bin/bash
  2. # Bootstrapper for buildbot slave
  3. DIR="build"
  4. MACHINE="starfive-dubhe"
  5. CONFFILE="conf/auto.conf"
  6. BITBAKEIMAGE="virtual/kernel"
  7. # clean up the output dir
  8. #echo "Cleaning build dir"
  9. #rm -rf $DIR
  10. # make sure sstate is there
  11. #echo "Creating sstate directory"
  12. #mkdir -p ~/sstate/$MACHINE
  13. # fix permissions set by buildbot
  14. #echo "Fixing permissions for buildbot"
  15. #umask -S u=rwx,g=rx,o=rx
  16. #chmod -R 755 .
  17. # Reconfigure dash on debian-like systems
  18. which aptitude > /dev/null 2>&1
  19. ret=$?
  20. if [ "$(readlink /bin/sh)" = "dash" -a "$ret" = "0" ]; then
  21. sudo aptitude install expect -y
  22. expect -c 'spawn sudo dpkg-reconfigure -freadline dash; send "n\n"; interact;'
  23. elif [ "${0##*/}" = "dash" ]; then
  24. echo "dash as default shell is not supported"
  25. return
  26. fi
  27. # bootstrap OE
  28. if [[ ":$PATH:" != *":$PWD/meta-starfive:"* ]]; then
  29. export PATH=$PATH:$PWD/meta-starfive
  30. fi
  31. echo "Init OE"
  32. export BASH_SOURCE="openembedded-core/oe-init-build-env"
  33. . ./openembedded-core/oe-init-build-env $DIR
  34. # Symlink the cache
  35. #echo "Setup symlink for sstate"
  36. #ln -s ~/sstate/${MACHINE} sstate-cache
  37. # add the missing layers
  38. echo "Adding layers"
  39. bitbake-layers add-layer ../meta-openembedded/meta-oe
  40. bitbake-layers add-layer ../meta-openembedded/meta-python
  41. bitbake-layers add-layer ../meta-openembedded/meta-multimedia
  42. bitbake-layers add-layer ../meta-openembedded/meta-filesystems
  43. bitbake-layers add-layer ../meta-openembedded/meta-networking
  44. bitbake-layers add-layer ../meta-riscv
  45. bitbake-layers add-layer ../meta-starfive
  46. bitbake-layers add-layer ../meta-clang
  47. # fix the configuration
  48. echo "Creating auto.conf"
  49. if [ -e $CONFFILE ]; then
  50. rm -rf $CONFFILE
  51. fi
  52. cat <<EOF > $CONFFILE
  53. MACHINE ?= "${MACHINE}"
  54. #IMAGE_FEATURES += "tools-debug"
  55. #IMAGE_FEATURES += "tools-tweaks"
  56. #IMAGE_FEATURES += "dbg-pkgs"
  57. # rootfs for debugging
  58. #IMAGE_GEN_DEBUGFS = "1"
  59. #IMAGE_FSTYPES_DEBUGFS = "tar.gz"
  60. #EXTRA_IMAGE_FEATURES:append = " ssh-server-dropbear"
  61. EXTRA_IMAGE_FEATURES:append = " package-management"
  62. PACKAGECONFIG:append:pn-qemu-native = " sdl"
  63. PACKAGECONFIG:append:pn-nativesdk-qemu = " sdl"
  64. USER_CLASSES ?= "buildstats buildhistory buildstats-summary"
  65. require conf/distro/include/no-static-libs.inc
  66. require conf/distro/include/yocto-uninative.inc
  67. require conf/distro/include/security_flags.inc
  68. INHERIT += "uninative"
  69. DISTRO_FEATURES:append = " largefile opengl ptest multiarch wayland pam systemd "
  70. #DISTRO_FEATURES:append = " largefile opengl ptest multiarch wayland pam "
  71. DISTRO_FEATURES_BACKFILL_CONSIDERED += "sysvinit"
  72. VIRTUAL-RUNTIME_init_manager = "systemd"
  73. ##VIRTUAL-RUNTIME_initscripts = ""
  74. ##VIRTUAL-RUNTIME_syslog = ""
  75. HOSTTOOLS_NONFATAL:append = " ssh"
  76. DISTRO_NAME = "StarFive Linux SDK"
  77. #DISTRO_VERSION = ""
  78. #DISTRO_CODENAME = ""
  79. EOF
  80. echo "---------------------------------------------------"
  81. echo "Example: MACHINE=${MACHINE} bitbake ${BITBAKEIMAGE}"
  82. echo "---------------------------------------------------"
  83. echo ""
  84. echo "Buildable machine info"
  85. echo "---------------------------------------------------"
  86. echo "* qemuriscv64 : The 64-bit RISC-V machine"
  87. echo "* starfive-dubhe : The StarFive Dubhe machine"
  88. echo "---------------------------------------------------"
  89. # start build
  90. #echo "Starting build"
  91. #bitbake $BITBAKEIMAGE
  92. # Launch build script
  93. # Terminal Style
  94. PURPLE='\E[1;35m'
  95. YELLOW='\E[1;33m'
  96. GREEN='\E[0;32m'
  97. RED='\E[0;31m'
  98. NC='\E[0m'
  99. MARK="\033[0;32m\xE2\x9C\x94\033[0m"
  100. #Function
  101. runprog(){
  102. read -p "Do you want to runqemu?[Y/n]:" RES
  103. case $RES in
  104. [Yy])
  105. MACHINE=starfive-dubhe runqemu nographic $1;;
  106. [Nn])
  107. return;;
  108. *)
  109. echo "Invalid option $RES , [Y/n] only.";;
  110. esac
  111. }
  112. # Menu script
  113. echo ""
  114. echo -e "${PURPLE}*******************************************************************"
  115. echo "* *"
  116. echo "* Welcome to Starfive Yocto *"
  117. echo "* *"
  118. echo -e "*******************************************************************${NC}"
  119. echo "";
  120. echo -e "${YELLOW}Description : ";
  121. echo "";
  122. echo "This build script consists of two types image.";
  123. echo "";
  124. echo "1) QSPI-Image";
  125. echo " - Initramfs has been bundled into qspi-image.";
  126. echo " - The image generated support both single and multicore vector.";
  127. echo " - Generated output : ";
  128. echo " QSPI-Image.bin for single core vector.";
  129. echo " QSPI-Image-Dual.bin for multicore vector.";
  130. echo "";
  131. echo "2) Dubhe-image-minimal";
  132. echo " - Rootfs has been packaged into SD-Image.img.";
  133. echo " - The image generated support both single and multicore vector.";
  134. echo " - Generated output : ";
  135. echo " QSPI-EXT4-Image.bin for single core vector.";
  136. echo " QSPI-EXT4-Image-Dual.bin for multicore vector.";
  137. echo -e " SD-Image.img for ext4 rootfs.${NC}";
  138. echo "";
  139. PS3="Select your action : "
  140. options=("Build qspi-image" "Build dubhe-image-minimal" "Show deployed image details" "Quit")
  141. select opt in "${options[@]}"
  142. do
  143. case $opt in
  144. "Build qspi-image")
  145. # cd ../build || { echo "Run setup.sh before building images."; cd meta-starfive; break; };
  146. if ! grep -q "ENABLE_EXT4" ./conf/local.conf; then
  147. echo 'ENABLE_EXT4="0"' >> ./conf/local.conf;
  148. else sed -i 's/ENABLE_EXT4="1"/ENABLE_EXT4="0"/g' ./conf/local.conf;
  149. fi;
  150. cur_ter=$(tty);
  151. output=$(MACHINE=starfive-dubhe bitbake qspi-image | tee $cur_ter);
  152. if [[ $output != *"ERROR"* ]]; then
  153. echo -e "\U0002705 ${GREEN}Build Complete${NC}"
  154. runprog dubhe-image-initramfs;
  155. else echo -e "\U000274C ${RED}Build Failed${NC}"
  156. fi;;
  157. "Build dubhe-image-minimal")
  158. # cd ../build || { echo "Run setup.sh before building images."; cd meta-starfive; break; };
  159. if ! grep -q "ENABLE_EXT4" ./conf/local.conf; then
  160. echo 'ENABLE_EXT4="1"' >> ./conf/local.conf;
  161. else sed -i 's/ENABLE_EXT4="0"/ENABLE_EXT4="1"/g' ./conf/local.conf;
  162. fi;
  163. cur_ter=$(tty);
  164. output_min=$(MACHINE=starfive-dubhe bitbake dubhe-image-minimal | tee $cur_ter);
  165. if [[ $output_min != *"ERROR"* ]]; then
  166. echo -e "\U0002705 ${GREEN}Build Complete${NC}"
  167. runprog console-image-minimal;
  168. else echo -e "\U000274C ${RED}Build Failed${NC}"
  169. fi;;
  170. "Show deployed image details")
  171. ls -lh tmp-glibc/deploy/images/starfive-dubhe/;;
  172. "Quit")
  173. break;;
  174. *)
  175. echo "Invalid option $REPLY. Kindly select choice between menu range."
  176. esac
  177. REPLY=
  178. done