[Yum-devel] Patch: Hard-link packages that have already been downloaded.
James Antill
james at fedoraproject.org
Fri Sep 18 04:15:17 UTC 2009
On Thu, 2009-09-17 at 20:33 -0400, Ryan Lynch wrote:
> I've attached a patch against 'reposync.py' that implements a feature
> I desperately need: Before attempting to download a package, the
> 'reposync' command can link to an existing local copy of the package,
> if one exists. By default, it creates only hardlinks, so the existing
> file and the repository must share a filesystem, but a command-line
> option will allow symlinks when they don't.
>
> The command-line option '--package-cache <DIR_PATH>' will tell
> 'reposync' where to look for existing packages, and it can be
> specified multiple times. The command line option
> '--cache-symlinks-ok' turns on symlinking for cases where hardlinks
> won't work. The command-line option '--checksum' turns on
> checksum-based integrity checking for verifying local package
> sameness.
The second option name seems unwieldly, maybe --allow-symlinks or
something. The third one is v. bad. Some yum commands already have
--checksum options and they don't do this this isn't a big deal though
as I think you want to just rm that option.
I'm still not crazy about using -k (package kache dir?:), and now -o
too, small option(s).
> PLAGIARISM NOTE: I basically cribbed my entire effort from a patch
> that Daniel Berrange originally submitted to this mailing list in 2007
I vaguely remember talking about it with Seth, and I don't think we
really objected to it ... probably just forgot about it.
[...]
Other notes on the patch:
1. Always do the checksum, that's what we do in downloads and it seems
sane to do the same thing here.
2. Why do you have pkgcache as a copy of cache?
3. Don't do the st_dev checks, do something like:
try:
os.link(foo, blah)
except:
if can_use_symlinks:
os.symlink()
...then it works no matter why link() failed.
4. I'm not sure you can just use 'path' for symlink's argument, might
need to do realpath() ... or at least normalize it.
5. No need to call os.path.exists() multiple times.
6. Might as well add the pkgs you download to the cache.
7. Use "blah in foo" instead of "foo.has_key(blah)".
--
James Antill <james at fedoraproject.org>
Fedora
More information about the Yum-devel
mailing list