diff mbox

[pacman-dev,v2] libalpm: process needed before group selection

Message ID 20181017154046.12299-1-morganamilo@gmail.com
State Accepted, archived
Delegated to: Andrew Gregory
Headers show

Commit Message

morganamilo Oct. 17, 2018, 3:40 p.m. UTC
When --needed is used, up to date packages are now filtered out
before showing the group select.

Fixes FS#22870.

Signed-off-by: morganamilo <morganamilo@gmail.com>
---
v2: Changed per Andrew's feedback.

Comments

Andrew Gregory Oct. 18, 2018, 12:33 a.m. UTC | #1
On 10/17/18 at 04:40pm, morganamilo wrote:
> When --needed is used, up to date packages are now filtered out
> before showing the group select.
> 
> Fixes FS#22870.
> 
> Signed-off-by: morganamilo <morganamilo@gmail.com>
> ---
> v2: Changed per Andrew's feedback.

I wasn't concerned about the misleading message for this patch, but
the failing test is another thing.  If you're not testing your patches
with `make check`, please do.  We could update the test, but let's
just go ahead and fix the "error" after all.  I recommend, in
a separate patch, adding a group_exists function and using that to
distinguish between a non-existent group and a group with no packages
selected after find_group_packages returns NULL.

> diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c
> index b6ae7b72..05f58fad 100644
> --- a/lib/libalpm/sync.c
> +++ b/lib/libalpm/sync.c
> @@ -277,10 +277,21 @@ alpm_list_t SYMEXPORT *alpm_find_group_pkgs(alpm_list_t *dbs,
>  
>  		for(j = grp->packages; j; j = j->next) {
>  			alpm_pkg_t *pkg = j->data;
> +			alpm_trans_t *trans = db->handle->trans;
>  
>  			if(alpm_pkg_find(ignorelist, pkg->name)) {
>  				continue;
>  			}
> +			if(trans != NULL && trans->flags & ALPM_TRANS_FLAG_NEEDED) {
> +				alpm_pkg_t *local = _alpm_db_get_pkgfromcache(db->handle->db_local, pkg->name);
> +				if(local && _alpm_pkg_compare_versions(pkg, local) == 0) {
> +					/* with the NEEDED flag, packages up to date are not reinstalled */
> +					_alpm_log(db->handle, ALPM_LOG_WARNING, _("%s-%s is up to date -- skipping\n"),
> +							local->name, local->version);
> +					ignorelist = alpm_list_add(ignorelist, pkg);
> +					continue;
> +				}
> +			}
>  			if(alpm_pkg_should_ignore(db->handle, pkg)) {
>  				alpm_question_install_ignorepkg_t question = {
>  					.type = ALPM_QUESTION_INSTALL_IGNOREPKG,
> -- 
> 2.19.1
morganamilo Oct. 18, 2018, 9:13 a.m. UTC | #2
On Thu, 18 Oct 2018 at 01:34, Andrew Gregory <andrew.gregory.8@gmail.com> wrote:
> I wasn't concerned about the misleading message for this patch, but
> the failing test is another thing.  If you're not testing your patches
> with `make check`, please do.  We could update the test, but let's
> just go ahead and fix the "error" after all.  I recommend, in
> a separate patch, adding a group_exists function and using that to
> distinguish between a non-existent group and a group with no packages
> selected after find_group_packages returns NULL.

I did say the patch set was incomplete ;)
group_exists does seem like the best idea though so will do. Would you
prefer that function be added to the backend or frontend?
diff mbox

Patch

diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c
index b6ae7b72..05f58fad 100644
--- a/lib/libalpm/sync.c
+++ b/lib/libalpm/sync.c
@@ -277,10 +277,21 @@  alpm_list_t SYMEXPORT *alpm_find_group_pkgs(alpm_list_t *dbs,
 
 		for(j = grp->packages; j; j = j->next) {
 			alpm_pkg_t *pkg = j->data;
+			alpm_trans_t *trans = db->handle->trans;
 
 			if(alpm_pkg_find(ignorelist, pkg->name)) {
 				continue;
 			}
+			if(trans != NULL && trans->flags & ALPM_TRANS_FLAG_NEEDED) {
+				alpm_pkg_t *local = _alpm_db_get_pkgfromcache(db->handle->db_local, pkg->name);
+				if(local && _alpm_pkg_compare_versions(pkg, local) == 0) {
+					/* with the NEEDED flag, packages up to date are not reinstalled */
+					_alpm_log(db->handle, ALPM_LOG_WARNING, _("%s-%s is up to date -- skipping\n"),
+							local->name, local->version);
+					ignorelist = alpm_list_add(ignorelist, pkg);
+					continue;
+				}
+			}
 			if(alpm_pkg_should_ignore(db->handle, pkg)) {
 				alpm_question_install_ignorepkg_t question = {
 					.type = ALPM_QUESTION_INSTALL_IGNOREPKG,