[pacman-dev] [PATCH 0/5] Group handling
This patch series adds support for manual group member selection during 'pacman -S <group>' operations (FS#19853). It also fixes FS#19854, adds 2 tests for FS#19854 and FS#15141, and corrects the existing test for FS#20221 (all of these are related to groups). Also available at http://github.com/schuay/pacman-arch/commits/group_backend I'm fairly unfamiliar with both C and the pacman codebase, so please check these patches thoroughly. Jakob Gruber (5): Tests: Adjust sync023 to correctly test FS#20221 Tests: Sync group which includes ignored pkgs Tests: '-S repo/group' syntax Reimplement advanced group handling Split group handling into separate function lib/libalpm/alpm.h | 11 ++++- lib/libalpm/sync.c | 91 +++++++++++++++++++++++++++++---------- src/pacman/callback.c | 21 +++++++++ src/pacman/util.c | 12 ++++- test/pacman/tests/ignore007.py | 21 +++++++++ test/pacman/tests/sync023.py | 7 ++- test/pacman/tests/sync024.py | 23 ++++++++++ 7 files changed, 154 insertions(+), 32 deletions(-) create mode 100644 test/pacman/tests/ignore007.py create mode 100644 test/pacman/tests/sync024.py -- 1.7.3
FS#20221 Issue: calling pacman with '-S --needed <group>', <group> has <pkg1> in more than one repo. <pkg1> is version 1.1 locally, version 1.1 in an earlier repo (for example testing), and 1.0 in a later repo (for example core). Example: <group> is base-devel make in testing is 1.1 make in core is 1.0 make installed locally is 1.1 pacman used to correctly skip make in testing (because versions match), but then try to downgrade to 1.0 (versions do NOT match). This test did not correctly check this scenario. Signed-off-by: Jakob Gruber <jakob.gruber@gmail.com> --- test/pacman/tests/sync023.py | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-) diff --git a/test/pacman/tests/sync023.py b/test/pacman/tests/sync023.py index 8233ab7..1bf0a0f 100644 --- a/test/pacman/tests/sync023.py +++ b/test/pacman/tests/sync023.py @@ -5,9 +5,9 @@ lp3 = pmpkg("pkg3") sp1 = pmpkg("pkg1") -sp2 = pmpkg("pkg2") +sp2 = pmpkg("pkg2", "1.2-1") sp3 = pmpkg("pkg3") -newp1 = pmpkg("pkg1", "1.1-1") +newp1 = pmpkg("pkg1", "1.2-1") for p in lp1, lp2, lp3, sp1, sp2, sp3, newp1: setattr(p, "groups", ["grp"]) @@ -26,4 +26,5 @@ for p in sp1, sp2, sp3: self.addrule("PKG_EXIST=%s" % p.name) # The newer version should still be installed -self.addrule("PKG_VERSION=pkg1|1.1-1") +self.addrule("PKG_VERSION=pkg1|1.2-1") +self.addrule("PKG_VERSION=pkg2|1.2-1") -- 1.7.3
On Sat, Sep 25, 2010 at 4:40 AM, Jakob Gruber <jakob.gruber@gmail.com> wrote:
FS#20221 ^^ unnecessary text here. :)
Issue: calling pacman with '-S --needed <group>', <group> has <pkg1> in more than one repo. <pkg1> is version 1.1 locally, version 1.1 in an earlier repo (for example testing), and 1.0 in a later repo (for example core).
Example: <group> is base-devel make in testing is 1.1 make in core is 1.0 make installed locally is 1.1
pacman used to correctly skip make in testing (because versions match), but then try to downgrade to 1.0 (versions do NOT match).
This test did not correctly check this scenario.
Should this just be a different test completely? You seemed to have changed both the setup and subsequent checks but didn't preserve the original checks. -Dan
Signed-off-by: Jakob Gruber <jakob.gruber@gmail.com> --- test/pacman/tests/sync023.py | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/test/pacman/tests/sync023.py b/test/pacman/tests/sync023.py index 8233ab7..1bf0a0f 100644 --- a/test/pacman/tests/sync023.py +++ b/test/pacman/tests/sync023.py @@ -5,9 +5,9 @@ lp3 = pmpkg("pkg3")
sp1 = pmpkg("pkg1") -sp2 = pmpkg("pkg2") +sp2 = pmpkg("pkg2", "1.2-1") sp3 = pmpkg("pkg3") -newp1 = pmpkg("pkg1", "1.1-1") +newp1 = pmpkg("pkg1", "1.2-1")
for p in lp1, lp2, lp3, sp1, sp2, sp3, newp1: setattr(p, "groups", ["grp"]) @@ -26,4 +26,5 @@ for p in sp1, sp2, sp3: self.addrule("PKG_EXIST=%s" % p.name) # The newer version should still be installed -self.addrule("PKG_VERSION=pkg1|1.1-1") +self.addrule("PKG_VERSION=pkg1|1.2-1") +self.addrule("PKG_VERSION=pkg2|1.2-1") -- 1.7.3
On 09/27/2010 05:29 PM, Dan McGee wrote:
On Sat, Sep 25, 2010 at 4:40 AM, Jakob Gruber<jakob.gruber@gmail.com> wrote:
FS#20221 ^^ unnecessary text here. :)
This is the related bug report. It does look kinda odd in the all by itself in the first line though :)
Issue: calling pacman with '-S --needed<group>',<group> has <pkg1> in more than one repo.<pkg1> is version 1.1 locally, version 1.1 in an earlier repo (for example testing), and 1.0 in a later repo (for example core).
Example:<group> is base-devel make in testing is 1.1 make in core is 1.0 make installed locally is 1.1
pacman used to correctly skip make in testing (because versions match), but then try to downgrade to 1.0 (versions do NOT match).
This test did not correctly check this scenario. Should this just be a different test completely? You seemed to have changed both the setup and subsequent checks but didn't preserve the original checks.
-Dan
I couldn't see how the original test made any sense, so I adjusted it to test FS#20221 (as specified in commit e702f56ea671c6cd1154a0ddb41fa63e97587c85). The old PKG_EXIST rules do nothing because pkg{1,2,3} are created in both the local repo and the sync repo. Likewise, the old PKG_VERSION rule has no effect because pkg1 is version 1.1-1 in all (local, sync, testing) repos. So the only thing it actually tests is that '-S --needed grp' runs without errors, and my updated test also checks for that. Or did I miss something? If you'd still like to have it as a separate test, let me know.
On Mon, Sep 27, 2010 at 8:38 PM, Jakob Gruber <jakob.gruber@gmail.com> wrote:
I couldn't see how the original test made any sense, so I adjusted it to test FS#20221 (as specified in commit e702f56ea671c6cd1154a0ddb41fa63e97587c85).
The old PKG_EXIST rules do nothing because pkg{1,2,3} are created in both the local repo and the sync repo.
Likewise, the old PKG_VERSION rule has no effect because pkg1 is version 1.1-1 in all (local, sync, testing) repos.
So the only thing it actually tests is that '-S --needed grp' runs without errors, and my updated test also checks for that.
Or did I miss something? If you'd still like to have it as a separate test, let me know.
Maybe what you missed is that the default version is 1.0-1 ? The existing sync023 pactest looks good to me.
On 09/27/2010 09:54 PM, Xavier Chantry wrote:
On Mon, Sep 27, 2010 at 8:38 PM, Jakob Gruber<jakob.gruber@gmail.com> wrote:
I couldn't see how the original test made any sense, so I adjusted it to test FS#20221 (as specified in commit e702f56ea671c6cd1154a0ddb41fa63e97587c85).
The old PKG_EXIST rules do nothing because pkg{1,2,3} are created in both the local repo and the sync repo.
Likewise, the old PKG_VERSION rule has no effect because pkg1 is version 1.1-1 in all (local, sync, testing) repos.
So the only thing it actually tests is that '-S --needed grp' runs without errors, and my updated test also checks for that.
Or did I miss something? If you'd still like to have it as a separate test, let me know.
Maybe what you missed is that the default version is 1.0-1 ?
The existing sync023 pactest looks good to me.
Ouch, can't believe I didn't notice that. Guess that makes my changes to sync023 superfluous.
See also FS#19854 (--ignore is ignored with groups) http://www.archlinux.org/pipermail/pacman-dev/2009-June/008847.html (operation aborts when a package from a group is ignored/and user chooses not to install it) If a group member is ignored, we expect a) a question whether to install b) after saying 'no' to a), the ignored member not to be installed c) all other group members to be installed d) pacman to execute successfully Signed-off-by: Jakob Gruber <jakob.gruber@gmail.com> --- test/pacman/tests/ignore007.py | 21 +++++++++++++++++++++ 1 files changed, 21 insertions(+), 0 deletions(-) create mode 100644 test/pacman/tests/ignore007.py diff --git a/test/pacman/tests/ignore007.py b/test/pacman/tests/ignore007.py new file mode 100644 index 0000000..bb5efdc --- /dev/null +++ b/test/pacman/tests/ignore007.py @@ -0,0 +1,21 @@ +self.description = "Sync group with ignored packages" + +pkg1 = pmpkg("package1") +pkg1.groups = ["grp"] +self.addpkg2db("sync", pkg1) + +pkg2 = pmpkg("package2") +pkg2.groups = ["grp"] +self.addpkg2db("sync", pkg2) + +pkg3 = pmpkg("package3") +pkg3.groups = ["grp"] +self.addpkg2db("sync", pkg3) + +self.option["IgnorePkg"] = ["package1"] +self.args = "--ask=1 -S grp" + +self.addrule("PACMAN_RETCODE=0") +self.addrule("!PKG_EXIST=%s" % pkg1.name) +self.addrule("PKG_EXIST=%s" % pkg2.name) +self.addrule("PACMAN_OUTPUT=IgnorePkg") -- 1.7.3
On Sat, Sep 25, 2010 at 4:40 AM, Jakob Gruber <jakob.gruber@gmail.com> wrote:
See also FS#19854 (--ignore is ignored with groups) http://www.archlinux.org/pipermail/pacman-dev/2009-June/008847.html (operation aborts when a package from a group is ignored/and user chooses not to install it)
If a group member is ignored, we expect a) a question whether to install b) after saying 'no' to a), the ignored member not to be installed c) all other group members to be installed d) pacman to execute successfully
Signed-off-by: Jakob Gruber <jakob.gruber@gmail.com>
I'm assuming this fails now. Please include this in the original commit of the test so one can bisect without problems: + +self.expectfailure = True And then remove that line in the commit that actually fixes it. See the history for test/pacman/tests/sync023.py for an example of this.
--- test/pacman/tests/ignore007.py | 21 +++++++++++++++++++++ 1 files changed, 21 insertions(+), 0 deletions(-) create mode 100644 test/pacman/tests/ignore007.py
diff --git a/test/pacman/tests/ignore007.py b/test/pacman/tests/ignore007.py new file mode 100644 index 0000000..bb5efdc --- /dev/null +++ b/test/pacman/tests/ignore007.py @@ -0,0 +1,21 @@ +self.description = "Sync group with ignored packages" + +pkg1 = pmpkg("package1") +pkg1.groups = ["grp"] +self.addpkg2db("sync", pkg1) + +pkg2 = pmpkg("package2") +pkg2.groups = ["grp"] +self.addpkg2db("sync", pkg2) + +pkg3 = pmpkg("package3") +pkg3.groups = ["grp"] +self.addpkg2db("sync", pkg3) + +self.option["IgnorePkg"] = ["package1"] +self.args = "--ask=1 -S grp" + +self.addrule("PACMAN_RETCODE=0") +self.addrule("!PKG_EXIST=%s" % pkg1.name) +self.addrule("PKG_EXIST=%s" % pkg2.name) +self.addrule("PACMAN_OUTPUT=IgnorePkg") -- 1.7.3
On 09/27/2010 05:32 PM, Dan McGee wrote:
I'm assuming this fails now. Please include this in the original commit of the test so one can bisect without problems: + +self.expectfailure = True
And then remove that line in the commit that actually fixes it. See the history for test/pacman/tests/sync023.py for an example of this.
* Rebased on top of master * Adapted the code to recent changes in util.c * Removed the extra 'FS#20221' line from commit message * Added + then removed self.expectfailure from ignore007.py Available at http://github.com/schuay/pacman-arch/commits/group_backend_revised
when calling '-S repo/group', only group members in <repo> should should be installed (group members in other repos are ignored) Signed-off-by: Jakob Gruber <jakob.gruber@gmail.com> --- test/pacman/tests/sync024.py | 23 +++++++++++++++++++++++ 1 files changed, 23 insertions(+), 0 deletions(-) create mode 100644 test/pacman/tests/sync024.py diff --git a/test/pacman/tests/sync024.py b/test/pacman/tests/sync024.py new file mode 100644 index 0000000..6d1192f --- /dev/null +++ b/test/pacman/tests/sync024.py @@ -0,0 +1,23 @@ +self.description = "Install a group from a sync db repo/group syntax" + +sp1 = pmpkg("pkg1") +sp2 = pmpkg("pkg2") +sp3 = pmpkg("pkg3") +newp1 = pmpkg("pkg1", "1.2-1") + +for p in sp1, sp2, sp3, newp1: + setattr(p, "groups", ["grp"]) + +self.addpkg2db("testing", newp1); + +for p in sp1, sp2, sp3: + self.addpkg2db("sync", p); + +self.args = "-S testing/grp" + +self.addrule("PACMAN_RETCODE=0") +for p in sp2, sp3: + self.addrule("!PKG_EXIST=%s" % p.name) +self.addrule("PKG_EXIST=%s" % newp1.name) +# The newer version should still be installed +self.addrule("PKG_VERSION=pkg1|1.2-1") -- 1.7.3
On Sat, Sep 25, 2010 at 4:40 AM, Jakob Gruber <jakob.gruber@gmail.com> wrote:
when calling '-S repo/group', only group members in <repo> should should be installed (group members in other repos are ignored)
Signed-off-by: Jakob Gruber <jakob.gruber@gmail.com> --- test/pacman/tests/sync024.py | 23 +++++++++++++++++++++++ I wonder if we should move some of these group-related tests to groupXXX.py.
Looks good; just the same note as the other test regarding the expectfailure thing.
1 files changed, 23 insertions(+), 0 deletions(-) create mode 100644 test/pacman/tests/sync024.py
diff --git a/test/pacman/tests/sync024.py b/test/pacman/tests/sync024.py new file mode 100644 index 0000000..6d1192f --- /dev/null +++ b/test/pacman/tests/sync024.py @@ -0,0 +1,23 @@ +self.description = "Install a group from a sync db repo/group syntax" + +sp1 = pmpkg("pkg1") +sp2 = pmpkg("pkg2") +sp3 = pmpkg("pkg3") +newp1 = pmpkg("pkg1", "1.2-1") + +for p in sp1, sp2, sp3, newp1: + setattr(p, "groups", ["grp"]) + +self.addpkg2db("testing", newp1); + +for p in sp1, sp2, sp3: + self.addpkg2db("sync", p); + +self.args = "-S testing/grp" + +self.addrule("PACMAN_RETCODE=0") +for p in sp2, sp3: + self.addrule("!PKG_EXIST=%s" % p.name) +self.addrule("PKG_EXIST=%s" % newp1.name) +# The newer version should still be installed +self.addrule("PKG_VERSION=pkg1|1.2-1") I believe PKG_VERSION will cover the EXIST check too, but not a big deal.
-- 1.7.3
On 09/27/2010 05:35 PM, Dan McGee wrote:
On Sat, Sep 25, 2010 at 4:40 AM, Jakob Gruber<jakob.gruber@gmail.com> wrote:
when calling '-S repo/group', only group members in<repo> should should be installed (group members in other repos are ignored)
Signed-off-by: Jakob Gruber<jakob.gruber@gmail.com> --- test/pacman/tests/sync024.py | 23 +++++++++++++++++++++++ I wonder if we should move some of these group-related tests to groupXXX.py.
Looks good; just the same note as the other test regarding the expectfailure thing.
This one already passes with pacman 3.4.1 (and maybe earlier versions too).
Allows user interaction during group installation, and makes groups installation use the same code paths as individual packages which should ensure proper handling of additional flag (like --needed, --ignore, ...). Implemented in libalpm using callbacks for user interaction. Reimplements group handling lost in b4317a740ac2d4f5e4d1aa56a97171c52be70d02. Related issues: * http://www.archlinux.org/pipermail/pacman-dev/2009-June/008847.html operation aborts when a package from a group is ignored and user chooses not to install it * FS#15141 'pacman -S <repo>/<group>' syntax * FS#19854 --ignore is ignored when installing a group * FS#19853 no prompting about groups * FS#20221 installing group from multiple repos with --needed Signed-off-by: Jakob Gruber <jakob.gruber@gmail.com> --- lib/libalpm/alpm.h | 11 ++++++++- lib/libalpm/sync.c | 51 ++++++++++++++++++++++++++++++++++++++++++------ src/pacman/callback.c | 21 ++++++++++++++++++++ src/pacman/util.c | 12 ++++++++-- 4 files changed, 83 insertions(+), 12 deletions(-) diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h index 0c01f21..f02bcbf 100644 --- a/lib/libalpm/alpm.h +++ b/lib/libalpm/alpm.h @@ -368,6 +368,11 @@ typedef enum _pmtransevt_t { * The repository's tree name is passed to the callback. */ PM_TRANS_EVT_RETRIEVE_START, + /** Package not found during sync, looking for group */ + PM_TRANS_EVT_PKG_NOT_FOUND, + /** Group will be installed, group and db is + * passed to the callback. */ + PM_TRANS_EVT_INSTALL_GROUP, } pmtransevt_t; /*@}*/ @@ -379,6 +384,8 @@ typedef enum _pmtransconv_t { PM_TRANS_CONV_CORRUPTED_PKG = (1 << 3), PM_TRANS_CONV_LOCAL_NEWER = (1 << 4), PM_TRANS_CONV_REMOVE_PKGS = (1 << 5), + PM_TRANS_CONV_INSTALL_GROUPPKG = (1 << 6), + PM_TRANS_CONV_INSTALL_GROUP = (1 << 7), } pmtransconv_t; /* Transaction Progress */ @@ -411,8 +418,8 @@ int alpm_trans_interrupt(void); int alpm_trans_release(void); int alpm_sync_sysupgrade(int enable_downgrade); -int alpm_sync_target(char *target); -int alpm_sync_dbtarget(char *db, char *target); +int alpm_sync_target(const char *target); +int alpm_sync_dbtarget(char *db, const char *target); int alpm_add_target(char *target); int alpm_remove_target(char *target); diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c index f819396..8982874 100644 --- a/lib/libalpm/sync.c +++ b/lib/libalpm/sync.c @@ -248,7 +248,7 @@ static int sync_pkg(pmpkg_t *spkg, alpm_list_t *pkg_list) return(0); } -static int sync_target(alpm_list_t *dbs_sync, char *target) +static int sync_target(alpm_list_t *dbs_sync, const char *target) { alpm_list_t *i, *j; alpm_list_t *known_pkgs = NULL; @@ -271,15 +271,53 @@ static int sync_target(alpm_list_t *dbs_sync, char *target) return(sync_pkg(spkg, handle->trans->add)); } + /* begin group handling. this section is responsible for looking for + * groups, user interaction, and finally adding group members to the + * queue. to stay consistent with individual package handling, it + * calls sync_target() for each group member to be installed */ _alpm_log(PM_LOG_DEBUG, "%s package not found, searching for group...\n", target); + EVENT(handle->trans, PM_TRANS_EVT_PKG_NOT_FOUND, (void*)target, NULL); + for(i = dbs_sync; i; i = i->next) { pmdb_t *db = i->data; grp = alpm_db_readgrp(db, target); + if(grp) { found = 1; - for(j = alpm_grp_get_pkgs(grp); j; j = j->next) { - pmpkg_t *pkg = j->data; - if(sync_pkg(pkg, known_pkgs) == -1) { + + /* display group members */ + EVENT(handle->trans, PM_TRANS_EVT_INSTALL_GROUP, (void*)grp, + (void*)db); + + /* ask if user wants to install all group members */ + int installall = 1; + QUESTION(handle->trans, PM_TRANS_CONV_INSTALL_GROUP, db, grp, + NULL, &installall); + + /* individually process all member packages */ + for(j = alpm_grp_get_pkgs(grp); j; j = alpm_list_next(j)) { + pmpkg_t *pkg = alpm_list_getdata(j); + const char *pkgname = alpm_pkg_get_name(pkg); + + /* package already processed in another repo, skip */ + if(known_pkgs && alpm_list_find_str(known_pkgs, pkgname)) { + continue; + } + known_pkgs = alpm_list_add(known_pkgs, (void*)pkgname); + + /* confirm user wants to install group member */ + if(installall == 0) { + int install = 1; + QUESTION(handle->trans, PM_TRANS_CONV_INSTALL_GROUPPKG, pkg, grp, + NULL, &install); + if(install == 0) { + continue; + } + } + + /* try adding pkg to transaction list (and run it through all + * checks - needed, ignored, ...) */ + if(sync_target(i, alpm_pkg_get_name(pkg)) == -1) { if(pm_errno == PM_ERR_TRANS_DUP_TARGET || pm_errno == PM_ERR_PKG_IGNORED) { /* just skip duplicate or ignored targets */ continue; @@ -288,7 +326,6 @@ static int sync_target(alpm_list_t *dbs_sync, char *target) return(-1); } } - known_pkgs = alpm_list_add(known_pkgs, pkg); } } } @@ -309,7 +346,7 @@ static int sync_target(alpm_list_t *dbs_sync, char *target) * @param target the name of the sync target to add * @return 0 on success, -1 on error (pm_errno is set accordingly) */ -int SYMEXPORT alpm_sync_dbtarget(char *dbname, char *target) +int SYMEXPORT alpm_sync_dbtarget(char *dbname, const char *target) { alpm_list_t *i; alpm_list_t *dbs_sync; @@ -340,7 +377,7 @@ int SYMEXPORT alpm_sync_dbtarget(char *dbname, char *target) * @param target the name of the sync target to add * @return 0 on success, -1 on error (pm_errno is set accordingly) */ -int SYMEXPORT alpm_sync_target(char *target) +int SYMEXPORT alpm_sync_target(const char *target) { alpm_list_t *dbs_sync; diff --git a/src/pacman/callback.c b/src/pacman/callback.c index 32dafb5..b91358b 100644 --- a/src/pacman/callback.c +++ b/src/pacman/callback.c @@ -229,6 +229,16 @@ void cb_trans_evt(pmtransevt_t event, void *data1, void *data2) case PM_TRANS_EVT_RETRIEVE_START: printf(_(":: Retrieving packages from %s...\n"), (char*)data1); break; + case PM_TRANS_EVT_PKG_NOT_FOUND: + printf(_("%s package not found, searching for group...\n"), + (char*)data1); + break; + case PM_TRANS_EVT_INSTALL_GROUP: + printf( _(":: group %s/%s:\n"), + (char*)alpm_db_get_name(data2), + (char*)alpm_grp_get_name(data1)); + display_targets(alpm_grp_get_pkgs(data1), 2); + break; /* all the simple done events, with fallthrough for each */ case PM_TRANS_EVT_FILECONFLICTS_DONE: case PM_TRANS_EVT_CHECKDEPS_DONE: @@ -309,6 +319,17 @@ void cb_trans_conv(pmtransconv_t event, void *data1, void *data2, *response = yesno(_(":: File %s is corrupted. Do you want to delete it?"), (char *)data1); break; + case PM_TRANS_CONV_INSTALL_GROUP: + *response = yesno(_(":: Install whole content from group %s/%s?"), + alpm_db_get_name(data1), + alpm_grp_get_name(data2)); + break; + case PM_TRANS_CONV_INSTALL_GROUPPKG: + *response = yesno(_(":: Install %s from group %s?"), + alpm_pkg_get_name(data1), + alpm_grp_get_name(data2)); + break; + } if(config->noask) { if(config->ask & event) { diff --git a/src/pacman/util.c b/src/pacman/util.c index b0824cf..9ccda90 100644 --- a/src/pacman/util.c +++ b/src/pacman/util.c @@ -506,8 +506,9 @@ void list_display_linebreak(const char *title, const alpm_list_t *list) } } } -/* prepare a list of pkgs to display */ -void display_targets(const alpm_list_t *pkgs, int install) +/* prepare a list of pkgs to display + * mode: 0=remove, 1=install, 2=group display */ +void display_targets(const alpm_list_t *pkgs, int mode) { char *str; const alpm_list_t *i; @@ -544,7 +545,7 @@ void display_targets(const alpm_list_t *pkgs, int install) mbdlsize = dlsize / (1024.0 * 1024.0); mbisize = isize / (1024.0 * 1024.0); - if(install) { + if(mode == 1) { asprintf(&str, _("Targets (%d):"), alpm_list_count(targets)); list_display(str, targets); free(str); @@ -554,6 +555,11 @@ void display_targets(const alpm_list_t *pkgs, int install) if(!(config->flags & PM_TRANS_FLAG_DOWNLOADONLY)) { printf(_("Total Installed Size: %.2f MB\n"), mbisize); } + } else if(mode == 2) { + asprintf(&str, _("Members (%d):"), alpm_list_count(targets)); + list_display(str, targets); + free(str); + printf("\n"); } else { asprintf(&str, _("Remove (%d):"), alpm_list_count(targets)); list_display(str, targets); -- 1.7.3
For improved readability. Signed-off-by: Jakob Gruber <jakob.gruber@gmail.com> --- lib/libalpm/sync.c | 42 ++++++++++++++++++++++++------------------ 1 files changed, 24 insertions(+), 18 deletions(-) diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c index 8982874..8bd34b1 100644 --- a/lib/libalpm/sync.c +++ b/lib/libalpm/sync.c @@ -248,29 +248,13 @@ static int sync_pkg(pmpkg_t *spkg, alpm_list_t *pkg_list) return(0); } -static int sync_target(alpm_list_t *dbs_sync, const char *target) -{ +static int sync_target(alpm_list_t *dbs_sync, const char *target); +static int sync_group(alpm_list_t *dbs_sync, const char *target) { alpm_list_t *i, *j; alpm_list_t *known_pkgs = NULL; - pmpkg_t *spkg; - pmdepend_t *dep; /* provisions and dependencies are also allowed */ pmgrp_t *grp; int found = 0; - ALPM_LOG_FUNC; - - /* Sanity checks */ - ASSERT(target != NULL && strlen(target) != 0, RET_ERR(PM_ERR_WRONG_ARGS, -1)); - ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1)); - - dep = _alpm_splitdep(target); - spkg = _alpm_resolvedep(dep, dbs_sync, NULL, 1); - _alpm_dep_free(dep); - - if(spkg != NULL) { - return(sync_pkg(spkg, handle->trans->add)); - } - /* begin group handling. this section is responsible for looking for * groups, user interaction, and finally adding group members to the * queue. to stay consistent with individual package handling, it @@ -342,6 +326,28 @@ static int sync_target(alpm_list_t *dbs_sync, const char *target) return(0); } +static int sync_target(alpm_list_t *dbs_sync, const char *target) +{ + pmpkg_t *spkg; + pmdepend_t *dep; /* provisions and dependencies are also allowed */ + + ALPM_LOG_FUNC; + + /* Sanity checks */ + ASSERT(target != NULL && strlen(target) != 0, RET_ERR(PM_ERR_WRONG_ARGS, -1)); + ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1)); + + dep = _alpm_splitdep(target); + spkg = _alpm_resolvedep(dep, dbs_sync, NULL, 1); + _alpm_dep_free(dep); + + if(spkg != NULL) { + return(sync_pkg(spkg, handle->trans->add)); + } + + return(sync_group(dbs_sync, target)); +} + /** Add a sync target to the transaction. * @param target the name of the sync target to add * @return 0 on success, -1 on error (pm_errno is set accordingly) -- 1.7.3
participants (3)
-
Dan McGee
-
Jakob Gruber
-
Xavier Chantry