summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElliot <apachehaisley@gmail.com>2024-09-22 12:51:31 -0400
committerJussi Pakkanen <jpakkane@gmail.com>2024-09-28 22:14:05 +0300
commit83b2968118ca6dae1444267b2651d2d9a2efd07f (patch)
tree2f7a1d5086e8a8ac833029146bef3aa238e7747d
parentb7ce7c2d39cb537d9158e24e458ee5ce293a7bd3 (diff)
downloadmeson-83b2968118ca6dae1444267b2651d2d9a2efd07f.tar.gz
Don't fail to package when run twice
Guards against exit when the default nuget source is already installed, or when wix is installed but not the wix ui toolset.
-rwxr-xr-xpackaging/createmsi.py44
1 files changed, 34 insertions, 10 deletions
diff --git a/packaging/createmsi.py b/packaging/createmsi.py
index 77667fe68..bb2fade72 100755
--- a/packaging/createmsi.py
+++ b/packaging/createmsi.py
@@ -20,6 +20,8 @@ from mesonbuild import coredata
# Elementtree does not support CDATA. So hack it.
WINVER_CHECK = 'Installed OR (VersionNT64 &gt; 602)>'
+NUGET_INDEX = 'https://api.nuget.org/v3/index.json'
+WIXEXT_TOOL = 'WixToolset.UI.wixext'
def gen_guid():
'''
@@ -302,28 +304,50 @@ class PackageGenerator:
])
+def is_nuget_source_active():
+ '''
+ Check if nuget source is active
+ '''
+ result = subprocess.run(['dotnet', 'nuget', 'list', 'source', '--format', 'Short'], stdout=subprocess.PIPE)
+ return f'E {NUGET_INDEX}' in result.stdout.decode('utf-8')
+
+def is_wixext_installed():
+ '''
+ Check if wix extension is installed
+ '''
+ result = subprocess.run(['wix', 'extension', 'list'], stdout=subprocess.PIPE)
+ return WIXEXT_TOOL in result.stdout.decode('utf-8')
+
def install_wix():
- subprocess.check_call(['dotnet',
- 'nuget',
- 'add',
- 'source',
- 'https://api.nuget.org/v3/index.json'])
+ # Check if nuget source is active before trying to add it
+ # dotnet nuget add source returns non-zero if the source already exists
+ if not is_nuget_source_active():
+ subprocess.check_call(['dotnet',
+ 'nuget',
+ 'add',
+ 'source',
+ NUGET_INDEX])
+
subprocess.check_call(['dotnet',
'tool',
'install',
'--global',
'wix'])
- subprocess.check_call(['wix',
- 'extension',
- 'add',
- 'WixToolset.UI.wixext',
- ])
if __name__ == '__main__':
if not os.path.exists('meson.py'):
sys.exit(print('Run me in the top level source dir.'))
if not shutil.which('wix'):
install_wix()
+
+ # Install wixext if not installed
+ if not is_wixext_installed():
+ subprocess.check_call(['wix',
+ 'extension',
+ 'add',
+ WIXEXT_TOOL,
+ ])
+
subprocess.check_call(['pip', 'install', '--upgrade', 'pyinstaller'])
p = PackageGenerator()