[Yum-devel] Patch submission for --noremotepath option

Philip Mather phil at philipmather.me.uk
Sun Jun 12 17:33:56 UTC 2011


Afternoon,
   A rainy Sunday afternoon has lead to me hacking around with
spacewalk and syncing repos into a new and consistent structure at
which point I was thwarted in my efforts by reposync, reasonably
enough, appending the remote path into the local one. Specifically
CentOS 5.6 x86_64 repos seem to have remote paths containing "RPMS/"
or "CentOS/" for example, as this doesn't fit in my new world order I
added a new option --noremotepath to remove it and rely only on the
repoid only.
   Very much in the same vain as...

http://www.spinics.net/linux/fedora/yum/msg11328.html

...not entirely sure of the logicality of using both options at once,
nor tested it but given the above restricts it's use to only single
repos at a time you still wouldn't be able to use this new option to
accidentally mash multiple repos together (I remember yum complaining
if a repoid is duplicated), the worst that would happen is that the
files go straight into the specified destination directory.
   Patch is below, I should probably mention I'm not exactly a Python
programmer so you might want to double check I've not done something
assine. ;^)


--- /usr/bin/reposync	2010-08-03 17:14:22.000000000 +0100
+++ /tmp/reposync-1.1.28-1-modified	2011-06-12 18:00:47.319046532 +0100
@@ -111,6 +111,8 @@
         default=os.getcwd(), help="Path to download packages to:
defaults to current dir")
     parser.add_option("--norepopath", dest='norepopath',
default=False, action="store_true",
         help="Don't add the reponame to the download path. Can only
be used when syncing a single repository (default is to add the
reponame)")
+    parser.add_option("--noremotepath", dest='noremotepath',
default=False, action="store_true",
+        help="Don't add the remote path structure used by some repos
(e.g. RPMS or CentOS) to the download path only use repoid.")
     parser.add_option("-g", "--gpgcheck", default=False, action="store_true",
         help="Remove packages that fail GPG signature checking after
downloading")
     parser.add_option("-u", "--urls", default=False, action="store_true",
@@ -282,7 +284,13 @@
             n = n + 1
             repo = my.repos.getRepo(pkg.repoid)
             remote = pkg.returnSimple('relativepath')
-            local = local_repo_path + '/' + remote
+
+            if opts.noremotepath:
+                (remotepath, remotename) = os.path.split(remote)
+                local = local_repo_path + '/' + remotename
+            else:
+                local = local_repo_path + '/' + remote
+
             localdir = os.path.dirname(local)
             if not os.path.exists(localdir):
                 os.makedirs(localdir)


-- 
Regards,
   Phil


More information about the Yum-devel mailing list