[PATCH] use repo config files instead of a list

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In past releases of Fedora, we've maintained a list in the install class
that specifies extra repos that should be added to the task list UI.  In
the last release (F9), we got nailed because the mirror URLs changed and
we didn't notice, so clicking "Additional Fedora Software" failed.
Further, people keep wanting the updates repo enabled.

What better way to fix up both these problems than to use the existing
/etc/yum.repos.d/* files from the fedora-release package instead of
maintaing our own list?  That's what the attached patch does.  It's not
complete yet but it is getting there.

Problems:

- Driver disks should write out repo files as well, but I think driver
  disks are broken in general so it's not really worth fixing this
  immediately.
- The repo configured in loader that gets passed to anaconda as method=
  is enabled, as is the regular Fedora release repo from the
  fedora-release package.  This sounds like an exciting battle.  I
  suppose it can be fixed a little bit with cost=, but I probably need
  a way to only enable one "base" repo.

Thoughts?

- Chris
diff --git a/installclasses/fedora.py b/installclasses/fedora.py
index a6657cf..c51c743 100644
--- a/installclasses/fedora.py
+++ b/installclasses/fedora.py
@@ -45,8 +45,6 @@ class InstallClass(BaseInstallClass):
              (N_("Software Development"), ["development-libs", "development-tools", "gnome-software-development", "x-software-development"],),
              (N_("Web server"), ["web-server"])]
 
-    repos = { "Additional Fedora Software": (None, "http://mirrors.fedoraproject.org/mirrorlist?repo=%s&arch=%s"; %(productVersion, rpmUtils.arch.getBaseArch())) }
-
     def getPackagePaths(self, uri):
         if not type(uri) == types.ListType:
             uri = [uri,]
diff --git a/iw/task_gui.py b/iw/task_gui.py
index e7a8e3a..441d2da 100644
--- a/iw/task_gui.py
+++ b/iw/task_gui.py
@@ -371,6 +371,8 @@ class TaskWindow(InstallWindow):
         store = gtk.ListStore(gobject.TYPE_BOOLEAN,
                               gobject.TYPE_STRING,
                               gobject.TYPE_PYOBJECT)
+        store.set_sort_column_id(1, gtk.SORT_ASCENDING)
+
         tl = self.xml.get_widget("repoList")
         tl.set_model(store)
 
diff --git a/kickstart.py b/kickstart.py
index cbe387d..06c0841 100644
--- a/kickstart.py
+++ b/kickstart.py
@@ -676,6 +676,32 @@ class Raid(commands.raid.F9_Raid):
         addPartRequest(self.handler.anaconda, request)
         self.handler.skipSteps.extend(["partition", "zfcpconfig", "parttype"])
 
+class Repo(commands.repo.F8_Repo):
+    def parse(self, args):
+        commands.repo.F8_Repo.parse(self, args)
+        repo = self.repoList[-1]
+        repoid = repo.name.replace(" ", "-")
+
+        buf = """
+[%(repoid)]
+name=%(name)
+enabled=1
+gpgcheck=0
+""" % {"repoid": repoid, "name": repo.name}
+
+        # pykickstart enforces that only one of these options may be specified
+        if repo.mirrorlist:
+            buf += "\nmirrorlist=%s" % repo.mirrorlist
+        else:
+            buf += "\nbaseurl=%s" % repo.baseurl
+
+        if repo.priority:
+            buf += "\ncost=%s" % repo.priority
+
+        fd = open("/etc/yum.repos.d/%s.repo" % repoid, "w")
+        fd.write(buf)
+        fd.close()
+
 class RootPw(commands.rootpw.F8_RootPw):
     def parse(self, args):
         commands.rootpw.F8_RootPw.parse(self, args)
@@ -801,7 +827,7 @@ commandMap = {
         "poweroff": Reboot,
         "raid": Raid,
         "reboot": Reboot,
-        "repo": commands.repo.F8_Repo,
+        "repo": Repo,
         "rootpw": RootPw,
         "selinux": SELinux,
         "services": commands.services.FC6_Services,
diff --git a/scripts/upd-instroot b/scripts/upd-instroot
index 1645aad..d9eaca9 100755
--- a/scripts/upd-instroot
+++ b/scripts/upd-instroot
@@ -165,7 +165,7 @@ PACKAGES="glibc-common setup python newt slang libselinux
 	 device-mapper device-mapper-libs dmraid keyutils-libs libsemanage-python
 	 python-pyblock mkinitrd libbdevid libbdevid-python nss nspr pcre
 	 cryptsetup-luks libgcrypt libgpg-error dbus dbus-python hal
-	 cracklib-python module-init-tools cracklib-dicts"
+	 cracklib-python module-init-tools cracklib-dicts system-release"
 
 if [ $ARCH = i386 ]; then
     PACKAGES="$PACKAGES glibc.i386 openssl.i386"
@@ -329,6 +329,7 @@ etc/selinux/targeted
 etc/shells
 etc/udev
 etc/yum/pluginconf.d/fedorakmod.conf
+etc/yum/yum.repos.d/*
 lib/terminfo
 $LIBDIR/libnss_dns*
 $LIBDIR/libnss_files*
diff --git a/yuminstall.py b/yuminstall.py
index 6713a6c..460294c 100644
--- a/yuminstall.py
+++ b/yuminstall.py
@@ -488,16 +488,49 @@ class AnacondaYum(YumSorter):
                    text=kwargs["text"], range=kwargs["range"], copy_local=1)
         return kwargs["local"]
 
-    def doConfigSetup(self, fn='/etc/yum.conf', root='/'):
-        self.conf = yum.config.YumConf()
-        self.conf.installroot = root
-        self.conf.reposdir=["/tmp/repos.d"]
-        self.conf.logfile="/tmp/yum.log"
-        self.conf.obsoletes=True
-        self.conf.cache=0
-        self.conf.cachedir = "%s/var/cache/yum" % self.anaconda.rootPath
-        self.conf.metadata_expire = 0
+    # XXX: This is straight out of yum, but we need to override it here in
+    # order to use our own repo class.
+    def readRepoConfig(self, parser, section):
+        '''Parse an INI file section for a repository.
+
+        @param parser: ConfParser or similar to read INI file values from.
+        @param section: INI file section to read.
+        @return: YumRepository instance.
+        '''
+        repo = AnacondaYumRepo(section)
+        repo.populate(parser, section, self.conf)
+
+        # Ensure that the repo name is set
+        if not repo.name:
+            repo.name = section
+            self.logger.error(_('Repository %r is missing name in configuration, '
+                    'using id') % section)
+
+        # Set attributes not from the config file
+        repo.basecachedir = self.conf.cachedir
+        repo.yumvar.update(self.conf.yumvar)
+        repo.cfg = parser
+
+        return repo
+
+    # We need to make sure $releasever gets set up before .repo files are
+    # read.  Since there's no redhat-release package in /mnt/sysimage (and
+    # won't be for quite a while), we need to do our own substutition.
+    def getReposFromConfig(self):
+        def _getReleasever():
+            from ConfigParser import ConfigParser
+            c = ConfigParser()
+            ConfigParser.read(c, "%s/.treeinfo" % self.tree)
+            return c.get("general", "version")
+
+        self.yumvar["releasever"] = _getReleasever()
+        YumSorter.getReposFromConfig(self)
+
+    # Override this method so yum doesn't nuke our existing logging config.
+    def doLoggingSetup(self, debuglevel, errorlevel):
+        pass
 
+    def doConfigSetup(self, fn='/etc/yum.conf', root='/'):
         if self.anaconda.methodstr.startswith("nfs:"):
             if os.path.isdir(self.anaconda.methodstr[4:]):
                 self.tree = self.anaconda.methodstr[4:]
@@ -514,7 +547,9 @@ class AnacondaYum(YumSorter):
         elif self.anaconda.methodstr.startswith("ftp:") or self.anaconda.methodstr.startswith("http:"):
             methodstr = self.anaconda.methodstr
 
-        # set up logging to log to our logs
+        YumSorter.doConfigSetup(self, fn=fn, root=root)
+
+        # override default logging to use our logs
         ylog = logging.getLogger("yum")
         map(lambda x: ylog.addHandler(x), log.handlers)
 
@@ -550,19 +585,6 @@ class AnacondaYum(YumSorter):
             repo.enable()
             self.repos.add(repo)
 
-        extraRepos = []
-
-        # add some additional not enabled by default repos.
-        # FIXME: this is a hack and should probably be integrated
-        # with the above
-        for (name, (uri, mirror)) in self.anaconda.id.instClass.repos.items():
-            rid = name.replace(" ", "")
-            repo = AnacondaYumRepo(uri=uri, mirrorlist=mirror, repoid=rid,
-                                   root=root)
-            repo.name = name
-            repo.disable()
-            extraRepos.append(repo)
-
         if self.anaconda.id.extraModules:
             for d in glob.glob("/tmp/DD-*/rpms"):
                 dirname = os.path.basename(os.path.dirname(d))
