Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package opi for openSUSE:Factory checked in 
at 2021-07-08 22:49:20
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/opi (Old)
 and      /work/SRC/openSUSE:Factory/.opi.new.2625 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "opi"

Thu Jul  8 22:49:20 2021 rev:19 rq:904731 version:2.1.0

Changes:
--------
--- /work/SRC/openSUSE:Factory/opi/opi.changes  2021-05-06 22:53:42.330482695 
+0200
+++ /work/SRC/openSUSE:Factory/.opi.new.2625/opi.changes        2021-07-08 
22:49:40.367888542 +0200
@@ -1,0 +2,9 @@
+Tue Jul  6 09:38:22 UTC 2021 - Dominik Heidler <dheid...@suse.de>
+
+- Version 2.1.0
+  * Added
+    - Support for dnf backend
+  * Changed
+    - Deduplicated packman repo creation code 
+
+-------------------------------------------------------------------

Old:
----
  opi-2.0.0.tar.gz

New:
----
  opi-2.1.0.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ opi.spec ++++++
--- /var/tmp/diff_new_pack.fZeAMD/_old  2021-07-08 22:49:40.755885549 +0200
+++ /var/tmp/diff_new_pack.fZeAMD/_new  2021-07-08 22:49:40.759885518 +0200
@@ -17,7 +17,7 @@
 
 
 Name:           opi
-Version:        2.0.0
+Version:        2.1.0
 Release:        0
 Summary:        OBS Package Installer (CLI)
 License:        GPL-3.0-only

++++++ opi-2.0.0.tar.gz -> opi-2.1.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/opi-2.0.0/CHANGELOG.md new/opi-2.1.0/CHANGELOG.md
--- old/opi-2.0.0/CHANGELOG.md  2021-05-03 16:40:25.000000000 +0200
+++ new/opi-2.1.0/CHANGELOG.md  2021-07-05 16:14:29.000000000 +0200
@@ -7,6 +7,16 @@
 
 ## [Unreleased]
 
