[pacman-dev] [PATCH 2/2] pacman: add front end support for disabled repos

Dave Reisner d at falconindy.com
Mon Jul 2 20:15:39 EDT 2012


On Tue, Jul 03, 2012 at 10:02:03AM +1000, Allan McRae wrote:
> On 03/07/12 09:45, Dave Reisner wrote:
> > Hook up a per-repo 'Disabled' flag in the config for users to mark repos
> > as disabled. This can take a boolean value such as 'yes', 'true', or
> > '1', or the similar negated 'no', 'false', or '0'.
> 
> Why do we need this complexity?   Why not just specifying "Disabled"
> disables the repo and not specifying does not...
> 

We may not. Dan brought up the idea of making this a bit more granular,
but I don't have my IRC logs to recall exactly what was mentioned... he
can weigh in here.

> > Signed-off-by: Dave Reisner <dreisner at archlinux.org>
> > ---
> > It's possible that I'm blowing smoke with my strcasecmp commment...
> > 
> >  doc/pacman.conf.5.txt |  7 +++++++
> >  src/pacman/conf.c     | 38 ++++++++++++++++++++++++++++++++++++++
> >  2 files changed, 45 insertions(+)
> > 
> > diff --git a/doc/pacman.conf.5.txt b/doc/pacman.conf.5.txt
> > index a9c5db3..cc2d88f 100644
> > --- a/doc/pacman.conf.5.txt
> > +++ b/doc/pacman.conf.5.txt
> > @@ -226,6 +226,13 @@ even be used for different architectures.
> >  	Set the signature verification level for this repository. For more
> >  	information, see <<SC,Package and Database Signature Checking>> below.
> >  
> > +*Disabled =* boolean::
> > +	Allows a repository to be marked as disabled. Disabled repositories will
> > +	not be searched when looking for updates, but will continue to be refreshed.
> > +	This option takes a boolean true or false value.  True can be the string
> > +	``1'', ``yes'', or ``true'', case insensitive. False can be the string ``0'',
> > +	``no'', or ``false'', case insensitive.
> > +
> >  Package and Database Signature Checking
> >  ---------------------------------------
> >  The 'SigLevel' directive is valid in both the `[options]` and repository
> > diff --git a/src/pacman/conf.c b/src/pacman/conf.c
> > index 4aaacb5..4d042aa 100644
> > --- a/src/pacman/conf.c
> > +++ b/src/pacman/conf.c
> > @@ -636,6 +636,7 @@ struct section_t {
> >  	/* db section option gathering */
> >  	alpm_siglevel_t siglevel;
> >  	alpm_list_t *servers;
> > +	int disabled;
> >  };
> >  
> >  /**
> > @@ -669,6 +670,8 @@ static int finish_section(struct section_t *section, int parse_options)
> >  		goto cleanup;
> >  	}
> >  
> > +	alpm_db_set_disabled(db, section->disabled);
> > +
> >  	for(i = section->servers; i; i = alpm_list_next(i)) {
> >  		char *value = i->data;
> >  		if(_add_mirror(db, value) != 0) {
> > @@ -687,9 +690,29 @@ cleanup:
> >  	section->siglevel = ALPM_SIG_USE_DEFAULT;
> >  	free(section->name);
> >  	section->name = NULL;
> > +	section->disabled = 0;
> >  	return ret;
> >  }
> >  
> > +static int string_to_boolean(const char *string)
> > +{
> > +	/* usage of strcasecmp here is allowed since we're comparing
> > +	 * against fixed strings */
> > +	if(strcasecmp(string, "1") == 0 ||
> > +		 strcasecmp(string, "true") == 0 ||
> > +		 strcasecmp(string, "yes") == 0) {
> > +		return 1;
> > +	}
> > +
> > +	if(strcasecmp(string, "0") == 0 ||
> > +		 strcasecmp(string, "false") == 0 ||
> > +		 strcasecmp(string, "no") == 0) {
> > +		return 0;
> > +	}
> > +
> > +	return -1;
> > +}
> > +
> >  /** The "real" parseconfig. Each "Include" directive will recall this method so
> >   * recursion and stack depth are limited to 10 levels. The publicly visible
> >   * parseconfig calls this with a NULL section argument so we can recall from
> > @@ -856,6 +879,21 @@ static int _parseconfig(const char *file, struct section_t *section,
> >  					}
> >  					FREELIST(values);
> >  				}
> > +			} else if(strcmp(key, "Disabled") == 0) {
> > +				if(value == NULL) {
> > +					pm_printf(ALPM_LOG_ERROR, _("config file %s, line %d: directive '%s' needs a value\n"),
> > +							file, linenum, key);
> > +					ret = 1;
> > +					goto cleanup;
> > +				}
> > +				section->disabled = string_to_boolean(value);
> > +				if (section->disabled < 0) {
> > +					pm_printf(ALPM_LOG_ERROR, _("config file %s, line %d: directive '%s' has "
> > +								"invalid boolean value %s\n"),
> > +							file, linenum, key, value);
> > +					ret = 1;
> > +					goto cleanup;
> > +				}
> >  			} else {
> >  				pm_printf(ALPM_LOG_WARNING,
> >  						_("config file %s, line %d: directive '%s' in section '%s' not recognized.\n"),
> > 
> 
> 
> 


More information about the pacman-dev mailing list