createmsi: retrieve file handle explicitely so we can close it at the end
Seen on https://ci.libreoffice.org/view/tb%20platform%20status/job/lo_daily_tb_win_wix/3/console [build PRL] CustomTarget/instsetoo_native/install/install.phony Exception ignored in: <_io.FileIO name='lo.json' mode='rb' closefd=True> Traceback (most recent call last): File "C:\cygwin64\home\tdf\jenkins\daily_workspace\tb\src_master\msicreator\createmsi.py", line 42, in __init__ jsondata = json.load(open(jsonfile, 'rb')) ResourceWarning: unclosed file <_io.BufferedReader name='lo.json'> Change-Id: I98b7436e4e870f4cbcd31a41a4e9d0e84249f5f9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159566 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
This commit is contained in:
committed by
Mike Kaganski
parent
533e993f2d
commit
39f83d3dc2
@@ -39,65 +39,66 @@ class UIGraphics:
|
|||||||
class PackageGenerator:
|
class PackageGenerator:
|
||||||
|
|
||||||
def __init__(self, jsonfile):
|
def __init__(self, jsonfile):
|
||||||
jsondata = json.load(open(jsonfile, 'rb'))
|
with open(jsonfile, 'rb') as f:
|
||||||
self.product_name = jsondata['product_name']
|
jsondata = json.load(f)
|
||||||
self.manufacturer = jsondata['manufacturer']
|
self.product_name = jsondata['product_name']
|
||||||
self.version = jsondata['version']
|
self.manufacturer = jsondata['manufacturer']
|
||||||
self.comments = jsondata['comments']
|
self.version = jsondata['version']
|
||||||
self.installdir = jsondata['installdir']
|
self.comments = jsondata['comments']
|
||||||
self.license_file = jsondata.get('license_file', None)
|
self.installdir = jsondata['installdir']
|
||||||
self.name = jsondata['name']
|
self.license_file = jsondata.get('license_file', None)
|
||||||
self.guid = jsondata.get('product_guid', '*')
|
self.name = jsondata['name']
|
||||||
self.upgrade_guid = jsondata['upgrade_guid']
|
self.guid = jsondata.get('product_guid', '*')
|
||||||
self.basename = jsondata['name_base']
|
self.upgrade_guid = jsondata['upgrade_guid']
|
||||||
self.need_msvcrt = jsondata.get('need_msvcrt', False)
|
self.basename = jsondata['name_base']
|
||||||
self.addremove_icon = jsondata.get('addremove_icon', None)
|
self.need_msvcrt = jsondata.get('need_msvcrt', False)
|
||||||
self.startmenu_shortcut = jsondata.get('startmenu_shortcut', None)
|
self.addremove_icon = jsondata.get('addremove_icon', None)
|
||||||
self.desktop_shortcut = jsondata.get('desktop_shortcut', None)
|
self.startmenu_shortcut = jsondata.get('startmenu_shortcut', None)
|
||||||
self.main_xml = self.basename + '.wxs'
|
self.desktop_shortcut = jsondata.get('desktop_shortcut', None)
|
||||||
self.main_o = self.basename + '.wixobj'
|
self.main_xml = self.basename + '.wxs'
|
||||||
self.idnum = 0
|
self.main_o = self.basename + '.wixobj'
|
||||||
self.graphics = UIGraphics()
|
self.idnum = 0
|
||||||
if 'graphics' in jsondata:
|
self.graphics = UIGraphics()
|
||||||
if 'banner' in jsondata['graphics']:
|
if 'graphics' in jsondata:
|
||||||
self.graphics.banner = jsondata['graphics']['banner']
|
if 'banner' in jsondata['graphics']:
|
||||||
if 'background' in jsondata['graphics']:
|
self.graphics.banner = jsondata['graphics']['banner']
|
||||||
self.graphics.background = jsondata['graphics']['background']
|
if 'background' in jsondata['graphics']:
|
||||||
if 'arch' in jsondata:
|
self.graphics.background = jsondata['graphics']['background']
|
||||||
self.arch = jsondata['arch']
|
if 'arch' in jsondata:
|
||||||
else:
|
self.arch = jsondata['arch']
|
||||||
# rely on the environment variable since python architecture may not be the same as system architecture
|
|
||||||
if 'PROGRAMFILES(X86)' in os.environ:
|
|
||||||
self.arch = 64
|
|
||||||
else:
|
else:
|
||||||
self.arch = 32 if '32' in platform.architecture()[0] else 64
|
# rely on the environment variable since python architecture may not be the same as system architecture
|
||||||
self.final_output = '%s-%s-%d.msi' % (self.basename, self.version, self.arch)
|
if 'PROGRAMFILES(X86)' in os.environ:
|
||||||
if self.arch == 64:
|
self.arch = 64
|
||||||
self.progfile_dir = 'ProgramFiles64Folder'
|
else:
|
||||||
if platform.system() == "Windows":
|
self.arch = 32 if '32' in platform.architecture()[0] else 64
|
||||||
redist_glob = 'C:\\Program Files\\Microsoft Visual Studio\\*\\*\\VC\\Redist\\MSVC\\v*\\MergeModules\\Microsoft_VC*_CRT_x64.msm'
|
self.final_output = '%s-%s-%d.msi' % (self.basename, self.version, self.arch)
|
||||||
|
if self.arch == 64:
|
||||||
|
self.progfile_dir = 'ProgramFiles64Folder'
|
||||||
|
if platform.system() == "Windows":
|
||||||
|
redist_glob = 'C:\\Program Files\\Microsoft Visual Studio\\*\\*\\VC\\Redist\\MSVC\\v*\\MergeModules\\Microsoft_VC*_CRT_x64.msm'
|
||||||
|
else:
|
||||||
|
redist_glob = '/usr/share/msicreator/Microsoft_VC141_CRT_x64.msm'
|
||||||
else:
|
else:
|
||||||
redist_glob = '/usr/share/msicreator/Microsoft_VC141_CRT_x64.msm'
|
self.progfile_dir = 'ProgramFilesFolder'
|
||||||
else:
|
if platform.system() == "Windows":
|
||||||
self.progfile_dir = 'ProgramFilesFolder'
|
redist_glob = 'C:\\Program Files\\Microsoft Visual Studio\\*\\Community\\VC\\Redist\\MSVC\\*\\MergeModules\\Microsoft_VC*_CRT_x86.msm'
|
||||||
if platform.system() == "Windows":
|
else:
|
||||||
redist_glob = 'C:\\Program Files\\Microsoft Visual Studio\\*\\Community\\VC\\Redist\\MSVC\\*\\MergeModules\\Microsoft_VC*_CRT_x86.msm'
|
redist_glob = '/usr/share/msicreator/Microsoft_VC141_CRT_x86.msm'
|
||||||
else:
|
trials = glob(redist_glob)
|
||||||
redist_glob = '/usr/share/msicreator/Microsoft_VC141_CRT_x86.msm'
|
if self.need_msvcrt:
|
||||||
trials = glob(redist_glob)
|
if len(trials) > 1:
|
||||||
if self.need_msvcrt:
|
sys.exit('There are more than one redist dirs: ' +
|
||||||
if len(trials) > 1:
|
', '.join(trials))
|
||||||
sys.exit('There are more than one redist dirs: ' +
|
if len(trials) == 0:
|
||||||
', '.join(trials))
|
sys.exit('No redist dirs were detected, install MSM redistributables with VS installer.')
|
||||||
if len(trials) == 0:
|
self.redist_path = trials[0]
|
||||||
sys.exit('No redist dirs were detected, install MSM redistributables with VS installer.')
|
self.component_num = 0
|
||||||
self.redist_path = trials[0]
|
self.registry_entries = jsondata.get('registry_entries', None)
|
||||||
self.component_num = 0
|
self.major_upgrade = jsondata.get('major_upgrade', None)
|
||||||
self.registry_entries = jsondata.get('registry_entries', None)
|
self.parts = jsondata['parts']
|
||||||
self.major_upgrade = jsondata.get('major_upgrade', None)
|
self.feature_components = {}
|
||||||
self.parts = jsondata['parts']
|
self.feature_properties = {}
|
||||||
self.feature_components = {}
|
|
||||||
self.feature_properties = {}
|
|
||||||
|
|
||||||
def generate_files(self):
|
def generate_files(self):
|
||||||
self.root = ET.Element('Wix', {'xmlns': 'http://schemas.microsoft.com/wix/2006/wi'})
|
self.root = ET.Element('Wix', {'xmlns': 'http://schemas.microsoft.com/wix/2006/wi'})
|
||||||
|
Reference in New Issue
Block a user