-
Notifications
You must be signed in to change notification settings - Fork 173
/
Makefile
83 lines (67 loc) · 2.42 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
VERSION=$(shell grep "var Version" shared/version/version.go | cut -d'"' -f2)
ARCHIVE=distrobuilder-$(VERSION).tar
GO111MODULE=on
SPHINXENV=.sphinx/venv/bin/activate
GOPATH=$(shell go env GOPATH)
.PHONY: default
default:
go env -w GOCACHE=$(shell go env GOCACHE)
$(shell go env | grep -v GOENV | sed "s/'//g" > $(shell go env GOENV))
gofmt -s -w .
go install -v ./...
@echo "distrobuilder built successfully"
.PHONY: update-gomod
update-gomod:
go get -t -v -d -u ./...
go mod tidy -go=1.22.7
.PHONY: check
check: default
sudo GOENV=$(shell go env GOENV) go test -v ./...
.PHONY: dist
dist:
# Cleanup
rm -Rf $(ARCHIVE).gz
# Create build dir
$(eval TMP := $(shell mktemp -d))
git archive --prefix=distrobuilder-$(VERSION)/ HEAD | tar -x -C $(TMP)
mkdir -p $(TMP)/_dist/src/github.com/lxc
ln -s ../../../../distrobuilder-$(VERSION) $(TMP)/_dist/src/github.com/lxc/distrobuilder
# Download dependencies
cd $(TMP)/distrobuilder-$(VERSION) && go mod vendor
# Assemble tarball
tar --exclude-vcs -C $(TMP) -zcf $(ARCHIVE).gz distrobuilder-$(VERSION)/
# Cleanup
rm -Rf $(TMP)
.PHONY: doc-setup
doc-setup:
@echo "Setting up documentation build environment"
python3 -m venv .sphinx/venv
. $(SPHINXENV) ; pip install --upgrade -r .sphinx/requirements.txt
mkdir -p .sphinx/deps/ .sphinx/themes/
wget -N -P .sphinx/_static/download https://linuxcontainers.org/static/img/favicon.ico https://linuxcontainers.org/static/img/containers.png https://linuxcontainers.org/static/img/containers.small.png
rm -Rf doc/html
.PHONY: doc
doc: doc-setup doc-incremental
.PHONY: doc-incremental
doc-incremental:
@echo "Build the documentation"
. $(SPHINXENV) ; sphinx-build -c .sphinx/ -b dirhtml doc/ doc/html/ -w .sphinx/warnings.txt
.PHONY: doc-serve
doc-serve:
cd doc/html; python3 -m http.server 8001
.PHONY: doc-spellcheck
doc-spellcheck: doc
. $(SPHINXENV) ; python3 -m pyspelling -c .sphinx/.spellcheck.yaml
.PHONY: doc-linkcheck
doc-linkcheck: doc-setup
. $(SPHINXENV) ; sphinx-build -c .sphinx/ -b linkcheck doc/ doc/html/
.PHONY: doc-lint
doc-lint:
.sphinx/.markdownlint/doc-lint.sh
.PHONY: static-analysis
static-analysis:
ifeq ($(shell command -v golangci-lint),)
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOPATH)/bin
endif
$(GOPATH)/bin/golangci-lint run --timeout 5m
run-parts $(shell run-parts -V 2> /dev/null 1> /dev/null && echo -n "--exit-on-error --regex '.sh'") test/lint