Skip to content
Snippets Groups Projects
Commit 2adcfaa7 authored by Alexandre Lision's avatar Alexandre Lision
Browse files

make-ring: cleanup unnecessary strings

Distributions names are hardcoded across various functions. We have a
couple of arrays listing distros but they were not put to use through
the file
OSX_DISTRIBUTION_NAME and ANDROID_DISTRIBUTION_NAME have also been added
to replace the hardcoded strings

Change-Id: Iab00585d62e94808e476db11d93e824153a8011b
parent c7336d3f
Branches
Tags
No related merge requests found
...@@ -16,6 +16,8 @@ import multiprocessing ...@@ -16,6 +16,8 @@ import multiprocessing
import shutil import shutil
IOS_DISTRIBUTION_NAME="iOS" IOS_DISTRIBUTION_NAME="iOS"
OSX_DISTRIBUTION_NAME="OSX"
ANDROID_DISTRIBUTION_NAME="Android"
APT_BASED_DISTROS = [ APT_BASED_DISTROS = [
'Debian', 'Debian',
...@@ -175,16 +177,11 @@ STOP_SCRIPT = [ ...@@ -175,16 +177,11 @@ STOP_SCRIPT = [
def run_dependencies(args): def run_dependencies(args):
if args.distribution == "Ubuntu": if args.distribution in APT_BASED_DISTROS:
execute_script(APT_INSTALL_SCRIPT, execute_script(APT_INSTALL_SCRIPT,
{"packages": ' '.join(APT_DEPENDENCIES)} {"packages": ' '.join(APT_DEPENDENCIES)}
) )
elif args.distribution == "Debian": elif args.distribution in DNF_BASED_DISTROS:
execute_script(
APT_INSTALL_SCRIPT,
{"packages": ' '.join(APT_DEPENDENCIES)}
)
elif args.distribution == "Fedora":
execute_script( execute_script(
RPM_INSTALL_SCRIPT, RPM_INSTALL_SCRIPT,
{"packages": ' '.join(DNF_DEPENDENCIES)} {"packages": ' '.join(DNF_DEPENDENCIES)}
...@@ -199,19 +196,19 @@ def run_dependencies(args): ...@@ -199,19 +196,19 @@ def run_dependencies(args):
RPM_INSTALL_SCRIPT, RPM_INSTALL_SCRIPT,
{"packages": ' '.join(MINGW64_FEDORA_DEPENDENCIES)} {"packages": ' '.join(MINGW64_FEDORA_DEPENDENCIES)}
) )
elif args.distribution == "Arch Linux": elif args.distribution in PACMAN_BASED_DISTROS:
execute_script( execute_script(
PACMAN_INSTALL_SCRIPT, PACMAN_INSTALL_SCRIPT,
{"packages": ' '.join(PACMAN_DEPENDENCIES)} {"packages": ' '.join(PACMAN_DEPENDENCIES)}
) )
elif args.distribution == "openSUSE": elif args.distribution in ZYPPER_BASED_DISTROS:
execute_script( execute_script(
ZYPPER_INSTALL_SCRIPT, ZYPPER_INSTALL_SCRIPT,
{"packages": ' '.join(ZYPPER_DEPENDENCIES)} {"packages": ' '.join(ZYPPER_DEPENDENCIES)}
) )
elif args.distribution == "OSX": elif args.distribution == OSX_DISTRIBUTION_NAME:
execute_script( execute_script(
BREW_UNLINK_SCRIPT, BREW_UNLINK_SCRIPT,
{"packages": ' '.join(OSX_DEPENDENCIES_UNLINK)} {"packages": ' '.join(OSX_DEPENDENCIES_UNLINK)}
...@@ -231,7 +228,7 @@ def run_dependencies(args): ...@@ -231,7 +228,7 @@ def run_dependencies(args):
{"packages": ' '.join(IOS_DEPENDENCIES)} {"packages": ' '.join(IOS_DEPENDENCIES)}
) )
elif args.distribution == "Android": elif args.distribution == ANDROID_DISTRIBUTION_NAME:
print("The Android version does not need more dependencies.\nPlease continue with the --install instruction.") print("The Android version does not need more dependencies.\nPlease continue with the --install instruction.")
sys.exit(1) sys.exit(1)
...@@ -269,7 +266,7 @@ def run_install(args): ...@@ -269,7 +266,7 @@ def run_install(args):
install_args += ' -s' install_args += ' -s'
if args.global_install: if args.global_install:
install_args += ' -g' install_args += ' -g'
if args.distribution == "OSX": if args.distribution == OSX_DISTRIBUTION_NAME:
proc= subprocess.Popen("brew --prefix qt5", shell=True, stdout=subprocess.PIPE) proc= subprocess.Popen("brew --prefix qt5", shell=True, stdout=subprocess.PIPE)
qt5dir = proc.stdout.read() qt5dir = proc.stdout.read()
os.environ['CMAKE_PREFIX_PATH'] = str(qt5dir.decode('ascii')) os.environ['CMAKE_PREFIX_PATH'] = str(qt5dir.decode('ascii'))
...@@ -278,7 +275,7 @@ def run_install(args): ...@@ -278,7 +275,7 @@ def run_install(args):
elif args.distribution == IOS_DISTRIBUTION_NAME: elif args.distribution == IOS_DISTRIBUTION_NAME:
os.chdir("./client-ios") os.chdir("./client-ios")
execute_script(["./compile-ios.sh"]) execute_script(["./compile-ios.sh"])
elif args.distribution == "Android": elif args.distribution == ANDROID_DISTRIBUTION_NAME:
os.chdir("./client-android") os.chdir("./client-android")
execute_script(["./compile.sh"]) execute_script(["./compile.sh"])
elif args.distribution == 'mingw32': elif args.distribution == 'mingw32':
...@@ -292,21 +289,21 @@ def run_install(args): ...@@ -292,21 +289,21 @@ def run_install(args):
os.environ['PATH'] = '/usr/x86_64-w64-mingw32/bin/qt5/:' + os.environ['PATH'] os.environ['PATH'] = '/usr/x86_64-w64-mingw32/bin/qt5/:' + os.environ['PATH']
execute_script(["./scripts/win_compile.sh --arch=64"]) execute_script(["./scripts/win_compile.sh --arch=64"])
else: else:
if args.distribution == "openSUSE": if args.distribution in ZYPPER_BASED_DISTROS:
os.environ['JSONCPP_LIBS'] = "-ljsoncpp" #fix jsoncpp pkg-config bug, remove when jsoncpp package bumped os.environ['JSONCPP_LIBS'] = "-ljsoncpp" #fix jsoncpp pkg-config bug, remove when jsoncpp package bumped
install_args += ' -c client-gnome' install_args += ' -c client-gnome'
execute_script(["./scripts/install.sh " + install_args]) execute_script(["./scripts/install.sh " + install_args])
def run_uninstall(args): def run_uninstall(args):
if args.distribution == "OSX": if args.distribution == OSX_DISTRIBUTION_NAME:
execute_script(OSX_UNINSTALL_SCRIPT) execute_script(OSX_UNINSTALL_SCRIPT)
else: else:
execute_script(UNINSTALL_SCRIPT) execute_script(UNINSTALL_SCRIPT)
def run_run(args): def run_run(args):
if args.distribution == "OSX": if args.distribution == OSX_DISTRIBUTION_NAME:
subprocess.Popen(["install/client-macosx/Ring.app/Contents/MacOS/Ring"]) subprocess.Popen(["install/client-macosx/Ring.app/Contents/MacOS/Ring"])
return True return True
...@@ -388,7 +385,7 @@ def validate_args(parsed_args): ...@@ -388,7 +385,7 @@ def validate_args(parsed_args):
"""Validate the args values, exit if error is found""" """Validate the args values, exit if error is found"""
# Check arg values # Check arg values
supported_distros = ['Android', 'Ubuntu', 'Debian', 'OSX', IOS_DISTRIBUTION_NAME, 'Fedora', 'Arch Linux', 'openSUSE', 'Automatic', 'mingw32', 'mingw64'] supported_distros = [ANDROID_DISTRIBUTION_NAME, OSX_DISTRIBUTION_NAME, IOS_DISTRIBUTION_NAME] + APT_BASED_DISTROS + DNF_BASED_DISTROS + PACMAN_BASED_DISTROS + ZYPPER_BASED_DISTROS + ['mingw32','mingw64']
if parsed_args.distribution not in supported_distros: if parsed_args.distribution not in supported_distros:
print('Distribution \''+parsed_args.distribution+'\' not supported.\nChoose one of: %s' \ print('Distribution \''+parsed_args.distribution+'\' not supported.\nChoose one of: %s' \
...@@ -450,7 +447,7 @@ def choose_distribution(): ...@@ -450,7 +447,7 @@ def choose_distribution():
if k.strip() == 'NAME': if k.strip() == 'NAME':
return v.strip().replace('"','').split(' ')[0] return v.strip().replace('"','').split(' ')[0]
elif system == "darwin": elif system == "darwin":
return 'OSX' return OSX_DISTRIBUTION_NAME
return 'Unknown' return 'Unknown'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment