diff --git a/Makefile b/Makefile index 90246b9..690230d 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,19 @@ -RAR = "C:/Program Files/WinRAR/Rar.exe" -GIT = "C:/Program Files/Git/cmd/git.exe" +ifeq ($(OS),Windows_NT) + RAR := "C:/Program Files/WinRAR/Rar.exe" + GIT := "C:/Program Files/Git/cmd/git.exe" + PACKAGE_EXT := rar + PACKAGE_CMD = $(RAR) a -ma5 -md1024 -m5 -mt32 -htb -s -rr1p -QO+ $@ $^ + PACKAGE_DEPS := .git update.bat README.md README_EN.md MinGit +else + GIT := git + PACKAGE_EXT := tar.gz + PACKAGE_CMD = tar -czf $@ $^ + PACKAGE_DEPS := update.sh README.md README_EN.md +endif -FactoryBluePrints.rar: .git update.bat README.md README_EN.md MinGit +FactoryBluePrints.$(PACKAGE_EXT): $(PACKAGE_DEPS) $(GIT) repack -a -d --window-memory=0 --depth=4095 - $(RAR) a -ma5 -md1024 -m5 -mt32 -htb -s -rr1p -QO+ $@ $^ + $(PACKAGE_CMD) repack: $(GIT) config core.compression 9 @@ -12,4 +22,8 @@ repack: $(GIT) repack -a -d -f -F --window-memory=0 --depth=4095 clean: +ifeq ($(OS),Windows_NT) rm *.rar +else + rm *.tar.gz +endif diff --git a/update.sh b/update.sh new file mode 100644 index 0000000..5ccb520 --- /dev/null +++ b/update.sh @@ -0,0 +1,42 @@ +#!/bin/bash +# This script is used to manually fetch blueprints from remote + +LOG_PATH="update.log" +REMOTE_URI="git@github.com:DSPBluePrints/FactoryBluePrints.git" + +cd "$(dirname "$0")" + +# debug info +ls > $LOG_PATH +echo "----" >> $LOG_PATH + +# test dir +if [ ! -d "../../Blueprint" ]; then + echo "$(date '+%x %X') Warning: Abnormal installation path" >> "$LOG_PATH" + echo "警告:您似乎安装到了错误的路径,这可能导致文件权限异常" +fi + +# test git +# git should already be installed as a package +if git --version &> /dev/null; then + echo "$(date '+%x %X') Infomation: GIT_PATH=$(command -v git)" +else + echo "错误:无法找到git" + echo "$(date '+%x %X') Error: git not found" >> "$LOG_PATH" + exit 1 +fi + +# find .git +if [ ! -d ".git" ]; then + echo "警告:无法找到.git" + echo "$(date '+%x %X') Warning: .git not found" >> "$LOG_PATH" + git init + git remote add origin $REMOTE_URI +fi + +# force-reset +git remote set-url origin $REMOTE_URI +git fetch --all +git reset --hard origin/main +echo "$(date '+%x %X') Information : git reset --hard" >> "$LOG_PATH" +# git clean -fd