Skip to content

Commit 5109c04

Browse files
author
Piotr Obrzut
committed
Bug#26181622 MSI BUILD FAIL DUE TO DUPLICATED FILE ID
Fixed generated mysql_server.wxs not to contain duplicates, or too long ids
1 parent 9877ac1 commit 5109c04

File tree

1 file changed

+23
-8
lines changed

1 file changed

+23
-8
lines changed

packaging/WiX/create_msi.cmake.in

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved.
22
#
33
# This program is free software; you can redistribute it and/or modify
44
# it under the terms of the GNU General Public License as published by
@@ -229,22 +229,37 @@ MACRO(GENERATE_GUID VarName)
229229
OUTPUT_STRIP_TRAILING_WHITESPACE)
230230
ENDMACRO()
231231

232-
SET(INC_VAR 0)
232+
# Make sure that WIX identifier created from a path matches all the rules:
233+
# - it is shorter than 72 characters
234+
# - doesn't contain reserver characters ('+', '-' and '/')
235+
# ID_SET contains a global list of all identifiers which are too long.
236+
# Every time we use an identifier which is too long we use its index in
237+
# ID_SET to shorten the name.
238+
SET_PROPERTY(GLOBAL PROPERTY ID_SET)
233239
MACRO(MAKE_WIX_IDENTIFIER str varname)
234240
STRING(REPLACE "/" "." ${varname} "${str}")
241+
STRING(REPLACE "+" "p" ${varname} "${str}")
242+
STRING(REPLACE "-" "m" ${varname} "${str}")
235243
STRING(REGEX REPLACE "[^a-zA-Z_0-9.]" "_" ${varname} "${${varname}}")
236244
STRING(LENGTH "${${varname}}" len)
245+
# FIXME: the prefix length has to be controlled better
237246
# Identifier should be smaller than 72 character
238-
# We have to cut down the length to 70 chars, since we add 2 char prefix
247+
# We have to cut down the length to 40 chars, since we add prefixes
239248
# pretty often
240-
IF(len GREATER 70)
241-
STRING(SUBSTRING "${${varname}}" 0 67 shortstr)
242-
MATH(EXPR INC_VAR ${INC_VAR}+1)
243-
SET(${varname} "${shortstr}${INC_VAR}")
249+
IF(len GREATER 40)
250+
STRING(SUBSTRING "${${varname}}" 0 37 shortstr)
251+
GET_PROPERTY(LOCAL_LIST GLOBAL PROPERTY ID_SET)
252+
LIST(FIND LOCAL_LIST "${${varname}}" STRING_ID)
253+
IF(${STRING_ID} EQUAL -1)
254+
LIST(APPEND LOCAL_LIST "${${varname}}")
255+
SET_PROPERTY(GLOBAL PROPERTY ID_SET "${LOCAL_LIST}")
256+
LIST(LENGTH LOCAL_LIST STRING_ID)
257+
MATH(EXPR STRING_ID "${STRING_ID}-1" )
258+
ENDIF()
259+
SET(${varname} "${shortstr}${STRING_ID}")
244260
ENDIF()
245261
ENDMACRO()
246262

247-
248263
FUNCTION(TRAVERSE_FILES dir topdir file file_comp dir_root)
249264
FILE(RELATIVE_PATH dir_rel ${topdir} ${dir})
250265
IF(dir_rel)

0 commit comments

Comments
 (0)