#!/bin/bash
#"Usage:$0 image_dir [out_dir] or $0 or $0 Daily"
platform_name=`echo "$RL_PROJECT_NAME" | tr '[a-z]' '[A-Z]'`
platform=${platform_name%%-*}
project=`echo $RL_PROJECT_NAME | tr '[a-z]' '[A-Z]'`
ap_img_dir=`echo $FULL_PDT_NAME | tr '[a-z]' '[A-Z]'`
basemanifest=$(ls -l .repo/manifest.xml|awk -F'/' '{print $NF}')
month=`date +%m`
year=`date +%Y`
day=`date +%d`
modem_date=$year$month$day
for i in $@
do
if [ -d "$i" ];then
if [ $target_dir"yes" == "yes" ];then
target_dir==$i
else
out_dir=$i
fi
elif [ $i == "daily" -o $i == "Daily" ];then
build_daily="yes"
elif [ $i == "-p" ];then
un_upload_to_server="yes"
elif [ $i == "-c" ];then
build_pc_upgrade_emmc_version="yes"
elif [ $i == "-w" ];then
wcdma_maincode="yes"
elif [ $i == "-e" ];then
evdo_maincode="yes"
else
:
fi
done
function_before_day()
{
if [ $day -eq 1 ];then
let month=$month-1
Cal=`cal $month $year`
LastDay=`echo $Cal | awk '{print $NF}'`
day=$LastDay
else
let day=$day-1
fi
modem_date=$year$month$day
}
function_seek_modem_date()
{
while [[ $modem_date_un_exist == "" ]]
do
function_before_day
rsync -avz $USER@android-server:/data1/version_release/MSM/$platform/$modem_date/Maincode/* $out_dir/
if [ $? -eq 0 ];then
echo -e "\e[33mthe the modem_imgs is $modem_date \e[m"
month=`date +%m`
year=`date +%Y`
day=`date +%d`
modem_date=$year$month$day
break;
fi
done
}
function_before_ap_imgs()
{
RL_FACTORY=${RL_FACTORY_VERNO%_*}
function_before_day
ap_date=`date +%y`$month$day
RL_FACTORY_VERNO=$RL_FACTORY"_"$ap_date
echo "$RL_FACTORY_VERNO"
}
function_seek_ap_imgs()
{
while [[ $RL_FACTORY_VERNO_un_exist == "" ]]
do
function_before_ap_imgs
for i in $ap_imgs
do
rsync -avz $USER@android-server:/data1/version_release/MSM/$ap_img_dir/$RL_FACTORY_VERNO/$i $out_dir/
done
if [ -e $out_dir/system.2knand.img -o -e $out_dir/system.img.ext4 ];then
echo -e "\e[33mthe ap_imgs is $RL_FACTORY_VERNO \e[m"
month=`date +%m`
year=`date +%Y`
day=`date +%d`
modem_date=$year$month$day
break;
fi
done
}
write_qcn_for_msm()
{
if [ "$RL_BUILD_RELEASE" == "false" ];then
sed -i "1,/BACKUP/s/\(.*\)\(filename=.*\)\(label.*BACKUP.*\)/\1\ filename\=\"dummy.bin\" \3\n\1\2\3/" $out_dir/rawprogram0.xml
sed -i "1,/MODEM_ST1/s/\(.*\)\(filename=.*\)\(label.*MODEM_ST1.*\)/\1\ filename\=\"sdb10.bin\" \3\n\1\2\3/" $out_dir/rawprogram0.xml
sed -i "1,/MODEM_ST2/s/\(.*\)\(filename=.*\)\(label.*MODEM_ST2.*\)/\1\ filename\=\"sdb11.bin\" \3\n\1\2\3/" $out_dir/rawprogram0.xml
if [ "${qcn_dir}yes" != "yes" ];then
rsync -avz $USER@android-server:/data1/version_release/MSM/$qcn_dir/* $out_dir/
else
rsync -avz $USER@android-server:/data1/version_release/MSM/${platform}_qcn/* $out_dir/
fi
fi
}
function build_tcard_upgrade_8x25Q_emmc()
{
ap_imgs="emmc_appsboot.mbn emmc_appsboothd.mbn system.img boot.img userdata.img recovery.img splash.bin tag.xml"
modemimgs="qcsblhd_cfgdata.mbn qcsbl.mbn oemsblhd.mbn oemsbl.mbn fat.bin"
if [ "$build_daily" != "yes" ];then
echo "the target_dir is $target_dir"
if [ ! -e $target_dir/boot.img ];then
echo "You must ensure the target img have been produced"
exit
fi
for i in $ap_imgs
do
cp $target_dir/$i $out_dir/
done
else
#copy ap image from server
echo "the server ap image dir is:android-server:/data1/version_release/MSM/$ap_img_dir/`date +%Y%m%d`"
for i in $ap_imgs
do
rsync -avz $USER@android-server:/data1/version_release/MSM/$ap_img_dir/$RL_FACTORY_VERNO/$i $out_dir/
done
if [ ! -e $out_dir/system.img ];then
function_seek_ap_imgs
fi
fi
#here copy the script to the out_dir
cp -rf zprojects/8x25Q_emmc_factory_update/META-INF $out_dir/
cp -rf zprojects/8x25Q_emmc_factory_update/scripts $out_dir/
echo "the modem dir is:android-server:/data1/version_release/MSM/$platform/`date +%Y%m%d`/Maincode/"
if [ $modem_date"yes" == "yes" ];then
modem_date=`date +%Y%m%d`
fi
echo "Use the modem_daily_date is $modem_date"
for i in $modemimgs
do
rsync -avz $USER@android-server:/data1/version_release/MSM/$platform/$modem_date/Maincode/$i $out_dir/
done
result=$?
if [ $result -ne 0 ];then
function_seek_modem_date
fi
if [ ! -e $out_dir/fat.bin ];then
echo "the modem image is error,so exit"
exit
fi
cd $out_dir/
echo $out_dir
if [ -x ./scripts/build.sh ];then
./scripts/build.sh
else
echo "You Maybe in wrong place to execute $0,or do not sync with the server"
exit
fi
cd - >/dev/null
result=$?
if [ $result -eq 0 ];then
echo "Congratulations!!!The Tcard version of $RL_PROJECT_NAME is success in $out_dir"
else
echo "Error to make Tcard version!"
fi
if [ "${out_dir_bak}yes" != "yes" ];then
tcard_dir=`basename $out_dir_bak`
else
tcard_dir=`basename $out_dir`
fi
mkdir -p $out_dir/${tcard_dir}_"tcard_version"/factory_update
mv $out_dir/factory_update.zip $out_dir/${tcard_dir}_"tcard_version"/factory_update
if [ "$un_upload_to_server" != "yes" ];then
scp -r $out_dir/${tcard_dir}_"tcard_version" $USER@android-server:/data1/version_release/output_version/$ap_img_dir/
result=$?
if [ $result -ne 0 ];then
scp -r $out_dir/${tcard_dir}_"tcard_version" $USER@android-server:/data1/version_release/output_version/$platform/
result=$?
if [ $result -eq 0 ];then
echo "the Tcard Version $out_dir/${tcard_dir}_"tcard_version" has been successfully copied to android-server:/data1/version_release/output_version/$platform/
the target path:
\\\192.168.4.250\\version_release\output_version\\$platform\\${tcard_dir}_tcard_version"
else
echo "Copy Tcard Version error,you must first create the dir in the remote Server"
fi
else
echo "the Tcard Version $out_dir/${tcard_dir}_"tcard_version" has been successfully copied to $USER@android-server:/data1/version_release/output_version/$ap_img_dir/
the target path:
\\\192.168.4.250\\version_release\output_version\\$ap_img_dir\\${tcard_dir}_tcard_version"
fi
fi
}
function build_tcard_upgrade_emmc()
{
ap_imgs="emmc_appsboot.mbn emmc_appsboothd.mbn system.img.ext4 boot.img userdata.img.ext4 recovery.img splash.bin tag.xml"
modemimgs="qcsblhd_cfgdata.mbn qcsbl.mbn oemsblhd.mbn oemsbl.mbn fat.bin"
if [ "$build_daily" != "yes" ];then
echo "the target_dir is $target_dir"
if [ ! -e $target_dir/boot.img ];then
echo "You must ensure the target img have been produced"
exit
fi
for i in $ap_imgs
do
cp $target_dir/$i $out_dir/
done
else
#copy ap image from server
echo "the server ap image dir is:android-server:/data1/version_release/MSM/$ap_img_dir/`date +%Y%m%d`"
for i in $ap_imgs
do
rsync -avz $USER@android-server:/data1/version_release/MSM/$ap_img_dir/$RL_FACTORY_VERNO/$i $out_dir/
done
if [ ! -e $out_dir/system.img.ext4 ];then
function_seek_ap_imgs
fi
fi
#here copy the script to the out_dir
cp -rf zprojects/msm_emmc_factory_update/META-INF $out_dir/
cp -rf zprojects/msm_emmc_factory_update/scripts $out_dir/
echo "the modem dir is:android-server:/data1/version_release/MSM/$platform/`date +%Y%m%d`/Maincode/"
if [ $modem_date"yes" == "yes" ];then
modem_date=`date +%Y%m%d`
fi
echo "Use the modem_daily_date is $modem_date"
for i in $modemimgs
do
rsync -avz $USER@android-server:/data1/version_release/MSM/$platform/$modem_date/Maincode/$i $out_dir/
done
result=$?
if [ $result -ne 0 ];then
function_seek_modem_date
fi
if [ ! -e $out_dir/fat.bin ];then
echo "the modem image is error,so exit"
exit
fi
cd $out_dir/
echo $out_dir
if [ -x ./scripts/build.sh ];then
./scripts/build.sh
else
echo "You Maybe in wrong place to execute $0,or do not sync with the server"
exit
fi
cd - >/dev/null
result=$?
if [ $result -eq 0 ];then
echo "Congratulations!!!The Tcard version of $RL_PROJECT_NAME is success in $out_dir"
else
echo "Error to make Tcard version!"
fi
tcard_dir=`basename $out_dir`
mkdir -p $out_dir/${tcard_dir}_"tcard_version"/factory_update
mv $out_dir/factory_update.zip $out_dir/${tcard_dir}_"tcard_version"/factory_update
if [ "$un_upload_to_server" != "yes" ];then
scp -r $out_dir/${tcard_dir}_"tcard_version" $USER@android-server:/data1/version_release/output_version/$ap_img_dir/
result=$?
if [ $result -ne 0 ];then
scp -r $out_dir/${tcard_dir}_"tcard_version" $USER@android-server:/data1/version_release/output_version/$platform/
result=$?
if [ $result -eq 0 ];then
echo "the Tcard Version $out_dir/${tcard_dir}_"tcard_version" has been successfully copied to android-server:/data1/version_release/output_version/$platform/
the target path:
\\\192.168.4.250\\version_release\output_version\\$platform\\${tcard_dir}_tcard_version"
else
echo "Copy Tcard Version error,you must first create the dir in the remote Server"
fi
else
echo "the Tcard Version $out_dir/${tcard_dir}_"tcard_version" has been successfully copied to $USER@android-server:/data1/version_release/output_version/$ap_img_dir/
the target path:
\\\192.168.4.250\\version_release\output_version\\$ap_img_dir\\${tcard_dir}_tcard_version"
fi
fi
}
function build_tcard_upgrade_msm()
{
ap_imgs=" appsboot.mbn appsboothd.mbn system.2knand.img boot.2knand.img userdata.2knand.img persist.2knand.img recovery.2knand.img splash.bin tag.xml "
if [ "$build_daily" != "yes" ];then
echo "the target_dir is $target_dir"
for i in system.2knand.img boot.2knand.img userdata.2knand.img splash.bin appsboot.mbn recovery.2knand.img
do
if [ ! -e $target_dir/$i ];then
echo "You must ensure the $i have been produced"
exit
fi
done
for i in $ap_imgs
do
cp $target_dir/$i $out_dir/
done
else
#copy ap image from server
echo "the server ap image dir is:android-server:/data1/version_release/MSM/$ap_img_dir/`date +%Y%m%d`"
#rsync -avz $USER@android-server:/data1/version_release/MSM/$ap_img_dir/`date +%Y%m%d`/* $out_dir/
for i in $ap_imgs
do
rsync -avz $USER@android-server:/data1/version_release/MSM/$ap_img_dir/$RL_FACTORY_VERNO/$i $out_dir/
#scp -r $USER@android-server:/data1/version_release/MSM/$ap_img_dir/`date +%Y%m%d`/* $out_dir/
done
if [ ! -e $out_dir/system.2knand.img ];then
function_seek_ap_imgs
fi
fi
#here copy the script to the out_dir
cp -rf zprojects/msm_factory_update/android-info.txt $out_dir/
cp -rf zprojects/msm_factory_update/META-INF $out_dir/
cp -rf zprojects/msm_factory_update/scripts $out_dir/
echo "the modem dir is:android-server:/data1/version_release/MSM/$platform/`date +%Y%m%d`/Maincode/"
if [ $modem_date"yes" == "yes" ];then
modem_date=`date +%Y%m%d`
fi
echo "Use the modem_daily_date is $modem_date"
rsync -avz $USER@android-server:/data1/version_release/MSM/$platform/$modem_date/Maincode/* $out_dir/
#scp -r $USER@android-server:/data1/version_release/MSM/$platform/$modem_date/Maincode/* $out_dir/
result=$?
if [ $result -ne 0 ];then
function_seek_modem_date
fi
if [ ! -e $out_dir/amss.mbn ];then
echo "the modem image is error,so exit"
exit
fi
cd $out_dir/
if [ -x ./scripts/build.sh ];then
./scripts/build.sh
else
echo "You Maybe in wrong place to execute $0,or do not sync with the server"
exit
fi
cd - >/dev/null
result=$?
if [ $result -eq 0 ];then
echo "Congratulations!!!The Tcard version of $RL_PROJECT_NAME is success in $out_dir"
else
echo "Error to make Tcard version!"
fi
tcard_dir=`basename $out_dir`
mkdir -p $out_dir/${tcard_dir}_"tcard_version"/factory_update
mv $out_dir/factory_update.zip $out_dir/${tcard_dir}_"tcard_version"/factory_update
# echo -e '\e[33mdo you want copy tcard_version to android-server[y/n]?y \e[m'
# read ch
# echo "Your input is:$ch"
if [ "$un_upload_to_server" != "yes" ];then
#rsync -avz $out_dir/${tcard_dir}_"tcard_version" $USER@android-server:/data1/version_release/output_version/$ap_img_dir
scp -r $out_dir/${tcard_dir}_"tcard_version" $USER@android-server:/data1/version_release/output_version/$ap_img_dir/
result=$?
if [ $result -ne 0 ];then
#rsync -avz $out_dir/${tcard_dir}_"tcard_version" $USER@android-server:/data1/version_release/output_version/$platform
scp -r $out_dir/${tcard_dir}_"tcard_version" $USER@android-server:/data1/version_release/output_version/$platform/
result=$?
if [ $result -eq 0 ];then
echo "the Tcard Version $out_dir/${tcard_dir}_"tcard_version" has been successfully copied to android-server:/data1/version_release/output_version/$platform/
the target path:
\\\192.168.4.250\\version_release\output_version\\$platfor\\${tcard_dir}_tcard_version"
else
echo "Copy Tcard Version error,you must first create the dir in the remote Server"
fi
else
echo "the Tcard Version $out_dir/${tcard_dir}_"tcard_version" has been successfully copied to $USER@android-server:/data1/version_release/output_version/$ap_img_dir/"
echo " the target path:
\\\192.168.4.250\\version_release\output_version\\$ap_img_dir\\${tcard_dir}_tcard_version"
fi
fi
}
if [ $platform"yes" == "yes" ];then
echo "you must first set env by invoke . zprojects/envsetup.sh!"
exit
fi
if [ $project"yes" == "yes" ];then
echo "you must first set env by invoke . zprojects/envsetup.sh!"
exit
fi
if [ ! -e zprojects/msm_factory_update ];then
echo "You Maybe in wrong place to execute $0,or do not sync with the server"
exit
fi
if [ ${out_dir}"yes" == "yes" ];then
if [ $RL_FACTORY_VERNO"yes" == "yes" ];then
echo "You must invoke . zprojects/envsetup.sh first"
exit
fi
out_dir=$HOME/$RL_FACTORY_VERNO;
mkdir -p $out_dir
chmod 777 $out_dir
rm -rf $out_dir/*
echo "$out_dir"
else
rm -rf $out_dir/*
rm -rf $out_dir/appsboot.mbn $out_dir/appsboothd.mbn $out_dir/qcdlckie.mbn $out_dir/system.2knand.img $out_dir/boot.2knand.img $out_dir/userdata.2knand.img $out_dir/persist.2knand.img $out_dir/recovery.2knand.img $out_dir/splash.bin
rm -rf $out_dir/*.mbn $out_dir/*.tag $out_dir/*.hex $out_dir/*.img* $out_dir/*.qcn $out_dir/exist $out_dir/*.bin
rm -rf $out_dir/META-INF $out_dir/android-info.txt $out_dir/scripts
fi
echo "the output dir is $out_dir,`ls $out_dir`"
if [ ${target_dir}"yes" == "yes" ];then
target_dir=$ANDROID_PRODUCT_OUT
fi
accord_branch_select()
{
basemanifest=$(ls -l .repo/manifest.xml|awk -F'/' '{print $NF}')
if [ "${basemanifest##rl_msm8x25_1034.xml}" == "${basemanifest}" ];then
if [ "${basemanifest##rl_msm8x25q.xml}" == "${basemanifest}" ];then
build_tcard_upgrade_msm
else
select_wcdma_or_evdo_for_8x25Q
build_tcard_upgrade_8x25Q_emmc
fi
else
build_tcard_upgrade_emmc
if [ "$?" -eq "0" ];then
ap_imgs="emmc_appsboot.mbn emmc_appsboothd.mbn system.img.ext4 boot.img userdata.img.ext4 recovery.img splash.bin tag.xml *.unsparse rawprogram0.xml vmlinux obj/KERNEL_OBJ/vmlinux"
check_imgs="emmc_appsboot.mbn emmc_appsboothd.mbn system.img.ext4 boot.img userdata.img.ext4 recovery.img splash.bin"
build_pc_upgrade_emmc
fi
fi
}
accord_project_name_select()
{
pdt_name=$FULL_PDT_NAME
build_tcard_change=${pdt_name%-*}
if [ "$build_tcard_change" == "e771" -o "$build_tcard_change" == "e777" -o "$build_tcard_change" == "e775" ];then
build_tcard_upgrade_msm
elif [ "$build_tcard_change" == "e666" -o "$build_tcard_change" == "e333" -o "$build_tcard_change" == "e663" -o "$build_tcard_change" == "e756" -o "$build_tcard_change" == "e668" ];then
build_tcard_upgrade_emmc
if [ "$?" -eq "0" ];then
ap_imgs="emmc_appsboot.mbn emmc_appsboothd.mbn system.img.ext4 boot.img userdata.img.ext4 recovery.img splash.bin tag.xml *.unsparse rawprogram0.xml vmlinux obj/KERNEL_OBJ/vmlinux"
check_imgs="emmc_appsboot.mbn emmc_appsboothd.mbn system.img.ext4 boot.img userdata.img.ext4 recovery.img splash.bin"
build_pc_upgrade_emmc
fi
else
accord_branch_select
fi
}
build_pc_upgrade_emmc()
{
if [ "$build_daily" != "yes" ];then
for i in $check_imgs
do
if [ ! -e $target_dir/"$i" ];then
echo "You must ensure the $i have been produced"
exit
fi
done
echo "the target_dir is $target_dir"
for i in $ap_imgs
do
cp -u -v $target_dir/$i $out_dir/
done
else
#copy ap image from server
echo "the server ap image dir is:android-server:/data1/version_release/MSM/$ap_img_dir/`date +%Y%m%d`"
for i in $ap_imgs
do
rsync -avz $USER@android-server:/data1/version_release/MSM/$ap_img_dir/$RL_FACTORY_VERNO/$i $out_dir/
done
if [ ! -e $out_dir/boot.img ];then
function_seek_ap_imgs
fi
fi
write_qcn_for_msm
echo "the modem dir is:android-server:/data1/version_release/MSM/$platform/`date +%Y%m%d`/Maincode/"
if [ $modem_date"yes" == "yes" ];then
modem_date=`date +%Y%m%d`
fi
echo "Use the modem_daily_date is $modem_date"
rsync -vz --exclude=rawprog*.xml $USER@android-server:/data1/version_release/MSM/$platform/$modem_date/Maincode/* $out_dir/
result=$?
if [ $result -ne 0 ];then
function_seek_modem_date
fi
if [ ! -e $out_dir/fat.bin ];then
echo "the modem image is error,so exit"
exit
fi
for i in $out_dir/*
do
if [ -d "$i" ];then
rm "$i" -rf
fi
done
if [ "${out_dir_bak}yes" != "yes" ];then
rm $out_dir_bak -rf
mv $out_dir $out_dir_bak
scp -r $out_dir_bak $USER@android-server:/data1/version_release/output_version/$ap_img_dir/
else
scp -r $out_dir $USER@android-server:/data1/version_release/output_version/$ap_img_dir/
fi
# if [ "$basemanifest" == "rl_msm8x25q.xml" ];then
# ssh $USER@android-server "cd /data1/version_release/output_version/$ap_img_dir/ ;rm $RL_FACTORY_VERNO_bak -rf; mv $RL_FACTORY_VERNO $RL_FACTORY_VERNO_bak"
# fi
echo "
the pc_upgrade_version path:
\\\192.168.4.250\\version_release\output_version\\$ap_img_dir
"
}
select_wcdma_or_evdo_for_8x25Q()
{
if [ "$basemanifest" == "rl_msm8x25q.xml" ];then
if [ "$wcdma_maincode" == "yes" ];then
platform=${platform}_W
out_dir_bak=${out_dir/_BT_/_WCDMA_BT_}
qcn_dir=${platform}_qcn
elif [ "$evdo_maincode" == "yes" ];then
platform=${platform}_E
out_dir_bak=${out_dir/_BT_/_EVDO_BT_}
qcn_dir=${platform}_qcn
else
echo "please add evdo(-e) or wcdma(-w) options!"
exit 1
fi
fi
}
if [ "$build_pc_upgrade_emmc_version" == "yes" ];then
if [ "$basemanifest" == "rl_msm8x25q.xml" ];then
ap_imgs="emmc_appsboot.mbn emmc_appsboothd.mbn system.img boot.img userdata.img recovery.img splash.bin tag.xml *.unsparse rawprogram0.xml vmlinux obj/KERNEL_OBJ/vmlinux"
check_imgs="emmc_appsboot.mbn emmc_appsboothd.mbn system.img boot.img userdata.img recovery.img splash.bin"
elif [ "$basemanifest" == "rl_msm8x25_1034.xml" ];then
ap_imgs="emmc_appsboot.mbn emmc_appsboothd.mbn system.img.ext4 boot.img userdata.img.ext4 recovery.img splash.bin tag.xml *.unsparse rawprogram0.xml vmlinux obj/KERNEL_OBJ/vmlinux"
check_imgs="emmc_appsboot.mbn emmc_appsboothd.mbn system.img.ext4 boot.img userdata.img.ext4 recovery.img splash.bin"
else
echo "error:please ensure branch correct!"
exit
fi
if [ "$platform" == "E688" ];then
select_wcdma_or_evdo_for_8x25Q
fi
build_pc_upgrade_emmc
exit
fi
if [ "$build_daily" == "yes" ];then
accord_project_name_select
else
accord_branch_select
fi