From a2d7f6f2061fdf0ff225eaceda5c78ee520495ff Mon Sep 17 00:00:00 2001 From: Xavier Chantry Date: Sun, 17 Oct 2010 19:27:38 +0200 Subject: [PATCH 1/2] libalpm/remove: fix funny progress bar problem with empty packages $ pacman -Rd kde-meta Remove (15): kde-meta-kdewebdev-4.5-1 [0.00 MB] kde-meta-kdeutils-4.5-1 [0.00 MB] kde-meta-kdetoys-4.5-1 [0.00 MB] kde-meta-kdesdk-4.5-1 [0.00 MB] kde-meta-kdeplasma-addons-4.5-1 [0.00 MB] kde-meta-kdepim-4.5-1 [0.00 MB] kde-meta-kdenetwork-4.5-1 [0.00 MB] kde-meta-kdemultimedia-4.5-1 [0.00 MB] kde-meta-kdegraphics-4.5-1 [0.00 MB] kde-meta-kdegames-4.5-1 [0.00 MB] kde-meta-kdeedu-4.5-1 [0.00 MB] kde-meta-kdebase-4.5-1 [0.00 MB] kde-meta-kdeartwork-4.5-1 [0.00 MB] kde-meta-kdeadmin-4.5-1 [0.00 MB] kde-meta-kdeaccessibility-4.5-1 [0.00 MB] Total Removed Size: 0.06 MB Do you want to remove these packages? [Y/n] ( 1/15) removing kde-meta-kdewebdev [------------------------] 100% $ it stopped here.. On one side, libalpm did not initialize the progress bar at 0 percent. So with meta-packages that have 0 files, there was only one progress bar call with percent == 100. On the other side, pacman callback kept track of the last percent that it received. When there are only meta-packages, we always received only 100, so pacman believed the progress bar needed not update. Thus only the first package was actually displayed. A proper fix for the callback would be to keep track of last package name to make sure the recorded prev percent applies. But since we now specify that both Add and Remove should at least send percent=0 at beginning and percent=100 at the end, there is no need for that. Signed-off-by: Xavier Chantry Signed-off-by: Dan McGee --- lib/libalpm/remove.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/libalpm/remove.c b/lib/libalpm/remove.c index dfaba03a..153c0426 100644 --- a/lib/libalpm/remove.c +++ b/lib/libalpm/remove.c @@ -414,6 +414,10 @@ int _alpm_remove_packages(pmtrans_t *trans, pmdb_t *db) alpm_list_t *newfiles; _alpm_log(PM_LOG_DEBUG, "removing %d files\n", filenum); + /* init progress bar */ + PROGRESS(trans, PM_TRANS_PROGRESS_REMOVE_START, info->name, 0, + pkg_count, (pkg_count - targcount + 1)); + /* iterate through the list backwards, unlinking files */ newfiles = alpm_list_reverse(files); for(lp = newfiles; lp; lp = alpm_list_next(lp)) { From 30734c9a4a63a1bfac0921b944e84f24dc87d76f Mon Sep 17 00:00:00 2001 From: Xavier Chantry Date: Sat, 16 Oct 2010 12:27:34 +0200 Subject: [PATCH 2/2] alpm/sync: very small memleak fix Signed-off-by: Xavier Chantry Signed-off-by: Dan McGee --- lib/libalpm/sync.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c index f8193962..57097fd1 100644 --- a/lib/libalpm/sync.c +++ b/lib/libalpm/sync.c @@ -333,7 +333,9 @@ int SYMEXPORT alpm_sync_dbtarget(char *dbname, char *target) if(dbs == NULL) { RET_ERR(PM_ERR_PKG_REPO_NOT_FOUND, -1); } - return(sync_target(dbs, target)); + int ret = sync_target(dbs, target); + alpm_list_free(dbs); + return(ret); } /** Add a sync target to the transaction.