+## [2.1.0] - 2021-07-05
+
+### Added
+
+- Support for dnf backend [#58](https://github.com/openSUSE/opi/pull/58)
+
+### Changed
+
+- Deduplicated packman repo creation code
+
 ## [2.0.0] - 2021-05-03
 
 ### Added
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/opi-2.0.0/README.md new/opi-2.1.0/README.md
--- old/opi-2.0.0/README.md     2021-05-03 16:40:25.000000000 +0200
+++ new/opi-2.1.0/README.md     2021-07-05 16:14:29.000000000 +0200
@@ -16,6 +16,10 @@
 - python3-lxml
 - python3-termcolor
 
+If you want to use dnf instead of zypper, you also need:
+- dnf
+- libdnf-repo-config-zypp
+
 ## Install
 
 ### openSUSE Tumbleweed and Leap
@@ -46,6 +50,18 @@
 
 ![Screenshot](screenshot.png)
 
+### Using DNF instead of Zypper
+If you want to, you can use [DNF](https://en.opensuse.org/SDB:DNF) instead of 
Zypper.
+To do this, change the content of `~/.config/opi/config.json` so that it looks 
like this:
+
+```json
+{
+  "backend": "dnf"
+}
+```
+
+If you want to go back to Zypper, just change the value of `backend` back to 
`zypp`.
+
 ### Packages from Other Repositories
 
 **Packman Codecs** (enable you to play MP4 videos and YouTube)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/opi-2.0.0/opi/__init__.py 
new/opi-2.1.0/opi/__init__.py
--- old/opi-2.0.0/opi/__init__.py       2021-05-03 16:40:25.000000000 +0200
+++ new/opi-2.1.0/opi/__init__.py       2021-07-05 16:14:29.000000000 +0200
@@ -7,6 +7,7 @@
 import lxml.etree
 from termcolor import colored
 
+from opi.backends import get_backend, BackendConstants
 
 OBS_APIROOT = {
        'openSUSE': 'https://api.opensuse.org',
@@ -63,22 +64,29 @@
        project = project.replace(':', '_')
        project = project.replace('Factory', 'Tumbleweed')
 
-       url = 'https://ftp.gwdg.de/pub/linux/misc/packman/suse/%s/' % project
-       subprocess.call(['sudo', 'zypper', 'ar', '--refresh', '--priority', 
'90', '--name', 'Packman', url, 'packman'])
-       subprocess.call(['sudo', 'zypper', 'refresh'])
+       add_repo(
+               filename = 'packman',
+               name = 'Packman',
+               url = 'https://ftp.gwdg.de/pub/linux/misc/packman/suse/%s/' % 
project,
+               auto_refresh = True,
+               priority = 90
+       )
 
        if dup:
-               subprocess.call(['sudo', 'zypper', 'dist-upgrade', '--from', 
'packman', '--allow-downgrade', '--allow-vendor-change'])
+               if get_backend() == BackendConstants.zypp:
+                       subprocess.call(['sudo', 'zypper', 'dist-upgrade', 
'--from', 'packman', '--allow-downgrade', '--allow-vendor-change'])
+               elif get_backend() == BackendConstants.dnf:
+                       subprocess.call(['sudo', 'dnf', 'dup', 
'--setopt=allow_vendor_change=True', '--repo', 'packman'])
 
 def install_packman_packages(packages, **kwargs):
        install_packages(packages, from_repo='packman', **kwargs)
 
 
-############
-### ZYPP ###
-############
+################
+### ZYPP/DNF ###
+################
 
-def add_repo(filename, name, url, enabled=True, gpgcheck=True, gpgkey=None, 
repo_type='rpm-md', auto_import_key=False):
+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')
        tf.file.write("[%s]\n" % filename)
        tf.file.write("name=%s\n" % name)
@@ -89,22 +97,46 @@
        if gpgkey:
                subprocess.call(['sudo', 'rpm', '--import', gpgkey])
                tf.file.write("gpgkey=%s\n" % gpgkey)
+       if auto_refresh:
+               tf.file.write("autorefresh=1\n")
+       if priority:
+               tf.file.write("priority=%i\n" % priority)
        tf.file.flush()
        subprocess.call(['sudo', 'cp', tf.name, '/etc/zypp/repos.d/%s.repo' % 
filename])
        subprocess.call(['sudo', 'chmod', '644', '/etc/zypp/repos.d/%s.repo' % 
filename])
        tf.file.close()
-       refresh_cmd = ['sudo', 'zypper']
-       if auto_import_key:
-               refresh_cmd.append('--gpg-auto-import-keys')
-       refresh_cmd.append('ref')
+       refresh_cmd = []
+       if get_backend() == BackendConstants.zypp:
+               refresh_cmd = ['sudo', 'zypper']
+               if auto_import_key:
+                       refresh_cmd.append('--gpg-auto-import-keys')
+               refresh_cmd.append('ref')
+       elif get_backend() == BackendConstants.dnf:
+               refresh_cmd = ['sudo', 'dnf', 'ref']
        subprocess.call(refresh_cmd)
 
-def install_packages(packages, from_repo=None, flags=None):
-       args = ['sudo', 'zypper', 'in']
-       if from_repo:
-               args.extend(['--from', from_repo])
-       if flags:
-               args.extend(flags)
+def install_packages(packages, from_repo=None, allow_vendor_change=False, 
allow_arch_change=False, allow_downgrade=False, allow_name_change=False):
+       if get_backend() == BackendConstants.zypp:
+               args = ['sudo', 'zypper', 'in']
+               if from_repo:
+                       args.extend(['--from', from_repo])
+       elif get_backend() == BackendConstants.dnf:
+               args = ['sudo', 'dnf', 'in']
+               if from_repo:
+                       args.extend(['--repo', from_repo])
+       if get_backend() == BackendConstants.zypp:
+               if allow_downgrade:
+                       args.append('--allow-downgrade')
+               if allow_arch_change:
+                       args.append('--allow-arch-change')
+               if allow_name_change:
+                       args.append('--allow-name-change')
+               if allow_vendor_change:
+                       args.append('--allow-vendor-change')
+       elif get_backend() == BackendConstants.dnf:
+               # allow_downgrade and allow_name_change are default in DNF
+               if allow_vendor_change:
+                       args.append('--setopt=allow_vendor_change=True')
        args.extend(packages)
        subprocess.call(args)
 
@@ -230,16 +262,18 @@
                # Install from official repos (don't add a repo)
                install_packages([name_with_arch])
        else:
-               repo_url = "https://download.opensuse.org/repositories/%s/%s/"; 
% (project, repository)
-               repo_file = "%s/%s.repo" % (repo_url, project)
-               subprocess.call(['sudo', 'zypper', 'ar', '--refresh', 
repo_file])
-               project = project.replace(':', '_')
-               repo_file_local = '/etc/zypp/repos.d/%s.repo' % project
-               # Change http to https
-               subprocess.call(['sudo', 'sed', '-i', 
's~http://download.opensuse.org~https://download.opensuse.org~g', 
repo_file_local])
-               subprocess.call(['sudo', 'zypper', 'refresh'])
-               install_packages([name_with_arch], from_repo=project, 
flags=['--allow-vendor-change', '--allow-arch-change', '--allow-downgrade', 
'--allow-name-change'])
-               ask_keep_repo(project)
+               repo_alias = project.replace(':', '_')
+               project_path = project.replace(':', ':/')
+               add_repo(
+                       filename = repo_alias,
+                       name = project,
+                       url = 
"https://download.opensuse.org/repositories/%s/%s/"; % (project_path, 
repository),
+                       gpgkey = 
"https://download.opensuse.org/repositories/%s/%s/repodata/repomd.xml.key"; % 
(project_path, repository),
+                       gpgcheck = True,
+                       auto_refresh = True
+               )
+               install_packages([name_with_arch], from_repo=repo_alias, 
allow_downgrade=True, allow_arch_change=True, allow_name_change=True, 
allow_vendor_change=True)
+               ask_keep_repo(repo_alias)
 
 
 ########################
@@ -267,8 +301,10 @@
 
 def ask_keep_repo(repo):
        if not ask_yes_or_no('Do you want to keep the repo "%s"?' % repo, 'y'):
-               subprocess.call(['sudo', 'zypper', 'rr', repo])
-
+               if get_backend() == BackendConstants.zypp:
+                       subprocess.call(['sudo', 'zypper', 'rr', repo])
+               if get_backend() == BackendConstants.dnf:
+                       subprocess.call(['sudo', 'rm', '/etc/zypp/repos.d/' + 
repo + '.repo'])
 
 def print_package_names(package_names):
        i = 1
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/opi-2.0.0/opi/backends/__init__.py 
new/opi-2.1.0/opi/backends/__init__.py
--- old/opi-2.0.0/opi/backends/__init__.py      1970-01-01 01:00:00.000000000 
+0100
+++ new/opi-2.1.0/opi/backends/__init__.py      2021-07-05 16:14:29.000000000 
+0200
@@ -0,0 +1,12 @@
+import opi.config as config
+
+class BackendConstants:
+       zypp = "zypp"
+       dnf = "dnf"
+
+
+def get_backend():
+       backend = config.get_key_from_config("backend")
+       if not backend in ["zypp", "dnf"]:
+               raise config.ConfigError("Invalid backend configuration.")
+       return backend
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/opi-2.0.0/opi/config/__init__.py 
new/opi-2.1.0/opi/config/__init__.py
--- old/opi-2.0.0/opi/config/__init__.py        1970-01-01 01:00:00.000000000 
+0100
+++ new/opi-2.1.0/opi/config/__init__.py        2021-07-05 16:14:29.000000000 
+0200
@@ -0,0 +1,34 @@
+import os
+import pwd
+import subprocess
+import json
+
+cache = {}
+
+class ConfigError(Exception):
+       pass
+
+def create_default_config():
+       path = pwd.getpwuid(os.getuid()).pw_dir + "/.config/opi/"
+       subprocess.call(["mkdir", "-p", path])
+       config = {
+               "backend": "zypp"
+       }
+       config_file = open(path + 'config.json', 'w')
+       json.dump(config, config_file, indent=4)
+
+def get_key_from_config(key: str):
+       if not key in cache:
+               path = pwd.getpwuid(os.getuid()).pw_dir + 
"/.config/opi/config.json"
+               if not os.path.isfile(path):
+                       create_default_config()
+               config = json.loads(open(path).read())
+               cache[key] = config[key]
+               return cache[key]
+       else:
+               return cache[key]
+
+path = pwd.getpwuid(os.getuid()).pw_dir + "/.config/opi/config.json"
+if not os.path.isfile(path):
+       create_default_config()
+
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/opi-2.0.0/opi/plugins/chrome.py 
new/opi-2.1.0/opi/plugins/chrome.py
--- old/opi-2.0.0/opi/plugins/chrome.py 2021-05-03 16:40:25.000000000 +0200
+++ new/opi-2.1.0/opi/plugins/chrome.py 2021-07-05 16:14:29.000000000 +0200
@@ -4,7 +4,7 @@
 
 class GoogleChrome(BasePlugin):
        main_query = "chrome"
-       description = "Google Chrome webbrowser"
+       description = "Google Chrome web browser"
        queries = ('chrome', 'google-chrome')
 
        @classmethod
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/opi-2.0.0/opi/plugins/ms_edge.py 
new/opi-2.1.0/opi/plugins/ms_edge.py
--- old/opi-2.0.0/opi/plugins/ms_edge.py        2021-05-03 16:40:25.000000000 
+0200
+++ new/opi-2.1.0/opi/plugins/ms_edge.py        2021-07-05 16:14:29.000000000 
+0200
@@ -4,7 +4,7 @@
 
 class MSEdge(BasePlugin):
        main_query = "msedge"
-       description = "Microsoft Edge"
+       description = "Microsoft Edge Dev"
        queries = ('microsoftedge', 'msedge', 'edge')
 
        @classmethod
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/opi-2.0.0/opi/plugins/packman.py 
new/opi-2.1.0/opi/plugins/packman.py
--- old/opi-2.0.0/opi/plugins/packman.py        2021-05-03 16:40:25.000000000 
+0200
+++ new/opi-2.1.0/opi/plugins/packman.py        2021-07-05 16:14:29.000000000 
+0200
@@ -3,7 +3,7 @@
 
 class PackmanCodecsPlugin(BasePlugin):
        main_query = "codecs"
-       description = "Media Codecs from Packman Repo"
+       description = "Media Codecs from Packman and official repo"
        queries = ('packman', 'codecs')
 
        @classmethod
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/opi-2.0.0/opi/plugins/teamviewer.py 
new/opi-2.1.0/opi/plugins/teamviewer.py
--- old/opi-2.0.0/opi/plugins/teamviewer.py     2021-05-03 16:40:25.000000000 
+0200
+++ new/opi-2.1.0/opi/plugins/teamviewer.py     2021-07-05 16:14:29.000000000 
+0200
@@ -4,7 +4,7 @@
 
 class Teamviewer(BasePlugin):
        main_query = "teamviewer"
-       description = "Teamviewer remote access"
+       description = "TeamViewer remote access"
        queries = ('teamviewer')
 
        @classmethod
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/opi-2.0.0/opi/plugins/vivaldi.py 
new/opi-2.1.0/opi/plugins/vivaldi.py
--- old/opi-2.0.0/opi/plugins/vivaldi.py        2021-05-03 16:40:25.000000000 
+0200
+++ new/opi-2.1.0/opi/plugins/vivaldi.py        2021-07-05 16:14:29.000000000 
+0200
@@ -4,7 +4,7 @@
 
 class Vivaldi(BasePlugin):
        main_query = "vivaldi"
-       description = "Vivaldi webbrowser"
+       description = "Vivaldi web browser"
        queries = ('vivaldi')
 
        @classmethod
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/opi-2.0.0/opi/plugins/zoom.py 
new/opi-2.1.0/opi/plugins/zoom.py
--- old/opi-2.0.0/opi/plugins/zoom.py   2021-05-03 16:40:25.000000000 +0200
+++ new/opi-2.1.0/opi/plugins/zoom.py   2021-07-05 16:14:29.000000000 +0200
@@ -4,12 +4,12 @@
 
 class Zoom(BasePlugin):
        main_query = "zoom"
-       description = "ZOOM Video Conference"
+       description = "Zoom Video Conference"
        queries = ('zoom')
 
        @classmethod
        def run(cls, query):
-               if not opi.ask_yes_or_no("Do you want to install zoom from 
zoom.us?", 'y'):
+               if not opi.ask_yes_or_no("Do you want to install Zoom from 
zoom.us?", 'y'):
                        return
 
                subprocess.call(['sudo', 'rpm', '--import', 
'https://zoom.us/linux/download/pubkey'])
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/opi-2.0.0/opi/version.py new/opi-2.1.0/opi/version.py
--- old/opi-2.0.0/opi/version.py        2021-05-03 16:40:25.000000000 +0200
+++ new/opi-2.1.0/opi/version.py        2021-07-05 16:14:29.000000000 +0200
@@ -1 +1 @@
-__version__ = '2.0.0'
+__version__ = '2.1.0'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/opi-2.0.0/setup.py new/opi-2.1.0/setup.py
--- old/opi-2.0.0/setup.py      2021-05-03 16:40:25.000000000 +0200
+++ new/opi-2.1.0/setup.py      2021-07-05 16:14:29.000000000 +0200
@@ -11,9 +11,9 @@
     version=__version__,
     license='GPLv3',
     description='Tool to Search and install almost all packages available for 
openSUSE and SLE',
-    author='Guo Yunhe, Dominik Heidler',
-    author_email='i...@guoyunhe.me, dheid...@suse.de',
+    author='Guo Yunhe, Dominik Heidler, KaratekHD',
+    author_email='i...@guoyunhe.me, dheid...@suse.de, kara...@karatek.net',
     requires=['lxml', 'requests', 'termcolor'],
-    packages=['opi', 'opi.plugins'],
+    packages=['opi', 'opi.plugins', 'opi.config', 'opi.backends'],
     scripts=['bin/opi'],
 )
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/opi-2.0.0/test/02_install_from_home.py 
new/opi-2.1.0/test/02_install_from_home.py
--- old/opi-2.0.0/test/02_install_from_home.py  2021-05-03 16:40:25.000000000 
+0200
+++ new/opi-2.1.0/test/02_install_from_home.py  2021-07-05 16:14:29.000000000 
+0200
@@ -13,9 +13,6 @@
 c.expect("2. .*X11:Utilities", timeout=10)
 c.sendline('2')
 
-c.expect("Do you want to reject the key", timeout=10)
-c.sendline('t')
-
 c.expect("new packages to install", timeout=10)
 c.expect("Continue", timeout=10)
 c.sendline('y')

Reply via email to