forked from krisnova/kush
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
89 lines (75 loc) · 4.72 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
84
85
86
87
88
89
# =========================================================================== #
# MIT License Copyright (c) 2022 Kris Nóva <[email protected]> #
# #
# ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ #
# ┃ ███╗ ██╗ ██████╗ ██╗ ██╗ █████╗ ┃ #
# ┃ ████╗ ██║██╔═████╗██║ ██║██╔══██╗ ┃ #
# ┃ ██╔██╗ ██║██║██╔██║██║ ██║███████║ ┃ #
# ┃ ██║╚██╗██║████╔╝██║╚██╗ ██╔╝██╔══██║ ┃ #
# ┃ ██║ ╚████║╚██████╔╝ ╚████╔╝ ██║ ██║ ┃ #
# ┃ ╚═╝ ╚═══╝ ╚═════╝ ╚═══╝ ╚═╝ ╚═╝ ┃ #
# ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ #
# #
# This machine kills fascists. #
# #
# =========================================================================== #
all: compile
version = 0.0.1
target = kobfuscate
org = kris-nova
authorname = Kris Nóva
authoremail = [email protected]
license = MIT
year = 2022
copyright = Copyright (c) $(year)
image_repo = krisnova
image_name = kush
image_tag = latest
sha = $(shell git rev-parse HEAD)
cpuset = $(shell cat /proc/1/status | grep -i cpus_allowed_list | cut -d ":" -f 2 | sed 's/\t//g')
compile: ## Compile for the local architecture ⚙
@echo "Compiling..."
go build -installsuffix cgo -ldflags "\
-X 'github.com/$(org)/$(target).Version=$(version)' \
-X 'github.com/$(org)/$(target).AuthorName=$(authorname)' \
-X 'github.com/$(org)/$(target).AuthorEmail=$(authoremail)' \
-X 'github.com/$(org)/$(target).Copyright=$(copyright)' \
-X 'github.com/$(org)/$(target).License=$(license)' \
-X 'github.com/$(org)/$(target).Name=$(target)'" \
-o $(target) cmd/*.go
install: ## Install the program to /usr/bin 🎉
@echo "Installing..."
sudo cp -v $(target) /usr/bin/$(target)
sudo cp -v root/bin/* /usr/bin/
test: clean compile install ## 🤓 Run go tests
@echo "Testing..."
go test -v ./...
container: ## Build the kush container
docker build --cpuset-cpus=$(cpuset) -t $(image_repo)/$(image_name):$(image_tag) .
#docker build --cpuset-cpus=$(cpuset) -t $(image_repo)/$(image_name):$(sha) .
push: ## Push the kush container
docker push $(image_repo)/$(image_name):$(image_tag)
#docker push $(image_repo)/$(image_name):$(sha)
container-base: ## Build the base container
docker build --cpuset-cpus=$(cpuset) -t $(image_repo)/$(image_name)base:$(image_tag) image/
#docker build --cpuset-cpus=$(cpuset) -t $(image_repo)/$(image_name)base:$(sha) .
push-base: ## Push the kush container
docker push $(image_repo)/$(image_name)base:$(image_tag)
#docker push $(image_repo)/$(image_name)base:$(sh)
exec: ## Run an exec into a kush container
docker run -it $(image_repo)/$(image_name):$(image_tag) /bin/kush
clean: ## Clean your artifacts 🧼
@echo "Cleaning..."
rm -rvf release/*
rm -rvf kobfuscate
.PHONY: release
release: ## Make the binaries for a GitHub release 📦
mkdir -p release
GOOS="linux" GOARCH="amd64" go build -ldflags "-X 'github.com/$(org)/$(target).Version=$(version)'" -o release/$(target)-linux-amd64 cmd/*.go
GOOS="linux" GOARCH="arm" go build -ldflags "-X 'github.com/$(org)/$(target).Version=$(version)'" -o release/$(target)-linux-arm cmd/*.go
GOOS="linux" GOARCH="arm64" go build -ldflags "-X 'github.com/$(org)/$(target).Version=$(version)'" -o release/$(target)-linux-arm64 cmd/*.go
GOOS="linux" GOARCH="386" go build -ldflags "-X 'github.com/$(org)/$(target).Version=$(version)'" -o release/$(target)-linux-386 cmd/*.go
GOOS="darwin" GOARCH="amd64" go build -ldflags "-X 'github.com/$(org)/$(target).Version=$(version)'" -o release/$(target)-darwin-amd64 cmd/*.go
.PHONY: help
help: ## 🤔 Show help messages for make targets
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[32m%-30s\033[0m %s\n", $$1, $$2}'