From 03ec0b2509469ddff89911f7d442be02aea48d37 Mon Sep 17 00:00:00 2001 From: guowenxue <guowenxue@gmail.com> Date: Sun, 11 Aug 2019 18:04:38 +0800 Subject: [PATCH] update setup env shell script --- tools/setup_env.sh | 149 +++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 117 insertions(+), 32 deletions(-) diff --git a/tools/setup_env.sh b/tools/setup_env.sh index 2dfb91c..8e1df3f 100755 --- a/tools/setup_env.sh +++ b/tools/setup_env.sh @@ -1,49 +1,134 @@ +#!/bin/bash # This shell script used to setup ok335x build envrionment # # 1. U-boot, Linux kernel and root file system all compiled or generated by this crosstool. # 2. This crsootool is built in i386, running on x86-64 depends on lib32 # 3. Install mkimage and mkfs.ubifs tools -if [ `id -u` != 0 ] ; then +LYFTP_PUB=ftp://master.iot-yun.club/pub/ + +set -e + +function sudo_banner() +{ + if [ `id -u` != 0 ] ; then + echo "WARRNING: Follow linux command maybe need input sudo passwd here:" + echo "" + fi +} + +function msg_banner() +{ + echo "" + echo "+-----------------------------------------------------------------------" + echo "| $1 " + echo "+-----------------------------------------------------------------------" echo "" - echo "ERROR: This shell script must be excuted as root or by sudo" - echo "" - exit 1; -fi -CROSSTOOL_PATH=/opt/crosstool -CROSSTOOL_NAME=cortex-a7 +} -CROSSTOOL_VER=gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabi -CROSSTOOL_TAR=${CROSSTOOL_VER}.tar.xz -CROSSTOOL_DLADDR=ftp://master.iot-yun.club/pub/$CROSSTOOL_TAR +function prepare_instpath() +{ + if [ -w /apps -a -w /opt ] ; then + return ; + fi -echo "apt-get update ..." -apt-get update > /dev/null 2>&1 -apt-get install -y lib32z1 lib32ncurses5 + msg_banner "/apps and /opt not writable, use chmod to give writable permissions" -mkimage -V > /dev/null 2>&1 -if [ $? != 0 ] ; then - apt-get install -y u-boot-tools -fi + sudo_banner -mkfs.ubifs -V > /dev/null 2>&1 -if [ $? != 0 ] ; then - apt-get install -y mtd-utils -fi + #QT build will installed to this path + sudo mkdir -p /apps && sudo chmod 777 /apps -if [ ! -d ${CROSSTOOL_PATH}/${CROSSTOOL_NAME} ] ; then - mkdir -p ${CROSSTOOL_PATH} + #crosstool will installed to this path + sudo chmod 777 /opt/ +} - if [ ! -f $CROSSTOOL_TAR ] ; then - wget -c $CROSSTOOL_DLADDR - fi +function install_systools() +{ + mkimage -V > /dev/null 2>&1 + if [ $? == 0 ] ; then + return 0; + fi - tar -xJf ${CROSSTOOL_TAR} -C ${CROSSTOOL_PATH} - mv ${CROSSTOOL_PATH}/${CROSSTOOL_VER}/ ${CROSSTOOL_PATH}/${CROSSTOOL_NAME} - -fi + systools="gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath socat \ + libsdl1.2-dev xterm sed cvs subversion coreutils texi2html docbook-utils python-pysqlite2 \ + help2man make gcc g++ desktop-file-utils libgl1-mesa-dev libglu1-mesa-dev mercurial autoconf \ + automake groff curl lzop asciidoc lib32z1 lib32ncurses5" + + devtools="u-boot-tools mtd-utils " + + msg_banner "start apt-get install system devlopment tools(commands)" + + sudo_banner + + sudo apt-get update > /dev/null 2>&1 + sudo apt-get install -y $systools $devtools +} + +function install_crosstool() +{ + CROSSTOOL_PATH=/opt/crosstool + CROSSTOOL_NAME=cortex-a7 + + CROSSTOOL_VER=gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabi + CROSSTOOL_TAR=${CROSSTOOL_VER}.tar.xz + CROSSTOOL_DLADDR=${LYFTP_PUB}/$CROSSTOOL_TAR + + if [ -d ${CROSSTOOL_PATH}/${CROSSTOOL_NAME} ] ; then + msg_banner "$CROSSTOOL_VER already installed to $CROSSTOOL_PATH/$CROSSTOOL_NAME" + return 0; + fi -# QT build will install to this path -mkdir -p /apps && chmod 777 /apps + mkdir -p ${CROSSTOOL_PATH} + + if [ ! -f $CROSSTOOL_TAR ] ; then + msg_banner "download $CROSSTOOL_VER now..." + wget -c $CROSSTOOL_DLADDR + fi + + msg_banner "install $CROSSTOOL_VER to $CROSSTOOL_PATH/$CROSSTOOL_NAME now..." + tar -xJf ${CROSSTOOL_TAR} -C ${CROSSTOOL_PATH} + mv ${CROSSTOOL_PATH}/${CROSSTOOL_VER}/ ${CROSSTOOL_PATH}/${CROSSTOOL_NAME} +} + +function install_buildroot() +{ + BUILDROOT_PATH=/opt/buildroot + BUILDROOT_NAME=cortex-a5 + + BUILDROOT_VER=buildroot-2019.02-gcc7.4.0-cortexA5-x86_64_arm-linux-gnueabihf + BUILDROOT_TAR=${BUILDROOT_VER}.tar.xz + BUILDROOT_DLADDR=${LYFTP_PUB}/$BUILDROOT_TAR + + if [ -d ${BUILDROOT_PATH}/${BUILDROOT_NAME} ] ; then + LDROOTmsg_banner "$BUILDROOT_VER already installed to $BUILDROOT_PATH/$BUILDROOT_NAME" + return 0; + fi + + + mkdir -p ${BUILDROOT_PATH} + + if [ ! -f $BUILDROOT_TAR ] ; then + msg_banner "download $BUILDROOT_VER now..." + wget -c $BUILDROOT_DLADDR + fi + + msg_banner "install $BUILDROOT_VER to $BUILDROOT_PATH/$BUILDROOT_NAME now..." + tar -xJf ${BUILDROOT_TAR} -C ${BUILDROOT_PATH} -C ${BUILDROOT_PATH} +} + + +prepare_instpath + +install_systools + +#install_crosstool + +install_buildroot + +exit; + + + -- Gitblit v1.9.1