github.com/minio/minio@v0.0.0-20240328213742-3f72439b8a27/Makefile (about) 1 PWD := $(shell pwd) 2 GOPATH := $(shell go env GOPATH) 3 LDFLAGS := $(shell go run buildscripts/gen-ldflags.go) 4 5 GOARCH := $(shell go env GOARCH) 6 GOOS := $(shell go env GOOS) 7 8 VERSION ?= $(shell git describe --tags) 9 REPO ?= quay.io/minio 10 TAG ?= $(REPO)/minio:$(VERSION) 11 12 GOLANGCI_DIR = .bin/golangci/$(GOLANGCI_VERSION) 13 GOLANGCI = $(GOLANGCI_DIR)/golangci-lint 14 15 all: build 16 17 checks: ## check dependencies 18 @echo "Checking dependencies" 19 @(env bash $(PWD)/buildscripts/checkdeps.sh) 20 21 help: ## print this help 22 @grep -E '^[a-zA-Z_-]+:.*?## .*$$' Makefile | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-40s\033[0m %s\n", $$1, $$2}' 23 24 getdeps: ## fetch necessary dependencies 25 @mkdir -p ${GOPATH}/bin 26 @echo "Installing golangci-lint" && curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOLANGCI_DIR) 27 @echo "Installing msgp" && go install -v github.com/tinylib/msgp@v1.1.10-0.20240227114326-6d6f813fff1b 28 @echo "Installing stringer" && go install -v golang.org/x/tools/cmd/stringer@latest 29 30 crosscompile: ## cross compile minio 31 @(env bash $(PWD)/buildscripts/cross-compile.sh) 32 33 verifiers: lint check-gen 34 35 check-gen: ## check for updated autogenerated files 36 @go generate ./... >/dev/null 37 @(! git diff --name-only | grep '_gen.go$$') || (echo "Non-committed changes in auto-generated code is detected, please commit them to proceed." && false) 38 39 lint: getdeps ## runs golangci-lint suite of linters 40 @echo "Running $@ check" 41 @$(GOLANGCI) run --build-tags kqueue --timeout=10m --config ./.golangci.yml 42 43 lint-fix: getdeps ## runs golangci-lint suite of linters with automatic fixes 44 @echo "Running $@ check" 45 @$(GOLANGCI) run --build-tags kqueue --timeout=10m --config ./.golangci.yml --fix 46 47 check: test 48 test: verifiers build build-debugging ## builds minio, runs linters, tests 49 @echo "Running unit tests" 50 @MINIO_API_REQUESTS_MAX=10000 CGO_ENABLED=0 go test -v -tags kqueue ./... 51 52 test-root-disable: install-race 53 @echo "Running minio root lockdown tests" 54 @env bash $(PWD)/buildscripts/disable-root.sh 55 56 test-decom: install-race 57 @echo "Running minio decom tests" 58 @env bash $(PWD)/docs/distributed/decom.sh 59 @env bash $(PWD)/docs/distributed/decom-encrypted.sh 60 @env bash $(PWD)/docs/distributed/decom-encrypted-sse-s3.sh 61 @env bash $(PWD)/docs/distributed/decom-compressed-sse-s3.sh 62 63 test-versioning: install-race 64 @echo "Running minio versioning tests" 65 @env bash $(PWD)/docs/bucket/versioning/versioning-tests.sh 66 67 test-configfile: install-race 68 @env bash $(PWD)/docs/distributed/distributed-from-config-file.sh 69 70 test-upgrade: install-race 71 @echo "Running minio upgrade tests" 72 @(env bash $(PWD)/buildscripts/minio-upgrade.sh) 73 74 test-race: verifiers build ## builds minio, runs linters, tests (race) 75 @echo "Running unit tests under -race" 76 @(env bash $(PWD)/buildscripts/race.sh) 77 78 test-iam: build ## verify IAM (external IDP, etcd backends) 79 @echo "Running tests for IAM (external IDP, etcd backends)" 80 @MINIO_API_REQUESTS_MAX=10000 CGO_ENABLED=0 go test -tags kqueue -v -run TestIAM* ./cmd 81 @echo "Running tests for IAM (external IDP, etcd backends) with -race" 82 @MINIO_API_REQUESTS_MAX=10000 GORACE=history_size=7 CGO_ENABLED=1 go test -race -tags kqueue -v -run TestIAM* ./cmd 83 84 test-sio-error: 85 @(env bash $(PWD)/docs/bucket/replication/sio-error.sh) 86 87 test-replication-2site: 88 @(env bash $(PWD)/docs/bucket/replication/setup_2site_existing_replication.sh) 89 90 test-replication-3site: 91 @(env bash $(PWD)/docs/bucket/replication/setup_3site_replication.sh) 92 93 test-delete-replication: 94 @(env bash $(PWD)/docs/bucket/replication/delete-replication.sh) 95 96 test-replication: install-race test-replication-2site test-replication-3site test-delete-replication test-sio-error ## verify multi site replication 97 @echo "Running tests for replicating three sites" 98 99 test-site-replication-ldap: install-race ## verify automatic site replication 100 @echo "Running tests for automatic site replication of IAM (with LDAP)" 101 @(env bash $(PWD)/docs/site-replication/run-multi-site-ldap.sh) 102 103 test-site-replication-oidc: install-race ## verify automatic site replication 104 @echo "Running tests for automatic site replication of IAM (with OIDC)" 105 @(env bash $(PWD)/docs/site-replication/run-multi-site-oidc.sh) 106 107 test-site-replication-minio: install-race ## verify automatic site replication 108 @echo "Running tests for automatic site replication of IAM (with MinIO IDP)" 109 @(env bash $(PWD)/docs/site-replication/run-multi-site-minio-idp.sh) 110 @echo "Running tests for automatic site replication of SSE-C objects" 111 @(env bash $(PWD)/docs/site-replication/run-ssec-object-replication.sh) 112 @echo "Running tests for automatic site replication of SSE-C objects with SSE-KMS enabled for bucket" 113 @(env bash $(PWD)/docs/site-replication/run-sse-kms-object-replication.sh) 114 @echo "Running tests for automatic site replication of SSE-C objects with compression enabled for site" 115 @(env bash $(PWD)/docs/site-replication/run-ssec-object-replication-with-compression.sh) 116 117 verify: ## verify minio various setups 118 @echo "Verifying build with race" 119 @GORACE=history_size=7 CGO_ENABLED=1 go build -race -tags kqueue -trimpath --ldflags "$(LDFLAGS)" -o $(PWD)/minio 1>/dev/null 120 @(env bash $(PWD)/buildscripts/verify-build.sh) 121 122 verify-healing: ## verify healing and replacing disks with minio binary 123 @echo "Verify healing build with race" 124 @GORACE=history_size=7 CGO_ENABLED=1 go build -race -tags kqueue -trimpath --ldflags "$(LDFLAGS)" -o $(PWD)/minio 1>/dev/null 125 @(env bash $(PWD)/buildscripts/verify-healing.sh) 126 @(env bash $(PWD)/buildscripts/heal-inconsistent-versions.sh) 127 128 verify-healing-with-root-disks: ## verify healing root disks 129 @echo "Verify healing with root drives" 130 @GORACE=history_size=7 CGO_ENABLED=1 go build -race -tags kqueue -trimpath --ldflags "$(LDFLAGS)" -o $(PWD)/minio 1>/dev/null 131 @(env bash $(PWD)/buildscripts/verify-healing-with-root-disks.sh) 132 133 verify-healing-with-rewrite: ## verify healing to rewrite old xl.meta -> new xl.meta 134 @echo "Verify healing with rewrite" 135 @GORACE=history_size=7 CGO_ENABLED=1 go build -race -tags kqueue -trimpath --ldflags "$(LDFLAGS)" -o $(PWD)/minio 1>/dev/null 136 @(env bash $(PWD)/buildscripts/rewrite-old-new.sh) 137 138 verify-healing-inconsistent-versions: ## verify resolving inconsistent versions 139 @echo "Verify resolving inconsistent versions build with race" 140 @GORACE=history_size=7 CGO_ENABLED=1 go build -race -tags kqueue -trimpath --ldflags "$(LDFLAGS)" -o $(PWD)/minio 1>/dev/null 141 @(env bash $(PWD)/buildscripts/resolve-right-versions.sh) 142 143 build-debugging: 144 @(env bash $(PWD)/docs/debugging/build.sh) 145 146 build: checks ## builds minio to $(PWD) 147 @echo "Building minio binary to './minio'" 148 @CGO_ENABLED=0 go build -tags kqueue -trimpath --ldflags "$(LDFLAGS)" -o $(PWD)/minio 1>/dev/null 149 150 hotfix-vars: 151 $(eval LDFLAGS := $(shell MINIO_RELEASE="RELEASE" MINIO_HOTFIX="hotfix.$(shell git rev-parse --short HEAD)" go run buildscripts/gen-ldflags.go $(shell git describe --tags --abbrev=0 | \ 152 sed 's#RELEASE\.\([0-9]\+\)-\([0-9]\+\)-\([0-9]\+\)T\([0-9]\+\)-\([0-9]\+\)-\([0-9]\+\)Z#\1-\2-\3T\4:\5:\6Z#'))) 153 $(eval VERSION := $(shell git describe --tags --abbrev=0).hotfix.$(shell git rev-parse --short HEAD)) 154 155 hotfix: hotfix-vars clean install ## builds minio binary with hotfix tags 156 @wget -q -c https://github.com/minio/pkger/releases/download/v2.2.9/pkger_2.2.9_linux_amd64.deb 157 @wget -q -c https://raw.githubusercontent.com/minio/minio-service/v1.0.1/linux-systemd/distributed/minio.service 158 @sudo apt install ./pkger_2.2.9_linux_amd64.deb --yes 159 @mkdir -p minio-release/$(GOOS)-$(GOARCH)/archive 160 @cp -af ./minio minio-release/$(GOOS)-$(GOARCH)/minio 161 @cp -af ./minio minio-release/$(GOOS)-$(GOARCH)/minio.$(VERSION) 162 @minisign -qQSm minio-release/$(GOOS)-$(GOARCH)/minio.$(VERSION) -s "${CRED_DIR}/minisign.key" < "${CRED_DIR}/minisign-passphrase" 163 @sha256sum < minio-release/$(GOOS)-$(GOARCH)/minio.$(VERSION) | sed 's, -,minio.$(VERSION),g' > minio-release/$(GOOS)-$(GOARCH)/minio.$(VERSION).sha256sum 164 @cp -af minio-release/$(GOOS)-$(GOARCH)/minio.$(VERSION)* minio-release/$(GOOS)-$(GOARCH)/archive/ 165 @pkger -r $(VERSION) --ignore 166 167 hotfix-push: hotfix 168 @scp -q -r minio-release/$(GOOS)-$(GOARCH)/* minio@dl-0.minio.io:~/releases/server/minio/hotfixes/linux-amd64/ 169 @scp -q -r minio-release/$(GOOS)-$(GOARCH)/* minio@dl-0.minio.io:~/releases/server/minio/hotfixes/linux-amd64/archive 170 @scp -q -r minio-release/$(GOOS)-$(GOARCH)/* minio@dl-1.minio.io:~/releases/server/minio/hotfixes/linux-amd64/ 171 @scp -q -r minio-release/$(GOOS)-$(GOARCH)/* minio@dl-1.minio.io:~/releases/server/minio/hotfixes/linux-amd64/archive 172 @echo "Published new hotfix binaries at https://dl.min.io/server/minio/hotfixes/linux-amd64/archive/minio.$(VERSION)" 173 174 docker-hotfix-push: docker-hotfix 175 @docker push -q $(TAG) && echo "Published new container $(TAG)" 176 177 docker-hotfix: hotfix-push checks ## builds minio docker container with hotfix tags 178 @echo "Building minio docker image '$(TAG)'" 179 @docker build -q --no-cache -t $(TAG) --build-arg RELEASE=$(VERSION) . -f Dockerfile.hotfix 180 181 docker: build ## builds minio docker container 182 @echo "Building minio docker image '$(TAG)'" 183 @docker build -q --no-cache -t $(TAG) . -f Dockerfile 184 185 install-race: checks ## builds minio to $(PWD) 186 @echo "Building minio binary with -race to './minio'" 187 @GORACE=history_size=7 CGO_ENABLED=1 go build -tags kqueue -race -trimpath --ldflags "$(LDFLAGS)" -o $(PWD)/minio 1>/dev/null 188 @echo "Installing minio binary with -race to '$(GOPATH)/bin/minio'" 189 @mkdir -p $(GOPATH)/bin && cp -f $(PWD)/minio $(GOPATH)/bin/minio 190 191 install: build ## builds minio and installs it to $GOPATH/bin. 192 @echo "Installing minio binary to '$(GOPATH)/bin/minio'" 193 @mkdir -p $(GOPATH)/bin && cp -f $(PWD)/minio $(GOPATH)/bin/minio 194 @echo "Installation successful. To learn more, try \"minio --help\"." 195 196 clean: ## cleanup all generated assets 197 @echo "Cleaning up all the generated files" 198 @find . -name '*.test' | xargs rm -fv 199 @find . -name '*~' | xargs rm -fv 200 @find . -name '.#*#' | xargs rm -fv 201 @find . -name '#*#' | xargs rm -fv 202 @rm -rvf minio 203 @rm -rvf build 204 @rm -rvf release 205 @rm -rvf .verify* 206 @rm -rvf minio-release 207 @rm -rvf minio.RELEASE*.hotfix.* 208 @rm -rvf pkger_*.deb