shell脚本在企业中的使用案例(1)--一键式打包

#!/bin/sh
function result()
{
if [ $1 -eq 0 ]
then
echo " $2..............................................sucess"
else
echo " $2..............................................fail,please check carefully!"
exit
fi
}
rm -rf .img
rootfs_dir=../../../../system/linux_filesystem/trunk/rootfs
app_dst_dir=$rootfs_dir/bnt6000/bin/
if [ -d $rootfs_dir ] && [ -d $app_dst_dir ]
then
echo "roofs dir is:$rootfs_dir"
echo "app_dest_dir is:$app_dst_dir"
else
echo "app_dest_dir or rootfs_dir is not exist,so tar rootfs_dir now!."
cd ../../../../system/linux_filesystem/trunk/
tar xvf rootfs
.gz
result $? tar
cd -
fi

if [ -c $rootfs_dir/dev/console ] && [ -c $rootfs_dir/dev/null ]
then
echo "/dev/console and /dev/null already exsit"
else
echo $rootfs_dir/dev/console
echo $rootfs_dir/dev/null
cd $rootfsdir/dev
mknod -m 660 console c 5 1
result $? mknod
/dev/console
mknod -m 660 null c 1 3
result $? mknod_/dev/null
cd -
fi
#pack dir cfg
#pack_dir=./test
#pack_dir=/share/pack_image/bnt4000hd/release/trunk/
pack_dir=.

if [ -d $pack_dir ]; then
echo "pack dir is:$pack_dir"
else
echo 'pack dir is not exist, so exit.'
exit
fi

#src dir cfg
src_dir=..
bnt6000File=$src_dir/main/bnt6000
avFile=$src_dir/av/venc/av
maintainFile=$src_dir/av/core/app
if [ -f $bnt6000File ] && [ -f $avFile ] && [ -f $maintainFile ]
then
echo "bnt6000 av app file ,success"
else
echo "bnt6000 av app file may be not exist "
exit
fi
#packFile=$src_dir/av/upgrade/pack_app

os_dir=../../../../system/linux_filesystem/trunk
#ramdisk=$os_dir/hifs-ramdisk.gz
#target_name=$app_src_dir/release/bnt4000hd.ramfs;
#source_name=$os_dir/hifs-ramdisk
#target_app=$app_dir/$maintainFile $app_dir/$bnt6000File $app_dir/$avFile

#ramdisk=$os_dir/hifs-ramdisk.gz
target_name=bnt4000hd.ramfs
source_name=hifs-ramdisk
#cp file
###########new 20120605
cp -av $maintainFile $app_dstdir
result $? cp
$maintainFile
cp -av $avFile $app_dstdir
result $? cp
$avFile
cp -av $bnt6000File $app_dstdir
result $? cp
$bnt6000File
cp -av $src_dir/update/check_update $app_dst_dir
result $? cp_check_update

#cp -av $src_dir/av/bntcomm/libbnt_comm.so $rootfs_dir/lib/
#cp -av $src_dir/av/database/libav_database.so $rootfs_dir/lib/

cp -av $src_dir/etc/bnt6000.conf $rootfs_dir/bnt6000/init/
result $? cp_bnt6000.conf
cp -av $src_dir/etc/registinfo.conf $rootfs_dir/bnt6000/init/
result $? cp_registinfo.conf
cp -av $src_dir/etc/terid.conf $rootfs_dir/bnt6000/init/
result $? cp_terid.conf
cp -av $src_dir/etc/start.sh $rootfs_dir/bnt6000/init/
result $? cp_start.sh
cp -av $src_dir/format/fmtsd $rootfs_dir/usr/sbin/
result $? cp_fmtsd
chmod +x $rootfs_dir/bnt6000/init/start.sh

#cp -av $KERNEL_DIR/arch/arm/boot/uImage $app_src_dir/release/bnt4000hd.uImg
#cp -av $UBOOT_DIR/u-boot.bin $app_src_dir/release/
cp -av $maintainFile $packdir
result $? cp
$maintainFile
cp -av $avFile $packdir
result $? cp
$avFile
cp -av $bnt6000File $packdir
result $? cp
$bnt6000File

#cp -av $packFile $pack_dir

genext2fs -b 20480 -d $os_dir/rootfs -i 10240 $source_name
result $? genext2fs
gzip -vf9 $source_name
result $? gzip
mkimage -A arm -O linux -T ramdisk -C gzip -a 0xc11fffc0 -e 0xc1200000 -n "RAMDISK" -d $source_name.gz $target_name
#cp -av $target_name ~/share -rf
result $? mkimage
cp -av $target_name ../system_imgs -rf
result 0 making_filesystem

#pack............

#1. export--------------------------------------
#(1) stm32 ver
export stm32Version=STM32_V3.2.1.149
#export stm32Version=STM32_V5.0.2.SZ
ver_num=svn info https://10.86.2.6:10443/svn/Embedded/project/linux/bnt4000hd//src/trunk/base | grep "Last Changed Rev: " | sed -e "s/Last Changed Rev: //g"

#(2) app ver, run pack_app view
#export linuxVersion=v3.3.3.4750
export linuxVersion=v4.3.18.$ver_num
export ubootBin=u-boot.bin_20141226
if [ $# -eq 2 ];then
linuxVersion=$1.$ver_num
stm32Version=$2
fi

#2.build-----------------------------------------
#(1)(uboot + kernel + rootfs + stm32 + app)
#uboot: -u
#kernel: -k
#rootfs: rootfs
#output: -o
./pack_app -f ../system_imgs/bnt4000hd.ramfs -k ../system_imgs/bnt4000hd.uImg -u ../system_imgs/"$ubootBin" -a ./stm324000hd/"$stm32Version".bin -r app -b bnt6000 -v av -o bnt4000hd"$linuxVersion"_"$stm32Version"_full.img

#(2)app+stm32
./pack_app -a ./stm324000hd/"$stm32Version".bin -r app -b bnt6000 -v av -o bnt4000hd"$linuxVersion"_"$stm32Version"_app.img

#(3)app
./packapp -r app -b bnt6000 -v av -o bnt4000hd"$linuxVersion"_linux_app.img

#(4)web
#./pack_app -r webservice.tar.gz -o ym8000_webservice.img

转载于:https://blog.51cto.com/13375232/2056134

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值