setup.sh 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  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="poky/oe-init-build-env"
  33. source poky/oe-init-build-env
  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. INHERIT += "uninative"
  66. DISTRO_FEATURES:append = " largefile opengl ptest multiarch wayland pam systemd "
  67. #DISTRO_FEATURES:append = " largefile opengl ptest multiarch wayland pam "
  68. DISTRO_FEATURES_BACKFILL_CONSIDERED += "sysvinit"
  69. VIRTUAL-RUNTIME_init_manager = "systemd"
  70. ##VIRTUAL-RUNTIME_initscripts = ""
  71. ##VIRTUAL-RUNTIME_syslog = ""
  72. HOSTTOOLS_NONFATAL:append = " ssh"
  73. DISTRO_NAME = "StarFive Linux SDK"
  74. #DISTRO_VERSION = ""
  75. #DISTRO_CODENAME = ""
  76. EOF
  77. echo "---------------------------------------------------"
  78. echo "Example: MACHINE=${MACHINE} bitbake ${BITBAKEIMAGE}"
  79. echo "---------------------------------------------------"
  80. echo ""
  81. echo "Buildable machine info"
  82. echo "---------------------------------------------------"
  83. echo "* qemuriscv64 : The 64-bit RISC-V machine"
  84. echo "* starfive-dubhe : The StarFive Dubhe machine"
  85. echo "---------------------------------------------------"
  86. # start build
  87. #echo "Starting build"
  88. #bitbake $BITBAKEIMAGE
  89. # Launch build script
  90. # Terminal Style
  91. PURPLE='\E[1;35m'
  92. YELLOW='\E[1;33m'
  93. GREEN='\E[0;32m'
  94. RED='\E[0;31m'
  95. NC='\E[0m'
  96. MARK="\033[0;32m\xE2\x9C\x94\033[0m"
  97. #Function
  98. runprog(){
  99. read -p "Do you want to runqemu?[Y/n]:" RES
  100. case $RES in
  101. [Yy])
  102. MACHINE=starfive-dubhe runqemu nographic $1;;
  103. [Nn])
  104. return;;
  105. *)
  106. echo "Invalid option $RES , [Y/n] only.";;
  107. esac
  108. }
  109. updatecfg(){
  110. cfg=("ENABLE_INIT" "ENABLE_EXT4" "ENABLE_UBI")
  111. for cfgname in ${cfg[@]}; do
  112. if [[ $1 == ${cfgname} ]]; then
  113. if ! grep -q $1 ./conf/local.conf; then
  114. echo $1="\"1"\" >> ./conf/local.conf;
  115. else sed -i "s/$1=\"0\"/$1=\"1\"/g" ./conf/local.conf;
  116. fi;
  117. else
  118. if ! grep -q ${cfgname} ./conf/local.conf; then
  119. echo ${cfgname}="\"0"\" >> ./conf/local.conf;
  120. else sed -i "s/${cfgname}=\"1\"/${cfgname}=\"0\"/g" ./conf/local.conf;
  121. fi;
  122. fi;
  123. done
  124. }
  125. # Menu script
  126. echo ""
  127. echo -e "${PURPLE}*******************************************************************"
  128. echo "* *"
  129. echo "* Welcome to Starfive Yocto *"
  130. echo "* *"
  131. echo -e "*******************************************************************${NC}"
  132. echo "";
  133. echo -e "${YELLOW}Description : ";
  134. echo "";
  135. echo "This build script can build three types of image.";
  136. echo "";
  137. echo "1) QSPI-Image";
  138. echo " - Initramfs has been bundled into qspi-image.";
  139. echo " - Generated output : ";
  140. echo " QSPI-Image.bin";
  141. echo "2) Dubhe-Image-Minimal";
  142. echo " - Minimal image with ext4 support.";
  143. echo " - Generated output : ";
  144. echo " QSPI-EXT4-Image.bin";
  145. echo " SD-Image.img";
  146. echo "3) QSPI-Ubifs-Image";
  147. echo " - Minimal image with ubifs support.";
  148. echo " - Generated output : ";
  149. echo -e " QSPI-Ubifs-Image.bin${NC}";
  150. #echo "4) QSPI-NFS-Image";
  151. #echo " - NFS config has been enabled.";
  152. #echo " - Generated output : ";
  153. #echo -e " QSPI-NFS-Image.bin${NC}";
  154. echo "";
  155. PS3="Select your action : "
  156. options=("Build qspi-image" "Build dubhe-image-minimal" "Build qspi-ubifs-image" "Quit")
  157. select opt in "${options[@]}"
  158. do
  159. case $opt in
  160. "Build qspi-image")
  161. # cd ../build || { echo "Run setup.sh before building images."; cd meta-starfive; break; };
  162. updatecfg ENABLE_INIT;
  163. cur_ter=$(tty);
  164. output=$(MACHINE=starfive-dubhe bitbake qspi-image | tee $cur_ter);
  165. if [[ $output != *"ERROR"* ]]; then
  166. echo -e "\U0002705 ${GREEN}Build Complete${NC}"
  167. runprog dubhe-image-initramfs;
  168. else echo -e "\U000274C ${RED}Build Failed${NC}"
  169. fi;;
  170. "Build dubhe-image-minimal")
  171. # cd ../build || { echo "Run setup.sh before building images."; cd meta-starfive; break; };
  172. updatecfg ENABLE_EXT4
  173. cur_ter=$(tty);
  174. output_min=$(MACHINE=starfive-dubhe bitbake dubhe-image-minimal | tee $cur_ter);
  175. if [[ $output_min != *"ERROR"* ]]; then
  176. echo -e "\U0002705 ${GREEN}Build Complete${NC}"
  177. runprog console-image-minimal;
  178. else echo -e "\U000274C ${RED}Build Failed${NC}"
  179. fi;;
  180. "Build qspi-ubifs-image")
  181. # cd ../build || { echo "Run setup.sh before building images."; cd meta-starfive; break; };
  182. updatecfg ENABLE_UBI
  183. cur_ter=$(tty);
  184. output=$(MACHINE=starfive-dubhe bitbake qspi-ubifs-image | tee $cur_ter);
  185. if [[ $output != *"ERROR"* ]]; then
  186. echo -e "\U0002705 ${GREEN}Build Complete${NC}"
  187. else echo -e "\U000274C ${RED}Build Failed${NC}"
  188. fi;;
  189. "Build qspi-nfs-image")
  190. # cd ../build || { echo "Run setup.sh before building images."; cd meta-starfive; break; };
  191. sed -n 10p ../meta-starfive/recipes-kernel/linux/files/nfs.patch;
  192. read -p "Kindly confirm boot argument such as nfs path and ip address before build (/meta-starfive/recipes-kernel/linux/files/nfs.patch). Proceed to build?[Y/n]:" RES;
  193. case $RES in
  194. [Yy])
  195. updatecfg ENABLE_NFS
  196. cur_ter=$(tty);
  197. output_min=$(MACHINE=starfive-dubhe bitbake qspi-nfs-image | tee $cur_ter);
  198. if [[ $output_min != *"ERROR"* ]]; then
  199. echo -e "\U0002705 ${GREEN}Build Complete${NC}"
  200. else echo -e "\U000274C ${RED}Build Failed${NC}"
  201. fi;;
  202. [Nn])
  203. return;;
  204. *)
  205. echo "Invalid option $RES , [Y/n] only.";
  206. esac;;
  207. "Quit")
  208. break;;
  209. *)
  210. echo "Invalid option $REPLY. Kindly select choice between menu range."
  211. esac
  212. REPLY=
  213. done