Skip to content

Commit

Permalink
Add openh264 (#119)
Browse files Browse the repository at this point in the history
* 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 <dheidler@suse.de>
  • Loading branch information
13werwolf13 and asdil12 authored Feb 13, 2023
1 parent 104f826 commit ca06e1e
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 3 deletions.
34 changes: 31 additions & 3 deletions opi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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"),
}
Expand All @@ -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')
Expand Down Expand Up @@ -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(
Expand Down
10 changes: 10 additions & 0 deletions opi/plugins/packman.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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',
])

0 comments on commit ca06e1e

Please sign in to comment.