diff options
author | Thibault Saunier <thibault.saunier@osg.samsung.com> | 2016-09-30 10:48:19 -0300 |
---|---|---|
committer | Thibault Saunier <thibault.saunier@osg.samsung.com> | 2016-09-30 12:53:13 -0300 |
commit | fdd72f28d3fc525f9fd55a4d764e08a3898052d6 (patch) | |
tree | 3826b19d102f5d4bed59ae3d54b8ff0384c9eea9 | |
parent | f980fd91c1c1fd01333966041a4a535366e897bd (diff) |
Add a script to copy shared assets to GStreamer modules
And add getpluginsdir here as it is shared by many modules
-rw-r--r-- | tests/check/getpluginsdir | 25 | ||||
-rwxr-xr-x | update_gst_modules_assets.py | 90 |
2 files changed, 115 insertions, 0 deletions
diff --git a/tests/check/getpluginsdir b/tests/check/getpluginsdir new file mode 100644 index 0000000..102e3c8 --- /dev/null +++ b/tests/check/getpluginsdir @@ -0,0 +1,25 @@ +#!/usr/bin/env python3 + +import os +import sys +import subprocess + +builddir = os.environ['MESON_BUILD_ROOT'] + +res = '' +args = sys.argv[1:] +for i in range(0, len(args), 2): + project = args[i] + pkg_name = args[i + 1] + path = os.path.join(builddir, 'subprojects', project) + if os.path.exists(path): + res += ':' + path + else: + try: + res += ':' + subprocess.check_output(['pkg-config', + '--variable=pluginsdir', + pkg_name]).decode() + except subprocess.CalledProcessError: + exit(1) + +print(res.strip(":")) diff --git a/update_gst_modules_assets.py b/update_gst_modules_assets.py new file mode 100755 index 0000000..5d90a61 --- /dev/null +++ b/update_gst_modules_assets.py @@ -0,0 +1,90 @@ +#!/usr/bin/env python3 + +import os +import shutil +import sys +import argparse +import subprocess + +parser = argparse.ArgumentParser(prog="update-gstreamer-common-files", + description="Copy files that are common to several repository" + " to the right places in those.") +parser.add_argument("-m", "--commit-message", + help="git add modified files and commit the changes with this message.") +parser.add_argument('rootdir', metavar='rootdir', nargs=1, + help='The directory where to find GStreamer modules repoos.') + + +SCRIPTDIR = os.path.dirname(__file__) +FILES_TO_COPY = ['hooks/pre-commit.hook'] +GETPLUGINSDIR = 'tests/check/getpluginsdir' + +FILES_TO_COPY_PER_MODULE = { + 'gstreamer': [], + 'gst-plugins-base': [GETPLUGINSDIR], + 'gst-plugins-good': [GETPLUGINSDIR], + 'gst-plugins-ugly': [GETPLUGINSDIR], + 'gst-plugins-bad': [], + 'gst-libav': [], + 'gst-editing-services': [GETPLUGINSDIR], + 'gst-devtools': [(GETPLUGINSDIR, "validate/tests/")], + 'gst-python': [], +} + +if __name__ == "__main__": + options = parser.parse_args() + rootpath = options.rootdir[0] + if not os.path.exists(rootpath): + print("Please path the root directory where to find GStreamer modules repos" + " %s does not exists", rootpath) + exit(1) + + summary = "" + for module, files in FILES_TO_COPY_PER_MODULE.items(): + files += FILES_TO_COPY + + repodir = os.path.abspath(os.path.join(rootpath, module)) + if not os.path.exists(repodir): + print("Repo %s does not exists" % repodir) + exit(1) + + if options.commit_message: + dirty = False + try: + dirty = subprocess.check_output('git status --porcelain --untracked-files=no'.split(' '), + cwd=repodir) + except Exception as e: + dirty = True + + if dirty: + print("Can not commit %s as the repository is dirty." % + (repodir)) + exit(1) + + for f in files: + if isinstance(f, tuple): + destdir = os.path.join(repodir, f[1]) + f = f[0] + else: + dirname = os.path.dirname(f) + destdir = os.path.join(repodir, dirname) + + if destdir and not os.path.exists(destdir): + print("Making dir %s" % destdir) + os.makedirs(destdir, exist_ok=True) + + dest = os.path.join(destdir, os.path.basename(f)) + print("Copying %s to %s" %(f, dest)) + shutil.copy(os.path.join(SCRIPTDIR, f), dest) + if options.commit_message: + subprocess.check_call(['git', 'add', os.path.abspath(dest)], + cwd=repodir) + + if options.commit_message: + if subprocess.call('git diff-index --quiet --cached HEAD'.split(' '), cwd=repodir) != 0: + subprocess.call(['git', 'commit', '-m', options.commit_message], cwd=repodir) + if not summary: + summary = "Commited:\n" + summary += repodir + '\n' + + print(summary) |