[PATCH 11/14] Store methodstr url of repo.

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

 



We need it for repo editing or correction of repo= arguments in UI, especially
in case of nfs: or cdrom: which can't be stored in AnacondaYum.baseurl,
---
 iw/task_gui.py |   25 ++++++++++++++-----------
 yuminstall.py  |   21 +++++++++++++++++++++
 2 files changed, 35 insertions(+), 11 deletions(-)

diff --git a/iw/task_gui.py b/iw/task_gui.py
index b9b2029..12d9a45 100644
--- a/iw/task_gui.py
+++ b/iw/task_gui.py
@@ -194,17 +194,18 @@ class RepoEditor:
 
         if self.repo:
             self.nameEntry.set_text(self.repo.name)
-            self.typeComboBox.set_active(self._methodToIndex(self.anaconda.methodstr))
+            if self.repo.anacondabaseurls:
+                url = self.repo.anacondabaseurls[0]
+            else:
+                url = ''
+            self.typeComboBox.set_active(self._methodToIndex(url))
 
-            if not self.anaconda.methodstr or self.anaconda.methodstr.startswith("http") or self.anaconda.methodstr.startswith("ftp"):
+            if not url or url.startswith("http") or url.startswith("ftp"):
                 if self.repo.mirrorlist:
                     self.baseurlEntry.set_text(self.repo.mirrorlist)
                     self.mirrorlistCheckbox.set_active(True)
                 else:
-                    if self.repo.baseurl:
-                        self.baseurlEntry.set_text(self.repo.baseurl[0])
-                    else:
-                        self.baseurlEntry.set_text("")
+                    self.baseurlEntry.set_text(url)
 
                     self.mirrorlistCheckbox.set_active(False)
 
@@ -217,18 +218,18 @@ class RepoEditor:
                 else:
                     self.proxyCheckbox.set_active(False)
                     self.proxyTable.set_sensitive(False)
-            elif self.anaconda.methodstr.startswith("nfs:"):
-                method_server_dir = self.anaconda.methodstr.split(":")
+            elif url.startswith("nfs"):
+                method_server_dir = url.split(":")
                 try:
                     self.nfsServerEntry.set_text(method_server_dir[1])
                     self.nfsPathEntry.set_text(method_server_dir[2])
                 except IndexError:
                     pass
                 self.nfsOptionsEntry.set_text("")
-            elif self.anaconda.methodstr.startswith("cdrom:"):
+            elif url.startswith("cdrom:"):
                 pass
-            elif self.anaconda.methodstr.startswith("hd:"):
-                m = self.anaconda.methodstr[3:]
+            elif url.startswith("hd:"):
+                m = url[3:]
                 if m.count(":") == 1:
                     (device, path) = m.split(":")
                     fstype = "auto"
@@ -279,6 +280,7 @@ class RepoEditor:
         else:
             repo.baseurl = [repourl]
             repo.mirrorlist = None
+        repo.anacondabaseurls = repo.baseurl
 
         repo.name = self.nameEntry.get_text()
 
@@ -327,6 +329,7 @@ class RepoEditor:
                 return False
 
             repo.baseurl = "file://%s" % dest
+            repo.anacondabaseurls = ["nfs:%s:%s" % (server,path)]
             return True
 
     def _applyHd(self, repo):
diff --git a/yuminstall.py b/yuminstall.py
index 13c56af..4fd4954 100644
--- a/yuminstall.py
+++ b/yuminstall.py
@@ -243,6 +243,7 @@ class AnacondaYumRepo(YumRepository):
     def __init__(self, *args, **kwargs):
         YumRepository.__init__(self, *args, **kwargs)
         self.enablegroups = True
+        self._anacondabaseurls = []
 
     def needsNetwork(self):
         def _isURL(s):
@@ -267,6 +268,18 @@ class AnacondaYumRepo(YumRepository):
                 if os.path.exists("%s/packages" % cachedir):
                     shutil.rmtree("%s/packages" % cachedir)
 
+    # needed to store nfs: repo url that yum doesn't know
+    @property
+    def anacondabaseurls(self):
+        return (self._anacondabaseurls or self.baseurl or
+                (type(self.mirrorlist) is type([]) and self.mirrorlist) or
+                [self.mirrorlist])
+
+
+    @anacondabaseurls.setter
+    def anacondabaseurls(self, value):
+        self._anacondabaseurls = value
+
 class YumSorter(yum.YumBase):
     def _transactionDataFactory(self):
         return SplitMediaTransactionData()
@@ -475,6 +488,9 @@ class AnacondaYum(YumSorter):
             return
 
         # add default repos
+        anacondabaseurl = (self.anaconda.methodstr or
+                           "cdrom:%s" % (self.anaconda.mediaDevice))
+        anacondabasepaths = self.anaconda.id.instClass.getPackagePaths(anacondabaseurl)
         for (name, uri) in self.anaconda.id.instClass.getPackagePaths(self._baseRepoURL).items():
             rid = name.replace(" ", "")
 
@@ -482,6 +498,7 @@ class AnacondaYum(YumSorter):
                 try:
                     repo = self.repos.getRepo("anaconda-%s-%s" % (rid, productStamp))
                     repo.baseurl = uri
+                    repo.anacondabaseurls = anacondabasepaths[name]
                 except RepoError:
                     replace = False
 
@@ -489,6 +506,7 @@ class AnacondaYum(YumSorter):
             if not replace:
                 repo = AnacondaYumRepo("anaconda-%s-%s" % (rid, productStamp))
                 repo.baseurl = uri
+                repo.anacondabaseurls = anacondabasepaths[name]
 
             repo.name = name
             repo.cost = 100
@@ -649,6 +667,7 @@ class AnacondaYum(YumSorter):
                 # yum doesn't understand nfs:// and doesn't want to.  We need
                 # to first do the mount, then translate it into a file:// that
                 # yum does understand.
+                anacondabaseurls = []
                 if ksrepo.baseurl and ksrepo.baseurl.startswith("nfs://"):
                     if not network.hasActiveNetDev() and not self.anaconda.intf.enableNetwork():
                         self.anaconda.intf.messageWindow(_("No Network Available"),
@@ -666,6 +685,7 @@ class AnacondaYum(YumSorter):
                     except Exception as e:
                         log.error("error mounting NFS repo: %s" % e)
 
+                    anacondabaseurls = [ksrepo.baseurl]
                     ksrepo.baseurl = "file://%s" % dest
 
                 repo = AnacondaYumRepo(ksrepo.name)
@@ -676,6 +696,7 @@ class AnacondaYum(YumSorter):
                     repo.baseurl = []
                 else:
                     repo.baseurl = [ ksrepo.baseurl ]
+                repo.anacondabaseurls = anacondabaseurls
 
                 if ksrepo.cost:
                     repo.cost = ksrepo.cost
-- 
1.6.0.6

_______________________________________________
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