@@ -572,33 +594,8 @@ class AnacondaYum(YumSorter):
                                        root=root, addon=False)
                 repo.name = "Driver Disk %s" % dirname.split("-")[1]
                 repo.enable()
-                extraRepos.append(repo)
-
-        if self.anaconda.isKickstart:
-            for ksrepo in self.anaconda.id.ksdata.repo.repoList:
-                repo = AnacondaYumRepo(uri=ksrepo.baseurl,
-                                       mirrorlist=ksrepo.mirrorlist,
-                                       repoid=ksrepo.name)
-                repo.name = ksrepo.name
-                repo.enable()
-                extraRepos.append(repo)
-
-        for repo in extraRepos:
-            try:
-                self.repos.add(repo)
-                log.info("added repository %s with URL %s" % (repo.name, repo.mirrorlist or repo.baseurl))
-            except yum.Errors.DuplicateRepoError, e:
-                log.warning("ignoring duplicate repository %s with URL %s" % (repo.name, repo.mirrorlist or repo.baseurl))
-
-        self.doPluginSetup(searchpath=["/usr/lib/yum-plugins",
-                                       "/tmp/updates/yum-plugins",
-                                       "/mnt/source/RHupdates/yum-plugins"], 
-                           confpath=["/etc/yum/pluginconf.d",
-                                     "/tmp/updates/pluginconf.d",
-                                     "/mnt/source/RHupdates/pluginconf.d"])
-        self.plugins.run('init')
 
