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 6from six.moves.urllib.parse import urlunsplit 7 8product_ftp_map = { 9 "fennec": "mobile", 10} 11 12 13def product2ftp(product): 14 return product_ftp_map.get(product, product) 15 16 17def getCandidatesDir(product, version, buildNumber, protocol=None, server=None): 18 if protocol: 19 assert server is not None, "server is required with protocol" 20 21 product = product2ftp(product) 22 directory = "/{}/candidates/{}-candidates/build{}".format( 23 product, 24 str(version), 25 str(buildNumber), 26 ) 27 28 if protocol: 29 return urlunsplit((protocol, server, directory, None, None)) 30 else: 31 return directory 32 33 34def getReleasesDir(product, version=None, protocol=None, server=None): 35 if protocol: 36 assert server is not None, "server is required with protocol" 37 38 directory = "/{}/releases".format(product) 39 if version: 40 directory = "{}/{}".format(directory, version) 41 42 if protocol: 43 return urlunsplit((protocol, server, directory, None, None)) 44 else: 45 return directory 46 47 48def getReleaseInstallerPath(productName, brandName, version, platform, locale="en-US"): 49 if productName not in ("fennec",): 50 if platform.startswith("linux"): 51 return "/".join( 52 [ 53 p.strip("/") 54 for p in [ 55 platform, 56 locale, 57 "%s-%s.tar.bz2" % (productName, version), 58 ] 59 ] 60 ) 61 elif "mac" in platform: 62 return "/".join( 63 [ 64 p.strip("/") 65 for p in [platform, locale, "%s %s.dmg" % (brandName, version)] 66 ] 67 ) 68 elif platform.startswith("win"): 69 return "/".join( 70 [ 71 p.strip("/") 72 for p in [ 73 platform, 74 locale, 75 "%s Setup %s.exe" % (brandName, version), 76 ] 77 ] 78 ) 79 else: 80 raise "Unsupported platform" 81 else: 82 if platform.startswith("android"): 83 filename = "%s-%s.%s.android-arm.apk" % (productName, version, locale) 84 return "/".join([p.strip("/") for p in [platform, locale, filename]]) 85 else: 86 raise "Unsupported platform" 87