blob: 39c608fd8fb8936c13ed5285a699274f8fb39830 [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
Deb McLemore68215012022-02-11 10:59:34 -060013$(2)_FW_VERSION_SHORT_FILE = $$(OPENPOWER_VERSION_DIR)/$(1).fwversion_short.txt
14$(2)_FW_VERSION_LONG_FILE = $$(OPENPOWER_VERSION_DIR)/$(1).fwversion_long.txt
Stephen Cpreke7254c72015-02-19 14:33:38 -060015ALL_SUBPACKAGE_VERSIONS += $$($(2)_VERSION_FILE)
16
17### Create subpackage patch file
18define $(2)_OPENPOWER_PATCH_FILE
19
20mkdir -p "$$(OPENPOWER_VERSION_DIR)";
21
22# Remove patch file to start off fresh
23if [ -f $$(OPENPOWER_VERSION_DIR)/$(1).patch.txt ]; then \
24 rm -rf $$(OPENPOWER_VERSION_DIR)/$(1).patch.txt; \
25fi
26
27# Check all global patch directories
28$$(foreach path, $$(BR2_GLOBAL_PATCH_DIR),if ls $$(path)/$(1)/*.patch 2>/dev/null; then \
29 sha512sum $$(path)/$(1)/*.patch | sha512sum | \
30 xargs echo >> $$(OPENPOWER_VERSION_DIR)/$(1).tmp_patch.txt; fi;)
31
32# Check the package patch dir, $$(PKGDIR) doesn't exist when running the version rules
33if [ -n "$$(PKGDIR)" ]; then \
34 if ls $$(PKGDIR)*.patch 2>/dev/null; then sha512sum $$(PKGDIR)*.patch | sha512sum | \
35 xargs echo >> $$(OPENPOWER_VERSION_DIR)/$(1).tmp_patch.txt; \
36 fi; \
37else \
Joel Stanley5ab5fdb2016-10-31 23:10:24 +103038 if ls $$(BR2_EXTERNAL_OP_BUILD_PATH)/package/$(1)/*.patch 2>/dev/null; then sha512sum \
39 $$(BR2_EXTERNAL_OP_BUILD_PATH)/package/$(1)/*.patch | sha512sum | \
Stephen Cpreke7254c72015-02-19 14:33:38 -060040 xargs echo >> $$(OPENPOWER_VERSION_DIR)/$(1).tmp_patch.txt; \
41 fi; \
42fi
43
Sam Mendoza-Jonase56617a2016-03-09 11:59:08 +110044# If this is for linux, also check openpower/linux
Stewart Smithfd7a2262017-02-17 17:20:54 +110045if [ "LINUX" == "$(2)" ]; then \
Joel Stanley5ab5fdb2016-10-31 23:10:24 +103046 if ls $$(BR2_EXTERNAL_OP_BUILD_PATH)/$(1)/*.patch 2>/dev/null; then sha512sum \
47 $$(BR2_EXTERNAL_OP_BUILD_PATH)/$(1)/*.patch | sha512sum | \
Sam Mendoza-Jonase56617a2016-03-09 11:59:08 +110048 xargs echo >> $$(OPENPOWER_VERSION_DIR)/$(1).tmp_patch.txt; \
49 fi; \
50fi;
51
Stephen Cpreke7254c72015-02-19 14:33:38 -060052# Combine all the patches found in the package and global package directories
53if [ -f $$(OPENPOWER_VERSION_DIR)/$(1).tmp_patch.txt ]; then \
54 cat $$(OPENPOWER_VERSION_DIR)/$(1).tmp_patch.txt | sha512sum | cut -c 1-7 | \
55 xargs echo -n > $$(OPENPOWER_VERSION_DIR)/$(1).patch.txt; \
56fi
57
58# Remove the tmp_patch file
59if [ -f $$(OPENPOWER_VERSION_DIR)/$(1).tmp_patch.txt ]; then \
60 rm -rf $$(OPENPOWER_VERSION_DIR)/$(1).tmp_patch.txt; \
61fi
62
Klaus Heinrich Kiwid2551242020-07-16 16:59:04 -030063endef # $(2)_OPENPOWER_PATCH_FILE
Stephen Cpreke7254c72015-02-19 14:33:38 -060064
65### Create subpackage version file
66define $(2)_OPENPOWER_VERSION_FILE
67
68mkdir -p "$$(OPENPOWER_VERSION_DIR)"
69
70# Add package name
71echo -n " $(1)-" > $$($(2)_VERSION_FILE)
72
73# If site local
74# Add site local and user, local commit, if local is dirty
75# Else not local
Sam Mendoza-Jonasddc5fab2016-03-11 14:37:04 +110076# Add package version, extraversion if linux, op-build is dirty, op-build patches
Stephen Cpreke7254c72015-02-19 14:33:38 -060077if [ "$$($(2)_SITE_METHOD)" == "local" ]; then \
78echo -n "site_local-" >> $$($(2)_VERSION_FILE); \
79whoami | xargs echo -n >> $$($(2)_VERSION_FILE); \
80echo -n "-" >> $$($(2)_VERSION_FILE); \
81\
Stewart Smithfd7a2262017-02-17 17:20:54 +110082cd "$$($(2)_SITE)"; (git describe --always --dirty || echo "unknown") \
83 |sed -e 's/$(1)-//' | xargs echo -n\
Stephen Cpreke7254c72015-02-19 14:33:38 -060084 >> $$($(2)_VERSION_FILE); \
85\
Stephen Cpreke7254c72015-02-19 14:33:38 -060086else \
87\
88[ `echo -n $$($(2)_VERSION) | wc -c` == "40" ] && (echo -n $$($(2)_VERSION) | \
Stewart Smith93157d12015-05-14 16:01:44 +100089 sed "s/^\([0-9a-f]\{7\}\).*/\1/;s/$(1)-//;" >> $$($(2)_VERSION_FILE)) \
90 || echo -n $$($(2)_VERSION) | sed -e 's/$(1)-//' >> $$($(2)_VERSION_FILE); \
Stephen Cpreke7254c72015-02-19 14:33:38 -060091\
Stewart Smithfd7a2262017-02-17 17:20:54 +110092if [ "LINUX" == "$(2)" ]; then \
Sam Mendoza-Jonasddc5fab2016-03-11 14:37:04 +110093 if ls $$(BUILD_DIR)/$(1)-$$($(2)_VERSION)/Makefile 1>/dev/null; then \
94 head $$(BUILD_DIR)/$(1)-$$($(2)_VERSION)/Makefile | grep EXTRAVERSION \
95 | cut -d ' ' -f 3 | \
96 xargs echo -n >> $$($(2)_VERSION_FILE); \
97 fi; \
98fi; \
99\
Stephen Cpreke7254c72015-02-19 14:33:38 -0600100if [ -f $$(OPENPOWER_VERSION_DIR)/$(1).patch.txt ]; then \
Stewart Smithfd7a2262017-02-17 17:20:54 +1100101 echo -n "-p" >> $$($(2)_VERSION_FILE); \
Stephen Cpreke7254c72015-02-19 14:33:38 -0600102 cat $$(OPENPOWER_VERSION_DIR)/$(1).patch.txt >> $$($(2)_VERSION_FILE); fi \
103fi
104
Deb McLemore68215012022-02-11 10:59:34 -0600105# Check the package name against HOSTBOOT_P to filter out other
106# packages such as HOSTBOOT_BINARIES, we only want HOSTBOOT_P10, HOSTBOOT_P11, etc.
107# This allows future usage of this logic since the Hostboot repo build process
108# seeds from this output file and does -NOT- know about package names, etc.
109# All Hostboot repo build needs is the git hashes built which are cat'd to the
110# _FW_VERSION_*_FILE
111#
112# If OPBUILD_VERSION is used in the environment then we trim
113# the string since we are limited to 16 chars for the PELs in Hostboot.
114# If OPBUILD_VERSION is empty we run the git commands to get the hashes.
115# Sample OPBUILD_VERSION OP10-v2.7-10.146 gets trimmed to v2.7-10.146
116# sed 's/[^\-]*-//' up until first dash
117#
118# The *_FW_VERSION_SHORT_FILE is the FW subsystem identifier to aide
119# mapping op-build images to proper build level. The FW subsystem
120# string is subsequently embedded in the Hostboot images built.
121#
122$(if $(findstring HOSTBOOT_P, $(2)),
123if [ -n "$$(OPBUILD_VERSION)" ]; then \
124 echo -n "$$(OPBUILD_VERSION)" \
125 | sed 's/[^\-]*-//' | xargs echo -n\
126 > $$($(2)_FW_VERSION_SHORT_FILE); \
127else \
128cd "$$(BR2_EXTERNAL_OP_BUILD_PATH)"; (git describe --always || echo "unknown") \
129 | sed -e 's/\(.*\)-.*/\1/' | xargs echo -n\
130 > $$($(2)_FW_VERSION_SHORT_FILE); \
131fi\)
132
133# Remove with sed any empty line
134# /./ matches any character, including newline
135# ! negates the select, makes the command apply to lines which do -NOT- match selector, i.e. empty lines
136# d deletes the selected lines
137# sed `/./!d'
138$(if $(findstring HOSTBOOT_P, $(2)),
139cd "$$(BR2_EXTERNAL_OP_BUILD_PATH)"; (git describe --always --long || echo "unknown") \
140 | sed '/./!d' | xargs echo -n\
141 > $$($(2)_FW_VERSION_LONG_FILE); \)
142
Stephen Cpreke7254c72015-02-19 14:33:38 -0600143# Add new line to version.txt
144echo "" >> $$($(2)_VERSION_FILE);
Deb McLemore68215012022-02-11 10:59:34 -0600145echo "" >> $$($(2)_FW_VERSION_SHORT_FILE);
146echo "" >> $$($(2)_FW_VERSION_LONG_FILE);
Stephen Cpreke7254c72015-02-19 14:33:38 -0600147
Klaus Heinrich Kiwid2551242020-07-16 16:59:04 -0300148endef # $(2)_OPENPOWER_VERSION_FILE
Stephen Cpreke7254c72015-02-19 14:33:38 -0600149
Klaus Heinrich Kiwid2551242020-07-16 16:59:04 -0300150# Add appropriate templates to hooks if they're not there already
151ifeq (,$$(findstring $(2)_OPENPOWER_PATCH_FILE,$$($(2)_POST_PATCH_HOOKS)))
Stephen Cpreke7254c72015-02-19 14:33:38 -0600152$(2)_POST_PATCH_HOOKS += $(2)_OPENPOWER_PATCH_FILE
Klaus Heinrich Kiwid2551242020-07-16 16:59:04 -0300153endif
154ifeq (,$$(findstring $(2)_OPENPOWER_VERSION_FILE,$$($(2)_PRE_CONFIGURE_HOOKS)))
Samuel Mendoza-Jonasd38455d2016-07-15 16:32:18 +1000155$(2)_PRE_CONFIGURE_HOOKS += $(2)_OPENPOWER_VERSION_FILE
Klaus Heinrich Kiwid2551242020-07-16 16:59:04 -0300156endif
Stephen Cpreke7254c72015-02-19 14:33:38 -0600157
158# Top-level rule to print or generate a subpackage version
159$(1)-version: $$(if $$(wildcard $$($(2)_VERSION_FILE)),$(1)-print-version,$(1)-build-version)
160
161# Rule to print out subpackage version
162$(1)-print-version:
163 @echo "=== $(2)_VERSION ==="
164 @cat $$($(2)_VERSION_FILE) | xargs echo
165
166# Rule to generate subpackage version
167$(1)-build-version:
168 @echo "=== $(2)_VERSION ==="
169 @echo " Searching for patches..."
170 @$$($(2)_OPENPOWER_PATCH_FILE)
171 @echo " End of patches...";
172 @echo " Creating version string (various output may display)..."
173 @$$($(2)_OPENPOWER_VERSION_FILE)
174 @echo " End creating version string..."
175 @echo -n " version: "; cat $$($(2)_VERSION_FILE) | xargs echo
176
Klaus Heinrich Kiwid2551242020-07-16 16:59:04 -0300177endef # OPENPOWER_SUBPACKAGE_VERSION
Stephen Cpreke7254c72015-02-19 14:33:38 -0600178
Stephen Cpreke7254c72015-02-19 14:33:38 -0600179
Klaus Heinrich Kiwid2551242020-07-16 16:59:04 -0300180####
181# $(1) is the lowercase package version
Daniel Crowell2aa26f32022-01-27 16:14:28 -0600182# $(2) is the uppercase package version
Klaus Heinrich Kiwid2551242020-07-16 16:59:04 -0300183####
184define INNER_OPENPOWER_VERSION
185
186$(2)_VERSION_FILE = $$(OPENPOWER_VERSION_DIR)/$(1).version.txt
187ifeq ($$(BR2_PACKAGE_OPENPOWER_PNOR_P10),y)
188UPPER_CASE_SIGN_MODE = $(call UPPERCASE,$$(BR2_OPENPOWER_P10_SECUREBOOT_SIGN_MODE))
189CONFIG_NAME = $$(BR2_OPENPOWER_P10_CONFIG_NAME)
190VERSIONED_SUBPACKAGES = $$(OPENPOWER_PNOR_P10_VERSIONED_SUBPACKAGES)
191else
Nick Bofferding6fafd622017-09-28 15:23:23 -0500192UPPER_CASE_SIGN_MODE = $(call UPPERCASE,$$(BR2_OPENPOWER_SECUREBOOT_SIGN_MODE))
Klaus Heinrich Kiwid2551242020-07-16 16:59:04 -0300193CONFIG_NAME = $$(BR2_OPENPOWER_CONFIG_NAME)
194VERSIONED_SUBPACKAGES = $$(OPENPOWER_VERSIONED_SUBPACKAGES)
195endif
Stephen Cpreke7254c72015-02-19 14:33:38 -0600196
Klaus Heinrich Kiwid2551242020-07-16 16:59:04 -0300197$$(eval $$(foreach pkg,$$(VERSIONED_SUBPACKAGES), \
Stephen Cpreke7254c72015-02-19 14:33:38 -0600198 $$(call OPENPOWER_SUBPACKAGE_VERSION,$$(pkg),$$(call UPPERCASE,$$(pkg)))))
199
200### Combine subpackage files into one version file
Klaus Heinrich Kiwid2551242020-07-16 16:59:04 -0300201define $(2)_OPENPOWER_VERSION_FILE
Stephen Cpreke7254c72015-02-19 14:33:38 -0600202
203mkdir -p "$$(OPENPOWER_VERSION_DIR)"
204
205# Add vendor or default open-power
Deb McLemore68215012022-02-11 10:59:34 -0600206
Stewart Smithfd7a2262017-02-17 17:20:54 +1100207if [ -n "$$(OPBUILD_VENDOR)" ]; then \
Klaus Heinrich Kiwid2551242020-07-16 16:59:04 -0300208echo -n "$$(OPBUILD_VENDOR)-" > $$($(2)_VERSION_FILE); \
Stephen Cpreke7254c72015-02-19 14:33:38 -0600209else \
Klaus Heinrich Kiwid2551242020-07-16 16:59:04 -0300210echo -n "open-power-" > $$($(2)_VERSION_FILE); \
Stephen Cpreke7254c72015-02-19 14:33:38 -0600211fi
212
213# Add platform or default from defconfig
Stewart Smithfd7a2262017-02-17 17:20:54 +1100214if [ -n "$$(OPBUILD_PLATFORM)" ]; then \
Klaus Heinrich Kiwid2551242020-07-16 16:59:04 -0300215echo -n "$$(OPBUILD_PLATFORM)-" >> $$($(2)_VERSION_FILE); \
Stephen Cpreke7254c72015-02-19 14:33:38 -0600216else \
Klaus Heinrich Kiwid2551242020-07-16 16:59:04 -0300217echo -n "$$(CONFIG_NAME)-" >> $$($(2)_VERSION_FILE); \
Stephen Cpreke7254c72015-02-19 14:33:38 -0600218fi
219
220# Add op-build version
221# Order: OPBUILD_VERSION, tag, commit, unknown
Stewart Smithfd7a2262017-02-17 17:20:54 +1100222if [ -n "$$(OPBUILD_VERSION)" ]; then \
Klaus Heinrich Kiwid2551242020-07-16 16:59:04 -0300223 echo -n "$$(OPBUILD_VERSION)" >> $$($(2)_VERSION_FILE); \
Stephen Cpreke7254c72015-02-19 14:33:38 -0600224else \
Stewart Smithfd7a2262017-02-17 17:20:54 +1100225cd "$$(BR2_EXTERNAL_OP_BUILD_PATH)"; (git describe --always --dirty || echo "unknown") \
226 | xargs echo -n \
Klaus Heinrich Kiwid2551242020-07-16 16:59:04 -0300227 >> $$($(2)_VERSION_FILE); \
Stephen Cpreke7254c72015-02-19 14:33:38 -0600228fi
229
Nick Bofferding6fafd622017-09-28 15:23:23 -0500230# Flag whether op-build is production signed
231if [ "$$(UPPER_CASE_SIGN_MODE)" == 'PRODUCTION' ]; then \
Klaus Heinrich Kiwid2551242020-07-16 16:59:04 -0300232 echo -n "-prod" >> $$($(2)_VERSION_FILE); \
Nick Bofferding6fafd622017-09-28 15:23:23 -0500233fi
234
Klaus Heinrich Kiwid2551242020-07-16 16:59:04 -0300235# Add new line to $$($(2)_VERSION_FILE)
236echo "" >> $$($(2)_VERSION_FILE);
Stephen Cpreke7254c72015-02-19 14:33:38 -0600237
Sam Mendoza-Jonasdc7e2382016-03-09 16:13:02 +1100238# Add a specific line for op-build if it has been overwritten
Stewart Smithfd7a2262017-02-17 17:20:54 +1100239if [ -n "$$(OPBUILD_VENDOR)" ]; then \
Klaus Heinrich Kiwid2551242020-07-16 16:59:04 -0300240echo -n " op-build-" >> $$($(2)_VERSION_FILE); \
Stewart Smithfd7a2262017-02-17 17:20:54 +1100241(cd "$$(BR2_EXTERNAL_OP_BUILD_PATH)"; (git describe --always --dirty || echo "unknown")) \
242 | xargs echo \
Klaus Heinrich Kiwid2551242020-07-16 16:59:04 -0300243 >> $$($(2)_VERSION_FILE); \
Sam Mendoza-Jonasdc7e2382016-03-09 16:13:02 +1100244fi
245
246# Include the currently checked-out buildroot version
Klaus Heinrich Kiwid2551242020-07-16 16:59:04 -0300247echo -n " buildroot-" >> $$($(2)_VERSION_FILE);
Stewart Smithfd7a2262017-02-17 17:20:54 +1100248(git describe --always --dirty || echo "unknown") \
249 | xargs echo \
Klaus Heinrich Kiwid2551242020-07-16 16:59:04 -0300250 >> $$($(2)_VERSION_FILE); \
Sam Mendoza-Jonasdc7e2382016-03-09 16:13:02 +1100251
Daniel Crowell2aa26f32022-01-27 16:14:28 -0600252# Include the named pnor build name if there is one
253if [ -n "$$(OPBUILD_BUILDNAME)" ]; then \
254 echo -n " op-build-buildname-" >> $$($(2)_VERSION_FILE); \
255 echo $$(OPBUILD_BUILDNAME) >> $$($(2)_VERSION_FILE); \
256fi
Sam Mendoza-Jonasdc7e2382016-03-09 16:13:02 +1100257
Klaus Heinrich Kiwid2551242020-07-16 16:59:04 -0300258# Combing subpackage version files into $$($(2)_VERSION_FILE)
Stephen Cpreke7254c72015-02-19 14:33:38 -0600259$$(foreach verFile,$$(ALL_SUBPACKAGE_VERSIONS),
260 if [ -f $$(verFile) ]; then cat $$(verFile) \
Klaus Heinrich Kiwid2551242020-07-16 16:59:04 -0300261 >>$$($(2)_VERSION_FILE); fi )
Stephen Cpreke7254c72015-02-19 14:33:38 -0600262
Klaus Heinrich Kiwid2551242020-07-16 16:59:04 -0300263endef # $(2)_OPENPOWER_VERSION_FILE
Stephen Cpreke7254c72015-02-19 14:33:38 -0600264
Klaus Heinrich Kiwid2551242020-07-16 16:59:04 -0300265$(2)_PRE_BUILD_HOOKS += $(2)_OPENPOWER_VERSION_FILE
Stephen Cpreke7254c72015-02-19 14:33:38 -0600266
267# Top-level rule to print or generate openpower-pnor version
Klaus Heinrich Kiwid2551242020-07-16 16:59:04 -0300268$(1)-version: $$(if $$(wildcard $$($(2)_VERSION_FILE)),$(1)-print-version,$(1)-build-version)
Stephen Cpreke7254c72015-02-19 14:33:38 -0600269
270# Rule to print out pnor version
271$(1)-print-version:
Klaus Heinrich Kiwid2551242020-07-16 16:59:04 -0300272 @echo "=== $(2)_VERSION ==="
273 @cat $$($(2)_VERSION_FILE)
Stephen Cpreke7254c72015-02-19 14:33:38 -0600274 @echo ""; echo "**See openpower/package/VERSION.readme for detailed info on package strings"; echo ""
275
Stephen Cpreke7254c72015-02-19 14:33:38 -0600276# Rule to generate pnor version
Klaus Heinrich Kiwid2551242020-07-16 16:59:04 -0300277$(1)-build-version: $$(foreach pkg,$$(VERSIONED_SUBPACKAGES), $$(pkg)-version)
278 @$$($(2)_OPENPOWER_VERSION_FILE)
279 @echo "=== $(2)_VERSION ==="
280 @cat $$($(2)_VERSION_FILE)
Stephen Cpreke7254c72015-02-19 14:33:38 -0600281 @echo ""; echo "**See openpower/package/VERSION.readme for detailed info on package strings"; echo ""
282
Stephen Cprekded98fb2015-04-15 17:11:52 -0500283# Rule to force re-generation of all versioned subpackages
Klaus Heinrich Kiwid2551242020-07-16 16:59:04 -0300284$(1)-build-version-all: $$(foreach pkg,$$(VERSIONED_SUBPACKAGES), $$(pkg)-build-version)
285 @$$($(2)_OPENPOWER_VERSION_FILE)
286 @echo "=== $(2)_VERSION ==="
287 @cat $$($(2)_VERSION_FILE)
Stephen Cprekded98fb2015-04-15 17:11:52 -0500288 @echo ""; echo "**See openpower/package/VERSION.readme for detailed info on package strings"; echo ""
289
Klaus Heinrich Kiwid2551242020-07-16 16:59:04 -0300290endef # INNER_OPENPOWER_VERSION
291
292OPENPOWER_VERSION = $(call INNER_OPENPOWER_VERSION,$(pkgname),$(call UPPERCASE,$(pkgname)))
293