[pacman-dev] [PATCH] Allow cleaning only some cachedirs
From: "Jan Alexander Steffens (heftig)" <jan.steffens@gmail.com> When cleaning the cache, ask for each cachedir separately. Signed-off-by: Jan Alexander Steffens (heftig) <jan.steffens@gmail.com> --- src/pacman/sync.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/pacman/sync.c b/src/pacman/sync.c index 3b09485..5210bbf 100644 --- a/src/pacman/sync.c +++ b/src/pacman/sync.c @@ -172,10 +172,6 @@ static int sync_cleancache(int level) alpm_list_t *cachedirs = alpm_option_get_cachedirs(config->handle); int ret = 0; - for(i = cachedirs; i; i = alpm_list_next(i)) { - printf(_("Cache directory: %s\n"), (const char *)i->data); - } - if(!config->cleanmethod) { /* default to KeepInstalled if user did not specify */ config->cleanmethod = PM_CLEAN_KEEPINST; @@ -189,22 +185,28 @@ static int sync_cleancache(int level) if(config->cleanmethod & PM_CLEAN_KEEPCUR) { printf(_(" All current sync database packages\n")); } - if(!yesno(_("Do you want to remove all other packages from cache?"))) { - return 0; - } - printf(_("removing old packages from cache...\n")); - } else { - if(!noyes(_("Do you want to remove ALL files from cache?"))) { - return 0; - } - printf(_("removing all files from cache...\n")); } for(i = cachedirs; i; i = alpm_list_next(i)) { const char *cachedir = i->data; - DIR *dir = opendir(cachedir); + DIR *dir; struct dirent *ent; + printf(_("Cache directory: %s\n"), (const char *)i->data); + + if(level == 1) { + if(!yesno(_("Do you want to remove all other packages from cache?"))) { + continue; + } + printf(_("removing old packages from cache...\n")); + } else { + if(!noyes(_("Do you want to remove ALL files from cache?"))) { + continue; + } + printf(_("removing all files from cache...\n")); + } + + dir = opendir(cachedir); if(dir == NULL) { pm_printf(ALPM_LOG_ERROR, _("could not access cache directory %s\n"), cachedir); -- 1.7.10.4
On 16/06/12 09:12, Jan Alexander Steffens (heftig) wrote:
From: "Jan Alexander Steffens (heftig)" <jan.steffens@gmail.com>
When cleaning the cache, ask for each cachedir separately.
Signed-off-by: Jan Alexander Steffens (heftig) <jan.steffens@gmail.com> --- src/pacman/sync.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-)
Ack - the output looks a bit clumped though:
sudo ./src/pacman/pacman -Sc Packages to keep: All current sync database packages Cache directory: /home/arch/pkgcache/ Do you want to remove all other packages from cache? [Y/n] n Cache directory: /home/allan/ Do you want to remove all other packages from cache? [Y/n] n
Database directory: /var/lib/pacman/ Do you want to remove unused repositories? [Y/n] n Adding: diff --git a/src/pacman/sync.c b/src/pacman/sync.c index 5210bbf..9f13687 100644 --- a/src/pacman/sync.c +++ b/src/pacman/sync.c @@ -186,6 +186,7 @@ static int sync_cleancache(int level) printf(_(" All current sync database packages\n")); } } + printf("\n"); for(i = cachedirs; i; i = alpm_list_next(i)) { const char *cachedir = i->data; @@ -196,11 +197,13 @@ static int sync_cleancache(int level) if(level == 1) { if(!yesno(_("Do you want to remove all other packages from cache?"))) { + printf("\n"); continue; } printf(_("removing old packages from cache...\n")); } else { if(!noyes(_("Do you want to remove ALL files from cache?"))) { + printf("\n"); continue; } printf(_("removing all files from cache...\n")); @@ -301,6 +304,7 @@ static int sync_cleancache(int level) } } closedir(dir); + printf("\n"); } return ret; @@ -921,7 +925,6 @@ int pacman_sync(alpm_list_t *targets) } ret += sync_cleancache(config->op_s_clean); - printf("\n"); ret += sync_cleandb_all(); if(trans_release() == -1) { Makes the output:
sudo ./src/pacman/pacman -Sc Packages to keep: All current sync database packages
Cache directory: /home/arch/pkgcache/ Do you want to remove all other packages from cache? [Y/n] n Cache directory: /home/allan/ Do you want to remove all other packages from cache? [Y/n] n Database directory: /var/lib/pacman/ Do you want to remove unused repositories? [Y/n] n I have committed the patch with those minor changes to my working branch. Allan
participants (2)
-
Allan McRae
-
Jan Alexander Steffens (heftig)