This repository has been archived by the owner on Feb 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
70 lines (57 loc) · 1.65 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
GIT_COMMIT = $(shell git rev-parse HEAD)
GIT_TAG = $(shell git describe --tags 2>/dev/null || echo "v.0.0.1" )
PKG := ./...
LDFLAGS := -w -s
LDFLAGS += -X "github.com/rancher-sandbox/luet-mtree/internal/version.version=${GIT_TAG}"
LDFLAGS += -X "github.com/rancher-sandbox/luet-mtree/internal/version.gitCommit=${GIT_COMMIT}"
LUET?=/usr/bin/luet
BACKEND?=docker
CONCURRENCY?=1
export ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
COMPRESSION?=gzip
TREE?=./luet-packages
export LUET_BIN?=$(LUET)
build:
go build -ldflags '$(LDFLAGS)' -o bin/
vet:
go vet ${PKG}
fmt:
go fmt ${PKG}
test:
ifneq ($(shell id -u), 0)
@echo "Tests need to run under root user to download and unpack docker images."
@exit 1
else
go test ${PKG} -race -coverprofile=coverage.txt -covermode=atomic
endif
clean-repo:
ifneq ($(shell id -u), 0)
@echo "Clean needs to run under root user."
@exit 1
else
rm -rf build/ *.tar *.metadata.yaml
endif
build-repo: clean-repo
ifneq ($(shell id -u), 0)
@echo "Build repo needs to run under root user."
@exit 1
else
mkdir -p $(ROOT_DIR)/build
$(LUET) build --no-spinner --all --tree=$(TREE) --destination $(ROOT_DIR)/build --backend $(BACKEND) --concurrency $(CONCURRENCY) --compression $(COMPRESSION)
endif
create-repo:
ifneq ($(shell id -u), 0)
@echo "Create repo need to run under root user."
@exit 1
else
$(LUET) create-repo --no-spinner --tree "$(TREE)" \
--output $(ROOT_DIR)/build \
--packages $(ROOT_DIR)/build \
--name "luet-mtree" \
--descr "Luet mtree official repository" \
--urls "http://localhost:8000" \
--tree-compression gzip \
--type http
endif
lint: fmt vet
all: lint test build