echo on
for /f "tokens=1,2 delims==" %%i in (AutoBuildConfig.ini) do (
if "%%i"=="WinRAR_Path" set WinRARPath=%%j
if "%%i"=="Shell_path" set ShellPath=%%j
if "%%i"=="SUSE10_IP" set vSUSE10_IP=%%j
if "%%i"=="SUSE10_USER" set vSUSE10_USER=%%j
if "%%i"=="SUSE10_PASSWD" set vSUSE10_PASSWD=%%j
if "%%i"=="SUSE11_IP" set vSUSE11_IP=%%j
if "%%i"=="SUSE11_USER" set vSUSE11_USER=%%j
if "%%i"=="SUSE11_PASSWD" set vSUSE11_PASSWD=%%j
)
for /f "tokens=1,2 delims==" %%i in (BuildConfig.ini) do (
if "%%i"=="version" set vVersion=%%j
)
@rem 获得当前脚本自身所在的目录
set vSelfPath=%~dp0
@rem 第一步 打包源码
chdir %vSelfPath%
call :package_sourcecode
@rem 第二步 上传源码suse下编译suse版本
chdir %vSelfPath%
::rd /S /Q Release
::mkdir Release
@rem 如果IP为空,则说明参数输入错误
if not "s%vSUSE10_IP%"=="s" (
set SoftWare=HUAWEI USSD %vVersion%_SuSE10_Install.tar.gz
call :upload_package %vSUSE10_IP% %vSUSE10_USER% %vSUSE10_PASSWD% ssh
)
@rem 如果IP为空,则说明参数输入错误
if not "s%vSUSE11_IP%"=="s" (
set SoftWare=HUAWEI USSD %vVersion%_SuSE11_Install.tar.gz
call :upload_package %vSUSE11_IP% %vSUSE11_USER% %vSUSE11_PASSWD% ssh
)
@rem 第三步 编译tool
::chdir %vSelfPath%
::call support.bat
::copy %vSelfPath%\Release\*.zip %vSelfPath%\Release
::copy %vSelfPath%\Release\*.zip.md5 %vSelfPath%\Release
exit
@rem 打包源码
:package_sourcecode
chdir ../
rd /S /Q temp
mkdir temp
mkdir temp\sourcecode
xcopy .\commonlib .\temp\sourcecode\commonlib /e /i /y /v
xcopy .\commonfiles .\temp\sourcecode\commonfiles /e /i /y /v
xcopy .\make .\temp\sourcecode\make /e /i /y /v
xcopy .\ussddbg .\temp\sourcecode\ussddbg /e /i /y /v
xcopy .\ussdgateway .\temp\sourcecode\ussdgateway /e /i /y /v
xcopy .\ussdlicproxy .\temp\sourcecode\ussdlicproxy /e /i /y /v
xcopy .\ussdproxy .\temp\sourcecode\ussdproxy /e /i /y /v
xcopy .\ussdserver .\temp\sourcecode\ussdserver /e /i /y /v
xcopy .\mtiserver .\temp\sourcecode\mtiserver /e /i /y /v
xcopy .\filemirror .\temp\sourcecode\filemirror /e /i /y /v
xcopy .\clustermng .\temp\sourcecode\clustermng /e /i /y /v
xcopy .\gentdefdatatool .\temp\sourcecode\gentdefdatatool /e /i /y /v
xcopy ..\package_suse10 .\temp\package_suse10 /e /i /y /v
xcopy ..\package_suse11 .\temp\package_suse11 /e /i /y /v
for /r . %%a in (temp) do @if exist "%%a\.svn" rd /s /q "%%a\.svn"
del /Q "sourcecode.zip"
chdir temp
"%WinRARPath%" a -r -ibck -x*\.svn -x*\.svn\* -x*.ncb -x*.bat -x*.exe -x*.vbs -x*.sln -x*.vcproj "..\sourcecode.zip" ".\sourcecode\*" ".\package_suse10\*" ".\package_suse11\*"
chdir ../
goto:EOF
@rem 上传源码到服务器上进行编译 下载生成的软件包
:upload_package sIP sUSER sPASSWORD sPROTOCOL
chdir ../
del /Q "%SoftWare%"
@rem 清空目录
del /Q "tmp_cmd.txt"
echo rm -rf *>tmp_cmd.txt
echo exit>>tmp_cmd.txt
"%ShellPath%" -%4 %1 -l %2 -pw %3 -m tmp_cmd.txt
del /Q "tmp_cmd.txt"
@rem 上传源码
echo open %1>ftp.txt
echo %2>>ftp.txt
echo %3>>ftp.txt
echo bin>>ftp.txt
echo put sourcecode.zip>>ftp.txt
echo bye>>ftp.txt
ftp -s:ftp.txt
del ftp.txt
@rem 执行编译
del tmp_cmd.txt
echo unzip -qo sourcecode.zip>tmp_cmd.txt
echo cd sourcecode/make>>tmp_cmd.txt
echo dos2unix ussd_csh.sh>>tmp_cmd.txt
echo chmod +x ussd_csh.sh>>tmp_cmd.txt
echo ./ussd_csh.sh>>tmp_cmd.txt
"%ShellPath%" -%4 %1 -l %2 -pw %3 -m tmp_cmd.txt
del tmp_cmd.txt
@rem 下载软件包
echo open %1>ftp.txt
echo %2>>ftp.txt
echo %3>>ftp.txt
echo bin>>ftp.txt
echo cd>>ftp.txt
echo lcd %vSelfPath%>>ftp.txt
echo get "%SoftWare%">>ftp.txt
echo get "%SoftWare%.md5">>ftp.txt
echo bye>>ftp.txt
ftp -s:ftp.txt
del ftp.txt
goto:EOF