Package: apt Version: 0.9.9 Severity: wishlist Hi maintainers,
It would be useful to have the ability to apt-get update a single repository, without touching the state of other repositories or downloading their package lists. Updating a single sources.list.d file would also suffice, and might be easier in terms of syntax.
The primary use case for this would be sbuild: currently, the apt resolver needs to create a new repository inside the chroot and make apt aware of it, but if sbuild is run without --apt-update, running `apt-get update` (which updates every repository) would be inappropriate. So it resorts to doing some black magic to write out the appropriate /var/lib/apt/lists/ file without actually invoking apt:
http://sources.debian.net/src/sbuild/0.64.0-1/lib/Sbuild/ResolverBase.pm#L179Being able to run `apt-get update sbuild-build-depends-archive.list` or something would be much cleaner.
The reason I care about this is that I'm hoping to extend sbuild to allow adding a new repository at the sbuild command line to provide build dependencies for the current build only (see bug #700522). I'd rather not add code to do _more_ of the black magic, and would prefer that apt had a documented interface to take a new sources.list.d file into account without updating everything else.
There's also a use case for "normal" end users with lots of repositories, where a full `apt-get update` takes a while, and they're only looking for a package in a specific repository.
I tried writing a patch for this, but the most obvious approach ended up with apt thinking that one sources.list.d file was the _only_ one configured (and forgetting all other repositories). Patch is attached because why not; I haven't had time to look into making it work properly, yet, but might end up doing so eventually.
-- Geoffrey Thomas gtho...@mokafive.com
diff -Nru apt-0.9.7.5ubuntu5.2/apt-pkg/cachefile.cc apt-0.9.7.5ubuntu5.2+gthomas1/apt-pkg/cachefile.cc --- apt-0.9.7.5ubuntu5.2/apt-pkg/cachefile.cc 2012-11-01 02:48:40.000000000 -0700 +++ apt-0.9.7.5ubuntu5.2+gthomas1/apt-pkg/cachefile.cc 2013-03-04 18:22:17.000000000 -0800 @@ -110,6 +110,20 @@ return true; } /*}}}*/ +// CacheFile::BuildSourceListFile - Open and build one sources.list file/*{{{*/ +// --------------------------------------------------------------------- +/* */ +bool pkgCacheFile::BuildSourceListFile(std::string file, OpProgress *Progress) +{ + if (SrcList != NULL) + return true; + + SrcList = new pkgSourceList(); + if (SrcList->Read(file) == false) + return _error->Error(_("The list of sources could not be read.")); + return true; +} + /*}}}*/ // CacheFile::BuildPolicy - Open and build all relevant preferences /*{{{*/ // --------------------------------------------------------------------- /* */ diff -Nru apt-0.9.7.5ubuntu5.2/apt-pkg/cachefile.h apt-0.9.7.5ubuntu5.2+gthomas1/apt-pkg/cachefile.h --- apt-0.9.7.5ubuntu5.2/apt-pkg/cachefile.h 2012-11-01 02:48:40.000000000 -0700 +++ apt-0.9.7.5ubuntu5.2+gthomas1/apt-pkg/cachefile.h 2013-03-04 18:22:12.000000000 -0800 @@ -62,6 +62,7 @@ bool BuildCaches(OpProgress *Progress = NULL,bool WithLock = true); __deprecated bool BuildCaches(OpProgress &Progress,bool const &WithLock = true) { return BuildCaches(&Progress, WithLock); }; bool BuildSourceList(OpProgress *Progress = NULL); + bool BuildSourceListFile(std::string file, OpProgress *Progress = NULL); bool BuildPolicy(OpProgress *Progress = NULL); bool BuildDepCache(OpProgress *Progress = NULL); bool Open(OpProgress *Progress = NULL, bool WithLock = true); diff -Nru apt-0.9.7.5ubuntu5.2/cmdline/apt-get.cc apt-0.9.7.5ubuntu5.2+gthomas1/cmdline/apt-get.cc --- apt-0.9.7.5ubuntu5.2/cmdline/apt-get.cc 2012-11-09 00:40:44.000000000 -0800 +++ apt-0.9.7.5ubuntu5.2+gthomas1/cmdline/apt-get.cc 2013-03-04 18:21:04.000000000 -0800 @@ -1641,14 +1641,19 @@ /* */ bool DoUpdate(CommandLine &CmdL) { - if (CmdL.FileSize() != 1) - return _error->Error(_("The update command takes no arguments")); + if (CmdL.FileSize() > 2) + return _error->Error(_("The update command takes at most one argument")); CacheFile Cache; // Get the source list - if (Cache.BuildSourceList() == false) - return false; + if (CmdL.FileSize() == 2) { + if (Cache.BuildSourceListFile(CmdL.FileList[1]) == false) + return false; + } else { + if (Cache.BuildSourceList() == false) + return false; + } pkgSourceList *List = Cache.GetSourceList(); // Create the progress