From b6209b4ba495dd4379806b72735dac78b8843c03 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Thu, 12 Jan 2012 07:47:29 -0600 Subject: Use fileno() in isatty() call This was our only use of the function that had a hardcoded file descriptor. Signed-off-by: Dan McGee --- src/pacman/pacman.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index 326664dd..bce73d21 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -801,7 +801,7 @@ int main(int argc, char *argv[]) config = config_new(); /* disable progressbar if the output is redirected */ - if(!isatty(1)) { + if(!isatty(fileno(stdout))) { config->noprogressbar = 1; } -- cgit v1.2.3 From be229d129eeb43e774217921e1c7e1bb802775fe Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Wed, 18 Jan 2012 12:12:39 -0600 Subject: Don't remove unknown files in cache cleaning code This removes the hack I added to skip '*.sig' files earlier since there are other files that also fall into the same bucket- source packages from `makepkg --source`, delta files, etc. Rather than prompting for each and every one, simply skip them. Doing '-Scc' rather than '-Sc' will delete these files if that is really what you want to do. Signed-off-by: Dan McGee --- src/pacman/sync.c | 32 ++++++++++---------------------- 1 file changed, 10 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/pacman/sync.c b/src/pacman/sync.c index 2773708c..2c64f090 100644 --- a/src/pacman/sync.c +++ b/src/pacman/sync.c @@ -198,7 +198,6 @@ static int sync_cleancache(int level) /* step through the directory one file at a time */ while((ent = readdir(dir)) != NULL) { char path[PATH_MAX]; - size_t pathlen; int delete = 1; alpm_pkg_t *localpkg = NULL, *pkg = NULL; const char *local_name, *local_version; @@ -209,30 +208,18 @@ static int sync_cleancache(int level) /* build the full filepath */ snprintf(path, PATH_MAX, "%s%s", cachedir, ent->d_name); - /* short circuit for removing all packages from cache */ + /* short circuit for removing all files from cache */ if(level > 1) { unlink(path); continue; } - /* we handle .sig files with packages, not separately */ - pathlen = strlen(path); - if(strcmp(path + pathlen - 4, ".sig") == 0) { - continue; - } - - /* attempt to load the package, prompt removal on failures as we may have - * files here that aren't valid packages. we also don't need a full - * load of the package, just the metadata. */ - if(alpm_pkg_load(config->handle, path, 0, 0, &localpkg) != 0 - || localpkg == NULL) { - if(yesno(_("File %s does not seem to be a valid package, remove it?"), - path)) { - if(localpkg) { - alpm_pkg_free(localpkg); - } - unlink(path); - } + /* attempt to load the file as a package. if we cannot load the file, + * simply skip it and move on. we don't need a full load of the package, + * just the metadata. */ + if(alpm_pkg_load(config->handle, path, 0, 0, &localpkg) != 0) { + pm_printf(ALPM_LOG_DEBUG, "skipping %s, could not load as package\n", + path); continue; } local_name = alpm_pkg_get_name(localpkg); @@ -244,7 +231,7 @@ static int sync_cleancache(int level) if(pkg != NULL && alpm_pkg_vercmp(local_version, alpm_pkg_get_version(pkg)) == 0) { /* package was found in local DB and version matches, keep it */ - pm_printf(ALPM_LOG_DEBUG, "pkg %s-%s found in local db\n", + pm_printf(ALPM_LOG_DEBUG, "package %s-%s found in local db\n", local_name, local_version); delete = 0; } @@ -258,7 +245,7 @@ static int sync_cleancache(int level) if(pkg != NULL && alpm_pkg_vercmp(local_version, alpm_pkg_get_version(pkg)) == 0) { /* package was found in a sync DB and version matches, keep it */ - pm_printf(ALPM_LOG_DEBUG, "pkg %s-%s found in sync db\n", + pm_printf(ALPM_LOG_DEBUG, "package %s-%s found in sync db\n", local_name, local_version); delete = 0; } @@ -268,6 +255,7 @@ static int sync_cleancache(int level) alpm_pkg_free(localpkg); if(delete) { + size_t pathlen = strlen(path); unlink(path); /* unlink a signature file if present too */ if(PATH_MAX - 5 >= pathlen) { -- cgit v1.2.3 From 7b1a86b8939f59693f8bb0ea0454a702d5e2434e Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Wed, 18 Jan 2012 15:32:34 -0600 Subject: Remove unused strtoupper() function Signed-off-by: Dan McGee --- src/pacman/util.c | 13 ------------- src/pacman/util.h | 1 - 2 files changed, 14 deletions(-) (limited to 'src') diff --git a/src/pacman/util.c b/src/pacman/util.c index b9ee8c9c..e4e44c63 100644 --- a/src/pacman/util.c +++ b/src/pacman/util.c @@ -312,19 +312,6 @@ void indentprint(const char *str, size_t indent) free(wcstr); } -/* Convert a string to uppercase - */ -char *strtoupper(char *str) -{ - char *ptr = str; - - while(*ptr) { - (*ptr) = (char)toupper((unsigned char)*ptr); - ptr++; - } - return str; -} - /* Trim whitespace and newlines from a string */ char *strtrim(char *str) diff --git a/src/pacman/util.h b/src/pacman/util.h index 6ec962ff..49cf1dbd 100644 --- a/src/pacman/util.h +++ b/src/pacman/util.h @@ -55,7 +55,6 @@ int rmrf(const char *path); const char *mbasename(const char *path); char *mdirname(const char *path); void indentprint(const char *str, size_t indent); -char *strtoupper(char *str); char *strtrim(char *str); char *strreplace(const char *str, const char *needle, const char *replace); alpm_list_t *strsplit(const char *str, const char splitchar); -- cgit v1.2.3 From d9af1a0cf2383eed009ed2bedfb1b34f1a5c7418 Mon Sep 17 00:00:00 2001 From: Olivier Brunel Date: Thu, 12 Jan 2012 16:08:48 +0100 Subject: Fix broken output when asking question and stdin is piped When asking question and stdin is piped, the response does not get printed out, resulting in a missing \n and broken output (FS#27909); printing the response fixes it. Signed-off-by: Olivier Brunel Signed-off-by: Dan McGee --- src/pacman/util.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/pacman/util.c b/src/pacman/util.c index e4e44c63..d72509a5 100644 --- a/src/pacman/util.c +++ b/src/pacman/util.c @@ -1365,6 +1365,12 @@ static int question(short preset, char *fmt, va_list args) return preset; } + /* if stdin is piped, response does not get printed out, and as a result + * a \n is missing, resulting in broken output (FS#27909) */ + if(!isatty(fileno(stdin))) { + fprintf(stream, "%s\n", response); + } + if(strcasecmp(response, _("Y")) == 0 || strcasecmp(response, _("YES")) == 0) { return 1; } else if(strcasecmp(response, _("N")) == 0 || strcasecmp(response, _("NO")) == 0) { -- cgit v1.2.3 From c77cec2ffc850fa28c5720b8902acc5421069ae4 Mon Sep 17 00:00:00 2001 From: Allan McRae Date: Thu, 19 Jan 2012 11:29:36 +1000 Subject: Fix missing [removal] output Currently, a transaction is considered to be purely package removal until the first package install is found. This resulted in the removed packages at the start of a combined upgrade/removal transaction not getting the "[removal]" output. Fixes FS#27981. Signed-off-by: Allan McRae Signed-off-by: Dan McGee --- src/pacman/util.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/pacman/util.c b/src/pacman/util.c index d72509a5..76054132 100644 --- a/src/pacman/util.c +++ b/src/pacman/util.c @@ -835,8 +835,12 @@ static void _display_targets(alpm_list_t *targets, int verbose) /* add up size of all removed packages */ rsize += alpm_pkg_get_isize(target->remove); } + } + + /* form data for both verbose and non-verbose display */ + for(i = targets; i; i = alpm_list_next(i)) { + pm_target_t *target = i->data; - /* form data for both verbose and non-verbose display */ rows = alpm_list_add(rows, create_verbose_row(target, show_dl_size)); if(target->install) { pm_asprintf(&str, "%s-%s", alpm_pkg_get_name(target->install), -- cgit v1.2.3 From 1b50223f8240456b8c989b5c1e016f4a245b527c Mon Sep 17 00:00:00 2001 From: Olivier Brunel Date: Mon, 9 Jan 2012 21:37:31 +0100 Subject: util.c, rmrf(): only create string when needed The entry's name is only used when not "." or ".." so only print the string then. Signed-off-by: Olivier Brunel Signed-off-by: Dan McGee --- src/pacman/util.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/pacman/util.c b/src/pacman/util.c index 76054132..a8f19682 100644 --- a/src/pacman/util.c +++ b/src/pacman/util.c @@ -192,10 +192,10 @@ int rmrf(const char *path) return 1; } for(dp = readdir(dirp); dp != NULL; dp = readdir(dirp)) { - if(dp->d_ino) { - char name[PATH_MAX]; - sprintf(name, "%s/%s", path, dp->d_name); + if(dp->d_name) { if(strcmp(dp->d_name, "..") != 0 && strcmp(dp->d_name, ".") != 0) { + char name[PATH_MAX]; + snprintf(name, PATH_MAX, "%s/%s", path, dp->d_name); errflag += rmrf(name); } } -- cgit v1.2.3 From 562109c0e8717eaac3b9078271c4ca4f82abfecd Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Wed, 18 Jan 2012 22:25:27 -0600 Subject: Update copyright on changed files since beginning of year Signed-off-by: Dan McGee --- src/pacman/pacman.c | 2 +- src/pacman/sync.c | 2 +- src/pacman/util.c | 2 +- src/pacman/util.h | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index bce73d21..4c0d69ed 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -223,7 +223,7 @@ static void version(void) { printf("\n"); printf(" .--. Pacman v%s - libalpm v%s\n", PACKAGE_VERSION, alpm_version()); - printf("/ _.-' .-. .-. .-. Copyright (C) 2006-2011 Pacman Development Team\n"); + printf("/ _.-' .-. .-. .-. Copyright (C) 2006-2012 Pacman Development Team\n"); printf("\\ '-. '-' '-' '-' Copyright (C) 2002-2006 Judd Vinet\n"); printf(" '--'\n"); printf(_(" This program may be freely redistributed under\n" diff --git a/src/pacman/sync.c b/src/pacman/sync.c index 2c64f090..4f10e6b9 100644 --- a/src/pacman/sync.c +++ b/src/pacman/sync.c @@ -1,7 +1,7 @@ /* * sync.c * - * Copyright (c) 2006-2011 Pacman Development Team + * Copyright (c) 2006-2012 Pacman Development Team * Copyright (c) 2002-2006 by Judd Vinet * * This program is free software; you can redistribute it and/or modify diff --git a/src/pacman/util.c b/src/pacman/util.c index a8f19682..facdc1c9 100644 --- a/src/pacman/util.c +++ b/src/pacman/util.c @@ -1,7 +1,7 @@ /* * util.c * - * Copyright (c) 2006-2011 Pacman Development Team + * Copyright (c) 2006-2012 Pacman Development Team * Copyright (c) 2002-2006 by Judd Vinet * * This program is free software; you can redistribute it and/or modify diff --git a/src/pacman/util.h b/src/pacman/util.h index 49cf1dbd..1b5a3daf 100644 --- a/src/pacman/util.h +++ b/src/pacman/util.h @@ -1,7 +1,7 @@ /* * util.h * - * Copyright (c) 2006-2011 Pacman Development Team + * Copyright (c) 2006-2012 Pacman Development Team * Copyright (c) 2002-2006 by Judd Vinet * * This program is free software; you can redistribute it and/or modify -- cgit v1.2.3