#!/bin/bash # Description: This shell script used to build linux system SDK. You can # use command line argument to specify build target, or select # it by hand if no argument given by command line. More detail # information can refer to the help message. # # Author: guowenxue # Version: 1.0.0 PROJ_PATH=`pwd` PACK_PATH=${PROJ_PATH}/tarballs PATCH_PATH=${PROJ_PATH}/patches PATCH_SUFIX=ok335x.patch LINUX_SRC=linux-3.2.0 UBOOT_SRC=u-boot-2011.09 ROOTFS_SRC=rootfs ROOTFS_IMG=ubifs.img TFTP_PATH=/tftp IMGS_PATH=images target= set -e function show_help() { printf "Usage: $1 [system/u-boot/kernel/rootfs/clean]\n\n" echo "system: build all source code " echo "u-boot: just build u-boot " echo "kernel: just build linux kernel " echo "rootfs: just build rootfs images" printf "clean : clean the source code\n\n" exit 0; } function show_banner() { echo "+---------------------------------------------+" printf "$1\n" echo "+---------------------------------------------+" } function select_target() { targets=("" "system" "u-boot" "kernel" "rootfs" "clean") echo "Please select a build target:" echo "1 , build all source code " echo "2 , just build u-boot " echo "3 , just build linux kernel " echo "4 , just build rootfs image" echo "5 , clean the source code" echo "" stty erase '^H' read -p "Enter your choise [1-5] : " choice if [ $choice -gt 5 ] ; then echo "ERROR: Invalid input choice, exit now..." exit 1; fi target=${targets[$choice]} } function build_uboot() { if [ ! -d ${UBOOT_SRC} ] ; then tar -xJf ${PACK_PATH}/${UBOOT_SRC}.tar.xz cd ${UBOOT_SRC} patch -p1 < ${PATCH_PATH}/${UBOOT_SRC}-${PATCH_SUFIX} else cd ${UBOOT_SRC} fi show_banner "| start uboot build task... |" chmod a+x build.sh bash build.sh show_banner "| uboot build task over! |" cd - } function build_kernel() { if [ ! -d ${ROOTFS_SRC} ] ; then echo "WARNNING: decompress rootfs need input sudo passwd here: " sudo tar -xJf ${PACK_PATH}/${ROOTFS_SRC}.tar.xz fi if [ ! -d ${LINUX_SRC} ] ; then tar -xJf ${PACK_PATH}/${LINUX_SRC}.tar.xz cd ${LINUX_SRC} patch -p1 < ${PATCH_PATH}/${LINUX_SRC}-${PATCH_SUFIX} else cd ${LINUX_SRC} fi show_banner "| start kernel build task... |" chmod a+x build.sh bash build.sh show_banner "| kernel build task over! |" cd - } function build_ubifs() { mkfs.ubifs –F -q -r ${ROOTFS_SRC} -m 2048 -e 126976 -c 2047 -o ubi.img cat > ubinize.cfg <