FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > ArchLinux > ArchLinux Pacman Development

 
 
LinkBack Thread Tools
 
Old 07-02-2012, 11:45 PM
Dave Reisner
 
Default pacman: add front end support for disabled repos

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'.

Signed-off-by: Dave Reisner <dreisner@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
"),
+ 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
"),
+ 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.
"),
--
1.7.11.1
 

Thread Tools




All times are GMT. The time now is 11:04 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org