summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYongqin Liu <yongqin.liu@linaro.org>2013-09-01 14:32:07 +0800
committerYongqin Liu <yongqin.liu@linaro.org>2013-10-02 00:23:53 +0800
commitca8d312873e8ed697f41b4910f6691587131d22c (patch)
tree43a386950d118df0d85e3e73a434653d0f49b23d
parentf7ff2b0b89e159eacddd5a2e2068d2cbf27ede37 (diff)
downloadlinaro-android-tools-ca8d312873e8ed697f41b4910f6691587131d22c.tar.gz
build.sh and deploy-panda.sh: add scripts for build and deploy panda images
buils.sh: make the build of linaro images simply, do not need to set the related environment variables manually, and can be used anytime after the source downloaded deploy-panda.sh: make the deployment of panda images only need one command, do not need to remember the installation of binaries particularly Change-Id: I00f82696deb0c11da4718f1b44fc4a830d6dbbbe Signed-off-by: Yongqin Liu <yongqin.liu@linaro.org>
-rwxr-xr-xbuild.sh249
-rwxr-xr-xdeploy-panda.sh84
-rw-r--r--envsetup/common.sh9
3 files changed, 342 insertions, 0 deletions
diff --git a/build.sh b/build.sh
new file mode 100755
index 0000000..8f204bd
--- /dev/null
+++ b/build.sh
@@ -0,0 +1,249 @@
+#!/bin/bash
+
+CUR_PWD=`pwd`
+link_src=$(readlink $0)
+if [ -z "${link_src}" ]; then
+ PARENT=$(cd $(dirname $0); pwd)
+else
+ PARENT=$(cd $(dirname ${link_src}); pwd)
+fi
+DEFAULT_BUILD_TARGET="boottarball systemtarball userdatatarball"
+BUILD_DEP=false
+CLEAN=false
+
+function func_init(){
+ PKGS='zip curl flex bison build-essential git-core gnupg gperf zlib1g-dev libx11-dev x11proto-core-dev gcc-multilib g++-multilib libc6-dev-i386 ia32-libs lib32z-dev uboot-mkimage uuid-dev openjdk-6-jdk ant lib32ncurses5-dev automake texinfo'
+ sudo apt-get install $PKGS
+ if [ $? -ne 0 ]; then
+ echo "Failed to install necessary packages"
+ exit 1
+ fi
+ #following seems not work correctly
+ MISSING=`dpkg-query -W -f='${Status}\n' ${PKGS} 2>&1 | grep 'No packages found matching' | cut -d' ' -f5`
+ if [ -n "$MISSING" ] ; then
+ echo "Missing required packages:"
+ for m in $MISSING ; do
+ echo -n "${m%?} "
+ done
+ echo
+ exit 1
+ fi
+}
+
+function func_export(){
+ cd ${TOP}
+ # android common environment
+ source build/envsetup.sh
+
+ # linaro common environment
+ local file_env_common="${PARENT}/envsetup/common.sh"
+ if [ -f "${file_env_common}" ];then
+ source ${file_env_common}
+ fi
+ # board specific environment
+ local file_env_board="${PARENT}/envsetup/${TARGET_PRODUCT}.sh"
+ if [ -f "${file_env_board}" ];then
+ source ${file_env_board}
+ fi
+
+ # set the default value again, actually the same as defined in common.sh
+ # just in case there is no envsetup/common.sh
+ export INCLUDE_PERF=${INCLUDE_PERF:-0}
+ export TARGET_SIMULATOR=${TARGET_SIMULATOR:-false}
+ export TARGET_TOOLS_PREFIX=${TARGET_TOOLS_PREFIX:-prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.8-linaro/bin/arm-linux-androideabi-}
+ export BUILD_FS_IMAGE=${BUILD_FS_IMAGE:-0}
+ export BUILD_TINY_ANDROID=${BUILD_TINY_ANDROID:-}
+
+ export TARGET_PRODUCT=${TARGET_PRODUCT:-pandaboard}
+ export TARGET_CPU_VARIANT=${TARGET_CPU_VARIANT:-cortex-a9}
+ export LINARO_BUILD_SPEC=${LINARO_BUILD_SPEC:-panda-jb-gcc47-tilt-stable-blob}
+}
+
+function func_sync(){
+ cd ${TOP}
+ # download the repo tool for android
+ curl "http://android.git.linaro.org/gitweb?p=tools/repo.git;a=blob_plain;f=repo;hb=refs/heads/stable" > repo
+ chmod +x repo
+ while ! ./repo sync; do
+ sleep 5
+ done
+}
+
+function func_build(){
+ cd ${TOP}
+ local cpus=`grep -c processor /proc/cpuinfo`
+ local build_tgts=${build_tgts:-${DEFAULT_BUILD_TARGET}}
+ local normal_tgts=""
+ local dir_tgts=""
+ for target in ${build_tgts}; do
+ if [ -d "${target}" ]; then
+ dir_tgts="${dir_tgts} ${target}"
+ else
+ normal_tgts="${normal_tgts} ${target}"
+ fi
+ done
+ func_export
+ if ${CLEAN}; then
+ if [ -n "${TARGET_PRODUCT}" ]; then
+ rm -fr out/target/product/${TARGET_PRODUCT}
+ else
+ rm -fr out
+ fi
+ fi
+ normal_tgts=$(echo "${normal_tgts}"|sed 's/^ \+//g'|sed 's/ \+$//g')
+ dir_tgts=$(echo "${dir_tgts}"|sed 's/^ \+//g'|sed 's/ \+$//g')
+ if [ -n "${normal_tgts}" ]; then
+ make -j${cpus} -l2.5 ${normal_tgts} showcommands 2>&1 |tee build-${TARGET_PRODUCT}.log
+ fi
+ if [ -n "${dir_tgts}" ]; then
+ if ${BUILD_DEP}; then
+ mmma ${dir_tgts} showcommands 2>&1 |tee build-${TARGET_PRODUCT}.log
+ else
+ mmm ${dir_tgts} showcommands 2>&1 |tee build-${TARGET_PRODUCT}.log
+ fi
+ fi
+}
+
+function getTop(){
+ parent_dir=$1
+ if [ -z "${parent_dir}" ] || [ "X${parent_dir}" == "X/" ]; then
+ return
+ fi
+ if [ -f "${parent_dir}/build/envsetup.sh" ]; then
+ echo "${parent_dir}"
+ return
+ fi
+ new_parent=$(cd $(dirname ${parent_dir}); pwd)
+ getTop "${new_parent}"
+}
+
+function show_usage(){
+ echo "Usage:"
+ echo -e "\t`basename $0`"
+ echo -e "\t\t help"
+ echo -e "\t\t\t print the help message"
+ echo -e "\t\t build [--product|-p <PRODUCT>] [--clean|-c] [--dependency|-d] [<module>]"
+ echo -e "\t\t\t build for the specified product"
+ echo -e "\t\t\t will use the product defined in ${TOP}/.product.default as default which is recorded last time"
+ echo -e "\t\t\t if module is not specified, then will build the default \"${DEFAULT_BUILD_TARGET}\""
+ echo -e "\t\t sync"
+ echo -e "\t\t\t do repo sync until it run successfully"
+ echo -e "\t\t init"
+ echo -e "\t\t\t install required packages for build"
+ echo -e "\t source $0 [-p|--product <PRODUCT>]"
+ echo -e "\t\t\t export the necessary enviroment variables for building product"
+ echo -e "\t\t\t will use the product defined in ${TOP}/.product.default as default which is recorded last time"
+}
+
+function parse_argv() {
+ if [ "X${sub_cmd}" != "Xsource" ]; then
+ sub_cmd=$1 && shift
+ if [ -z "${sub_cmd}" ]; then
+ echo "Please specify the sub command you want to do"
+ show_usage
+ exit 1
+ fi
+ fi
+ if [ "X${sub_cmd}" == "Xhelp" ]; then
+ show_usage
+ exit 0
+ fi
+ while test -n "$1"; do
+ case "$1" in
+ --product|-p)
+ tgt_product=$2
+ shift 2
+ ;;
+ --clean|-c)
+ CLEAN=true
+ shift
+ ;;
+ --dependency|-d)
+ BUILD_DEP=true
+ shift
+ ;;
+ *)
+ build_tgts="${build_tgts} $1"
+ shift
+ ;;
+ esac
+ done
+}
+
+function check_parameters(){
+ if [ -z "${sub_cmd}" ]; then
+ echo "Please specify the sub command for what you want to do"
+ show_usage
+ exit 1
+ fi
+ check_subcommand
+}
+
+function check_subcommand(){
+ valid_sub_cmds="help init sync build source"
+ for valid_cmd in ${valid_sub_cmds}; do
+ if [ "X${sub_cmd}" == "X${valid_cmd}" ]; then
+ return
+ fi
+ done
+
+ echo "The specified sub command($sub_cmd) is not supported."
+ show_usage
+ exit 1
+}
+
+function main(){
+ #type_path=i$(type -p $0)
+ if [ "X${BASH_SOURCE}" != "X${0}" ]; then
+ #this script is run via the souce command
+ sub_cmd="source"
+ fi
+
+ parse_argv "$@"
+ check_parameters
+ # install necessary package for builds the android source
+ if [ "X${sub_cmd}" == "Xinit" ];then
+ func_init
+ exit
+ fi
+
+ TOP=$(getTop ${PARENT})
+ if [ -z "${TOP}" ]; then
+ echo "Failed to find the android root directory, please make to put this script under the root directory of the android source"
+ exit 1
+ fi
+ # All the operations will be run under the root directory of android source
+ cd $TOP
+
+ # sycn the android source
+ if [ "X${sub_cmd}" == "Xsync" ];then
+ func_sync
+ exit
+ fi
+
+ # Check the target product name as build and source need
+ local product_file="${TOP}/.product.default"
+ if [ -n "${tgt_product}" ]; then
+ TARGET_PRODUCT="${tgt_product}"
+ echo "TARGET_PRODUCT=\"${tgt_product}\"" > "${product_file}"
+ elif [ -f "${TOP}/.product.default" ]; then
+ source "${TOP}/.product.default"
+ fi
+ if [ -z "${TARGET_PRODUCT}" ];then
+ echo "Please specify the tartget product name"
+ exit 1
+ fi
+
+ # export the environment variables as source
+ if [ "X${sub_cmd}" == "Xsource" ];then
+ func_export
+ fi
+
+ # build the modules or images for the specified target product
+ if [ "X${sub_cmd}" == "Xbuild" ];then
+ func_build
+ exit
+ fi
+}
+
+main "$@"
diff --git a/deploy-panda.sh b/deploy-panda.sh
new file mode 100755
index 0000000..58d1c69
--- /dev/null
+++ b/deploy-panda.sh
@@ -0,0 +1,84 @@
+#!/bin/bash
+
+parent=$(cd $(dirname $0);pwd)
+function create_media(){
+ which linaro-android-media-create &>/dev/null
+ if [ $? -ne 0 ]; then
+ sudo add-apt-repository ppa:linaro-maintainers/tools
+ sudo apt-get update
+ sudo apt-get install linaro-image-tools
+ fi
+ linaro-android-media-create \
+ --mmc $device \
+ --dev panda \
+ --boot $product_dir/boot.tar.bz2 \
+ --system $product_dir/system.tar.bz2 \
+ --userdata $product_dir/userdata.tar.bz2 \
+ --extra-boot-args "fixrtc earlyprintk"
+ if [ $? -ne 0 ]; then
+ echo "Failed to run linaro-android-media-create"
+ exit 1
+ fi
+}
+
+function install_binaries(){
+ script_name="install-binaries-4.0.4.sh"
+ script_path="${parent}/${script_name}"
+ if [ ! -f "${script_path}" ]; then
+ wget http://people.linaro.org/~vishalbhoj/${script_name} -O ${script_path}
+ chmod a+x ${script_path}
+ fi
+ ${script_path}
+ if [ $? -ne 0 ]; then
+ echo "Failed to install the binaries"
+ exit 1
+ fi
+}
+
+function show_usage(){
+ echo "Usage:"
+ echo -e "\t`basename $0` --device|-d <device> <images_dir>"
+ echo -e "\t\t device: the sdcard path on you system, something like /dev/sdb or /dev/mmcblk0"
+ echo -e "\t\t images_dir: the directory path where image files like boot.tar.bz2 system.tar.bz2 userdata.tar.bz2 are located"
+}
+
+function parse_argv() {
+ while test -n "$1"; do
+ case "$1" in
+ --device|-d)
+ device=$2
+ shift 2
+ ;;
+ *)
+ if [ -z "${images_dir}" ]; then
+ images_dir=$1
+ shift
+ else
+ show_usage
+ exit 1
+ fi
+ ;;
+ esac
+ done
+}
+
+function check_args(){
+ if [ -z "${device}" ]; then
+ echo "Please specify the device path to create"
+ exit 1
+ fi
+ if [ -z "${images_dir}" ]; then
+ echo "Please specify the directory path where image files are saved"
+ exit 1
+ fi
+}
+
+function main(){
+ parse_argv "$@"
+ check_args
+ product_dir="$images_dir/"
+ create_media
+ install_binaries
+}
+
+main "$@"
diff --git a/envsetup/common.sh b/envsetup/common.sh
new file mode 100644
index 0000000..2f48787
--- /dev/null
+++ b/envsetup/common.sh
@@ -0,0 +1,9 @@
+export INCLUDE_PERF=${INCLUDE_PERF:-0}
+export TARGET_SIMULATOR=${TARGET_SIMULATOR:-false}
+export TARGET_TOOLS_PREFIX=${TARGET_TOOLS_PREFIX:-prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.8-linaro/bin/arm-linux-androideabi-}
+export BUILD_FS_IMAGE=${BUILD_FS_IMAGE:-0}
+export BUILD_TINY_ANDROID=${BUILD_TINY_ANDROID:-}
+
+export TARGET_PRODUCT=${TARGET_PRODUCT:-pandaboard}
+export TARGET_CPU_VARIANT=${TARGET_CPU_VARIANT:-cortex-a9}
+export LINARO_BUILD_SPEC=${LINARO_BUILD_SPEC:-panda-jb-gcc47-tilt-stable-blob}