Skip to content

Commit ab125a6

Browse files
authored
507 makefile fixes (#611)
* Makefile updates Signed-off-by: Mihai Criveti <[email protected]> * Fix localpy port Signed-off-by: Mihai Criveti <[email protected]> * Fix shell-lint section Signed-off-by: Mihai Criveti <[email protected]> --------- Signed-off-by: Mihai Criveti <[email protected]>
1 parent 504f645 commit ab125a6

File tree

1 file changed

+46
-31
lines changed

1 file changed

+46
-31
lines changed

Makefile

Lines changed: 46 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -933,7 +933,9 @@ trivy:
933933
echo " • Or run: make trivy-install"; \
934934
exit 1; \
935935
}
936-
@systemctl --user enable --now podman.socket 2>/dev/null || true
936+
@if command -v systemctl >/dev/null 2>&1; then \
937+
systemctl --user enable --now podman.socket 2>/dev/null || true; \
938+
fi
937939
@echo "🔎 trivy vulnerability scan..."
938940
@trivy --format table --severity HIGH,CRITICAL image $(IMG)
939941

@@ -1157,16 +1159,11 @@ endef
11571159
# help: use-podman - Switch to Podman runtime
11581160
# help: show-runtime - Show current container runtime
11591161

1160-
# .PHONY: container-build container-run container-run-host container-run-ssl container-run-ssl-host \
1161-
# container-push container-info container-stop container-logs container-shell \
1162-
# container-health image-list image-clean image-retag container-check-image \
1163-
# container-build-multi use-docker use-podman show-runtime
1164-
11651162
.PHONY: container-build container-run container-run-ssl container-run-ssl-host \
1166-
container-push container-info container-stop container-logs container-shell \
1167-
container-health image-list image-clean image-retag container-check-image \
1168-
container-build-multi use-docker use-podman show-runtime print-runtime \
1169-
print-image container-validate-env container-check-ports container-wait-healthy
1163+
container-push container-info container-stop container-logs container-shell \
1164+
container-health image-list image-clean image-retag container-check-image \
1165+
container-build-multi use-docker use-podman show-runtime print-runtime \
1166+
print-image container-validate-env container-check-ports container-wait-healthy
11701167

11711168

11721169
# Containerfile to use (can be overridden)
@@ -1430,9 +1427,8 @@ show-runtime:
14301427
# help: container-check-ports - Check if required ports are available
14311428

14321429
# Pre-flight validation
1433-
.PHONY: container-validate check-ports
1430+
.PHONY: container-validate container-check-ports
14341431

1435-
# container-validate: container-validate-env check-ports
14361432
container-validate: container-validate-env container-check-ports
14371433
@echo "✅ All validations passed"
14381434

@@ -1446,7 +1442,7 @@ container-check-ports:
14461442
@echo "🔍 Checking port availability..."
14471443
@if ! command -v lsof >/dev/null 2>&1; then \
14481444
echo "⚠️ lsof not installed - skipping port check"; \
1449-
echo "💡 Install with: brew install lsof (macOS) or apt-get install lsof (Linux)"; \
1445+
echo "💡 Install with: brew install lsof (macOS) or apt-get install lsof (Linux)"; \
14501446
exit 0; \
14511447
fi
14521448
@failed=0; \
@@ -2268,7 +2264,7 @@ argocd-app-sync:
22682264
# =============================================================================
22692265
# help: 🏠 LOCAL PYPI SERVER
22702266
# help: local-pypi-install - Install pypiserver for local testing
2271-
# help: local-pypi-start - Start local PyPI server on :8084 (no auth)
2267+
# help: local-pypi-start - Start local PyPI server on :8085 (no auth)
22722268
# help: local-pypi-start-auth - Start local PyPI server with basic auth (admin/admin)
22732269
# help: local-pypi-stop - Stop local PyPI server
22742270
# help: local-pypi-upload - Upload existing package to local PyPI (no auth)
@@ -2290,12 +2286,12 @@ local-pypi-install:
22902286
@mkdir -p $(LOCAL_PYPI_DIR)
22912287

