折腾:
【规避解决】crifan.com的腾讯云的香港hk服务器被举报违规
后,已经删除了:
https://book.crifan.com/books/scientific_network_summary/website/
然后此处自己的Gitbook的Makefile的脚本:
https://github.com/crifan/gitbook_template/blob/master/GitbookCommon.mk
也要去更新,确保之后,每次发布时,不再上传内容到上述地址
不过要同时保留上传到
https://crifan.github.io/scientific_network_summary/website/
且不要影响其他gitbook的book。
所以要去:
新增一个gitbook的deploy的book.crifan.com的ignore的列表
然后在Makefile中判断,如果当前发布的book包含在ignore列表内,就不发布到book.crifan.com
deploy_ignore_book_crifan_com.txt
scientific_network_summary
然后去更新Makefile:GitbookCommon.mk
期间需要用到Makefile的一些功能
先要去
再去读取deploy_ignore_book_crifan_com.txt
得到一个列表
再去判断一个字符串,当前的book的name,是否在这个列表内
再去执行动作
【已解决】Makefile中如何在目标中根据条件判断执行不同动作
再去想办法获取当前路径
makefile get current directory
gnu make – How to get current relative directory of your Makefile? – Stack Overflow
后来才发现,之前已经获取到当前路径了:
define getCurrentDirAndDirName $(eval MAKEFILE_LIST_LASTWORD = $(lastword $(MAKEFILE_LIST))) $(eval MAKEFILE_LIST_FIRSTWORD = $(firstword $(MAKEFILE_LIST))) $(eval MAKEFILE_PATH := $(abspath $(MAKEFILE_LIST_FIRSTWORD))) $(eval MAKEFILE_DIR := $(dir $(MAKEFILE_PATH))) $(eval MAKEFILE_DIR_PATSUBST := $(patsubst %/,%,$(MAKEFILE_DIR))) $(eval MAKEFILE_DIR_NOSLASH = $(MAKEFILE_DIR_PATSUBST)) $(eval CURRENT_DIR_WITH_SLASH = $(MAKEFILE_DIR)) $(eval CURRENT_DIR = $(MAKEFILE_DIR_NOSLASH)) $(eval CURRENT_DIR_NAME := $(notdir $(MAKEFILE_DIR_PATSUBST))) $(info CURRENT_DIR=$(CURRENT_DIR)) endef
所以直接去gitboo的root路径:
然后再想办法:
然后再去:
【已解决】Makefile中如何判断一个字符串变量存在另外一个字符串或列表中
【总结】
最后用的是:
$(eval GITBOOK_ROOT := $(abspath $(CURRENT_DIR)/..))
DEPLOY_IGNORE_FILE = $(GITBOOK_ROOT)/deploy_ignore_book_crifan_com.txt
# $(info DEPLOY_IGNORE_FILE=$(DEPLOY_IGNORE_FILE))
SHOULD_IGNORE = false
# ifneq (“$(wildcard $(DEPLOY_IGNORE_FILE))”, “”)
ifneq ($(wildcard $(DEPLOY_IGNORE_FILE)), )
# $(info $(DEPLOY_IGNORE_FILE) is exist, not empty)
IGNORE_FILE_CONTENT := $(shell cat $(DEPLOY_IGNORE_FILE))
# IGNORE_FILE_CONTENT := $(file < $(DEPLOY_IGNORE_FILE))
FOUND_BOOK := $(findstring $(BOOK_NAME), $(IGNORE_FILE_CONTENT))
# $(info FOUND_BOOK=$(FOUND_BOOK))
# ifeq (“$(FOUND_BOOK)”, “”)
ifeq ($(FOUND_BOOK), )
$(info NOT found $(BOOK_NAME) in $(IGNORE_FILE_CONTENT))
SHOULD_IGNORE = false
else
$(info IS found $(BOOK_NAME) in $(IGNORE_FILE_CONTENT))
SHOULD_IGNORE = true
endif
endif
## Upload all genereted website/pdf/epub/mobi files to remote server using rsync. Create sshpass_password.txt file to contain password before use this
upload: all
@echo ================================================================================
ifeq ($(SHOULD_IGNORE), true)
@echo Ignore upload $(BOOK_NAME) to book.crifan.com
else
@echo Upload for $(BOOK_NAME)
sshpass -f $(PASSWORD_FILE) rsync -avzh –progress –stats –delete –force $(OUTPUT_PATH) $(REMOTE_USER)@$(REMOTE_SERVER):$(REMOTE_PATH)
endif
实现了:
在
deploy_ignore_book_crifan_com.txt
scientific_network_summary
然后去单个gitbook中去
make upload
时,可以根据当前book的name是否包含在
deploy_ignore_book_crifan_com.txt
的内容中
如果包含,则不执行upload
不上传该book到book.crifan.com
如果不包含,则正常upload
上传该book到book.crifan.com
此时:
make help
的输出是可以看到:
upload Upload all genereted website/pdf/epub/mobi files to remote server using rsync. Create sshpass_password.txt file to contain password before use this
而如果改为,逻辑上更完美的:
即,发现是ignore,就不需要upload依赖,无意义的多余的all这个target的了:
## Upload all genereted website/pdf/epub/mobi files to remote server using rsync. Create sshpass_password.txt file to contain password before use this ifeq ($(SHOULD_IGNORE), true) upload: @echo ================================================================================ @echo Ignore upload $(BOOK_NAME) to book.crifan.com else upload: all @echo ================================================================================ @echo Upload for $(BOOK_NAME) sshpass -f $(PASSWORD_FILE) rsync -avzh --progress --stats --delete --force $(OUTPUT_PATH) $(REMOTE_USER)@$(REMOTE_SERVER):$(REMOTE_PATH) endif
但是会导致
make help
无法输出
upload的说明了
-》因为make help是静态的,无法输出动态的目标upload的注释内容。