#!/bin/bash
#配置打包后会输出的路径
targetPath=~/Download/packages/
echo "****************************************"
echo "* Pack Language Packages. -- JustinYim *"
echo "****************************************"
echo "ouput path: ~/Download/packages/"
echo "Now Starting..."
if [ $# -lt 2 ];
then
echo "Oops, please append the Resources folder's path."
echo "And the version name like: pack xxx/xxx 1.1.2"
else
echo "Resources path: "$1
echo "Clening target path..."
rm -rf ~/Downloads/packages/*
echo "CPing files..."
#CP Files
cp -rf $1/*.lproj ~/Downloads/packages/
cd ~/Downloads/packages
#中文简体不进行更新,直接删掉
rm -rf zh_cn.lproj
#zip files
#新建一个配置文件
echo '[package]' > conf.conf
#设置包的起始值,因为之前已经有很多个包在服务器上了
num=7
#遍历所有文件
for filename in $(ls)
do
#不对配置文件进行压缩动作
if [ "$filename" = "conf.conf" ]
then
echo "Config file!"
continue
fi
#echo "ZIPing "$filename"..."
#替换掉版本号里面的.字符,如1.1.2改为1_1_2作为文件名用
ver=${2//./_}
#去掉文件名后缀,%表示从字符串尾部开始,找到.字符的时候,去掉后面的字符,如:ar.lproj会变成ar
#如果是 ${filename#.*} 则会变成从头部开始, ar.lproj会变成 lproj
lang=${filename%.*}
#设置zip文件的名字
zipname=x.strings.$lang.$ver.zip
#复制并压缩x.strings文件
cp $filename/x.strings x.strings.$lang
zip $zipname x.strings.$lang
#echo 'wirting config file...'
#自动编写配置文件
echo '[number'$num']' >> conf.conf
echo 'Id='$((++num)) >> conf.conf
echo 'PackPath=/xxx/package/'$zipname >> conf.conf
echo 'Name='$lang'|'$2 >> conf.conf
echo '' >> conf.conf
#clean files
#删掉临时文件
echo "Remove temp files..."
rm -rf $filename
rm x.strings.$lang
done
fi