Login
Log in using an SSO provider:
Fedora Account System
Red Hat Associate
Red Hat Customer
Login using a Red Hat Bugzilla account
Forgot Password
Create an Account
Red Hat Bugzilla – Attachment 1025371 Details for
Bug 1156552
[rfe] use dnf instead of yum
Home
New
Search
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh90 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
[?]
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
add dnf support
0001-dnf-support.patch (text/plain), 10.61 KB, created by
Michael Mráka
on 2015-05-14 12:27:19 UTC
(
hide
)
Description:
add dnf support
Filename:
MIME Type:
Creator:
Michael Mráka
Created:
2015-05-14 12:27:19 UTC
Size:
10.61 KB
patch
obsolete
>From f7f088c17ac96ced0be64facad2acf860fa3f003 Mon Sep 17 00:00:00 2001 >From: Michael Mraka <michael.mraka@redhat.com> >Date: Thu, 14 May 2015 14:06:51 +0200 >Subject: [PATCH] added dnf support > >--- > cobbler.spec | 4 ++ > cobbler/action_check.py | 8 +++ > cobbler/action_reposync.py | 89 +++++++++++++++++++++++++++-- > cobbler/codes.py | 2 +- > cobbler/modules/manage_import_signatures.py | 2 +- > koan/configurator.py | 41 ++++++++++++- > 6 files changed, 139 insertions(+), 7 deletions(-) > >diff --git a/cobbler.spec b/cobbler.spec >index 267bb30..059063f 100644 >--- a/cobbler.spec >+++ b/cobbler.spec >@@ -67,7 +67,11 @@ Requires: python-simplejson > Requires: python-urlgrabber > Requires: rsync > Requires: syslinux >+%if 0%{?fedora} >= 22 >+Requires: dnf-plugins-core >+%else > Requires: yum-utils >+%endif > Requires: logrotate > > %if 0%{?fedora} >= 18 || 0%{?rhel} >= 6 >diff --git a/cobbler/action_check.py b/cobbler/action_check.py >index ee23fe5..e096eb8 100644 >--- a/cobbler/action_check.py >+++ b/cobbler/action_check.py >@@ -89,6 +89,7 @@ class BootCheck: > self.check_rsync_conf(status) > self.check_httpd(status) > self.check_iptables(status) >+ self.check_dnf(status) > self.check_yum(status) > self.check_debmirror(status) > self.check_for_ksvalidator(status) >@@ -156,6 +157,13 @@ class BootCheck: > if rc == 0: > status.append(_("since iptables may be running, ensure 69, 80/443, and %(xmlrpc)s are unblocked") % { "xmlrpc" : self.settings.xmlrpc_port }) > >+ def check_dnf(self,status): >+ if self.checked_dist not in ["fedora"]: >+ return >+ >+ if not os.path.exists("/usr/bin/createrepo_c"): >+ status.append(_("createrepo_c package is not installed, needed for cobbler import and cobbler reposync, install createrepo_c?")) >+ > def check_yum(self,status): > if self.checked_dist in ["debian", "ubuntu"]: > return >diff --git a/cobbler/action_reposync.py b/cobbler/action_reposync.py >index 1e7500c..c78e093 100644 >--- a/cobbler/action_reposync.py >+++ b/cobbler/action_reposync.py >@@ -32,6 +32,11 @@ try: > import yum > except: > HAS_YUM = False >+HAS_DNF = True >+try: >+ import dnf >+except: >+ HAS_DNF = False > > import utils > from cexceptions import * >@@ -63,6 +68,7 @@ class RepoSync: > self.tries = tries > self.nofail = nofail > self.logger = logger >+ self.createrepo_bin = 'createrepo' > > if logger is None: > self.logger = clogger.Logger() >@@ -166,6 +172,8 @@ class RepoSync: > > if repo.breed == "rhn": > return self.rhn_sync(repo) >+ elif repo.breed == "dnf": >+ return self.dnf_sync(repo) > elif repo.breed == "yum": > return self.yum_sync(repo) > elif repo.breed == "apt": >@@ -189,8 +197,8 @@ class RepoSync: > # add any repo metadata we can use > mdoptions = [] > if os.path.isfile("%s/.origin/repomd.xml" % (dirname)): >- if not HAS_YUM: >- utils.die(self.logger,"yum is required to use this feature") >+ if not (HAS_YUM or HAS_DNF): >+ utils.die(self.logger,"yum or dnf is required to use this feature") > > rmd = yum.repoMDObject.RepoMD('', "%s/.origin/repomd.xml" % (dirname)) > if rmd.repoData.has_key("group"): >@@ -198,7 +206,8 @@ class RepoSync: > mdoptions.append("-g %s" % groupmdfile) > if rmd.repoData.has_key("prestodelta"): > # need createrepo >= 0.9.7 to add deltas >- if utils.check_dist() in ("redhat","fedora","centos","scientific linux","suse","opensuse"): >+ if self.createrepo_bin == 'createrepo' and \ >+ utils.check_dist() in ("redhat","fedora","centos","scientific linux","suse","opensuse"): > cmd = "/usr/bin/rpmquery --queryformat=%{VERSION} createrepo" > createrepo_ver = utils.subprocess_get(self.logger, cmd) > if utils.compare_versions_gt(createrepo_ver, "0.9.7"): >@@ -210,7 +219,7 @@ class RepoSync: > flags = blended.get("createrepo_flags","(ERROR: FLAGS)") > try: > # BOOKMARK >- cmd = "createrepo %s %s %s" % (" ".join(mdoptions), flags, dirname) >+ cmd = "%s %s %s %s" % (self.createrepo_bin, " ".join(mdoptions), flags, dirname) > utils.subprocess_call(self.logger, cmd) > except: > utils.log_exc(self.logger) >@@ -358,6 +367,78 @@ class RepoSync: > > # ==================================================================================== > >+ def dnf_sync(self, repo): >+ >+ """ >+ Handle copying of http:// and ftp:// repos. >+ """ >+ >+ # create the config file the hosts will use to access the repository. >+ repo_mirror = repo.mirror >+ dest_path = os.path.join(self.settings.webdir+"/repo_mirror", repo.name) >+ self.create_local_file(dest_path, repo) >+ self.createrepo_bin = 'createrepo_c' >+ >+ if not repo.mirror_locally: >+ return >+ >+ cmd = "" # command to run >+ has_rpm_list = False # flag indicating not to pull the whole repo >+ >+ # detect cases that require special handling >+ >+ if repo.rpm_list != "" and repo.rpm_list != []: >+ has_rpm_list = True >+ >+ # create dnf config file for use by reposync >+ temp_path = os.path.join(dest_path, ".origin") >+ >+ if not os.path.isdir(temp_path): >+ # FIXME: there's a chance this might break the RHN D/L case >+ os.makedirs(temp_path) >+ >+ temp_file = self.create_local_file(temp_path, repo, output=False) >+ >+ if not has_rpm_list: >+ # if we have not requested only certain RPMs, use reposync >+ cmd = "/usr/bin/dnf reposync %s --config=%s --repo=%s --download-path=%s" % (self.rflags, temp_file, repo.name, self.settings.webdir+"/repo_mirror") >+ if repo.arch != "": >+ if repo.arch == "x86": >+ repo.arch = "i386" # FIX potential arch errors >+ if repo.arch == "i386": >+ # counter-intuitive, but we want the newish kernels too >+ cmd = "%s -a i686" % (cmd) >+ else: >+ cmd = "%s -a %s" % (cmd, repo.arch) >+ >+ else: >+ >+ # create the output directory if it doesn't exist >+ if not os.path.exists(dest_path): >+ os.makedirs(dest_path) >+ >+ use_source = "" >+ if repo.arch == "src": >+ use_source = "--source" >+ >+ extra_flags = self.settings.yumdownloader_flags >+ cmd = "/usr/bin/dnf download %s %s --disablerepo=* --enablerepo=%s -c %s --destdir=%s %s" % (extra_flags, use_source, repo.name, temp_file, dest_path, " ".join(repo.rpm_list)) >+ >+ # now regardless of whether we're doing dnf download or reposync >+ # or whether the repo was http://, ftp://, or rhn://, execute all queued >+ # commands here. Any failure at any point stops the operation. >+ >+ rc = utils.subprocess_call(self.logger, cmd) >+ if rc !=0: >+ utils.die(self.logger,"cobbler reposync failed") >+ >+ repodata_path = os.path.join(dest_path, "repodata") >+ >+ # now run createrepo to rebuild the index >+ os.path.walk(dest_path, self.createrepo_walker, repo) >+ >+ # ==================================================================================== >+ > def yum_sync(self, repo): > > """ >diff --git a/cobbler/codes.py b/cobbler/codes.py >index ddbfe68..907d52a 100644 >--- a/cobbler/codes.py >+++ b/cobbler/codes.py >@@ -21,5 +21,5 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA > """ > > VALID_REPO_BREEDS = [ >- "rsync", "rhn", "yum", "apt", "wget" >+ "rsync", "rhn", "dnf", "yum", "apt", "wget" > ] >diff --git a/cobbler/modules/manage_import_signatures.py b/cobbler/modules/manage_import_signatures.py >index 08b6924..070f457 100644 >--- a/cobbler/modules/manage_import_signatures.py >+++ b/cobbler/modules/manage_import_signatures.py >@@ -498,7 +498,7 @@ class ImportSignatureManager: > for repo_breed in self.get_valid_repo_breeds(): > self.logger.info("checking for %s repo(s)" % repo_breed) > repo_adder = None >- if repo_breed == "yum": >+ if repo_breed == "yum" or repo_breed == "dnf": > repo_adder = self.yum_repo_adder > elif repo_breed == "rhn": > repo_adder = self.rhn_repo_adder >diff --git a/koan/configurator.py b/koan/configurator.py >index de351fc..800f0cd 100644 >--- a/koan/configurator.py >+++ b/koan/configurator.py >@@ -41,6 +41,11 @@ try: > yum_available = True > except: > yum_available = False >+try: >+ import dnf >+ dnf_available = True >+except: >+ dnf_available = False > > class KoanConfigure: > """ >@@ -120,6 +125,40 @@ class KoanConfigure: > # Enables the possibility to use different types of package configurators > if yum_available and self.dist == "redhat": > self.configure_yum_packages() >+ elif dnf_available and self.dist == "redhat": >+ self.configure_dnf_packages() >+ >+ def configure_dnf_packages(self): >+ """Configure package resources.""" >+ print "- Configuring Packages" >+ runtime_start = time.time() >+ fail = 0 >+ packages = self.config['packages'] >+ nsync = len(packages) >+ >+ base = dnf.Base() >+ base.conf.debuglevel = 0 >+ base.conf.errorlevel = 0 >+ base.conf.assumeyes = True >+ base.read_all_repos() >+ base.fill_sack() >+ >+ for package in packages: >+ action = packages[package]['action'] >+ if action == 'create': >+ base.install(package) >+ if action == 'remove': >+ base.remove(package) >+ >+ base.resolve(allow_erasing=True) >+ osync = (len(base.transaction.install_set) >+ + len(base.transaction.remove_set)) >+ if len(base.transaction): >+ base.do_transaction() >+ >+ runtime_end = time.time() >+ runtime = (runtime_end - runtime_start) >+ self.stats['pkg'] = {'runtime': runtime,'nsync': nsync,'osync': osync,'fail' : fail} > > def configure_yum_packages(self): > """Configure package resources.""" >@@ -318,4 +357,4 @@ class KoanConfigure: > if self.config['monit_enabled']: > self.configure_monit() > >- return self.stats >\ No newline at end of file >+ return self.stats >-- >1.8.3.1 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 1156552
: 1025371