diff --git a/Makefile b/Makefile index 8545fa1f8..bb5486b46 100644 --- a/Makefile +++ b/Makefile @@ -39,8 +39,9 @@ SOURCES := $(shell find cmd/ pkg/ vendor/ -name '*.go') PLUGIN_SOURCES := $(shell ls *.go) INTEGRATION_SOURCES := $(shell find integration/ -name '*.go') +CONTAINERD_BIN := containerd ifeq ($(GOOS),windows) - BIN_EXT := .exe + CONTAINERD_BIN := $(CONTAINERD_BIN).exe endif all: binaries @@ -82,7 +83,7 @@ sync-vendor: update-vendor: sync-vendor sort-vendor ## Syncs containerd/vendor.conf -> vendor.conf and sorts vendor.conf @echo "$(WHALE) $@" -$(BUILD_DIR)/containerd: $(SOURCES) $(PLUGIN_SOURCES) +$(BUILD_DIR)/$(CONTAINERD_BIN): $(SOURCES) $(PLUGIN_SOURCES) @echo "$(WHALE) $@" $(GO) build -o $@$(BIN_EXT) \ -tags '$(BUILD_TAGS)' \ @@ -117,29 +118,34 @@ clean: ## cleanup binaries @echo "$(WHALE) $@" @rm -rf $(BUILD_DIR)/* -binaries: $(BUILD_DIR)/containerd ## build a customized containerd (same result as make containerd) +binaries: $(BUILD_DIR)/$(CONTAINERD_BIN) ## build a customized containerd (same result as make containerd) @echo "$(WHALE) $@" static-binaries: GO_LDFLAGS += -extldflags "-fno-PIC -static" -static-binaries: $(BUILD_DIR)/containerd ## build static containerd +static-binaries: $(BUILD_DIR)/$(CONTAINERD_BIN) ## build static containerd @echo "$(WHALE) $@" -containerd: $(BUILD_DIR)/containerd ## build a customized containerd with CRI plugin for testing +containerd: $(BUILD_DIR)/$(CONTAINERD_BIN) ## build a customized containerd with CRI plugin for testing @echo "$(WHALE) $@" install-containerd: containerd ## installs customized containerd to system location @echo "$(WHALE) $@" - @install -D -m 755 $(BUILD_DIR)/containerd "$(BINDIR)/containerd" + @install -D -m 755 $(BUILD_DIR)/$(CONTAINERD_BIN) "$(BINDIR)/$(CONTAINERD_BIN)" install: install-containerd ## installs customized containerd to system location @echo "$(WHALE) $@" uninstall: ## remove containerd from system location @echo "$(WHALE) $@" - @rm -f "$(BINDIR)/containerd" + @rm -f "$(BINDIR)/$(CONTAINERD_BIN)" +ifeq ($(GOOS),windows) +$(BUILD_DIR)/$(TARBALL): static-binaries vendor.conf + @BUILD_DIR=$(BUILD_DIR) TARBALL=$(TARBALL) VERSION=$(VERSION) ./hack/release-windows.sh +else $(BUILD_DIR)/$(TARBALL): static-binaries vendor.conf @BUILD_DIR=$(BUILD_DIR) TARBALL=$(TARBALL) VERSION=$(VERSION) ./hack/release.sh +endif release: $(BUILD_DIR)/$(TARBALL) ## build release tarball diff --git a/hack/install/utils.sh b/hack/install/utils.sh index 69a6ea51e..b06fd30f3 100755 --- a/hack/install/utils.sh +++ b/hack/install/utils.sh @@ -16,11 +16,12 @@ source $(dirname "${BASH_SOURCE[0]}")/../utils.sh -# DESTDIR is the dest path to install dependencies. +# DESTDIR is the absolute dest path to install dependencies. DESTDIR=${DESTDIR:-"/"} # Convert to absolute path if it's relative. if [[ ${DESTDIR} != /* ]]; then - DESTDIR=${ROOT}/${DESTDIR} + echo "DESTDIR is not an absolute path" + exit 1 fi # NOSUDO indicates not to use sudo during installation. diff --git a/hack/install/windows/install-cni-config.sh b/hack/install/windows/install-cni-config.sh index 395292026..a2313bc6b 100755 --- a/hack/install/windows/install-cni-config.sh +++ b/hack/install/windows/install-cni-config.sh @@ -74,7 +74,7 @@ bash -c 'cat >"'"${CNI_CONFIG_DIR}"'"/0-containerd-nat.conf < ${tarball}.sha256 diff --git a/hack/release.sh b/hack/release.sh index 6c07a686f..fe99652aa 100755 --- a/hack/release.sh +++ b/hack/release.sh @@ -26,6 +26,10 @@ umask 0022 # BUILD_DIR is the directory to generate release tar. # TARBALL is the name of the release tar. BUILD_DIR=${BUILD_DIR:-"_output"} +# Convert to absolute path if it's relative. +if [[ ${BUILD_DIR} != /* ]]; then + BUILD_DIR=${ROOT}/${BUILD_DIR} +fi TARBALL=${TARBALL:-"cri-containerd.tar.gz"} # INCLUDE_CNI indicates whether to install CNI. By default don't # include CNI in release tarball.