Finish the packaging shell for windows.

This commit is contained in:
zicla 2019-05-03 03:45:14 +08:00
parent 2044aa1662
commit bda9339299
4 changed files with 90 additions and 87 deletions

1
.gitignore vendored
View File

@ -6,4 +6,5 @@ tmp
# build execute file # build execute file
tank tank
tank.exe

View File

@ -1,91 +1,74 @@
@if "%DEBUG%" == "" echo off @if "%DEBUG%" == "" ECHO off
@rem ########################################################################## @REM ##########################################################################
@rem @REM
@rem Tank build script for Windows @REM Tank build script for Windows
@rem @REM manual https://ss64.com/nt/
@rem ########################################################################## @REM
@REM ##########################################################################
@REM ==== START VALIDATION ==== @REM prepare the variables.
if "%GOPATH%"=="" (
echo The GOPATH environment variable is not defined correctly @REM version name
goto end SET VERSION_NAME=tank-3.0.0.beta1
@REM assign variable like Linux GOARCH=$(go env GOARCH) eg. amd64
FOR /f %%i IN ('go env GOARCH') DO SET GOARCH=%%i
ECHO GOARCH: %GOARCH%
@REM eg. D:\Group\Golang
FOR /f %%i IN ('go env GOPATH') DO SET GOPATH=%%i
ECHO GOPATH: %GOPATH%
@REM eg. windows
FOR /f %%i IN ('go env GOOS') DO SET GOOS=%%i
ECHO GOOS: %GOOS%
@REM service dir eg. D:\Group\eyeblue\tank\build\pack
SET PACK_DIR=%CD%
ECHO PACK_DIR: %PACK_DIR%
@REM build dir eg. D:\Group\eyeblue\tank\build
FOR %%F IN (%CD%) DO SET BUILD_DIR_SLASH=%%~dpF
SET BUILD_DIR=%BUILD_DIR_SLASH:~0,-1%
ECHO BUILD_DIR: %BUILD_DIR%
@REM project dir eg. D:\Group\eyeblue\tank
FOR %%F IN (%BUILD_DIR%) DO SET PROJECT_DIR_SLASH=%%~dpF
SET PROJECT_DIR=%PROJECT_DIR_SLASH:~0,-1%
ECHO PROJECT_DIR: %PROJECT_DIR%
@REM final zip file name. eg. tank-3.0.0.beta1.windows-amd64.zip
SET FILE_NAME=%VERSION_NAME%.%GOOS%-%GOARCH%.zip
ECHO FILE_NAME: %FILE_NAME%
@REM zip dist dir eg. D:\Group\eyeblue\tank\tmp\dist
SET DIST_DIR=%PROJECT_DIR%\tmp\dist
ECHO DIST_DIR: %DIST_DIR%
@REM component dir eg. D:\Group\eyeblue\tank\tmp\dist\tank-3.0.0.beta1
SET COMPONENT_DIR=%DIST_DIR%\%VERSION_NAME%
ECHO COMPONENT_DIR: %COMPONENT_DIR%
@REM final dist path eg. D:\Group\eyeblue\tank\tmp\dist\tank-3.0.0.beta1.windows-amd64.zip
SET DIST_PATH=%DIST_DIR%\%FILE_NAME%
ECHO DIST_PATH: %DIST_PATH%
cd %PROJECT_DIR%
ECHO go build -mod=readonly
go build -mod=readonly
IF EXIST %COMPONENT_DIR% (
rmdir /s/q %COMPONENT_DIR%
md %COMPONENT_DIR%
) ELSE (
md %COMPONENT_DIR%
) )
set PRE_DIR=%cd%
@rem version name ECHO copy .\tank.exe %COMPONENT_DIR%
set VERSION_NAME=tank-2.0.0 copy .\tank.exe %COMPONENT_DIR%
cd %GOPATH% ECHO %BUILD_DIR%\conf %COMPONENT_DIR%\conf /E/H/I
xcopy %BUILD_DIR%\conf %COMPONENT_DIR%\conf /E/H/I
@rem echo golang.org . Please download from: https://github.com/eyebluecn/golang.org and put in the directory with same level of github.com ECHO %BUILD_DIR%\html %COMPONENT_DIR%\html /E/H/I
@rem echo go get golang.org/x xcopy %BUILD_DIR%\html %COMPONENT_DIR%\html /E/H/I
@rem go get golang.org/x
echo git clone https://github.com/eyebluecn/golang.org.git %golangOrgFolder%
set golangOrgFolder=%GOPATH%\src\golang.org
if not exist %golangOrgFolder% (
git clone https://github.com/eyebluecn/golang.org.git %golangOrgFolder%
)
@rem resize image ECHO please zip to %DIST_PATH%
echo go get github.com/disintegration/imaging
go get github.com/disintegration/imaging
@rem json parser ECHO finish packaging!
echo go get github.com/json-iterator/go
go get github.com/json-iterator/go
@rem mysql
echo go get github.com/go-sql-driver/mysql
go get github.com/go-sql-driver/mysql
@rem dao database
echo go get github.com/jinzhu/gorm
go get github.com/jinzhu/gorm
@rem uuid
echo go get github.com/nu7hatch/gouuid
go get github.com/nu7hatch/gouuid
echo build tank ...
go install tank
echo packaging
set distFolder=%GOPATH%\src\tank\dist
if not exist %distFolder% (
md %distFolder%
)
set distPath=%distFolder%\%VERSION_NAME%
if exist %distPath% (
echo clear %distPath%
rmdir /s/q %distPath%
)
echo create directory %distPath%
md %distPath%
echo copying tank.exe
copy %GOPATH%\bin\tank.exe %distPath%
echo copying build
xcopy %GOPATH%\src\tank\build %distPath% /e/h
echo "remove pack"
rmdir /s/q %distPath%\pack
echo "remove service"
rmdir /s/q %distPath%\service
echo "remove doc"
rmdir /s/q %distPath%\doc
cd %PRE_DIR%
echo check the dist file in %distPath%
echo finish!

