File 5391-Win-installer-version-fix.patch of Package erlang

From 58efa0dc5169cb2f05a62cff0f1fa80e058ef359 Mon Sep 17 00:00:00 2001
From: Dan Gudmundsson <dgud@erlang.org>
Date: Sat, 4 Feb 2023 09:16:39 +0100
Subject: [PATCH] Win installer version fix

Use 0.0.0.0 for non releases as productversion (and also seen as file
version) on the installer for non release builds.

Only integers works, so use 0.0.0.0 to indicate that this is not a
normal release.
---
 erts/etc/win32/nsis/Makefile           |  5 ++++-
 erts/etc/win32/nsis/vsn_number.escript | 19 +++++++++++++------
 2 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/erts/etc/win32/nsis/Makefile b/erts/etc/win32/nsis/Makefile
index 79814f1521..4f57a0dc92 100644
--- a/erts/etc/win32/nsis/Makefile
+++ b/erts/etc/win32/nsis/Makefile
@@ -68,8 +68,9 @@ REDIST_DLL_NAME=$(shell (sh ./dll_version_helper.sh -n "$(NICEREDISTFILE)" || ec
 # $(info $$REDIST_DLL_NAME = [${REDIST_DLL_NAME}])
 # $(info $$REDIST_FILE = [${REDIST_FILE}])
 
+VERSION_TICKETS_FILE=$(shell (w32_path.sh -m "$(ERL_TOP)/make/otp_version_tickets" 2>/dev/null || echo "NOTFOUND"))
 # NSIS really want the product version number to be at least 4 digits long
-OTP_VERSION_LONG=$(shell $(ERL_TOP)/bootstrap/bin/escript.exe vsn_number.escript $(OTP_VERSION))
+OTP_VERSION_LONG=$(shell $(ERL_TOP)/bootstrap/bin/escript.exe vsn_number.escript $(OTP_VERSION) $(VERSION_TICKETS_FILE))
 YEAR=$(shell date +%Y)
 
 release_spec:
@@ -102,6 +103,8 @@ release_spec:
 	  then \
 		echo '!define HAVE_DOCS 1' >> $(VERSION_HEADER); \
 	  fi;\
+	  echo "OTP_VERSION = [${OTP_VERSION}]"; \
+	  echo "OTP_VERSION_LONG = [${OTP_VERSION_LONG}]"; \
 	  echo "Running $(MAKENSIS) $(MAKENSISFLAGS) erlang20.nsi";\
 	  $(MAKENSIS) $(MAKENSISFLAGS) erlang20.nsi;;\
 	*) \
diff --git a/erts/etc/win32/nsis/vsn_number.escript b/erts/etc/win32/nsis/vsn_number.escript
index 3b3093e010..7854860042 100644
--- a/erts/etc/win32/nsis/vsn_number.escript
+++ b/erts/etc/win32/nsis/vsn_number.escript
@@ -1,9 +1,16 @@
 
 
-main([OtpVsn]) ->
-    case string:lexemes(OtpVsn, ".") of
-        [_,_,_,_|_] -> io:format("~s~n", [OtpVsn]);
-        [_,_,_] -> io:format("~s.0~n",[OtpVsn]);
-        [_,_] -> io:format("~s.0.0~n",[OtpVsn]);
-        [_] -> io:format("~s.0.0.0~n",[OtpVsn])
+main([OtpVsn, WinPathFile]) ->
+    try
+        {ok, Bin} = file:read_file(WinPathFile),
+        <<"OTP-", _/binary>> = Bin,
+        case [list_to_integer(Str) || Str <- string:lexemes(OtpVsn, ".")] of
+            [_,_,_,_|_] -> io:format("~s~n", [OtpVsn]);
+            [_,_,_] -> io:format("~s.0~n",[OtpVsn]);
+            [_,_] -> io:format("~s.0.0~n",[OtpVsn]);
+            [_] -> io:format("~s.0.0.0~n",[OtpVsn])
+        end
+    catch _:_R:_ST -> %% release candidate or development branch set fake version as 0.0.0.0
+            %% io:format("Err: ~p ~p~n ~p~n",[_R,_ST, WinPathFile]),
+            io:format("0.0.0.0~n")
     end.
-- 
2.35.3

openSUSE Build Service is sponsored by