Skip to content
Snippets Groups Projects
Commit 2d6169b0 authored by Alexander Schlarb's avatar Alexander Schlarb
Browse files

make-ring: Use argument lists and quoting rather then unescaped shell lines

Change-Id: I857b5cc983dbca58a63787362584f164e8d9dc79
parent bddc1a20
No related branches found
No related tags found
No related merge requests found
...@@ -13,6 +13,7 @@ import sys ...@@ -13,6 +13,7 @@ import sys
import time import time
import platform import platform
import multiprocessing import multiprocessing
import shlex
import shutil import shutil
import signal import signal
...@@ -187,49 +188,50 @@ def run_dependencies(args): ...@@ -187,49 +188,50 @@ def run_dependencies(args):
'Set-ExecutionPolicy Unrestricted; .\\scripts\\build-package-windows.ps1') 'Set-ExecutionPolicy Unrestricted; .\\scripts\\build-package-windows.ps1')
elif args.distribution in APT_BASED_DISTROS: elif args.distribution in APT_BASED_DISTROS:
execute_script(APT_INSTALL_SCRIPT, execute_script(
{"packages": ' '.join(APT_DEPENDENCIES)} APT_INSTALL_SCRIPT,
) {"packages": ' '.join(map(shlex.quote, APT_DEPENDENCIES))}
)
elif args.distribution in DNF_BASED_DISTROS: elif args.distribution in DNF_BASED_DISTROS:
execute_script( execute_script(
RPM_INSTALL_SCRIPT, RPM_INSTALL_SCRIPT,
{"packages": ' '.join(DNF_DEPENDENCIES)} {"packages": ' '.join(map(shlex.quote, DNF_DEPENDENCIES))}
) )
elif args.distribution in PACMAN_BASED_DISTROS: elif args.distribution in PACMAN_BASED_DISTROS:
execute_script( execute_script(
PACMAN_INSTALL_SCRIPT, PACMAN_INSTALL_SCRIPT,
{"packages": ' '.join(PACMAN_DEPENDENCIES)} {"packages": ' '.join(map(shlex.quote, PACMAN_DEPENDENCIES))}
) )
elif args.distribution in ZYPPER_BASED_DISTROS: elif args.distribution in ZYPPER_BASED_DISTROS:
execute_script( execute_script(
ZYPPER_INSTALL_SCRIPT, ZYPPER_INSTALL_SCRIPT,
{"packages": ' '.join(ZYPPER_DEPENDENCIES)} {"packages": ' '.join(map(shlex.quote, ZYPPER_DEPENDENCIES))}
) )
elif args.distribution == OSX_DISTRIBUTION_NAME: elif args.distribution == OSX_DISTRIBUTION_NAME:
execute_script( execute_script(
BREW_UNLINK_SCRIPT, BREW_UNLINK_SCRIPT,
{"packages": ' '.join(OSX_DEPENDENCIES_UNLINK)}, {"packages": ' '.join(map(shlex.quote, OSX_DEPENDENCIES_UNLINK))},
False False
) )
execute_script( execute_script(
BREW_INSTALL_SCRIPT, BREW_INSTALL_SCRIPT,
{"packages": ' '.join(OSX_DEPENDENCIES)}, {"packages": ' '.join(map(shlex.quote, OSX_DEPENDENCIES))},
False False
) )
elif args.distribution == IOS_DISTRIBUTION_NAME: elif args.distribution == IOS_DISTRIBUTION_NAME:
execute_script( execute_script(
BREW_UNLINK_SCRIPT, BREW_UNLINK_SCRIPT,
{"packages": ' '.join(IOS_DEPENDENCIES_UNLINK)}, {"packages": ' '.join(map(shlex.quote, IOS_DEPENDENCIES_UNLINK))},
False False
) )
execute_script( execute_script(
BREW_INSTALL_SCRIPT, BREW_INSTALL_SCRIPT,
{"packages": ' '.join(IOS_DEPENDENCIES)}, {"packages": ' '.join(map(shlex.quote, IOS_DEPENDENCIES))},
False False
) )
...@@ -255,8 +257,8 @@ def run_init(): ...@@ -255,8 +257,8 @@ def run_init():
if line.startswith('[submodule "'): if line.startswith('[submodule "'):
module_names.append(line[line.find('"')+1:line.rfind('"')]) module_names.append(line[line.find('"')+1:line.rfind('"')])
os.system("git submodule update --init") subprocess.run(["git", "submodule", "update", "--init"], check=True)
os.system("git submodule foreach 'git checkout master && git pull'") subprocess.run(["git", "submodule", "foreach", "git checkout master && git pull"], check=True)
for name in module_names: for name in module_names:
copy_file("./scripts/commit-msg", ".git/modules/"+name+"/hooks") copy_file("./scripts/commit-msg", ".git/modules/"+name+"/hooks")
...@@ -274,33 +276,45 @@ def copy_file(src, dest): ...@@ -274,33 +276,45 @@ def copy_file(src, dest):
def run_install(args): def run_install(args):
install_args = ' -p ' + str(multiprocessing.cpu_count()) # Platforms with special compilation scripts
if args.distribution == IOS_DISTRIBUTION_NAME:
return subprocess.run(["./compile-ios.sh"], cwd="./client-ios", check=True)
elif args.distribution == ANDROID_DISTRIBUTION_NAME:
return subprocess.run(["./compile.sh"], cwd="./client-android", check=True)
elif args.distribution == WIN32_DISTRIBUTION_NAME:
return subprocess.run([
sys.executable, os.path.join(os.getcwd(), "scripts/build-windows.py"),
"--toolset", args.toolset,
"--sdk", args.sdk
], check=True)
# Unix-like platforms
environ = os.environ.copy()
install_args = ['-p', str(multiprocessing.cpu_count())]
if args.static: if args.static:
install_args += ' -s' install_args.append('-s')
if args.global_install: if args.global_install:
install_args += ' -g' install_args.append('-g')
if args.distribution == OSX_DISTRIBUTION_NAME: if args.distribution == OSX_DISTRIBUTION_NAME:
proc = subprocess.Popen("brew --prefix qt5", # The `universal_newlines` parameter has been renamed to `text` in
shell=True, stdout=subprocess.PIPE) # Python 3.7+ and triggering automatical binary to text conversion is
qt5dir = proc.stdout.read() # what it actually does
os.environ['CMAKE_PREFIX_PATH'] = str(qt5dir.decode('ascii')) proc = subprocess.run(["brew", "--prefix", "qt5"],
install_args += " -c client-macosx" stdout=subprocess.PIPE, check=True,
execute_script( universal_newlines=True)
["CONFIGURE_FLAGS='--without-dbus' ./scripts/install.sh " + install_args])
elif args.distribution == IOS_DISTRIBUTION_NAME: environ['CMAKE_PREFIX_PATH'] = proc.stdout.rstrip("\n")
os.chdir("./client-ios") environ['CONFIGURE_FLAGS'] = '--without-dbus'
execute_script(["./compile-ios.sh"]) install_args += ("-c", "client-macosx")
elif args.distribution == ANDROID_DISTRIBUTION_NAME:
os.chdir("./client-android")
execute_script(["./compile.sh"])
elif args.distribution == WIN32_DISTRIBUTION_NAME:
subprocess.call('python ' + os.getcwd() + '/scripts/build-windows.py ' + '--toolset ' + args.toolset + ' --sdk ' + args.sdk)
else: else:
if args.distribution in ZYPPER_BASED_DISTROS: if args.distribution in ZYPPER_BASED_DISTROS:
# fix jsoncpp pkg-config bug, remove when jsoncpp package bumped # fix jsoncpp pkg-config bug, remove when jsoncpp package bumped
os.environ['JSONCPP_LIBS'] = "-ljsoncpp" environ['JSONCPP_LIBS'] = "-ljsoncpp"
install_args += ' -c client-gnome' install_args += ("-c", "client-gnome")
execute_script(["./scripts/install.sh " + install_args])
return subprocess.run(["./scripts/install.sh"] + install_args, env=environ, check=True)
def run_uninstall(args): def run_uninstall(args):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment