#!/bin/sh #+-------------------------------------------------------------------------------------------- #|Description: This shell script used to download busybox source code and cross compile it. #| Author: GuoWenxue #| ChangeLog: #| 1, Initialize 1.0.0 on 2013.03.22 #+-------------------------------------------------------------------------------------------- PRJ_PATH=`pwd` ARCH=arm1176jzfs #APP_NAME="busybox-1.19.3" APP_NAME="busybox-1.20.2" PACK_SUFIX="tar.bz2" DL_ADDR="http://www.busybox.net/downloads/${APP_NAME}.${PACK_SUFIX}" INST_PATH= if [ -z "$ARCH" -a $# -gt 0 ] ; then ARCH=$1 fi INST_PATH=$PRJ_PATH/../../rootfs/rootfs_tree sup_arch=("" "arm920t" "arm926t" "arm1176jzfs") function select_arch() { echo "Current support ARCH: " i=1 len=${#sup_arch[*]} while [ $i -lt $len ]; do echo "$i: ${sup_arch[$i]}" let i++; done echo "Please select: " index= read index ARCH=${sup_arch[$index]} } function decompress_packet() ( echo "+---------------------------------------------+" echo "| Decompress $1 now" echo "+---------------------------------------------+" ftype=`file "$1"` case "$ftype" in "$1: Zip archive"*) unzip "$1" ;; "$1: gzip compressed"*) if [ 0 != `expr "$1" : ".*.tar.*" ` ] ; then tar -xzf $1 else gzip -d "$1" fi ;; "$1: bzip2 compressed"*) if [ 0 != `expr "$1" : ".*.tar.*" ` ] ; then tar -xjf $1 else bunzip2 "$1" fi ;; "$1: POSIX tar archive"*) tar -xf "$1" ;; *) echo "$1 is unknow compress format";; esac ) if [ -z "$CROSS" ] ; then if [ -z "$ARCH" ] ; then select_arch fi CROSS="/opt/buildroot-2012.08/${ARCH}/usr/bin/arm-linux-" fi # Download source code packet if [ ! -s $APP_NAME.$PACK_SUFIX ] ; then echo "+------------------------------------------------------------------+" echo "| Download $APP_NAME.$PACK_SUFIX now " echo "+------------------------------------------------------------------+" wget $DL_ADDR fi # Decompress source code packet if [ ! -d $APP_NAME ] ; then tar -xjf $APP_NAME.tar.* fi #Copy the configure file if [ ! -s .config ]; then cp patch/$APP_NAME.config $APP_NAME/.config fi if [ ! -s $APP_NAME/.config ]; then echo "+------------------------------------------------------------------+" echo "| ERROR: Miss default configure file" echo "+------------------------------------------------------------------+" exit -2 fi if [ -z $INST_PATH ] ; then INST_PATH=$PRJ_PATH/../$ARCH/mnt fi echo "+------------------------------------------------------------------+" echo "| Build $APP_NAME for $ARCH " echo "| Crosstool: $CROSS" echo "+------------------------------------------------------------------+" cd $APP_NAME #Modify the cross config in the configure file line=`sed -n '/CONFIG_CROSS_COMPILER_PREFIX/=' .config` sed -i -e ${line}s"|.*|CONFIG_CROSS_COMPILER_PREFIX=\"$CROSS\"|" .config #Modify the install path in the configure file line=`sed -n '/CONFIG_PREFIX=/=' .config` sed -i -e ${line}s"|.*|CONFIG_PREFIX=\"$INST_PATH\"|" .config #Fix strverscmp not define bug line=`sed -n '/^#define HAVE_STRVERSCMP/=' include/platform.h ` sed -i -e ${line}s"|.*|# undef HAVE_STRVERSCMP|" include/platform.h set -x make oldconfig make set +x #install busybox if [ -d $INST_PATH ] ; then sudo rm -rf $INST_PATH/bin/* sudo rm -rf $INST_PATH/sbin/* sudo make install fi file busybox cd -