[et-mgmt-tools] [PATCH] cobbler - add arch to repo definition to override default arch for reposync

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

 



For using cobbler to synchronize repositories via reposync, the default arch is always used which makes syncing with multiple arches not possible.  (For example to grab the src repos) 

To change this I added a --arch flag that can be used to override the default reposync arch.  If yumdownloader is used (in the case of using rpm_list to restrict the packages downloaded) --source is passed on the command line if --arch==src.  This allows source packages to be retrieved, but I don't know how to override yumdownloader to do architectures other than the current system arch.  Comments on this appreciated...

Signed-off-by: Perry Myers (pmyers@xxxxxxxxxx)

Thanks,

Perry

-- 
|=- Red Hat, Engineering, Emerging Technologies, Boston.  +1 703 362 9622 -=|

diff --git a/cobbler/action_reposync.py b/cobbler/action_reposync.py
index 76e673f..fdcf270 100644
--- a/cobbler/action_reposync.py
+++ b/cobbler/action_reposync.py
@@ -119,9 +119,11 @@ class RepoSync:
             temp_file = self.create_local_file(repo, temp_path, output=False)
 
             if not has_rpm_list:
-
                 # if we have not requested only certain RPMs, use reposync
                 cmd = "/usr/bin/reposync --config=%s --repoid=%s --download_path=%s" % (temp_file, repo.name, store_path)
+                if repo.arch != "":
+                    cmd = "%s -a %s" % (cmd, repo.arch)
+                    
                 print _("- %s") % cmd
                 cmds.append(cmd)
 
@@ -131,10 +133,14 @@ class RepoSync:
                 if not os.path.exists(dest_path):
                    os.makedirs(dest_path)
 
+                use_source = ""
+                if repo.arch == "src":
+                    use_source = "--source"
+
                 # if we only want certain RPMs, use yumdownloader (likely more than once)
                 # FIXME: yumdownloader has a current bug where --resolve blows up
                 # removing --resolve until I get the email from bugzilla saying it's fixed.
-                cmd = "/usr/bin/yumdownloader -c %s --destdir=%s %s" %(temp_file, dest_path, " ".join(repo.rpm_list))
+                cmd = "/usr/bin/yumdownloader %s -c %s --destdir=%s %s" % (use_source, temp_file, dest_path, " ".join(repo.rpm_list))
                 print _("- %s") % cmd
                 cmds.append(cmd)
         else:
@@ -146,6 +152,10 @@ class RepoSync:
                 print _("- warning: --rpm-list is not supported for RHN content")
             rest = repo.mirror[6:] # everything after rhn://
             cmd = "/usr/bin/reposync -r %s --download_path=%s" % (rest, store_path)
+
+            if repo.arch != "":
+                cmd = "%s -a %s" % (cmd, repo.arch)
+
             print _("- %s") %  cmd
             cmds.append(cmd)
 
diff --git a/cobbler/cobbler.py b/cobbler/cobbler.py
index e999d2d..e275f39 100755
--- a/cobbler/cobbler.py
+++ b/cobbler/cobbler.py
@@ -433,7 +433,8 @@ class BootCLI:
            '--keep-updated'     :  lambda(a): repo.set_keep_updated(a),
            '--local-filename'   :  lambda(a): repo.set_local_filename(a),
            '--rpm-list'         :  lambda(a): repo.set_rpm_list(a),
-           '--createrepo-flags' :  lambda(a): repo.set_createrepo_flags(a)
+           '--createrepo-flags' :  lambda(a): repo.set_createrepo_flags(a),
+           '--arch'             :  lambda(a): repo.set_arch(a)
         }
         def on_ok():
             if newname is not None:
diff --git a/cobbler/item_repo.py b/cobbler/item_repo.py
index f58cd1b..bdd1a48 100644
--- a/cobbler/item_repo.py
+++ b/cobbler/item_repo.py
@@ -31,7 +31,8 @@ class Repo(item.Item):
         self.keep_updated = 1               # has reasonable defaults
         self.local_filename = ""            # off by default
         self.rpm_list = ""                  # just get selected RPMs + deps
-        self.createrepo_flags = "-c cache"  # none by default
+        self.createrepo_flags = "-c cache"  # turn on cache by default for performance
+        self.arch = ""                      # use default arch
 
     def from_datastruct(self,seed_data):
         self.name             = self.load_item(seed_data, 'name')
@@ -40,6 +41,7 @@ class Repo(item.Item):
         self.local_filename   = self.load_item(seed_data, 'local_filename')
         self.rpm_list         = self.load_item(seed_data, 'rpm_list')
         self.createrepo_flags = self.load_item(seed_data, 'createrepo_flags', '-c cache')
+        self.arch             = self.load_item(seed_data, 'arch')
         return self
 
     def set_name(self,name):
@@ -108,6 +110,13 @@ class Repo(item.Item):
         self.createrepo_flags = createrepo_flags
         return True
 
+    def set_arch(self,arch):
+        """
+        Override the arch used for reposync
+        """
+        self.arch = arch
+        return True
+
     def is_valid(self):
         """
 	A repo is valid if it has a name and a mirror URL
@@ -125,7 +134,8 @@ class Repo(item.Item):
            'keep_updated'     : self.keep_updated,
            'local_filename'   : self.local_filename,
            'rpm_list'         : self.rpm_list,
-           'createrepo_flags' : self.createrepo_flags
+           'createrepo_flags' : self.createrepo_flags,
+           'arch'             : self.arch
         }
 
     def printable(self):
@@ -135,6 +145,7 @@ class Repo(item.Item):
         buf = buf + _("local filename   : %s\n") % self.local_filename
         buf = buf + _("rpm list         : %s\n") % self.rpm_list
         buf = buf + _("createrepo_flags : %s\n") % self.createrepo_flags
+        buf = buf + _("arch             : %s\n") % self.arch
         return buf
 
     def is_rsync_mirror(self):


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

  Powered by Linux