-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathMakefile
More file actions
94 lines (78 loc) · 3.38 KB
/
Makefile
File metadata and controls
94 lines (78 loc) · 3.38 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
SHELL := /bin/bash
ALL_RELEASES := $(sort $(patsubst subcomponents/releases/%.json,%,$(wildcard subcomponents/releases/*.json)))
# By default define RELEASE from Git tag
GIT_VERSION = $(shell git describe --tags --exact-match 2>/dev/null)
RELEASE ?= $(GIT_VERSION)
DESTDIR ?= /
prefix ?= $(DESTDIR)
inventorydir ?= /usr/share/mender/inventory
CONFLICTS_FORMAT ?= rpm
CONFLICTS_FILE ?= build/conflicts
help:
@echo 'Main commands:'
@echo ' build - Run all build-* targets'
@echo ' build-inventory-script - Build the inventory script'
@echo ' install - Run all install-* targets'
@echo ' install-inventory-script - Install the inventory script'
@echo ' generate-conflicts - Output conflicts string for package/recipe of this release'
@echo ' clean - Remove auto generated files'
@echo ''
@echo 'Using Mender Client release: $(RELEASE)'
@echo 'Available versions: $(ALL_RELEASES)'
@echo ''
@echo 'Use "RELEASE=... make" to specify a release. When not specified,'
@echo 'it defaults to the checked out Git tag. And if not in a Git tag,'
@echo 'it uses "unsupported" for the versions and generates no conflicts'
@echo ''
@echo 'Other commands:'
@echo ' check-dependencies - Check dependencies'
inventory-script/mender-inventory-client-version: build-inventory-script
build: build-inventory-script
build-inventory-script:
@if [ -z "$(RELEASE)" ]; then \
echo "Warning: No RELEASE specified, using 'unsupported'"; \
MENDER_CLIENT_VERSION=unsupported envsubst '$$MENDER_CLIENT_VERSION' < inventory-script/mender-inventory-client-version.in > inventory-script/mender-inventory-client-version; \
else \
test -f subcomponents/releases/$(RELEASE).json || { \
echo "Error: Release file subcomponents/releases/$(RELEASE).json not found"; \
exit 1; \
}; \
MENDER_CLIENT_VERSION=$$(jq -r '.version' subcomponents/releases/$(RELEASE).json); \
test "$$MENDER_CLIENT_VERSION" != "null" || { \
echo "Error: Could not extract version from subcomponents/releases/$(RELEASE).json"; \
exit 1; \
}; \
MENDER_CLIENT_VERSION=$$MENDER_CLIENT_VERSION envsubst '$$MENDER_CLIENT_VERSION' < inventory-script/mender-inventory-client-version.in > inventory-script/mender-inventory-client-version; \
fi
install: install-inventory-script
install-inventory-script: inventory-script/mender-inventory-client-version
install -d -m 755 $(prefix)$(inventorydir)
install -m 755 inventory-script/mender-inventory-client-version $(prefix)$(inventorydir)/
$(CONFLICTS_FILE): generate-conflicts
generate-conflicts:
@mkdir --parents $(shell dirname $(CONFLICTS_FILE))
@if [ -z "$(RELEASE)" ]; then \
echo "Warning: No RELEASE specified, generating empty conflicts file"; \
echo "" > $(CONFLICTS_FILE); \
else \
./generate-conflicts subcomponents/releases/$(RELEASE).json "$(CONFLICTS_FORMAT)" $(CONFLICTS_FILE); \
fi
check-dependencies:
@missing=""; \
for cmd in jq envsubst git; do \
which $$cmd >/dev/null 2>&1 || missing="$$missing $$cmd"; \
done; \
if [ -n "$$missing" ]; then \
echo "Error: The following required dependencies are missing:$$missing"; \
exit 1; \
fi
@echo "All dependencies are installed"
clean:
rm -rfv $(CONFLICTS_FILE)
rm -rfv inventory-script/mender-inventory-client-version
.PHONY: help
.PHONY: build
.PHONY: build-inventory-script
.PHONY: generate-conflicts
.PHONY: check-dependencies
.PHONY: clean