From ca06e1e1e240f5a1d91899df56ddf17b400dc6ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B0=D1=80=D0=BA=D0=BE=D0=B2=20=D0=94=D0=BC=D0=B8?= =?UTF-8?q?=D1=82=D1=80=D0=B8=D0=B9?= <13werwolf13@mail.ru> Date: Mon, 13 Feb 2023 15:14:52 +0500 Subject: [PATCH] Add openh264 (#119) * Add openh264 * Add gpg ref with openh264 repo and check if repo already exists * Use repo alias instead of file name when installing from a specific repo --------- Co-authored-by: Dominik Heidler --- opi/__init__.py | 34 +++++++++++++++++++++++++++++++--- opi/plugins/packman.py | 10 ++++++++++ 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/opi/__init__.py b/opi/__init__.py index 1fe0c24..3de8d32 100644 --- a/opi/__init__.py +++ b/opi/__init__.py @@ -103,6 +103,33 @@ def add_packman_repo(dup=False): elif get_backend() == BackendConstants.dnf: subprocess.call(['sudo', 'dnf', 'dup', '--setopt=allow_vendor_change=True', '--repo', 'packman']) +def add_openh264_repo(dup=False): + project = get_os_release()["NAME"] + project = project.replace(':', '_').replace(' ', '_') + + url = 'https://codecs.opensuse.org/openh264/%s/' % project + existing_repo = get_enabled_repo_by_url(url) + if existing_repo: + print(f"Installing from existing repo '{existing_repo['name']}'") + repo = existing_repo['alias'] + else: + repo = "openh264" + print(f"Adding repo '{repo}'") + add_repo( + filename = repo, + name = repo, + url = url, + gpgkey = f"{url}repodata/repomd.xml.key", + auto_refresh = True, + priority = 90 + ) + + if dup: + if get_backend() == BackendConstants.zypp: + subprocess.call(['sudo', 'zypper', 'dist-upgrade', '--from', repo, '--allow-downgrade', '--allow-vendor-change']) + elif get_backend() == BackendConstants.dnf: + subprocess.call(['sudo', 'dnf', 'dup', '--setopt=allow_vendor_change=True', '--repo', repo]) + def install_packman_packages(packages, **kwargs): install_packages(packages, from_repo='packman', **kwargs) @@ -125,6 +152,7 @@ def get_repos(): if not bool(int(cp.get(mainsec, "enabled"))): continue repo = { + "alias": mainsec, "name": re.sub(r"\.repo$", "", repo_file), "url": cp.get(mainsec, "baseurl"), } @@ -137,7 +165,7 @@ def get_repos(): def get_enabled_repo_by_url(url): for repo in get_repos(): if url_normalize(repo['url']) == url_normalize(url): - return repo['name'] + return repo def add_repo(filename, name, url, enabled=True, gpgcheck=True, gpgkey=None, repo_type='rpm-md', auto_import_key=False, auto_refresh=False, priority=None): tf = tempfile.NamedTemporaryFile('w') @@ -368,8 +396,8 @@ def install_binary(binary): existing_repo = get_enabled_repo_by_url(url) if existing_repo: # Install from existing repos (don't add a repo) - print(f"Installing from existing repo '{existing_repo}'") - install_packages([name_with_arch], from_repo=existing_repo) + print(f"Installing from existing repo '{existing_repo['name']}'") + install_packages([name_with_arch], from_repo=existing_repo['alias']) else: print(f"Adding repo '{project}'") add_repo( diff --git a/opi/plugins/packman.py b/opi/plugins/packman.py index f32a09d..3cdc996 100644 --- a/opi/plugins/packman.py +++ b/opi/plugins/packman.py @@ -20,6 +20,7 @@ def run(cls, query): 'gstreamer-plugins-bad-codecs', 'gstreamer-plugins-ugly-codecs', 'gstreamer-plugins-libav', + 'libfdk-aac2', ] if opi.get_version() != '15.4': packman_packages.append('pipewire-aptx') @@ -32,3 +33,12 @@ def run(cls, query): 'gstreamer-plugins-bad', 'gstreamer-plugins-ugly', ]) + + if not opi.ask_yes_or_no("Do you want to install openh264 codecs from openSUSE openh264 repository?", 'y'): + return + opi.add_openh264_repo(dup=True) + + opi.install_packages([ + 'libgstopenh264.so()(64bit)', + 'mozilla-openh264', + ])