diff options
author | Julian Andres Klode <jak@debian.org> | 2023-12-08 13:14:07 +0000 |
---|---|---|
committer | Julian Andres Klode <jak@debian.org> | 2023-12-08 13:14:07 +0000 |
commit | c555d8f1ae31d1f511bf811640423231b75a8e13 (patch) | |
tree | 1806c66db1d60fdd8c8f751027107c5e551a0bb3 /apt-private | |
parent | cc54a179c42e07cf61debd6740cb47542caccae5 (diff) | |
parent | bd7c126e3fb1b94e76e0e632c657cea854586844 (diff) |
Merge branch 'fix-959093' into 'main'
Add 'dist-clean' command to remove packages and list files
See merge request apt-team/apt!290
Diffstat (limited to 'apt-private')
-rw-r--r-- | apt-private/private-download.cc | 23 | ||||
-rw-r--r-- | apt-private/private-download.h | 2 |
2 files changed, 20 insertions, 5 deletions
diff --git a/apt-private/private-download.cc b/apt-private/private-download.cc index eddb901d0..b271ec03f 100644 --- a/apt-private/private-download.cc +++ b/apt-private/private-download.cc @@ -304,9 +304,20 @@ bool DoChangelog(CommandLine &CmdL) } /*}}}*/ -// DoClean - Remove download archives /*{{{*/ +// DoClean - Remove download archives /*{{{*/ bool DoClean(CommandLine &) { + return DoDistClean(false); +} + /*}}}*/ +// DoDistClean - Remove download archives and lists /*{{{*/ +bool DoDistClean(CommandLine &) +{ + return DoDistClean(true); +} +// DoDistClean - the worker +bool DoDistClean(bool ListsToo) +{ std::string const archivedir = _config->FindDir("Dir::Cache::archives"); std::string const listsdir = _config->FindDir("Dir::state::lists"); @@ -315,23 +326,25 @@ bool DoClean(CommandLine &) std::string const pkgcache = _config->FindFile("Dir::cache::pkgcache"); std::string const srcpkgcache = _config->FindFile("Dir::cache::srcpkgcache"); std::cout << "Del " << archivedir << "* " << archivedir << "partial/*"<< std::endl - << "Del " << listsdir << "partial/*" << std::endl - << "Del " << pkgcache << " " << srcpkgcache << std::endl; + << "Del " << listsdir << "partial/*" << (ListsToo ? " *_{Packages,Sources}{,.diff_Index}" : "") << std::endl + << "Del " << pkgcache << " " << srcpkgcache << std::endl; return true; } pkgAcquire Fetcher; if (archivedir.empty() == false && FileExists(archivedir) == true && - Fetcher.GetLock(archivedir) == true) + Fetcher.GetLock(archivedir) == true) { Fetcher.Clean(archivedir); Fetcher.Clean(archivedir + "partial/"); } if (listsdir.empty() == false && FileExists(listsdir) == true && - Fetcher.GetLock(listsdir) == true) + Fetcher.GetLock(listsdir) == true) { Fetcher.Clean(listsdir + "partial/"); + if (ListsToo) + Fetcher.CleanLists(listsdir); } pkgCacheFile::RemoveCaches(); diff --git a/apt-private/private-download.h b/apt-private/private-download.h index d829e8b24..918828241 100644 --- a/apt-private/private-download.h +++ b/apt-private/private-download.h @@ -33,6 +33,8 @@ APT_PUBLIC bool DoDownload(CommandLine &CmdL); APT_PUBLIC bool DoChangelog(CommandLine &CmdL); APT_PUBLIC bool DoClean(CommandLine &CmdL); +APT_PUBLIC bool DoDistClean(CommandLine &CmdL); +bool DoDistClean(bool ListsToo); APT_PUBLIC bool DoAutoClean(CommandLine &CmdL); #endif |