22922288
local-pypi-start: local-pypi-install local-pypi-stop
2293-
@echo "🚀 Starting local PyPI server on http://localhost:8084..."
2289+
@echo "🚀 Starting local PyPI server on http://localhost:8085..."
22942290
@/bin/bash -c "source $(VENV_DIR)/bin/activate && \
22952291
export PYPISERVER_BOTTLE_MEMFILE_MAX_OVERRIDE_BYTES=10485760 && \
2296-
pypi-server run -p 8084 -a . -P . $(LOCAL_PYPI_DIR) --hash-algo=sha256 & echo \$! > $(LOCAL_PYPI_PID)"
2292+
pypi-server run -p 8085 -a . -P . $(LOCAL_PYPI_DIR) --hash-algo=sha256 & echo \$! > $(LOCAL_PYPI_PID)"
22972293
@sleep 2
2298-
@echo "✅ Local PyPI server started at http://localhost:8084"
2294+
@echo "✅ Local PyPI server started at http://localhost:8085"
22992295
@echo "📂 Package directory: $(LOCAL_PYPI_DIR)"
23002296
@echo "🔓 No authentication required (open mode)"
23012297

@@ -2340,14 +2336,14 @@ local-pypi-upload:
23402336
echo "❌ No dist/ directory or files found. Run 'make dist' first."; \
23412337
exit 1; \
23422338
fi
2343-
@if ! curl -s http://localhost:8084 >/dev/null 2>&1; then \
2344-
echo "❌ Local PyPI server not running on port 8084. Run 'make local-pypi-start' first."; \
2339+
@if ! curl -s $(LOCAL_PYPI_URL) >/dev/null 2>&1; then \
2340+
echo "❌ Local PyPI server not running on port 8085. Run 'make local-pypi-start' first."; \
23452341
exit 1; \
23462342
fi
23472343
@/bin/bash -c "source $(VENV_DIR)/bin/activate && \
2348-
twine upload --verbose --repository-url http://localhost:8084 --skip-existing dist/*"
2344+
twine upload --verbose --repository-url $(LOCAL_PYPI_URL) --skip-existing dist/*"
23492345
@echo "✅ Package uploaded to local PyPI"
2350-
@echo "🌐 Browse packages: http://localhost:8084"
2346+
@echo "🌐 Browse packages: $(LOCAL_PYPI_URL)"
23512347

23522348
local-pypi-upload-auth:
23532349
@echo "📤 Uploading existing package to local PyPI with auth..."
@@ -2387,9 +2383,7 @@ local-pypi-status:
23872383
@echo "🔍 Local PyPI server status:"
23882384
@if [ -f $(LOCAL_PYPI_PID) ] && kill -0 $(cat $(LOCAL_PYPI_PID)) 2>/dev/null; then \
23892385
echo "✅ Server running (PID: $(cat $(LOCAL_PYPI_PID)))"; \
2390-
if curl -s http://localhost:8084 >/dev/null 2>&1; then \
2391-
echo "🌐 Server on port 8084: http://localhost:8084"; \
2392-
elif curl -s $(LOCAL_PYPI_URL) >/dev/null 2>&1; then \
2386+
if curl -s $(LOCAL_PYPI_URL) >/dev/null 2>&1; then \
23932387
echo "🌐 Server on port 8085: $(LOCAL_PYPI_URL)"; \
23942388
fi; \
23952389
echo "📂 Directory: $(LOCAL_PYPI_DIR)"; \
@@ -2679,6 +2673,8 @@ SHELL_SCRIPTS := $(shell find . -type f -name '*.sh' \
26792673
-not -path './build/*' \
26802674
-not -path './.tox/*')
26812675

2676+
# Define shfmt binary location
2677+
SHFMT := $(shell command -v shfmt 2>/dev/null || echo "$(HOME)/go/bin/shfmt")
26822678

26832679
.PHONY: shell-linters-install shell-lint shfmt-fix shellcheck bashate
26842680

@@ -2697,15 +2693,21 @@ shell-linters-install: ## 🔧 Install shellcheck, shfmt, bashate
26972693
esac ; \
26982694
fi ; \
26992695
# -------- shfmt (Go) -------- \
2700-
if ! command -v shfmt >/dev/null 2>&1 ; then \
2696+
if ! command -v shfmt >/dev/null 2>&1 && [ ! -f "$(HOME)/go/bin/shfmt" ] ; then \
27012697
echo "🛠 Installing shfmt..." ; \
27022698
if command -v go >/dev/null 2>&1; then \
27032699
GO111MODULE=on go install mvdan.cc/sh/v3/cmd/shfmt@latest; \
2704-
mkdir -p $(VENV_DIR)/bin; \
2705-
ln -sf $$HOME/go/bin/shfmt $(VENV_DIR)/bin/shfmt 2>/dev/null || true; \
2700+
echo "✅ shfmt installed to $(HOME)/go/bin/shfmt"; \
27062701
else \
2707-
echo "⚠️ Go not found - install Go or brew/apt shfmt package manually"; \
2702+
case "$$(uname -s)" in \
2703+
Darwin) brew install shfmt ;; \
2704+
Linux) { command -v apt-get && sudo apt-get update -qq && sudo apt-get install -y shfmt ; } || \
2705+
{ echo "⚠️ Go not found - install Go or shfmt package manually"; } ;; \
2706+
*) echo "⚠️ Please install shfmt manually" ;; \
2707+
esac ; \
27082708
fi ; \
2709+
else \
2710+
echo "✅ shfmt already installed at: $$(command -v shfmt || echo $(HOME)/go/bin/shfmt)"; \
27092711
fi ; \
27102712
# -------- bashate (pip) ----- \
27112713
if ! $(VENV_DIR)/bin/bashate -h >/dev/null 2>&1 ; then \
@@ -2719,10 +2721,14 @@ shell-linters-install: ## 🔧 Install shellcheck, shfmt, bashate
27192721

27202722
shell-lint: shell-linters-install ## 🔍 Run shfmt, ShellCheck & bashate
27212723
@echo "🔍 Running shfmt (diff-only)..."
2722-
@command -v shfmt >/dev/null 2>&1 || { \
2724+
@if command -v shfmt >/dev/null 2>&1; then \
2725+
shfmt -d -i 4 -ci $(SHELL_SCRIPTS) || true; \
2726+
elif [ -f "$(SHFMT)" ]; then \
2727+
$(SHFMT) -d -i 4 -ci $(SHELL_SCRIPTS) || true; \
2728+
else \
27232729
echo "⚠️ shfmt not installed - skipping"; \
27242730
echo "💡 Install with: go install mvdan.cc/sh/v3/cmd/shfmt@latest"; \
2725-
} && shfmt -d -i 4 -ci $(SHELL_SCRIPTS) || true
2731+
fi
27262732
@echo "🔍 Running ShellCheck..."
27272733
@command -v shellcheck >/dev/null 2>&1 || { \
27282734
echo "⚠️ shellcheck not installed - skipping"; \
@@ -2735,7 +2741,16 @@ shell-lint: shell-linters-install ## 🔍 Run shfmt, ShellCheck & bashate
27352741

27362742
shfmt-fix: shell-linters-install ## 🎨 Auto-format *.sh in place
27372743
@echo "🎨 Formatting shell scripts with shfmt -w..."
2738-
@shfmt -w -i 4 -ci $(SHELL_SCRIPTS)
2744+
@if command -v shfmt >/dev/null 2>&1; then \
2745+
shfmt -w -i 4 -ci $(SHELL_SCRIPTS); \
2746+
elif [ -f "$(SHFMT)" ]; then \
2747+
$(SHFMT) -w -i 4 -ci $(SHELL_SCRIPTS); \
2748+
else \
2749+
echo "❌ shfmt not found in PATH or $(HOME)/go/bin/"; \
2750+
echo "💡 Install with: go install mvdan.cc/sh/v3/cmd/shfmt@latest"; \
2751+
echo " Or: brew install shfmt (macOS)"; \
2752+
exit 1; \
2753+
fi
27392754
@echo "✅ shfmt formatting done."
27402755

27412756

0 commit comments

Comments
 (0)