зеркало из https://github.com/mozilla/stoneridge.git
Centralize some stuff
This commit is contained in:
Родитель
4da6e73f55
Коммит
302b72e084
|
@ -3,45 +3,83 @@ import platform
|
|||
import sys
|
||||
import traceback
|
||||
|
||||
_sys = None
|
||||
_sys_ver = None
|
||||
_dl_plat = None
|
||||
_dl_suffix = None
|
||||
_fx_bindir = None
|
||||
|
||||
def system_name():
|
||||
"""Determine the os from platform.system
|
||||
"""
|
||||
system = platform.system().lower()
|
||||
if system == 'darwin':
|
||||
system = 'mac'
|
||||
return system
|
||||
global _sys
|
||||
if _sys is None:
|
||||
_sys = platform.system().lower()
|
||||
if _sys == 'darwin':
|
||||
_sys = 'mac'
|
||||
return _sys
|
||||
|
||||
def system_version():
|
||||
"""Determine the os version
|
||||
"""
|
||||
system = platform.system().lower()
|
||||
if system == 'linux':
|
||||
return ' '.join(platform.linux_distribution[0:2])
|
||||
if system == 'darwin':
|
||||
return platform.mac_ver[0]
|
||||
if system == 'windows':
|
||||
return platform.win32_ver()[1]
|
||||
return 'Unknown'
|
||||
global _sys_ver
|
||||
if _sys_ver is None:
|
||||
system = platform.system().lower()
|
||||
if system == 'linux':
|
||||
_sys_ver = ' '.join(platform.linux_distribution[0:2])
|
||||
elif system == 'darwin':
|
||||
_sys_ver = platform.mac_ver[0]
|
||||
elif system == 'windows':
|
||||
_sys_ver = platform.win32_ver()[1]
|
||||
else:
|
||||
_sys_ver = 'Unknown'
|
||||
return _sys_ver
|
||||
|
||||
def download_platform():
|
||||
system = system_name()
|
||||
if system == 'linux':
|
||||
if platform.machine() == 'x86_64':
|
||||
return 'linux64'
|
||||
return 'linux32
|
||||
if system == 'windows':
|
||||
if platform.machine() == 'x86_64':
|
||||
return 'win64'
|
||||
return 'win32'
|
||||
return system
|
||||
"""Determine which platform to download files for
|
||||
"""
|
||||
global _dl_plat
|
||||
if _dl_plat is None:
|
||||
system = system_name()
|
||||
if system == 'linux':
|
||||
if platform.machine() == 'x86_64':
|
||||
_dl_plat = 'linux64'
|
||||
else:
|
||||
_dl_plat = 'linux32
|
||||
elif system == 'windows':
|
||||
if platform.machine() == 'x86_64':
|
||||
_dl_plat = 'win64'
|
||||
else:
|
||||
_dl_plat = 'win32'
|
||||
else:
|
||||
_dl_plat = system
|
||||
return _dl_plat
|
||||
|
||||
def download_suffix():
|
||||
system = platform.system().lower()
|
||||
if system == 'linux':
|
||||
return 'tar.gz'
|
||||
if system == 'darwin':
|
||||
return 'dmg'
|
||||
return 'zip'
|
||||
"""Determine the suffix of the firefox archive to download
|
||||
"""
|
||||
global _dl_suffix
|
||||
if _dl_suffix is None:
|
||||
system = platform.system().lower()
|
||||
if system == 'linux':
|
||||
_dl_suffix = 'tar.bz2'
|
||||
elif system == 'darwin':
|
||||
_dl_suffix = 'dmg'
|
||||
else:
|
||||
_dl_suffix = 'zip'
|
||||
return _dl_suffix
|
||||
|
||||
def firefox_bindir():
|
||||
"""Determine the location of the firefox binary based on platform
|
||||
"""
|
||||
global _fx_bindir
|
||||
if _fx_bindir is None:
|
||||
system = platform.system().lower()
|
||||
if system == 'darwin':
|
||||
_fx_bindir = os.path.join('FirefoxNightly.app', 'Contents', 'MacOS')
|
||||
else:
|
||||
_fx_bindir = 'firefox'
|
||||
return _fx_bindir
|
||||
|
||||
def main(_main):
|
||||
"""Mark a function as the main function to run when run as a script.
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import argparse
|
||||
import glob
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
|
@ -13,7 +12,7 @@ class StoneRidgeUnpacker(object):
|
|||
return WindowsUnpacker()
|
||||
elif sysname == 'linux':
|
||||
return LinuxUnpacker()
|
||||
elif sysname == 'Mac':
|
||||
elif sysname == 'mac':
|
||||
return MacUnpacker()
|
||||
|
||||
raise ValueError, 'Invalid system type: %s' % (sysname,)
|
||||
|
@ -23,7 +22,6 @@ class StoneRidgeUnpacker(object):
|
|||
self.firefoxpkg = os.path.abspath(firefoxpkg)
|
||||
self.testzip = os.path.abspath(testzip)
|
||||
self.xpcshell = 'xpcshell'
|
||||
self.fxbindir = 'firefox'
|
||||
|
||||
def run(self):
|
||||
# Make sure our destination directory exists and is empty
|
||||
|
@ -41,16 +39,16 @@ class StoneRidgeUnpacker(object):
|
|||
|
||||
# Put the xpcshell binary where it belongs
|
||||
xpcshell = os.path.join(unzipdir, 'bin', self.xpcshell)
|
||||
shutil.copy(xpcshell, self.fxbindir)
|
||||
shutil.copy(xpcshell, stoneridge.firefox_bindir())
|
||||
|
||||
# Put our components into place
|
||||
components = os.path.join(unzipdir, 'bin', 'components', '*')
|
||||
fxcomponents = os.path.join(self.fxbindir, 'components')
|
||||
fxcomponents = os.path.join(stoneridge.firefox_bindir(), 'components')
|
||||
subprocess.call(['bash', '-c',
|
||||
'cp -R "%s" "%s"' % (components, fxcomponents)])
|
||||
|
||||
# Put the plugins in place, in case we need them
|
||||
fxplugins = os.path.join(self.fxbindir, 'plugins')
|
||||
fxplugins = os.path.join(stoneridge.firefox_bindir(), 'plugins')
|
||||
if not os.path.exists(fxplugins):
|
||||
os.mkdir(fxplugins)
|
||||
plugins = os.path.join(unzipdir, 'bin', 'plugins', '*')
|
||||
|
@ -85,11 +83,6 @@ class MacUnpacker(StoneRidgeUnpacker):
|
|||
subprocess.call(['/bin/bash', installdmg, self.firefoxpkg],
|
||||
cwd=self.destdir)
|
||||
|
||||
pattern = os.path.join(self.destdir, '*.app')
|
||||
appdir = glob.glob(pattern)[0]
|
||||
appdir = os.path.basename(appdir)
|
||||
self.fxbindir = os.path.join(self.destdir, appdir, 'Contents', 'MacOS')
|
||||
|
||||
@stoneridge.main
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
|
|
Загрузка…
Ссылка в новой задаче