blob: be50245d1fd7a951b61e73bb95e1c93fd121144f [file] [log] [blame]
Stephen Cpreke7254c72015-02-19 14:33:38 -06001################################################################################
2#
3# pkg-versions
4#
5# Read VERSION.readme in the current directory to learn about the version
6# string structure
7#
8################################################################################
9
10define OPENPOWER_SUBPACKAGE_VERSION
11
12$(2)_VERSION_FILE = $$(OPENPOWER_VERSION_DIR)/$(1).version.txt
13ALL_SUBPACKAGE_VERSIONS += $$($(2)_VERSION_FILE)
14
15### Create subpackage patch file
16define $(2)_OPENPOWER_PATCH_FILE
17
18mkdir -p "$$(OPENPOWER_VERSION_DIR)";
19
20# Remove patch file to start off fresh
21if [ -f $$(OPENPOWER_VERSION_DIR)/$(1).patch.txt ]; then \
22 rm -rf $$(OPENPOWER_VERSION_DIR)/$(1).patch.txt; \
23fi
24
25# Check all global patch directories
26$$(foreach path, $$(BR2_GLOBAL_PATCH_DIR),if ls $$(path)/$(1)/*.patch 2>/dev/null; then \
27 sha512sum $$(path)/$(1)/*.patch | sha512sum | \
28 xargs echo >> $$(OPENPOWER_VERSION_DIR)/$(1).tmp_patch.txt; fi;)
29
30# Check the package patch dir, $$(PKGDIR) doesn't exist when running the version rules
31if [ -n "$$(PKGDIR)" ]; then \
32 if ls $$(PKGDIR)*.patch 2>/dev/null; then sha512sum $$(PKGDIR)*.patch | sha512sum | \
33 xargs echo >> $$(OPENPOWER_VERSION_DIR)/$(1).tmp_patch.txt; \
34 fi; \
35else \
Joel Stanley5ab5fdb2016-10-31 23:10:24 +103036 if ls $$(BR2_EXTERNAL_OP_BUILD_PATH)/package/$(1)/*.patch 2>/dev/null; then sha512sum \
37 $$(BR2_EXTERNAL_OP_BUILD_PATH)/package/$(1)/*.patch | sha512sum | \
Stephen Cpreke7254c72015-02-19 14:33:38 -060038 xargs echo >> $$(OPENPOWER_VERSION_DIR)/$(1).tmp_patch.txt; \
39 fi; \
40fi
41
Sam Mendoza-Jonase56617a2016-03-09 11:59:08 +110042# If this is for linux, also check openpower/linux
Stewart Smithfd7a2262017-02-17 17:20:54 +110043if [ "LINUX" == "$(2)" ]; then \
Joel Stanley5ab5fdb2016-10-31 23:10:24 +103044 if ls $$(BR2_EXTERNAL_OP_BUILD_PATH)/$(1)/*.patch 2>/dev/null; then sha512sum \
45 $$(BR2_EXTERNAL_OP_BUILD_PATH)/$(1)/*.patch | sha512sum | \
Sam Mendoza-Jonase56617a2016-03-09 11:59:08 +110046 xargs echo >> $$(OPENPOWER_VERSION_DIR)/$(1).tmp_patch.txt; \
47 fi; \
48fi;
49
Stephen Cpreke7254c72015-02-19 14:33:38 -060050# Combine all the patches found in the package and global package directories
51if [ -f $$(OPENPOWER_VERSION_DIR)/$(1).tmp_patch.txt ]; then \
52 cat $$(OPENPOWER_VERSION_DIR)/$(1).tmp_patch.txt | sha512sum | cut -c 1-7 | \
53 xargs echo -n > $$(OPENPOWER_VERSION_DIR)/$(1).patch.txt; \
54fi
55
56# Remove the tmp_patch file
57if [ -f $$(OPENPOWER_VERSION_DIR)/$(1).tmp_patch.txt ]; then \
58 rm -rf $$(OPENPOWER_VERSION_DIR)/$(1).tmp_patch.txt; \
59fi
60
61endef ###
62
63### Create subpackage version file
64define $(2)_OPENPOWER_VERSION_FILE
65
66mkdir -p "$$(OPENPOWER_VERSION_DIR)"
67
68# Add package name
69echo -n " $(1)-" > $$($(2)_VERSION_FILE)
70
71# If site local
72# Add site local and user, local commit, if local is dirty
73# Else not local
Sam Mendoza-Jonasddc5fab2016-03-11 14:37:04 +110074# Add package version, extraversion if linux, op-build is dirty, op-build patches
Stephen Cpreke7254c72015-02-19 14:33:38 -060075if [ "$$($(2)_SITE_METHOD)" == "local" ]; then \
76echo -n "site_local-" >> $$($(2)_VERSION_FILE); \
77whoami | xargs echo -n >> $$($(2)_VERSION_FILE); \
78echo -n "-" >> $$($(2)_VERSION_FILE); \
79\
Stewart Smithfd7a2262017-02-17 17:20:54 +110080cd "$$($(2)_SITE)"; (git describe --always --dirty || echo "unknown") \
81 |sed -e 's/$(1)-//' | xargs echo -n\
Stephen Cpreke7254c72015-02-19 14:33:38 -060082 >> $$($(2)_VERSION_FILE); \
83\
Stephen Cpreke7254c72015-02-19 14:33:38 -060084else \
85\
86[ `echo -n $$($(2)_VERSION) | wc -c` == "40" ] && (echo -n $$($(2)_VERSION) | \
Stewart Smith93157d12015-05-14 16:01:44 +100087 sed "s/^\([0-9a-f]\{7\}\).*/\1/;s/$(1)-//;" >> $$($(2)_VERSION_FILE)) \
88 || echo -n $$($(2)_VERSION) | sed -e 's/$(1)-//' >> $$($(2)_VERSION_FILE); \
Stephen Cpreke7254c72015-02-19 14:33:38 -060089\
Stewart Smithfd7a2262017-02-17 17:20:54 +110090if [ "LINUX" == "$(2)" ]; then \
Sam Mendoza-Jonasddc5fab2016-03-11 14:37:04 +110091 if ls $$(BUILD_DIR)/$(1)-$$($(2)_VERSION)/Makefile 1>/dev/null; then \
92 head $$(BUILD_DIR)/$(1)-$$($(2)_VERSION)/Makefile | grep EXTRAVERSION \
93 | cut -d ' ' -f 3 | \
94 xargs echo -n >> $$($(2)_VERSION_FILE); \
95 fi; \
96fi; \
97\
Stephen Cpreke7254c72015-02-19 14:33:38 -060098if [ -f $$(OPENPOWER_VERSION_DIR)/$(1).patch.txt ]; then \
Stewart Smithfd7a2262017-02-17 17:20:54 +110099 echo -n "-p" >> $$($(2)_VERSION_FILE); \
Stephen Cpreke7254c72015-02-19 14:33:38 -0600100 cat $$(OPENPOWER_VERSION_DIR)/$(1).patch.txt >> $$($(2)_VERSION_FILE); fi \
101fi
102
103# Add new line to version.txt
104echo "" >> $$($(2)_VERSION_FILE);
105
106endef ###
107
108# Add appropriate templates to hooks
109$(2)_POST_PATCH_HOOKS += $(2)_OPENPOWER_PATCH_FILE
Samuel Mendoza-Jonasd38455d2016-07-15 16:32:18 +1000110$(2)_PRE_CONFIGURE_HOOKS += $(2)_OPENPOWER_VERSION_FILE
Stephen Cpreke7254c72015-02-19 14:33:38 -0600111
112# Top-level rule to print or generate a subpackage version
113$(1)-version: $$(if $$(wildcard $$($(2)_VERSION_FILE)),$(1)-print-version,$(1)-build-version)
114
115# Rule to print out subpackage version
116$(1)-print-version:
117 @echo "=== $(2)_VERSION ==="
118 @cat $$($(2)_VERSION_FILE) | xargs echo
119
120# Rule to generate subpackage version
121$(1)-build-version:
122 @echo "=== $(2)_VERSION ==="
123 @echo " Searching for patches..."
124 @$$($(2)_OPENPOWER_PATCH_FILE)
125 @echo " End of patches...";
126 @echo " Creating version string (various output may display)..."
127 @$$($(2)_OPENPOWER_VERSION_FILE)
128 @echo " End creating version string..."
129 @echo -n " version: "; cat $$($(2)_VERSION_FILE) | xargs echo
130
131endef
132
133define OPENPOWER_VERSION
134
135UPPER_CASE_PKG = $(call UPPERCASE,$(1))
136$$(UPPER_CASE_PKG)_VERSION_FILE = $$(OPENPOWER_VERSION_DIR)/$(1).version.txt
Nick Bofferding6fafd622017-09-28 15:23:23 -0500137UPPER_CASE_SIGN_MODE = $(call UPPERCASE,$$(BR2_OPENPOWER_SECUREBOOT_SIGN_MODE))
Stephen Cpreke7254c72015-02-19 14:33:38 -0600138
139$$(eval $$(foreach pkg,$$(OPENPOWER_VERSIONED_SUBPACKAGES), \
140 $$(call OPENPOWER_SUBPACKAGE_VERSION,$$(pkg),$$(call UPPERCASE,$$(pkg)))))
141
142### Combine subpackage files into one version file
143define $$(UPPER_CASE_PKG)_OPENPOWER_VERSION_FILE
144
145mkdir -p "$$(OPENPOWER_VERSION_DIR)"
146
147# Add vendor or default open-power
Stewart Smithfd7a2262017-02-17 17:20:54 +1100148if [ -n "$$(OPBUILD_VENDOR)" ]; then \
Stephen Cpreke7254c72015-02-19 14:33:38 -0600149echo -n "$$(OPBUILD_VENDOR)-" > $$($$(UPPER_CASE_PKG)_VERSION_FILE); \
150else \
151echo -n "open-power-" > $$($$(UPPER_CASE_PKG)_VERSION_FILE); \
152fi
153
154# Add platform or default from defconfig
Stewart Smithfd7a2262017-02-17 17:20:54 +1100155if [ -n "$$(OPBUILD_PLATFORM)" ]; then \
Stephen Cpreke7254c72015-02-19 14:33:38 -0600156echo -n "$$(OPBUILD_PLATFORM)-" >> $$($$(UPPER_CASE_PKG)_VERSION_FILE); \
157else \
158echo -n "$$(BR2_OPENPOWER_CONFIG_NAME)-" >> $$($$(UPPER_CASE_PKG)_VERSION_FILE); \
159fi
160
161# Add op-build version
162# Order: OPBUILD_VERSION, tag, commit, unknown
Stewart Smithfd7a2262017-02-17 17:20:54 +1100163if [ -n "$$(OPBUILD_VERSION)" ]; then \
Stephen Cpreke7254c72015-02-19 14:33:38 -0600164 echo -n "$$(OPBUILD_VERSION)" >> $$($$(UPPER_CASE_PKG)_VERSION_FILE); \
165else \
Stewart Smithfd7a2262017-02-17 17:20:54 +1100166cd "$$(BR2_EXTERNAL_OP_BUILD_PATH)"; (git describe --always --dirty || echo "unknown") \
167 | xargs echo -n \
Stephen Cpreke7254c72015-02-19 14:33:38 -0600168 >> $$($$(UPPER_CASE_PKG)_VERSION_FILE); \
169fi
170
Nick Bofferding6fafd622017-09-28 15:23:23 -0500171# Flag whether op-build is production signed
172if [ "$$(UPPER_CASE_SIGN_MODE)" == 'PRODUCTION' ]; then \
173 echo -n "-prod" >> $$($$(UPPER_CASE_PKG)_VERSION_FILE); \
174fi
175
Stephen Cpreke7254c72015-02-19 14:33:38 -0600176# Add new line to $$($$(UPPER_CASE_PKG)_VERSION_FILE)
177echo "" >> $$($$(UPPER_CASE_PKG)_VERSION_FILE);
178
Sam Mendoza-Jonasdc7e2382016-03-09 16:13:02 +1100179# Add a specific line for op-build if it has been overwritten
Stewart Smithfd7a2262017-02-17 17:20:54 +1100180if [ -n "$$(OPBUILD_VENDOR)" ]; then \
Sam Mendoza-Jonasdc7e2382016-03-09 16:13:02 +1100181echo -n " op-build-" >> $$($$(UPPER_CASE_PKG)_VERSION_FILE); \
Stewart Smithfd7a2262017-02-17 17:20:54 +1100182(cd "$$(BR2_EXTERNAL_OP_BUILD_PATH)"; (git describe --always --dirty || echo "unknown")) \
183 | xargs echo \
Sam Mendoza-Jonasdc7e2382016-03-09 16:13:02 +1100184 >> $$($$(UPPER_CASE_PKG)_VERSION_FILE); \
Sam Mendoza-Jonasdc7e2382016-03-09 16:13:02 +1100185fi
186
187# Include the currently checked-out buildroot version
188echo -n " buildroot-" >> $$($$(UPPER_CASE_PKG)_VERSION_FILE);
Stewart Smithfd7a2262017-02-17 17:20:54 +1100189(git describe --always --dirty || echo "unknown") \
190 | xargs echo \
Sam Mendoza-Jonasdc7e2382016-03-09 16:13:02 +1100191 >> $$($$(UPPER_CASE_PKG)_VERSION_FILE); \
Sam Mendoza-Jonasdc7e2382016-03-09 16:13:02 +1100192
193
Stephen Cpreke7254c72015-02-19 14:33:38 -0600194# Combing subpackage version files into $$($$(UPPER_CASE_PKG)_VERSION_FILE)
195$$(foreach verFile,$$(ALL_SUBPACKAGE_VERSIONS),
196 if [ -f $$(verFile) ]; then cat $$(verFile) \
197 >> $$($$(UPPER_CASE_PKG)_VERSION_FILE); fi )
198
199endef ###
200
201$$(UPPER_CASE_PKG)_PRE_BUILD_HOOKS += $$(UPPER_CASE_PKG)_OPENPOWER_VERSION_FILE
202
203# Top-level rule to print or generate openpower-pnor version
204$(1)-version: $$(if $$(wildcard $$($$(UPPER_CASE_PKG)_VERSION_FILE)),$(1)-print-version,$(1)-build-version)
205
206# Rule to print out pnor version
207$(1)-print-version:
208 @echo "=== $$(UPPER_CASE_PKG)_VERSION ==="
209 @cat $$($$(UPPER_CASE_PKG)_VERSION_FILE)
210 @echo ""; echo "**See openpower/package/VERSION.readme for detailed info on package strings"; echo ""
211
Stephen Cpreke7254c72015-02-19 14:33:38 -0600212# Rule to generate pnor version
213$(1)-build-version: $$(foreach pkg,$$(OPENPOWER_VERSIONED_SUBPACKAGES), $$(pkg)-version)
214 @$$($$(UPPER_CASE_PKG)_OPENPOWER_VERSION_FILE)
215 @echo "=== $$(UPPER_CASE_PKG)_VERSION ==="
216 @cat $$($$(UPPER_CASE_PKG)_VERSION_FILE)
217 @echo ""; echo "**See openpower/package/VERSION.readme for detailed info on package strings"; echo ""
218
Stephen Cprekded98fb2015-04-15 17:11:52 -0500219# Rule to force re-generation of all versioned subpackages
220$(1)-build-version-all: $$(foreach pkg,$$(OPENPOWER_VERSIONED_SUBPACKAGES), $$(pkg)-build-version)
221 @$$($$(UPPER_CASE_PKG)_OPENPOWER_VERSION_FILE)
222 @echo "=== $$(UPPER_CASE_PKG)_VERSION ==="
223 @cat $$($$(UPPER_CASE_PKG)_VERSION_FILE)
224 @echo ""; echo "**See openpower/package/VERSION.readme for detailed info on package strings"; echo ""
225
Stephen Cpreke7254c72015-02-19 14:33:38 -0600226endef