# -*- coding: utf-8 -*- from setuphelpers import * import requests,re uninstallkey = [] def install(): print('Installing Tortoise Git') version = control['version'].split('-',1)[0] arch = '64' if iswin64() else '32' install_msi_if_needed('TortoiseGit-%s-%sbit.msi' % (version, arch)) def update_package(): print('Updating Tortoise Git Package') download = requests.get('https://tortoisegit.org/download/').text try: version = re.search('//download.tortoisegit.org/tgit/(\d+\.\d+\.\d+\.\d+)/TortoiseGit-\d+\.\d+\.\d+\.\d+-64bit.msi', download).group(1) except: error('Version not found') # Minor versions are served from the dir of the branch. Eg 2.10.0.2 is in the 2.10.0.0 folder branch = re.sub(r'\d+$', '0', version) print('Latest version is %s' % version) pe = PackageEntry(); control = pe.load_control_from_wapt('.') for arch in ['32','64']: filename = 'TortoiseGit-%s-%sbit.msi' % (version, arch) url = 'https://download.tortoisegit.org/tgit/%s/%s' % (branch, filename) if not isfile('TortoiseGit-%s-%sbit.msi' % (version, arch)): print('Downloading Tortoise Git %s for win%s from %s' % (version, arch, url)) wget(url, filename) if isfile(filename): for old in glob.glob(r'TortoiseGit-*%sbit.msi' % arch): if old != filename: remove_file(old) if Version(version) > Version(control['version'].split('-',1)[0]): print('Updating control file with new version %s' % version) pe.version = version + '-0' pe.maturity = 'PREPROD' pe.save_control_to_wapt('.')