[Yum-devel] Subject: Re: Re: Patch submission for --noremotepath option

Philip Mather phil at philipmather.me.uk
Fri Jun 17 09:44:13 UTC 2011


>  So there are two "problems" I see here:
>
> 1. Without a lot more work, this will break the options for syncing the
> repodata (as all the locations will be "wrong"). Probably easiest to
> just disallow usage of both options.
>sk
> 2. The name is kind of weird, and just does one change (from remote
> layout to current dir.) ... due to #1 maybe instead have it something
> like --packagesdir=. or something?
>

1. Good point, implemented below and tried making the help text clearer.
2. I was just following the --norepopath flag but I'm confused by the
"=" there? If you specify a fixed path instead of the variable repoid
with multiple repos then (as is) it'll mash them all together, if you
really don't want either the repoid or the reponame then you're going
to have to use both --noremotepath and --norepopath and hence do it
one repo at a time, at which point you can just specify an arbitrary
path in the -p option? Maybe I've misunderstood, if it's just naming
then call it whatever. :^)

I have to admit this is bordering the fringe case, by the time you get
to reorganising repos to this extent I think most people go for the
rsync/ftp and home brew script route but that's probably more
complicated than the 12 odd lines I added below to address my task.


--- /usr/bin/reposync	2010-08-03 17:14:22.000000000 +0100
+++ /tmp/reposync-1.1.28-1-modified	2011-06-17 10:38:11.293832653 +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 local path, excludes the use of
--download-metadata which would then contain incorrect paths.")
     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,15 @@
             n = n + 1
             repo = my.repos.getRepo(pkg.repoid)
             remote = pkg.returnSimple('relativepath')
-            local = local_repo_path + '/' + remote
+            if opts.noremotepath:
+                if opts.downloadmd:
+                    print >> sys.stderr, "Error: Can't use
--noremotepath with --download-metadata as paths in downloaded
metadata would be wrong, try using createrepo to rebuild metadata
instead."
+                    sys.exit(1)
+                (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