diff options
author | Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org> | 2020-09-15 18:49:10 +0200 |
---|---|---|
committer | Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org> | 2020-09-15 18:49:10 +0200 |
commit | 0d029f98a87360187e71f69ef0b0aa4245cf7541 (patch) | |
tree | 72d46bfb0914040b407914180526a6648fcbc9a6 | |
parent | 5a30d2a4fccbe4d89015df07f769541e64d55d46 (diff) | |
download | hardware_replicant_libsamsung-ipc-patches-todo/compilation-script.tar.gz hardware_replicant_libsamsung-ipc-patches-todo/compilation-script.tar.bz2 hardware_replicant_libsamsung-ipc-patches-todo/compilation-script.zip |
WIP: Add compilation test scriptpatches-todo/compilation-script
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
-rwxr-xr-x | scripts/compile_test.py | 136 |
1 files changed, 136 insertions, 0 deletions
diff --git a/scripts/compile_test.py b/scripts/compile_test.py new file mode 100755 index 0000000..0591c40 --- /dev/null +++ b/scripts/compile_test.py @@ -0,0 +1,136 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# +# Copyright (C) 2020 Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org> +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <https://www.gnu.org/licenses/>. + +import os +import re +import sh +import sys + +# TODO: replace by a config file +default_settings = [ + { + "host" : "lxc-f2a85m-pro-trisquel7-local", + "directory" : "replicant-4.2", + "replicant_version": "replicant-4.2", + "commit" : "HEAD", + "target" : "crespo", + }, + { + "host" : "lxc-f2a85m-pro-debian-local", + "directory": "replicant-6.0", + "replicant_version": "replicant-6.0", + "commit" : "HEAD", + "target" : "i9300", + }, + { + "host" : "lxc-f2a85m-pro-trisquel8-local", + "directory": "replicant-10", + "replicant_version": "replicant-10", + "commit" : "HEAD", + "target" : "i9300", + }, +] + +# Copied from vendor/replicant-scripts/patches/replicant_prepare_patch.py +def get_git_revision(git_revision): + output = sh.git('--no-pager', 'log', '--oneline', git_revision, '-1', + '--format=%H') + revision = re.sub(os.linesep, '', str(output)) + + return revision + +def remote_command(host, directory, command): + # Handle strings and arrays + if type(command) == type(list()): + command = " ".join(command) + + run_in_dir = "cd {directory} && ".format(directory=directory) + output = sh.ssh(host, run_in_dir + command) + print(output) + +def remote_git_command(host, replicant_dir, command): + # Handle strings and arrays + if type(command) == type(list()): + command = " ".join(command) + + directory = ["hardware", "replicant", "libsamsung-ipc"] + + remote_command(host, replicant_dir, + ["git", "-C", os.sep.join(directory), command]) + +def remote_screen_command(host, directory, command): + # Handle strings and arrays + if type(command) == type(list()): + command = " ".join(command) + + remote_command(host, directory, + ["screen", "-d", "-m", "-S", "compile_test.py", command]) + +def test_revision(host, commit, target, directory): + commit = get_git_revision(commit) + remote_git_command(host, directory, ["checkout", commit]) + + remote_screen_command(host, directory, "vendor/replicant/build.sh " + target) + +def usage(progname): + print("Usage:") + print("\t{} <replicant-version> [commit] [target] [host]".format(progname)) + print("\n") + print("Supported Replicant versions:") + for elm in default_settings: + print("- {}".format(elm['replicant_version'])) + sys.exit(1) + +def get_default(key, value): + # TODO: array of {key,value} and raise error if len(results) > 1 + for elm in default_settings: + if elm.get(key, None) == value: + return elm + +if __name__ == '__main__': + if len(sys.argv) not in [2, 3, 4, 5]: + usage(sys.argv[0]) + + replicant_version = None + target = None + commit = None + host = None + + if len(sys.argv) >= 2: + replicant_version = sys.argv[1] + if len(sys.argv) >= 3: + commit = sys.argv[2] + if len(sys.argv) >= 4: + target = sys.argv[3] + if len(sys.argv) >= 5: + host = sys.argv[4] + + entry = get_default("replicant_version", replicant_version) + directory = entry['directory'] + + if len(sys.argv) < 5: + host = entry['host'] + if len(sys.argv) < 4: + commit = entry['commit'] + if len(sys.argv) < 3: + target = entry['target'] + + test_revision(host=host, + commit=commit, + target=target, + directory=directory) |