index : pacman | |
Archlinux32 fork of pacman | gitolite user |
summaryrefslogtreecommitdiff |
-rw-r--r-- | src/pacman/callback.c | 10 | ||||
-rw-r--r-- | src/pacman/sync.c | 4 | ||||
-rw-r--r-- | src/pacman/upgrade.c | 1 | ||||
-rw-r--r-- | src/pacman/util.c | 2 | ||||
-rw-r--r-- | src/util/pactree.c | 96 | ||||
-rw-r--r-- | src/util/testpkg.c | 2 |
diff --git a/src/pacman/callback.c b/src/pacman/callback.c index 66b14cdd..ffca8bec 100644 --- a/src/pacman/callback.c +++ b/src/pacman/callback.c @@ -623,14 +623,14 @@ void cb_dl_progress(const char *filename, off_t file_xfered, off_t file_total) /* if padwid is < 0, we need to trim the string so padwid = 0 */ if(padwid < 0) { int i = filenamelen - 3; - wchar_t *p = wcfname; + wchar_t *wcp = wcfname; /* grab the max number of char columns we can fill */ - while(i > 0 && wcwidth(*p) < i) { - i -= wcwidth(*p); - p++; + while(i > 0 && wcwidth(*wcp) < i) { + i -= wcwidth(*wcp); + wcp++; } /* then add the ellipsis and fill out any extra padding */ - wcscpy(p, L"..."); + wcscpy(wcp, L"..."); padwid = i; } diff --git a/src/pacman/sync.c b/src/pacman/sync.c index f242c827..fa30b8da 100644 --- a/src/pacman/sync.c +++ b/src/pacman/sync.c @@ -443,7 +443,6 @@ static int sync_info(alpm_list_t *syncs, alpm_list_t *targets) if(targets) { for(i = targets; i; i = alpm_list_next(i)) { - pmdb_t *db = NULL; int foundpkg = 0; char target[512]; /* TODO is this enough space? */ @@ -452,6 +451,7 @@ static int sync_info(alpm_list_t *syncs, alpm_list_t *targets) strncpy(target, i->data, 512); pkgstr = strchr(target, '/'); if(pkgstr) { + pmdb_t *db = NULL; repo = target; *pkgstr = '\0'; ++pkgstr; @@ -767,7 +767,6 @@ static int sync_trans(alpm_list_t *targets) pm_fprintf(stderr, PM_LOG_ERROR, _("failed to prepare transaction (%s)\n"), alpm_strerror(err)); switch(err) { - alpm_list_t *i; case PM_ERR_PKG_INVALID_ARCH: for(i = data; i; i = alpm_list_next(i)) { char *pkg = alpm_list_getdata(i); @@ -835,7 +834,6 @@ static int sync_trans(alpm_list_t *targets) pm_fprintf(stderr, PM_LOG_ERROR, _("failed to commit transaction (%s)\n"), alpm_strerror(err)); switch(err) { - alpm_list_t *i; case PM_ERR_FILE_CONFLICTS: for(i = data; i; i = alpm_list_next(i)) { pmfileconflict_t *conflict = alpm_list_getdata(i); diff --git a/src/pacman/upgrade.c b/src/pacman/upgrade.c index 6587671b..c1f72f6d 100644 --- a/src/pacman/upgrade.c +++ b/src/pacman/upgrade.c @@ -166,7 +166,6 @@ int pacman_upgrade(alpm_list_t *targets) pm_fprintf(stderr, PM_LOG_ERROR, _("failed to commit transaction (%s)\n"), alpm_strerror(err)); switch(err) { - alpm_list_t *i; case PM_ERR_FILE_CONFLICTS: for(i = data; i; i = alpm_list_next(i)) { pmfileconflict_t *conflict = alpm_list_getdata(i); diff --git a/src/pacman/util.c b/src/pacman/util.c index 77a7e56c..75e67170 100644 --- a/src/pacman/util.c +++ b/src/pacman/util.c @@ -589,7 +589,7 @@ void list_display(const char *title, const alpm_list_t *list) printf("%s", str); cols += string_length(str); for(i = alpm_list_next(list); i; i = alpm_list_next(i)) { - const char *str = alpm_list_getdata(i); + str = alpm_list_getdata(i); int s = string_length(str); /* wrap only if we have enough usable column space */ if(maxcols > len && cols + s + 2 >= maxcols) { diff --git a/src/util/pactree.c b/src/util/pactree.c index 87bac6d1..5beaa5a7 100644 --- a/src/util/pactree.c +++ b/src/util/pactree.c @@ -26,6 +26,8 @@ #include <alpm.h> #include <alpm_list.h> +#define LINE_MAX 512 + /* output */ struct graph_style { const char *provides; @@ -85,8 +87,77 @@ int graphviz = 0; int max_depth = -1; int reverse = 0; int unique = 0; +int searchsyncs = 0; const char *dbpath = DBPATH; +static char *strtrim(char *str) +{ + char *pch = str; + + if(str == NULL || *str == '\0') { + /* string is empty, so we're done. */ + return str; + } + + while(isspace((unsigned char)*pch)) { + pch++; + } + if(pch != str) { + memmove(str, pch, (strlen(pch) + 1)); + } + + /* check if there wasn't anything but whitespace in the string. */ + if(*str == '\0') { + return str; + } + + pch = (str + (strlen(str) - 1)); + while(isspace((unsigned char)*pch)) { + pch--; + } + *++pch = '\0'; + + return str; +} + +static int register_syncs(void) { + FILE *fp; + char *ptr, *section = NULL; + char line[LINE_MAX]; + + fp = fopen(CONFFILE, "r"); + if(!fp) { + return 1; + } + + while(fgets(line, LINE_MAX, fp)) { + strtrim(line); + + if(line[0] == '#' || !strlen(line)) { + continue; + } + + if((ptr = strchr(line, '#'))) { + *ptr = '\0'; + strtrim(line); + } + + if(line[0] == '[' && line[strlen(line) - 1] == ']') { + free(section); + section = strndup(&line[1], strlen(line) - 2); + + if(section && strcmp(section, "options") != 0) { + alpm_db_register_sync(handle, section, PM_PGP_VERIFY_OPTIONAL); + } + } + } + + free(section); + fclose(fp); + + return 0; +} + static int parse_options(int argc, char *argv[]) { int opt, option_index = 0; @@ -100,11 +171,12 @@ static int parse_options(int argc, char *argv[]) {"help", no_argument, 0, 'h'}, {"linear", no_argument, 0, 'l'}, {"reverse", no_argument, 0, 'r'}, + {"sync", no_argument, 0, 'S'}, {"unique", no_argument, 0, 'u'}, {0, 0, 0, 0} }; - while((opt = getopt_long(argc, argv, "b:cd:ghlru", opts, &option_index))) { + while((opt = getopt_long(argc, argv, "b:cd:ghlrsu", opts, &option_index))) { if(opt < 0) { break; } @@ -133,6 +205,9 @@ static int parse_options(int argc, char *argv[]) case 'r': reverse = 1; break; + case 's': + searchsyncs = 1; + break; case 'u': unique = 1; style = &graph_linear; @@ -161,6 +236,7 @@ static void usage(void) " -g, --graph generate output for graphviz's dot\n" " -l, --linear enable linear output\n" " -r, --reverse show reverse dependencies\n" + " -s, --sync search sync DBs instead of local\n" " -u, --unique show dependencies with no duplicates (implies -l)\n\n" " -h, --help display this help message\n"); } @@ -324,7 +400,7 @@ static void walk_deps(alpm_list_t *dblist, pmpkg_t *pkg, int depth) int main(int argc, char *argv[]) { - int ret = 0; + int freelist = 0, ret = 0; enum _pmerrno_t err; const char *target_name; pmpkg_t *pkg; @@ -344,7 +420,17 @@ int main(int argc, char *argv[]) goto finish; } - dblist = alpm_list_add(dblist, alpm_option_get_localdb(handle)); + if(searchsyncs) { + if(register_syncs() != 0) { + fprintf(stderr, "error: failed to register sync DBs\n"); + ret = 1; + goto finish; + } + dblist = alpm_option_get_syncdbs(handle); + } else { + dblist = alpm_list_add(dblist, alpm_option_get_localdb(handle)); + freelist = 1; + } /* we only care about the first non option arg for walking */ target_name = argv[optind]; @@ -366,7 +452,9 @@ int main(int argc, char *argv[]) print_end(); - alpm_list_free(dblist); + if(freelist) { + alpm_list_free(dblist); + } finish: cleanup(); diff --git a/src/util/testpkg.c b/src/util/testpkg.c index c6f02e34..d4d058d8 100644 --- a/src/util/testpkg.c +++ b/src/util/testpkg.c @@ -60,7 +60,7 @@ int main(int argc, char *argv[]) if(alpm_pkg_load(handle, argv[1], 1, PM_PGP_VERIFY_OPTIONAL, &pkg) == -1 || pkg == NULL) { - enum _pmerrno_t err = alpm_errno(handle); + err = alpm_errno(handle); switch(err) { case PM_ERR_PKG_OPEN: printf("Cannot open the given file.\n"); |