Skip to content

Commit

Permalink
Yum -> DNF; ayum -> dbo
Browse files Browse the repository at this point in the history
Remove remaining references to Yum
  • Loading branch information
Conan-Kudo committed Nov 29, 2016
1 parent 617e737 commit ec870ce
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 28 deletions.
2 changes: 1 addition & 1 deletion docs/livecd-creator.pod
Expand Up @@ -88,7 +88,7 @@ livecd-creator \
=head1 REPO EXTENSIONS

livecd-creator provides for some extensions to the repo commands similar
to what yum supports. The strings $arch, $basearch and $releasever
to what DNF supports. The strings $arch, $basearch and $releasever
are replaced with the system arch, basearch and release version respectively.
When no --releasever is passed it defaults to the current system's version.
The allows the use of repo commands such as the following:
Expand Down
2 changes: 1 addition & 1 deletion imgcreate/__init__.py
Expand Up @@ -18,7 +18,7 @@

from imgcreate.live import *
from imgcreate.creator import *
from imgcreate.yuminst import *
from imgcreate.dnfinst import *
from imgcreate.kickstart import *
from imgcreate.fs import *
from imgcreate.debug import *
Expand Down
32 changes: 16 additions & 16 deletions imgcreate/creator.py
Expand Up @@ -38,7 +38,7 @@

from imgcreate.errors import *
from imgcreate.fs import *
from imgcreate.yuminst import *
from imgcreate.dnfinst import *
from imgcreate import kickstart

FSLABEL_MAXLEN = 32
Expand Down Expand Up @@ -521,7 +521,7 @@ def mount(self, base_on = None, cachedir = None):
base_on -- a previous install on which to base this install; defaults
to None, causing a new image to be created
cachedir -- a directory in which to store the Yum cache; defaults to
cachedir -- a directory in which to store the DNF cache; defaults to
None, causing a new cache to be created; by setting this
to another directory, the same cache can be reused across
multiple installs.
Expand Down Expand Up @@ -613,14 +613,14 @@ def cleanup(self):
shutil.rmtree(self.__builddir, ignore_errors = True)
self.__builddir = None

def __apply_selections(self, ayum):
def __apply_selections(self, dbo):
excludedPkgs = kickstart.get_excluded(self.ks, self._get_excluded_packages())

if kickstart.nocore(self.ks):
logging.info("skipping core group due to %%packages --nocore; system may not be complete")
else:
try:
ayum.selectGroup('core', excludedPkgs)
dbo.selectGroup('core', excludedPkgs)
logging.info("selected group: core")
except dnf.exceptions.MarkingError as e:
if kickstart.ignore_missing(self.ks):
Expand All @@ -635,7 +635,7 @@ def __apply_selections(self, ayum):

if env:
try:
ayum.selectEnvironment(env, excludedGroups, excludedPkgs)
dbo.selectEnvironment(env, excludedGroups, excludedPkgs)
logging.info("selected env: %s", env)
except dnf.exceptions.MarkingError as e:
if kickstart.ignore_missing(self.ks):
Expand All @@ -649,7 +649,7 @@ def __apply_selections(self, ayum):
continue

try:
ayum.selectGroup(group.name, excludedPkgs, group.include)
dbo.selectGroup(group.name, excludedPkgs, group.include)
logging.info("selected group: %s", group.name)
except dnf.exceptions.MarkingError as e:
if kickstart.ignore_missing(self.ks):
Expand All @@ -659,13 +659,13 @@ def __apply_selections(self, ayum):
(group.name, e))

for pkg_name in set(excludedPkgs):
ayum.deselectPackage(pkg_name)
dbo.deselectPackage(pkg_name)
logging.info("excluding package: '%s'", pkg_name)

