From 8ba8f6717559732c7aaf987fee4b60d2f5721367 Mon Sep 17 00:00:00 2001 From: gesangtome Date: Thu, 24 Mar 2022 19:55:12 +0800 Subject: [PATCH 1/8] Update string for go-check Looks like upstream has removed support built with GO 1.16, the string should be updated here. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 613c083262e74..9e6973ff767d9 100644 --- a/Makefile +++ b/Makefile @@ -205,7 +205,7 @@ help: go-check: $(eval GO_VERSION := $(shell printf "%03d%03d%03d" $(shell $(GO) version | grep -Eo '[0-9]+\.[0-9.]+' | tr '.' ' ');)) @if [ "$(GO_VERSION)" -lt "$(MIN_GO_VERSION)" ]; then \ - echo "Gitea requires Go 1.16 or greater to build. You can get it at https://golang.org/dl/"; \ + echo "Gitea requires Go 1.17 or greater to build. You can get it at https://golang.org/dl/"; \ exit 1; \ fi From 65e3d54ff99017c61daafc524ff869c83ce72efb Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Thu, 24 Mar 2022 21:41:54 +0800 Subject: [PATCH 2/8] Use go version in `go.mod` instead of magic number --- Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 9e6973ff767d9..5ba0de778c94a 100644 --- a/Makefile +++ b/Makefile @@ -25,7 +25,8 @@ HAS_GO = $(shell hash $(GO) > /dev/null 2>&1 && echo "GO" || echo "NOGO" ) COMMA := , XGO_VERSION := go-1.18.x -MIN_GO_VERSION := 001017000 +MIN_GO_VERSION_STR := $(shell cat go.mod | grep -Eo '^go\s+[0-9]+\.[0-9.]+' | cut -d' ' -f2) +MIN_GO_VERSION := $(shell printf "%03d%03d%03d" $(shell echo '$(MIN_GO_VERSION_STR)' | tr '.' ' ')) MIN_NODE_VERSION := 012017000 AIR_PACKAGE ?= github.com/cosmtrek/air@v1.29.0 @@ -205,7 +206,7 @@ help: go-check: $(eval GO_VERSION := $(shell printf "%03d%03d%03d" $(shell $(GO) version | grep -Eo '[0-9]+\.[0-9.]+' | tr '.' ' ');)) @if [ "$(GO_VERSION)" -lt "$(MIN_GO_VERSION)" ]; then \ - echo "Gitea requires Go 1.17 or greater to build. You can get it at https://golang.org/dl/"; \ + echo "Gitea requires Go $(MIN_GO_VERSION_STR) or greater to build. You can get it at https://golang.org/dl/"; \ exit 1; \ fi From 402d1c7772bdafcfd7760283710e583dc1e95898 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Thu, 24 Mar 2022 21:44:03 +0800 Subject: [PATCH 3/8] use new golang site url --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 5ba0de778c94a..9002ed73bccf1 100644 --- a/Makefile +++ b/Makefile @@ -206,7 +206,7 @@ help: go-check: $(eval GO_VERSION := $(shell printf "%03d%03d%03d" $(shell $(GO) version | grep -Eo '[0-9]+\.[0-9.]+' | tr '.' ' ');)) @if [ "$(GO_VERSION)" -lt "$(MIN_GO_VERSION)" ]; then \ - echo "Gitea requires Go $(MIN_GO_VERSION_STR) or greater to build. You can get it at https://golang.org/dl/"; \ + echo "Gitea requires Go $(MIN_GO_VERSION_STR) or greater to build. You can get it at https://go.dev/dl/"; \ exit 1; \ fi From fe7b8866236cf800bc6b63a1765f6b84a04d0d10 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Thu, 24 Mar 2022 21:45:54 +0800 Subject: [PATCH 4/8] use grep directly instead of cat --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 9002ed73bccf1..ae4b279f221f3 100644 --- a/Makefile +++ b/Makefile @@ -25,7 +25,7 @@ HAS_GO = $(shell hash $(GO) > /dev/null 2>&1 && echo "GO" || echo "NOGO" ) COMMA := , XGO_VERSION := go-1.18.x -MIN_GO_VERSION_STR := $(shell cat go.mod | grep -Eo '^go\s+[0-9]+\.[0-9.]+' | cut -d' ' -f2) +MIN_GO_VERSION_STR := $(shell grep -Eo '^go\s+[0-9]+\.[0-9.]+' go.mod | cut -d' ' -f2) MIN_GO_VERSION := $(shell printf "%03d%03d%03d" $(shell echo '$(MIN_GO_VERSION_STR)' | tr '.' ' ')) MIN_NODE_VERSION := 012017000 From 1d8fff75b44311cb7af6248abb680b175c76763b Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Thu, 24 Mar 2022 22:19:22 +0800 Subject: [PATCH 5/8] Revmoe magic number for nodejs version check --- Makefile | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index ae4b279f221f3..a1246a7c6ab07 100644 --- a/Makefile +++ b/Makefile @@ -25,9 +25,12 @@ HAS_GO = $(shell hash $(GO) > /dev/null 2>&1 && echo "GO" || echo "NOGO" ) COMMA := , XGO_VERSION := go-1.18.x + MIN_GO_VERSION_STR := $(shell grep -Eo '^go\s+[0-9]+\.[0-9.]+' go.mod | cut -d' ' -f2) MIN_GO_VERSION := $(shell printf "%03d%03d%03d" $(shell echo '$(MIN_GO_VERSION_STR)' | tr '.' ' ')) -MIN_NODE_VERSION := 012017000 + +MIN_NODE_VERSION_STR := $(shell grep -Eo '"node":.*[0-9.]+"' package.json | sed -n 's/.*[^0-9.]\([0-9.]*\)"/\1/p') +MIN_NODE_VERSION := $(shell printf "%03d%03d%03d" $(shell echo '$(MIN_NODE_VERSION_STR)' | tr '.' ' ')) AIR_PACKAGE ?= github.com/cosmtrek/air@v1.29.0 EDITORCONFIG_CHECKER_PACKAGE ?= github.com/editorconfig-checker/editorconfig-checker/cmd/editorconfig-checker@2.4.0 @@ -209,6 +212,7 @@ go-check: echo "Gitea requires Go $(MIN_GO_VERSION_STR) or greater to build. You can get it at https://go.dev/dl/"; \ exit 1; \ fi + @echo "checked whether go matches min version: $(MIN_GO_VERSION_STR)" .PHONY: git-check git-check: @@ -226,6 +230,7 @@ node-check: echo "Gitea requires Node.js $(MIN_NODE_VER_FMT) or greater and npm to build. You can get it at https://nodejs.org/en/download/"; \ exit 1; \ fi + @echo "checked nodejs matches min version: $(MIN_NODE_VERSION_STR)" .PHONY: clean-all clean-all: clean From d1d2df3c90c4caed3c985490efd487ba65f75bf7 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Thu, 24 Mar 2022 22:25:41 +0800 Subject: [PATCH 6/8] remove unnecessary MIN_NODE_VER_FMT --- Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Makefile b/Makefile index a1246a7c6ab07..8c9ffbdf70132 100644 --- a/Makefile +++ b/Makefile @@ -224,10 +224,9 @@ git-check: .PHONY: node-check node-check: $(eval NODE_VERSION := $(shell printf "%03d%03d%03d" $(shell node -v | cut -c2- | tr '.' ' ');)) - $(eval MIN_NODE_VER_FMT := $(shell printf "%g.%g.%g" $(shell echo $(MIN_NODE_VERSION) | grep -o ...))) $(eval NPM_MISSING := $(shell hash npm > /dev/null 2>&1 || echo 1)) @if [ "$(NODE_VERSION)" -lt "$(MIN_NODE_VERSION)" -o "$(NPM_MISSING)" = "1" ]; then \ - echo "Gitea requires Node.js $(MIN_NODE_VER_FMT) or greater and npm to build. You can get it at https://nodejs.org/en/download/"; \ + echo "Gitea requires Node.js $(MIN_NODE_VERSION_STR) or greater and npm to build. You can get it at https://nodejs.org/en/download/"; \ exit 1; \ fi @echo "checked nodejs matches min version: $(MIN_NODE_VERSION_STR)" From 8e4ae0a8a5b046dfe12fd20b5a22e23357c40739 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Thu, 24 Mar 2022 23:47:31 +0800 Subject: [PATCH 7/8] fix message string --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 8c9ffbdf70132..ccc65399c36bf 100644 --- a/Makefile +++ b/Makefile @@ -212,7 +212,7 @@ go-check: echo "Gitea requires Go $(MIN_GO_VERSION_STR) or greater to build. You can get it at https://go.dev/dl/"; \ exit 1; \ fi - @echo "checked whether go matches min version: $(MIN_GO_VERSION_STR)" + @echo "checked go matches min version: $(MIN_GO_VERSION_STR)" .PHONY: git-check git-check: From 124ff3de2e30e47ef43863d839f97ed5f2df8e0a Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Fri, 25 Mar 2022 00:44:26 +0800 Subject: [PATCH 8/8] Update Makefile --- Makefile | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index ccc65399c36bf..5ed50a67382cd 100644 --- a/Makefile +++ b/Makefile @@ -26,12 +26,6 @@ COMMA := , XGO_VERSION := go-1.18.x -MIN_GO_VERSION_STR := $(shell grep -Eo '^go\s+[0-9]+\.[0-9.]+' go.mod | cut -d' ' -f2) -MIN_GO_VERSION := $(shell printf "%03d%03d%03d" $(shell echo '$(MIN_GO_VERSION_STR)' | tr '.' ' ')) - -MIN_NODE_VERSION_STR := $(shell grep -Eo '"node":.*[0-9.]+"' package.json | sed -n 's/.*[^0-9.]\([0-9.]*\)"/\1/p') -MIN_NODE_VERSION := $(shell printf "%03d%03d%03d" $(shell echo '$(MIN_NODE_VERSION_STR)' | tr '.' ' ')) - AIR_PACKAGE ?= github.com/cosmtrek/air@v1.29.0 EDITORCONFIG_CHECKER_PACKAGE ?= github.com/editorconfig-checker/editorconfig-checker/cmd/editorconfig-checker@2.4.0 ERRCHECK_PACKAGE ?= github.com/kisielk/errcheck@v1.6.0 @@ -207,12 +201,13 @@ help: .PHONY: go-check go-check: + $(eval MIN_GO_VERSION_STR := $(shell grep -Eo '^go\s+[0-9]+\.[0-9.]+' go.mod | cut -d' ' -f2)) + $(eval MIN_GO_VERSION := $(shell printf "%03d%03d%03d" $(shell echo '$(MIN_GO_VERSION_STR)' | tr '.' ' '))) $(eval GO_VERSION := $(shell printf "%03d%03d%03d" $(shell $(GO) version | grep -Eo '[0-9]+\.[0-9.]+' | tr '.' ' ');)) @if [ "$(GO_VERSION)" -lt "$(MIN_GO_VERSION)" ]; then \ echo "Gitea requires Go $(MIN_GO_VERSION_STR) or greater to build. You can get it at https://go.dev/dl/"; \ exit 1; \ fi - @echo "checked go matches min version: $(MIN_GO_VERSION_STR)" .PHONY: git-check git-check: @@ -223,13 +218,14 @@ git-check: .PHONY: node-check node-check: + $(eval MIN_NODE_VERSION_STR := $(shell grep -Eo '"node":.*[0-9.]+"' package.json | sed -n 's/.*[^0-9.]\([0-9.]*\)"/\1/p')) + $(eval MIN_NODE_VERSION := $(shell printf "%03d%03d%03d" $(shell echo '$(MIN_NODE_VERSION_STR)' | tr '.' ' '))) $(eval NODE_VERSION := $(shell printf "%03d%03d%03d" $(shell node -v | cut -c2- | tr '.' ' ');)) $(eval NPM_MISSING := $(shell hash npm > /dev/null 2>&1 || echo 1)) @if [ "$(NODE_VERSION)" -lt "$(MIN_NODE_VERSION)" -o "$(NPM_MISSING)" = "1" ]; then \ echo "Gitea requires Node.js $(MIN_NODE_VERSION_STR) or greater and npm to build. You can get it at https://nodejs.org/en/download/"; \ exit 1; \ fi - @echo "checked nodejs matches min version: $(MIN_NODE_VERSION_STR)" .PHONY: clean-all clean-all: clean