View File

@ -1,27 +1,46 @@
#!/bin/bash #!/bin/bash
###########################################################################
#
# Tank build script for Linux or MacOS
#
###########################################################################
#prepare the variables. #prepare the variables.
# version name # version name
VERSION_NAME=tank-3.0.0.beta1 VERSION_NAME=tank-3.0.0.beta1
echo "VERSION_NAME: ${VERSION_NAME}"
# eg. amd64 # eg. amd64
GOARCH=$(go env GOARCH) GOARCH=$(go env GOARCH)
echo "GOARCH: ${GOARCH}"
# eg. /data/golang
GOPATH=$(go env GOPATH)
echo "GOPATH: ${GOPATH}"
# eg. darwin # eg. darwin
GOOS=$(go env GOOS) GOOS=$(go env GOOS)
echo "GOOS: ${GOOS}"
# service dir eg. /data/tank/build/pack # service dir eg. /data/tank/build/pack
SERVICE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" PACK_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
echo "PACK_DIR: ${PACK_DIR}"
# build dir eg. /data/tank/build
BUILD_DIR=$(dirname ${PACK_DIR})
echo "BUILD_DIR: ${BUILD_DIR}"
# project dir eg. /data/tank # project dir eg. /data/tank
PROJECT_DIR=$(dirname $(dirname ${SERVICE_DIR})) PROJECT_DIR=$(dirname ${BUILD_DIR})
# build dir echo "PROJECT_DIR: ${PROJECT_DIR}"
BUILD_DIR=${PROJECT_DIR}/build
# final zip file name. # final zip file name.
FILE_NAME=${VERSION_NAME}.${GOOS}-${GOARCH}.tar.gz FILE_NAME=${VERSION_NAME}.${GOOS}-${GOARCH}.tar.gz
echo "FILE_NAME: ${FILE_NAME}"
# zip dist dir eg. /data/tank/tmp/dist # zip dist dir eg. /data/tank/tmp/dist
DIST_DIR=${PROJECT_DIR}/tmp/dist DIST_DIR=${PROJECT_DIR}/tmp/dist
echo "DIST_DIR: ${DIST_DIR}"
# component dir eg. /data/tank/tmp/dist/tank-3.0.0.beta1 # component dir eg. /data/tank/tmp/dist/tank-3.0.0.beta1
COMPONENT_DIR=${DIST_DIR}/${VERSION_NAME} COMPONENT_DIR=${DIST_DIR}/${VERSION_NAME}
echo "COMPONENT_DIR: ${COMPONENT_DIR}"
# final dist path eg. /data/tank/tmp/dist/tank-3.0.0.beta1.darwin-amd64.tar.gz # final dist path eg. /data/tank/tmp/dist/tank-3.0.0.beta1.darwin-amd64.tar.gz
DIST_PATH=${DIST_DIR}/${FILE_NAME} DIST_PATH=${DIST_DIR}/${FILE_NAME}
echo "DIST_PATH: ${DIST_PATH}"
cd ${PROJECT_DIR} cd ${PROJECT_DIR}

View File

@ -107,7 +107,7 @@ func (this *MatterService) DownloadZip(
count = count + this.matterDao.CountByUserUuidAndPath(matter.UserUuid, matter.Path) count = count + this.matterDao.CountByUserUuidAndPath(matter.UserUuid, matter.Path)
} }
this.logger.Info("此次下载包含文件数量 %s", count) this.logger.Info("此次下载包含文件数量 %d", count)
//文件数量判断。 //文件数量判断。
if preference.DownloadDirMaxNum >= 0 { if preference.DownloadDirMaxNum >= 0 {
@ -172,7 +172,7 @@ func (this *MatterService) zipMatters(matters []*Matter, destPath string) {
} }
userUuid := matters[0].UserUuid userUuid := matters[0].UserUuid
puuid := matters[0].Puuid puuid := matters[0].Puuid
baseDirPath := util.GetDirOfPath(matters[0].AbsolutePath()) baseDirPath := util.GetDirOfPath(matters[0].AbsolutePath()) + "/"
for _, m := range matters { for _, m := range matters {
if m.UserUuid != userUuid { if m.UserUuid != userUuid {