for pkg_name in set(kickstart.get_packages(self.ks,
self._get_required_packages())) - set(excludedPkgs):
try:
ayum.selectPackage(pkg_name)
dbo.selectPackage(pkg_name)
logging.info("selected package: '%s'", pkg_name)
except dnf.exceptions.MarkingError as e:
if kickstart.ignore_missing(self.ks):
Expand All @@ -688,14 +688,14 @@ def install(self, repo_urls = {}):
"""
dnf_conf = self._mktemp(prefix = "dnf.conf-")

ayum = LiveCDYum(releasever=self.releasever, useplugins=self.useplugins)
ayum.setup(dnf_conf, self._instroot, cacheonly=self.cacheonly,
dbo = DnfLiveCD(releasever=self.releasever, useplugins=self.useplugins)
dbo.setup(dnf_conf, self._instroot, cacheonly=self.cacheonly,
excludeWeakdeps=self.excludeWeakdeps)

for repo in kickstart.get_repos(self.ks, repo_urls):
(name, baseurl, mirrorlist, proxy, inc, exc, cost, sslverify) = repo

yr = ayum.addRepository(name, baseurl, mirrorlist)
yr = dbo.addRepository(name, baseurl, mirrorlist)
if inc:
yr.includepkgs = inc
if exc:
Expand All @@ -713,19 +713,19 @@ def install(self, repo_urls = {}):
if kickstart.inst_langs(self.ks) != None:
rpm.addMacro("_install_langs", kickstart.inst_langs(self.ks))

ayum.fill_sack(load_system_repo = os.path.exists(self._instroot + "/var/lib/rpm/Packages"))
ayum.read_comps()
dbo.fill_sack(load_system_repo = os.path.exists(self._instroot + "/var/lib/rpm/Packages"))
dbo.read_comps()

try:
self.__apply_selections(ayum)
self.__apply_selections(dbo)

ayum.runInstall()
dbo.runInstall()
except (dnf.exceptions.DownloadError, dnf.exceptions.RepoError) as e:
raise CreatorError("Unable to download from repo : %s" % (e,))
except dnf.exceptions.Error as e:
raise CreatorError("Unable to install: %s" % (e,))
finally:
ayum.close()
dbo.close()
os.unlink(dnf_conf)

# do some clean up to avoid lvm info leakage. this sucks.
Expand Down
6 changes: 3 additions & 3 deletions imgcreate/yuminst.py → imgcreate/dnfinst.py
@@ -1,5 +1,5 @@
#
# yum.py : yum utilities
# dnfinst.py : dnf utilities
#
# Copyright 2007, Red Hat Inc.
# Copyright 2016, Kevin Kofler
Expand Down Expand Up @@ -41,7 +41,7 @@

from imgcreate.errors import *

class LiveCDYum(dnf.Base):
class DnfLiveCD(dnf.Base):
def __init__(self, releasever=None, useplugins=False):
"""
releasever = optional value to use in replacing $releasever in repos
Expand Down Expand Up @@ -152,7 +152,7 @@ def selectEnvironment(self, env_id, excluded, excludedPkgs):

def addRepository(self, name, url = None, mirrorlist = None):
def _varSubstitute(option):
# takes a variable and substitutes like yum configs do
# takes a variable and substitutes like dnf configs do
arch = hawkey.detect_arch()
option = option.replace("$basearch", dnf.rpm.basearch(arch))
option = option.replace("$arch", arch)
Expand Down
8 changes: 4 additions & 4 deletions tools/edit-livecd
Expand Up @@ -203,7 +203,7 @@ class LiveImageEditor(LiveImageCreator):
base_on -- the <LIVEIMG.src> a LiveOS.iso file or an attached LiveOS
device, such as, /dev/live for a currently running image.
cachedir -- a directory in which to store a Yum cache;
cachedir -- a directory in which to store a DNF cache;
Not used in edit-liveos.
"""
Expand Down Expand Up @@ -248,12 +248,12 @@ class LiveImageEditor(LiveImageCreator):
raise CreatorError("Failed to loopback mount '%s' : %s" %
(self._image, e))

cachesrc = cachedir or (self._ImageCreator__builddir + "/yum-cache")
cachesrc = cachedir or (self._ImageCreator__builddir + "/dnf-cache")
makedirs(cachesrc)

for (f, dest) in [("/sys", None), ("/proc", None),
("/dev/pts", None), ("/dev/shm", None),
(cachesrc, "/var/cache/yum")]:
(cachesrc, "/var/cache/dnf")]:
self._ImageCreator__bindmounts.append(BindChrootMount(f, self._instroot, dest))

self._do_bindmounts()
Expand Down Expand Up @@ -538,7 +538,7 @@ class LiveImageEditor(LiveImageCreator):
if baseurl.startswith("file://"):
baseurl=baseurl[7:]
elif not baseurl.startswith("/"):
raise CreatorError("edit-livecd accepts only --baseurl pointing to a local folder with RPMs (not YUM repo)")
raise CreatorError("edit-livecd accepts only --baseurl pointing to a local folder with RPMs (not RPM-MD repo)")
if not baseurl.endswith("/"):
baseurl+="/"
for pkg_from_list in kickstart.get_packages(self.ks):
Expand Down
6 changes: 3 additions & 3 deletions tools/livecd-creator
Expand Up @@ -26,7 +26,7 @@ import sys
import time
import optparse
import logging
from dnf.exceptions import Error as YumBaseError
from dnf.exceptions import Error as DnfBaseError

import imgcreate
from imgcreate.errors import KickstartError
Expand Down Expand Up @@ -54,7 +54,7 @@ def parse_options(args):
imgopt.add_option("-n", "--name", type="string", dest="fslabel",
help=optparse.SUPPRESS_HELP)
imgopt.add_option("-p", "--plugins", action="store_true", dest="plugins",
help="Use yum plugins during image creation",
help="Use DNF plugins during image creation",
default=False)
imgopt.add_option("", "--image-type", type="string", dest="image_type",
help=optparse.SUPPRESS_HELP)
Expand Down Expand Up @@ -227,7 +227,7 @@ def main():
creator.launch_shell()
creator.unmount()
creator.package()
except (imgcreate.CreatorError, YumBaseError) as e:
except (imgcreate.CreatorError, DnfBaseError) as e:
logging.error(u"Error creating Live CD : %s" % e)
return 1
finally:
Expand Down

0 comments on commit ec870ce

Please sign in to comment.