[pacman-dev] [PATCH 1/2] Add IgnoreGroup and --ignoregroup option.
This will be used in the next commit. Signed-off-by: Nathan Jones <nathanj@insightbb.com> --- doc/pacman.conf.5.txt | 4 ++++ lib/libalpm/alpm.h | 4 ++++ lib/libalpm/handle.c | 21 +++++++++++++++++++++ lib/libalpm/handle.h | 1 + src/pacman/pacman.c | 15 +++++++++++++++ 5 files changed, 45 insertions(+), 0 deletions(-) diff --git a/doc/pacman.conf.5.txt b/doc/pacman.conf.5.txt index 06ba81d..690e3f4 100644 --- a/doc/pacman.conf.5.txt +++ b/doc/pacman.conf.5.txt @@ -68,6 +68,10 @@ Options Instructs pacman to ignore any upgrades for this package when performing a '\--sysupgrade'. +*IgnoreGroup =* group ...:: + Instructs pacman to ignore any upgrades for all packages in this + group when performing a '\--sysupgrade'. + *Include =* path:: Include another config file. This file can include repositories or general configuration options. diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h index 20d7787..f8558e1 100644 --- a/lib/libalpm/alpm.h +++ b/lib/libalpm/alpm.h @@ -130,6 +130,10 @@ alpm_list_t *alpm_option_get_holdpkgs(); void alpm_option_add_holdpkg(const char *pkg); void alpm_option_set_holdpkgs(alpm_list_t *holdpkgs); +alpm_list_t *alpm_option_get_ignoregrps(); +void alpm_option_add_ignoregrp(const char *grp); +void alpm_option_set_ignoregrps(alpm_list_t *ignoregrps); + time_t alpm_option_get_upgradedelay(); void alpm_option_set_upgradedelay(time_t delay); diff --git a/lib/libalpm/handle.c b/lib/libalpm/handle.c index af54949..78ac117 100644 --- a/lib/libalpm/handle.c +++ b/lib/libalpm/handle.c @@ -100,6 +100,7 @@ void _alpm_handle_free(pmhandle_t *handle) FREELIST(handle->noextract); FREELIST(handle->ignorepkg); FREELIST(handle->holdpkg); + FREELIST(handle->ignoregrp); FREE(handle); } @@ -211,6 +212,15 @@ alpm_list_t SYMEXPORT *alpm_option_get_holdpkgs() return handle->holdpkg; } +alpm_list_t SYMEXPORT *alpm_option_get_ignoregrps() +{ + if (handle == NULL) { + pm_errno = PM_ERR_HANDLE_NULL; + return NULL; + } + return handle->ignoregrp; +} + time_t SYMEXPORT alpm_option_get_upgradedelay() { if (handle == NULL) { @@ -461,6 +471,17 @@ void SYMEXPORT alpm_option_set_holdpkgs(alpm_list_t *holdpkgs) if(holdpkgs) handle->holdpkg = holdpkgs; } +void SYMEXPORT alpm_option_add_ignoregrp(const char *grp) +{ + handle->ignoregrp = alpm_list_add(handle->ignoregrp, strdup(grp)); +} + +void alpm_option_set_ignoregrps(alpm_list_t *ignoregrps) +{ + if(handle->ignoregrp) FREELIST(handle->ignoregrp); + if(ignoregrps) handle->ignoregrp = ignoregrps; +} + void SYMEXPORT alpm_option_set_upgradedelay(time_t delay) { handle->upgradedelay = delay; diff --git a/lib/libalpm/handle.h b/lib/libalpm/handle.h index 0874ecd..63a4688 100644 --- a/lib/libalpm/handle.h +++ b/lib/libalpm/handle.h @@ -55,6 +55,7 @@ typedef struct _pmhandle_t { alpm_list_t *noextract; /* List of packages NOT to extract */ /*TODO is this used?*/ alpm_list_t *ignorepkg; /* List of packages to ignore */ alpm_list_t *holdpkg; /* List of packages which 'hold' pacman */ + alpm_list_t *ignoregrp; /* List of groups to ignore */ /* options */ unsigned short usesyslog; /* Use syslog instead of logfile? */ /* TODO move to frontend */ diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index 9c650f2..2f916e2 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -309,6 +309,7 @@ static int parseargs(int argc, char *argv[]) {"cachedir", required_argument, 0, 1007}, {"asdeps", no_argument, 0, 1008}, {"logfile", required_argument, 0, 1009}, + {"ignoregroup", required_argument, 0, 1010}, {0, 0, 0, 0} }; @@ -369,6 +370,7 @@ static int parseargs(int argc, char *argv[]) } config->have_logfile = 1; break; + case 1010: alpm_option_add_ignoregrp(strdup(optarg)); break; case 'A': config->op = (config->op != PM_OP_MAIN ? 0 : PM_OP_ADD); break; case 'F': config->op = (config->op != PM_OP_MAIN ? 0 : PM_OP_UPGRADE); @@ -627,6 +629,19 @@ static int _parseconfig(const char *file, const char *givensection, } alpm_option_add_ignorepkg(p); pm_printf(PM_LOG_DEBUG, "config: ignorepkg: %s\n", p); + } else if(strcmp(key, "IgnoreGroup") == 0 || strcmp(upperkey, "IGNOREGROUP") == 0) { + char *p = ptr; + char *q; + + while((q = strchr(p, ' '))) { + *q = '\0'; + alpm_option_add_ignoregrp(p); + pm_printf(PM_LOG_DEBUG, "config: ignoregroup: %s", p); + p = q; + p++; + } + alpm_option_add_ignoregrp(p); + pm_printf(PM_LOG_DEBUG, "config: ignoregroup: %s\n", p); } else if(strcmp(key, "HoldPkg") == 0 || strcmp(upperkey, "HOLDPKG") == 0) { char *p = ptr; char *q; -- 1.5.3.5
This option acts as if IgnorePkg was set on each package in the group. This closes FS#1592. Signed-off-by: Nathan Jones <nathanj@insightbb.com> --- lib/libalpm/db.c | 2 +- lib/libalpm/deps.c | 2 +- lib/libalpm/package.c | 32 +++++++++++++++++++++++++++++++- lib/libalpm/package.h | 1 + lib/libalpm/sync.c | 7 +++---- src/pacman/callback.c | 4 ++-- 6 files changed, 39 insertions(+), 9 deletions(-) diff --git a/lib/libalpm/db.c b/lib/libalpm/db.c index c06db3b..307b9ef 100644 --- a/lib/libalpm/db.c +++ b/lib/libalpm/db.c @@ -462,7 +462,7 @@ alpm_list_t SYMEXPORT *alpm_db_get_upgrades(void) if(strcmp(k->data, alpm_pkg_get_name(lpkg)) == 0) { _alpm_log(PM_LOG_DEBUG, "checking replacement '%s' for package '%s'\n", (char *)k->data, alpm_pkg_get_name(spkg)); - if(alpm_list_find_str(handle->ignorepkg, alpm_pkg_get_name(lpkg))) { + if(_alpm_pkg_should_ignore(lpkg)) { _alpm_log(PM_LOG_WARNING, _("%s-%s: ignoring package upgrade (to be replaced by %s-%s)\n"), alpm_pkg_get_name(lpkg), alpm_pkg_get_version(lpkg), alpm_pkg_get_name(spkg), alpm_pkg_get_version(spkg)); diff --git a/lib/libalpm/deps.c b/lib/libalpm/deps.c index d8cb0d6..cefffe5 100644 --- a/lib/libalpm/deps.c +++ b/lib/libalpm/deps.c @@ -730,7 +730,7 @@ int _alpm_resolvedeps(pmdb_t *local, alpm_list_t *dbs_sync, pmpkg_t *syncpkg, * something we're not supposed to. */ int usedep = 1; - if(alpm_list_find_str(handle->ignorepkg, alpm_pkg_get_name(sync))) { + if(_alpm_pkg_should_ignore(sync)) { pmpkg_t *dummypkg = _alpm_pkg_new(miss->target, NULL); QUESTION(trans, PM_TRANS_CONV_INSTALL_IGNOREPKG, dummypkg, sync, NULL, &usedep); _alpm_pkg_free(dummypkg); diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c index 1e59938..7c2870c 100644 --- a/lib/libalpm/package.c +++ b/lib/libalpm/package.c @@ -755,7 +755,7 @@ int alpm_pkg_compare_versions(pmpkg_t *local_pkg, pmpkg_t *pkg) /* compare versions and see if we need to upgrade */ cmp = _alpm_versioncmp(alpm_pkg_get_version(pkg), alpm_pkg_get_version(local_pkg)); - if(alpm_list_find_str(handle->ignorepkg, alpm_pkg_get_name(pkg))) { + if(_alpm_pkg_should_ignore(pkg)) { /* package should be ignored (IgnorePkg) */ if(cmp > 0) { _alpm_log(PM_LOG_WARNING, _("%s-%s: ignoring package upgrade (%s)\n"), @@ -1117,4 +1117,34 @@ int _alpm_pkg_istoonew(pmpkg_t *pkg) time(&t); return((pkg->date + handle->upgradedelay) > t); } + +/** Test if a package should be ignored. + * + * Checks if the package is ignored via IgnorePkg, or if the package is + * in a group ignored via IgnoreGrp. + * + * @param pkg the package to test + * + * @return 1 if the package should be ignored, 0 otherwise + */ +int _alpm_pkg_should_ignore(pmpkg_t *pkg) +{ + alpm_list_t *groups = NULL; + + /* first see if the package is ignored */ + if(alpm_list_find_str(handle->ignorepkg, alpm_pkg_get_name(pkg))) { + return(1); + } + + /* next see if the package is in a group that is ignored */ + for(groups = handle->ignoregrp; groups; groups = alpm_list_next(groups)) { + char *grp = (char *)alpm_list_getdata(groups); + if(alpm_list_find_str(alpm_pkg_get_groups(pkg), grp)) { + return(1); + } + } + + return(0); +} + /* vim: set ts=2 sw=2 noet: */ diff --git a/lib/libalpm/package.h b/lib/libalpm/package.h index daaeb36..ab93fd8 100644 --- a/lib/libalpm/package.h +++ b/lib/libalpm/package.h @@ -99,6 +99,7 @@ pmpkg_t *_alpm_pkg_load(const char *pkgfile, unsigned short full); pmpkg_t *_alpm_pkg_find(const char *needle, alpm_list_t *haystack); int _alpm_pkg_istoonew(pmpkg_t *pkg); void _alpm_pkg_update_requiredby(pmpkg_t *pkg); +int _alpm_pkg_should_ignore(pmpkg_t *pkg); #endif /* _ALPM_PACKAGE_H */ diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c index 7791e74..10a72a7 100644 --- a/lib/libalpm/sync.c +++ b/lib/libalpm/sync.c @@ -118,8 +118,7 @@ static int find_replacements(pmtrans_t *trans, pmdb_t *db_local, _alpm_log(PM_LOG_DEBUG, "checking replacement '%s' for package '%s'\n", replacement, spkg->name); /* ignore if EITHER the local or replacement package are to be ignored */ - if(alpm_list_find_str(handle->ignorepkg, spkg->name) - || alpm_list_find_str(handle->ignorepkg, lpkg->name)) { + if(_alpm_pkg_should_ignore(spkg) || _alpm_pkg_should_ignore(lpkg)) { _alpm_log(PM_LOG_WARNING, _("%s-%s: ignoring package upgrade (to be replaced by %s-%s)\n"), alpm_pkg_get_name(lpkg), alpm_pkg_get_version(lpkg), alpm_pkg_get_name(spkg), alpm_pkg_get_version(spkg)); @@ -217,7 +216,7 @@ int _alpm_sync_sysupgrade(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_s if(!_alpm_sync_find(trans->packages, alpm_pkg_get_name(spkg))) { /* If package is in the ignorepkg list, ask before we add it to * the transaction */ - if(alpm_list_find_str(handle->ignorepkg, alpm_pkg_get_name(local))) { + if(_alpm_pkg_should_ignore(local)) { int resp = 0; QUESTION(trans, PM_TRANS_CONV_INSTALL_IGNOREPKG, local, NULL, NULL, &resp); if(!resp) { @@ -322,7 +321,7 @@ int _alpm_sync_addtarget(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sy if(alpm_pkg_compare_versions(local, spkg) == 0) { /* spkg is NOT an upgrade, get confirmation before adding */ int resp = 0; - if(alpm_list_find_str(handle->ignorepkg, alpm_pkg_get_name(local))) { + if(_alpm_pkg_should_ignore(local)) { QUESTION(trans, PM_TRANS_CONV_INSTALL_IGNOREPKG, local, NULL, NULL, &resp); if(!resp) { return(0); diff --git a/src/pacman/callback.c b/src/pacman/callback.c index e935c87..90191aa 100644 --- a/src/pacman/callback.c +++ b/src/pacman/callback.c @@ -274,12 +274,12 @@ void cb_trans_conv(pmtransconv_t event, void *data1, void *data2, case PM_TRANS_CONV_INSTALL_IGNOREPKG: if(data2) { /* TODO we take this route based on data2 being not null? WTF */ - snprintf(str, LOG_STR_LEN, _(":: %s requires installing %s from IgnorePkg. Install anyway? [Y/n] "), + snprintf(str, LOG_STR_LEN, _(":: %s requires installing %s from IgnorePkg/IgnoreGroup. Install anyway? [Y/n] "), alpm_pkg_get_name(data1), alpm_pkg_get_name(data2)); *response = yesno(str); } else { - snprintf(str, LOG_STR_LEN, _(":: %s is in IgnorePkg. Install anyway? [Y/n] "), + snprintf(str, LOG_STR_LEN, _(":: %s is in IgnorePkg/IgnoreGroup. Install anyway? [Y/n] "), alpm_pkg_get_name(data1)); *response = yesno(str); } -- 1.5.3.5
I like this.
I forgot to add --ignoregroup to the --help message. The problem now is that the command name is too long: -y, --refresh download fresh package databases from the server --ignore <pkg> ignore a package upgrade (can be used more than once) --ignoregroup <grp> ignore a group upgrade (can be used more than once) --config <path> set an alternate configuration file --logfile <path> set an alternate log file Shortening to --ignoregrp is still one letter too large. Maybe --ignoregp? The current longest line is --print-uris which is 79 columns, so it is possible to add one more space between the command and description. Any ideas?
On Nov 12, 2007 3:51 PM, Nathan Jones <nathanj@insightbb.com> wrote:
I forgot to add --ignoregroup to the --help message. The problem now is that the command name is too long:
-y, --refresh download fresh package databases from the server --ignore <pkg> ignore a package upgrade (can be used more than once) --ignoregroup <grp> ignore a group upgrade (can be used more than once) --config <path> set an alternate configuration file --logfile <path> set an alternate log file
Shortening to --ignoregrp is still one letter too large. Maybe --ignoregp? The current longest line is --print-uris which is 79 columns, so it is possible to add one more space between the command and description.
Any ideas?
Break it up? Something like....
-y, --refresh download fresh package databases from the server --ignore <pkg> ignore a package upgrade (can be used more than once) --ignoregroup <grp> ignore a group upgrade (can be used more than once) --config <path> set an alternate configuration file --logfile <path> set an alternate log file
/me shrugs
On Nov 12, 2007 4:03 PM, Aaron Griffin <aaronmgriffin@gmail.com> wrote:
On Nov 12, 2007 3:51 PM, Nathan Jones <nathanj@insightbb.com> wrote:
I forgot to add --ignoregroup to the --help message. The problem now is that the command name is too long:
-y, --refresh download fresh package databases from the server --ignore <pkg> ignore a package upgrade (can be used more than once) --ignoregroup <grp> ignore a group upgrade (can be used more than once) --config <path> set an alternate configuration file --logfile <path> set an alternate log file
Shortening to --ignoregrp is still one letter too large. Maybe --ignoregp? The current longest line is --print-uris which is 79 columns, so it is possible to add one more space between the command and description.
Any ideas?
Break it up? Something like....
-y, --refresh download fresh package databases from the server --ignore <pkg> ignore a package upgrade (can be used more than once) --ignoregroup <grp> ignore a group upgrade (can be used more than once) --config <path> set an alternate configuration file --logfile <path> set an alternate log file
Let's keep the command clear and not shorten it just for the sake of the help message (we'd have i18n issues anyway- English tends to have terse descriptions). Just make it wrap lines BUT do it all in the same printf using \n and stuff. -Dan
Idézés Dan McGee <dpmcgee@gmail.com>:
On Nov 12, 2007 3:51 PM, Nathan Jones <nathanj@insightbb.com> wrote:
I forgot to add --ignoregroup to the --help message. The problem now is that the command name is too long:
-y, --refresh download fresh package databases from the server --ignore <pkg> ignore a package upgrade (can be used more than once) --ignoregroup <grp> ignore a group upgrade (can be used more than once) --config <path> set an alternate configuration file --logfile <path> set an alternate log file
Shortening to --ignoregrp is still one letter too large. Maybe --ignoregp? The current longest line is --print-uris which is 79 columns, so it is possible to add one more space between the command and description.
Any ideas?
Break it up? Something like....
-y, --refresh download fresh package databases from the server --ignore <pkg> ignore a package upgrade (can be used more than once) --ignoregroup <grp> ignore a group upgrade (can be used more
On Nov 12, 2007 4:03 PM, Aaron Griffin <aaronmgriffin@gmail.com> wrote: than once)
--config <path> set an alternate configuration file --logfile <path> set an alternate log file
(we'd have i18n issues anyway- English tends to have terse descriptions). +1 I would prefer --ignoregrp, --ignoregroup, --ignoregrp <g.> or --ignoregrp <gp>, and then mention <g.> or <gp> in the description. Bye, ngaba
---------------------------------------------------- SZTE Egyetemi Könyvtár - http://www.bibl.u-szeged.hu This mail sent through IMP: http://horde.org/imp/
Signed-off-by: Nathan Jones <nathanj@insightbb.com> --- doc/pacman.8.txt | 4 ++++ src/pacman/pacman.c | 1 + 2 files changed, 5 insertions(+), 0 deletions(-) diff --git a/doc/pacman.8.txt b/doc/pacman.8.txt index 9cb4476..db7f9c3 100644 --- a/doc/pacman.8.txt +++ b/doc/pacman.8.txt @@ -269,6 +269,10 @@ Sync Options[[SO]] Directs pacman to ignore upgrades of package even if there is one available. +*\--ignoregroup* <'group'>:: + Directs pacman to ignore upgrades of all packages in 'group' even if + there is one available. + Handling Config Files[[HCF]] ---------------------------- diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index b00e3dc..af61ab9 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -134,6 +134,7 @@ static void usage(int op, const char * const myname) printf(_(" -w, --downloadonly download packages but do not install/upgrade anything\n")); printf(_(" -y, --refresh download fresh package databases from the server\n")); printf(_(" --ignore <pkg> ignore a package upgrade (can be used more than once)\n")); + printf(_(" --ignoregroup <grp>\n ignore a group upgrade (can be used more than once)\n")); } printf(_(" --config <path> set an alternate configuration file\n")); printf(_(" --logfile <path> set an alternate log file\n")); -- 1.5.3.5
participants (4)
-
Aaron Griffin
-
Dan McGee
-
Nagy Gabor
-
Nathan Jones