1- # devstack developer tasks. The binary is named `devstack` (from ./cmd/devstack)
2- # regardless of the repo folder name.
1+ # devstack developer tasks. The binary is `devstack` (built from ./cmd/devstack);
2+ # the Go module is github.com/open-source-cloud/devstack. `make install` drops the
3+ # binary into a local bin dir; `make smoke` exercises the built binary end-to-end.
34
45BINARY := devstack
5- PKG := github.com/open-source-cloud/devdock-go
6+ PKG := github.com/open-source-cloud/devstack
67VERSION_PKG := $(PKG ) /internal/version
78VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo dev)
89COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null || echo none)
@@ -12,9 +13,15 @@ LDFLAGS := -s -w \
1213 -X $(VERSION_PKG ) .Commit=$(COMMIT ) \
1314 -X $(VERSION_PKG ) .Date=$(DATE )
1415
16+ # Where `make install` puts the binary: $XDG_BIN_HOME if set, else $(PREFIX)/bin
17+ # (~/.local/bin — the same place `devstack alias add` installs symlinks).
18+ # Override: make install PREFIX=/usr/local or make install BINDIR=/somewhere/bin
19+ PREFIX ?= $(HOME ) /.local
20+ BINDIR ?= $(or $(XDG_BIN_HOME ) ,$(PREFIX ) /bin)
21+
1522# The release binary MUST be CGO-free (static), but `go test -race` REQUIRES cgo.
1623# So CGO is set per-target, never globally.
17- .PHONY : build run test test-race test-one vet fmt fmt-check lint tidy vuln clean snapshot ci help
24+ .PHONY : build run test test-race test-one vet fmt fmt-check lint tidy vuln clean snapshot ci install uninstall smoke help
1825
1926build : # # Build the static binary into ./dist
2027 CGO_ENABLED=0 go build -trimpath -ldflags ' $(LDFLAGS)' -o dist/$(BINARY ) ./cmd/devstack
@@ -52,6 +59,42 @@ snapshot: ## Local goreleaser snapshot build (no publish)
5259
5360ci : fmt-check vet build test-race # # What CI runs
5461
62+ install : build # # Install the binary into $(BINDIR) (override with PREFIX= or XDG_BIN_HOME=)
63+ @install -d " $( BINDIR) "
64+ @install -m 0755 dist/$(BINARY ) " $( BINDIR) /$( BINARY) "
65+ @echo " installed $( BINDIR) /$( BINARY) ($( VERSION) )"
66+ @case " :$$ PATH:" in * " :$( BINDIR) :" * ) ;; * ) echo " note: $( BINDIR) is not on your PATH — add it to use \` $( BINARY) \` directly" ;; esac
67+
68+ uninstall : # # Remove the installed binary from $(BINDIR)
69+ @rm -f " $( BINDIR) /$( BINARY) " && echo " removed $( BINDIR) /$( BINARY) "
70+
71+ smoke : build # # Exercise the built binary end-to-end in an isolated XDG sandbox
72+ @set -eu; \
73+ bin=" $$ PWD/dist/$( BINARY) " ; \
74+ sandbox=" $$ (mktemp -d)" ; \
75+ trap ' rm -rf "$$sandbox"' EXIT; \
76+ export XDG_CONFIG_HOME=" $$ sandbox/config" XDG_DATA_HOME=" $$ sandbox/data" \
77+ XDG_STATE_HOME=" $$ sandbox/state" XDG_CACHE_HOME=" $$ sandbox/cache" \
78+ XDG_BIN_HOME=" $$ sandbox/bin" XDG_RUNTIME_DIR=" $$ sandbox/run" ; \
79+ printf ' \n== smoke: %s ==\n' " $$ bin" ; \
80+ echo " -> version is build-stamped" ; \
81+ " $$ bin" version | tee " $$ sandbox/version.txt" ; \
82+ grep -q ' commit' " $$ sandbox/version.txt" || { echo " FAIL: unexpected version output" ; exit 1; }; \
83+ echo " -> --help lists the command surface" ; \
84+ " $$ bin" --help 2>&1 | grep -q ' doctor' || { echo " FAIL: help missing 'doctor'" ; exit 1; }; \
85+ echo " -> alias add/list/remove round-trip" ; \
86+ " $$ bin" alias add rq > /dev/null; \
87+ test -L " $$ XDG_BIN_HOME/rq" || { echo " FAIL: alias symlink not created" ; exit 1; }; \
88+ " $$ bin" alias list | grep -qx ' rq' || { echo " FAIL: alias not listed" ; exit 1; }; \
89+ echo " -> argv[0] dispatch: the symlink runs the identical tree under its own name" ; \
90+ " $$ XDG_BIN_HOME/rq" version > /dev/null || { echo " FAIL: symlinked alias does not dispatch" ; exit 1; }; \
91+ " $$ bin" alias remove rq > /dev/null; \
92+ ! test -e " $$ XDG_BIN_HOME/rq" || { echo " FAIL: alias symlink not removed" ; exit 1; }; \
93+ echo " -> doctor --json emits the checks contract (a down daemon is OK here)" ; \
94+ " $$ bin" doctor --json > " $$ sandbox/doctor.json" 2> /dev/null || true ; \
95+ grep -q ' "checks"' " $$ sandbox/doctor.json" || { echo " FAIL: doctor --json missing \" checks\" " ; exit 1; }; \
96+ printf ' \n\033[32mok\033[0m smoke passed\n'
97+
5598clean :
5699 rm -rf dist
57100
0 commit comments