Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
169 lines (145 loc) · 6.36 KB
/
Copy pathMakefile
File metadata and controls
169 lines (145 loc) · 6.36 KB
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
GOOS ?= $(shell go env GOOS)
GO_BUILD_ENV := CGO_ENABLED=0 GOOS=$(GOOS)
VERSION ?= $(shell git describe --tags --always 2>/dev/null || echo "dev")
LDFLAGS := -ldflags "-X github.com/89luca89/distrobox/pkg/version.Version=$(VERSION)"
.PHONY: build
build:
$(GO_BUILD_ENV) go build $(LDFLAGS) -o ./bin/distrobox ./cmd/distrobox
# Regenerate man pages from docs/usage/*.md via pandoc.
# Requires pandoc on $PATH; run after touching docs/usage/.
.PHONY: man
man:
./man/gen-man
.PHONY: test
test: vet
$(GO_BUILD_ENV) go test -v ./...
.PHONY: vet
vet:
$(GO_BUILD_ENV) go vet ./...
.PHONY: fmt
fmt:
$(GO_BUILD_ENV) go fmt ./...
PREFIX ?= /usr/local
BINDIR ?= $(PREFIX)/bin
MANDIR ?= $(PREFIX)/share/man/man1
BASHCOMPDIR ?= $(PREFIX)/share/bash-completion/completions
ZSHCOMPDIR ?= $(PREFIX)/share/zsh/site-functions
ICONDIR ?= $(PREFIX)/share/icons/hicolor
ICON_SIZES := 16 22 24 32 36 48 64 72 96 128 256
V1_SUBCOMMANDS := assemble create enter ephemeral generate-entry ls list rm stop upgrade
.PHONY: install
install: build
install -d $(DESTDIR)$(BINDIR) $(DESTDIR)$(MANDIR) $(DESTDIR)$(BASHCOMPDIR) $(DESTDIR)$(ZSHCOMPDIR)
install -m 0755 ./bin/distrobox $(DESTDIR)$(BINDIR)/distrobox
install -m 0644 man/man1/*.1 $(DESTDIR)$(MANDIR)/
install -m 0644 completions/bash/distrobox $(DESTDIR)$(BASHCOMPDIR)/distrobox
install -m 0644 completions/zsh/_distrobox $(DESTDIR)$(ZSHCOMPDIR)/_distrobox
for sub in $(V1_SUBCOMMANDS); do \
ln -sf distrobox $(DESTDIR)$(BINDIR)/distrobox-$${sub}; \
done
install -m 0755 internal/inside-distrobox/assets/distrobox-init $(DESTDIR)$(BINDIR)/distrobox-init
install -m 0755 internal/inside-distrobox/assets/distrobox-export $(DESTDIR)$(BINDIR)/distrobox-export
install -m 0755 internal/inside-distrobox/assets/distrobox-host-exec $(DESTDIR)$(BINDIR)/distrobox-host-exec
install -d $(DESTDIR)$(ICONDIR)/scalable/apps
install -m 0644 icons/terminal-distrobox-icon.svg $(DESTDIR)$(ICONDIR)/scalable/apps/
for sz in $(ICON_SIZES); do \
install -d $(DESTDIR)$(ICONDIR)/$${sz}x$${sz}/apps; \
install -m 0644 icons/hicolor/$${sz}x$${sz}/apps/terminal-distrobox-icon.png \
$(DESTDIR)$(ICONDIR)/$${sz}x$${sz}/apps/; \
done
.PHONY: uninstall
uninstall:
rm -f $(DESTDIR)$(BINDIR)/distrobox $(DESTDIR)$(BINDIR)/distrobox-*
rm -f $(DESTDIR)$(MANDIR)/distrobox.1 $(DESTDIR)$(MANDIR)/distrobox-*.1
rm -f $(DESTDIR)$(BASHCOMPDIR)/distrobox
rm -f $(DESTDIR)$(ZSHCOMPDIR)/_distrobox
rm -f $(DESTDIR)$(ICONDIR)/scalable/apps/terminal-distrobox-icon.svg
for sz in $(ICON_SIZES); do \
rm -f $(DESTDIR)$(ICONDIR)/$${sz}x$${sz}/apps/terminal-distrobox-icon.png; \
done
.PHONY: clean
clean:
rm -f ./bin/distrobox
# lint / lint-fix invoke the same golangci-lint version as the Lint CI job
# (.github/workflows/main.yml: golangci/golangci-lint-action with version:
# v2.5.0) through a container so local runs cannot drift from CI results.
# Defaults to podman when it is on PATH, else docker. Override with
# CONTAINER_RUNTIME=... to pick explicitly.
GOLANGCI_LINT_VERSION ?= v2.5.0
GOLANGCI_LINT_IMAGE ?= docker.io/golangci/golangci-lint:$(GOLANGCI_LINT_VERSION)
CONTAINER_RUNTIME ?= $(shell command -v podman >/dev/null 2>&1 && echo podman || echo docker)
LINT_CACHE_DIR ?= $(CURDIR)/.cache/lint
LINT_USERNS := $(shell \
if [ "$(CONTAINER_RUNTIME)" = "podman" ] && \
podman info --format '{{.Host.Security.Rootless}}' 2>/dev/null | grep -qx true; then \
echo "--userns=keep-id"; \
fi)
LINT_RUN = $(CONTAINER_RUNTIME) run --rm \
--user $(shell id -u):$(shell id -g) \
$(LINT_USERNS) \
-v $(CURDIR):$(CURDIR) -w $(CURDIR) \
-v $(LINT_CACHE_DIR):/cache \
-e HOME=/cache \
-e GOPATH=/cache/go \
-e GOCACHE=/cache/go-build \
-e GOMODCACHE=/cache/go/pkg/mod \
-e GOLANGCI_LINT_CACHE=/cache/golangci \
$(GOLANGCI_LINT_IMAGE) golangci-lint run ./...
.PHONY: lint
lint:
@mkdir -p $(LINT_CACHE_DIR)/go/pkg/mod $(LINT_CACHE_DIR)/go-build $(LINT_CACHE_DIR)/golangci
$(LINT_RUN) --verbose
.PHONY: lint-fix
lint-fix:
@mkdir -p $(LINT_CACHE_DIR)/go/pkg/mod $(LINT_CACHE_DIR)/go-build $(LINT_CACHE_DIR)/golangci
$(LINT_RUN) --fix
# ---------------------------------------------------------------------------
# Local e2e via the hack/ci/*.sh scripts, on the freshly-built binary. Pulled
# images are kept so repeated runs do not re-download. Targets:
# e2e mirrors the per-PR gate (.github/workflows/e2e.yml): the gating
# image subset + commands.sh, on both backends (podman, docker).
# e2e-full the whole compatibility matrix (docs/compatibility.md) + commands.
# e2e-one one e2e.sh run for a single image + backend; override IMAGE=/CM=.
# e2e-commands just commands.sh on one image/backend; override IMAGE=/CM=.
# ---------------------------------------------------------------------------
IMAGE ?= docker.io/library/alpine:latest
CM ?= podman
E2E_ENV := DBX="$(CURDIR)/bin/distrobox" DBX_E2E_KEEP_IMAGE=1
E2E_IMAGES := \
docker.io/library/alpine:latest \
docker.io/library/debian:stable \
docker.io/library/ubuntu:24.04 \
docker.io/library/fedora:latest \
registry.opensuse.org/opensuse/distrobox:latest \
docker.io/library/archlinux:latest \
registry.access.redhat.com/ubi9/ubi-init
# Full compatibility matrix, derived from docs/compatibility.md like compatibility.yml
# (no drift). Lazy '=' so the pipeline runs only when e2e-full is invoked.
E2E_FULL_SKIP := bazzite|chimera|slackware|stream8|ublue|neon|steamos|alt:
E2E_FULL_IMAGES = $(shell sed -n -e '/| Alma/,/| Void/ p' docs/compatibility.md | cut -d'|' -f 4 | sed 's/<br>/\n/g' | tr -d ' ' | sed '/^[[:space:]]*$$/d' | sort -u | grep -Ev '$(E2E_FULL_SKIP)')
# print-<VAR> — echo a make variable; the CI matrices build from these lists.
.PHONY: print-%
print-%:
@echo '$($*)'
.PHONY: e2e-one
e2e-one: build
echo ">>> e2e: $(IMAGE) / $(CM)"; \
$(E2E_ENV) hack/ci/e2e.sh "$(IMAGE)" "$(CM)"
.PHONY: e2e-commands
e2e-commands: build
echo ">>> commands: $(IMAGE) / $(CM)"; \
$(E2E_ENV) hack/ci/commands.sh "$(IMAGE)" "$(CM)"
.PHONY: e2e
e2e: build
@for img in $(E2E_IMAGES); do \
for cm in podman docker; do \
$(MAKE) --no-print-directory e2e-one IMAGE="$$img" CM="$$cm" || exit 1; \
done; \
done
@for cm in podman docker; do \
$(MAKE) --no-print-directory e2e-commands CM="$$cm" || exit 1; \
done
# Full compatibility sweep (100+ images x 2 backends); local twin of compatibility.yml.
.PHONY: e2e-full
e2e-full:
$(MAKE) --no-print-directory e2e E2E_IMAGES="$(E2E_FULL_IMAGES)"