1# This Source Code Form is subject to the terms of the Mozilla Public 2# License, v. 2.0. If a copy of the MPL was not distributed with this 3# file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 5from __future__ import absolute_import 6 7from urlparse import urlunsplit 8 9product_ftp_map = { 10 "fennec": "mobile", 11} 12 13 14def product2ftp(product): 15 return product_ftp_map.get(product, product) 16 17 18def getCandidatesDir(product, version, buildNumber, protocol=None, server=None): 19 if protocol: 20 assert server is not None, "server is required with protocol" 21 22 product = product2ftp(product) 23 directory = "/{}/candidates/{}-candidates/build{}".format( 24 product, str(version), str(buildNumber), 25 ) 26 27 if protocol: 28 return urlunsplit((protocol, server, directory, None, None)) 29 else: 30 return directory 31 32 33def getReleasesDir(product, version=None, protocol=None, server=None): 34 if protocol: 35 assert server is not None, "server is required with protocol" 36 37 directory = "/{}/releases".format(product) 38 if version: 39 directory = "{}/{}".format(directory, version) 40 41 if protocol: 42 return urlunsplit((protocol, server, directory, None, None)) 43 else: 44 return directory 45 46 47def getReleaseInstallerPath(productName, brandName, version, platform, 48 locale='en-US'): 49 if productName not in ('fennec',): 50 if platform.startswith('linux'): 51 return '/'.join([p.strip('/') for p in [ 52 platform, locale, '%s-%s.tar.bz2' % (productName, version)]]) 53 elif 'mac' in platform: 54 return '/'.join([p.strip('/') for p in [ 55 platform, locale, '%s %s.dmg' % (brandName, version)]]) 56 elif platform.startswith('win'): 57 return '/'.join([p.strip('/') for p in [ 58 platform, locale, '%s Setup %s.exe' % (brandName, version)]]) 59 else: 60 raise "Unsupported platform" 61 else: 62 if platform.startswith('android'): 63 filename = '%s-%s.%s.android-arm.apk' % ( 64 productName, version, locale) 65 return '/'.join([p.strip('/') for p in [ 66 platform, locale, filename]]) 67 else: 68 raise "Unsupported platform" 69