nuvoton980 使用脚本自动化编译打包固件版本包(十一)

#!/bin/sh
echo "Generate Release Package for IOT-SC spi-nand boot......"

cur_dir=$(pwd)
uboot_dir=$cur_dir/u-boot-2016.11
kernel_dir=$cur_dir/linux-4.4.y
rootfs_dir=$cur_dir/rootfs
rootfs_package_dir=$cur_dir/package
doc_dir=$cur_dir/design
yaffs2utils_dir=$cur_dir/yaffs2utils


rootfs_bin=$cur_dir/rootfs.yaffs2


uboot_svn_url="xxx/trunk/u-boot-2016.11"
kernel_svn_url="xxx/trunk/linux-4.4.y"
rootfs_package_svn_url="xxx/package"
doc_svn_url="xxx/doc/design"
yaffs2utils_svn_url="xxx/trunk/yaffs2utils"

# need to export CROSS_COMPILER:
command -v arm-nuvoton-linux-uclibcgnueabi-gcc  >/dev/null 2>&1 || { echo >&2 "I require arm-nuvoton-linux-uclibcgnueabi-gcc but it's not installed.  Aborting."; exit 1; }
#export PATH=/home/vmuer/tmp/nuc980bsp/buildroot/output/host/usr/bin:$PATH

# clean tmp dir
[ -d $uboot_dir ]               &&  echo "rm $uboot_dir"           &&  rm  $uboot_dir          -rf
[ -d $kernel_dir ]              &&  echo "rm $kernel_dir"          &&  rm $kernel_dir          -rf
[ -d $rootfs_dir ]              &&  echo "rm $rootfs_dir"          &&  rm $rootfs_dir          -rf
[ -d $doc_dir ]                 &&  echo "rm $doc_dir"             &&  rm $doc_dir             -rf
[ -d $yaffs2utils_dir ]         &&  echo "rm $yaffs2utils_dir"     &&  rm $yaffs2utils_dir     -rf
[ -d $rootfs_package_dir ]      &&  echo "rm $rootfs_package_dir"  &&  rm $rootfs_package_dir  -rf

[ -f $rootfs_bin ]              &&  echo "rm $rootfs_bin"          &&  rm $rootfs_bin

# check out relate code
[ ! -d $cur_dir/image ] && mkdir $cur_dir/image -p

echo "checkout $uboot_svn_url  source code"
svn co -q $uboot_svn_url  $uboot_dir

echo "checkout $kernel_svn_url  source code"
svn co -q $kernel_svn_url $kernel_dir

echo  "checkout $rootfs_package_svn_url code"
svn co -q $rootfs_package_svn_url  $rootfs_package_dir

echo  "checkout $doc_svn_url code"
svn co -q $doc_svn_url  $doc_dir

echo  "checkout $yaffs2utils_svn_url code"
svn co -q $yaffs2utils_svn_url  $yaffs2utils_dir


# compile uboot and kernel
echo "compile uboot"
cd $uboot_dir
make nuc980_eth2uart_defconfig
make
cp spl/u-boot-spl.bin  ../image/
cp u-boot.bin          ../image/
cd -

echo "compile kernel"
cd $kernel_dir
make nuc980_eth2uart_defconfig
make uImage
cd -

#exit 1
# generate rootfs
echo  "generate rootfs"
#mkdir  $rootfs_dir -p
tar zxf  $rootfs_package_dir/rootfs.tar.gz -C  ./

#exit 1
# generate uboot kernel rootfs svn info
uboot_svn_version=$(svn info $uboot_dir | grep "Last Changed Rev" | cut -d' ' -f 4)
echo "uboot version: $uboot_svn_version"

kernel_svn_version=$(svn info $kernel_dir | grep "Last Changed Rev" | cut -d' ' -f 4)
echo "kernel version: $kernel_svn_version"

rootfs_svn_version=$(svn info $rootfs_package_dir | grep "Last Changed Rev" | cut -d' ' -f 4)
echo "rootfs version: $rootfs_svn_version"
#exit 1

# geterate armbian_uXXX_kXXX_rXXX-X.X.X.zip for release
IOTX_VERSION_MAJOR="1"
IOTX_VERSION_MINOR="1"
dot="."

release_dir=iot-sc_u${uboot_svn_version}_k${kernel_svn_version}_r${rootfs_svn_version}-${IOTX_VERSION_MAJOR}${dot}${IOTX_VERSION_MINOR}${dot}${rootfs_svn_version}-spi-nand
mkdir $release_dir
mkdir $release_dir/Release -p

echo "generate iotx_version to  /etc/iotx_version"
echo "${IOTX_VERSION_MAJOR}${dot}${IOTX_VERSION_MINOR}${dot}${rootfs_svn_version}"
echo "${IOTX_VERSION_MAJOR}${dot}${IOTX_VERSION_MINOR}${dot}${rootfs_svn_version}"   >   ${rootfs_dir}/etc/iotx_version

echo "generate build info to /etc/iotx_bindbuild_info"
echo "uboot  version : $uboot_svn_version"     
echo "kernel version : $kernel_svn_version"    
echo "rootfs version : $rootfs_svn_version"  
echo "uboot    version : $uboot_svn_version"     >   ${rootfs_dir}/etc/iotx_bindbuild_info
echo "kernel   version : $kernel_svn_version"    >>  ${rootfs_dir}/etc/iotx_bindbuild_info
echo "rootfs   version : $rootfs_svn_version"    >>  ${rootfs_dir}/etc/iotx_bindbuild_info

cp  $cur_dir/image                           $release_dir/   -a
cp  $doc_dir/IOT-SC-Release-Notes.pdf $release_dir/Release/


echo  "generate rootfs.yaffs2"
#generate rootfs
./yaffs2utils/mkyaffs2 --inband-tags -p 2048 -s 64 rootfs rootfs.yaffs2 && cp rootfs.yaffs2 $release_dir/image/
cd ${cur_dir}


echo  "generate ${release_dir}.zip"
zip -r ${release_dir}.zip ${release_dir}

最终生成的目录内容:如下所示:

 

文件名称为:

 

其名称包含了uboot kernel rootfs 对应的svn版本信息,有利于版本追述。

posted @ 2020-04-09 13:25  嵌入式实操  阅读(563)  评论(0编辑  收藏  举报