我又在和马基夫搏斗.我需要一些帮助。
check-fleet:
LOCAL_VERSION = $(shell fleetctl -version)
REMOTE_VERSION = $(shell ssh core@$(FLEETCTL_TUNNEL) fleetctl -version)
ifneq $(strip $(LOCAL_VERSION)) $(strip $(REMOTE_VERSION))
$(error Your fleetctl client version should match the server. Local version: $(LOCAL_VERSION), server version: $(REMOTE_VERSION). Uninstall your local version and install the latest build from https://github.com/coreos/fleet/releases)
endif当它执行时,我看到它确实是在断开并连接到服务器,但是错误总是发生,即使我手动设置这些变量的值!此外,它们在错误语句中始终是空白的。
即使设置它们有问题(即,如果它们是空的),那么至少它们是相等的,并且ifneq永远不会触发。
我想知道这是否与Makefile的两次传递处理有关,但是我尝试手动将变量设置为相等的已知字符串,而错误仍然会触发。我没有想法了..。
发布于 2014-04-25 20:50:44
重要的是要理解makefile中不属于菜谱一部分的行(通常,不缩进TAB)是由make解析的,而makefile的行是食谱的一部分(通常,缩进了TAB),它们被传递给shell,shell运行它们。
因此,将变量赋值或命令(如ifneq )放在菜谱中(与TAB缩进)是不合法或有效的。
如果希望将命令作为check-fleet目标的一部分运行,则必须在菜谱中编写shell脚本,而不是使用make构造。
check-fleet:
LOCAL_VERSION=`fleetctl -version`; \
REMOTE_VERSION=`ssh core@$(FLEETCTL_TUNNEL) fleetctl -version`; \
if [ $$LOCAL_VERSION != $$REMOTE_VERSION ]; then \
echo "Your fleetctl client version should match the server. Local version: $$LOCAL_VERSION, server version: $$REMOTE_VERSION. Uninstall your local version and install the latest build from https://github.com/coreos/fleet/releases"; exit 1; \
fihttps://stackoverflow.com/questions/23302158
复制相似问题