-        self.repos.setCacheDir("%s/var/cache/yum" % self.anaconda.rootPath)
+        self.repos.setCacheDir("%s/var/cache/yum" % self.conf.cachedir)
 
     def downloadHeader(self, po):
         while True:
@@ -882,6 +879,23 @@ class YumBackend(AnacondaBackend):
         AnacondaBackend.__init__(self, anaconda)
         self.supportsPackageSelection = True
 
+        buf = """
+[main]
+cachedir=%s/var/cache/yum
+installroot=%s
+keepcache=0
+logfile=/tmp/yum.log
+metadata_expire=0
+obsoletes=True
+pluginpath=/usr/lib/yum-plugins,/tmp/updates/yum-plugins,/mnt/source/RHupdates/yum-plugins
+pluginconfpath=/etc/yum/pluginconf.d,/tmp/updates/pluginconf.d,/mnt/source/RHupdates/pluginconf.d
+reposdir=/etc/yum.repos.d,/tmp/updates/yum.repos.d,/mnt/source/RHupdates/yum.repos.d
+""" % (anaconda.rootPath, anaconda.rootPath)
+
+        fd = open("/etc/yum.conf", "w")
+        fd.write(buf)
+        fd.close()
+
     def complete(self, anaconda):
         try:
             isys.umount(self.ayum.tree)
_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux