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-54-g00ecf 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 --- doc/pacman.8.txt | 2 +- src/pacman/sync.c | 32 ++++++++++---------------------- 2 files changed, 11 insertions(+), 23 deletions(-) (limited to 'src') diff --git a/doc/pacman.8.txt b/doc/pacman.8.txt index 59853812..275f8ac0 100644 --- a/doc/pacman.8.txt +++ b/doc/pacman.8.txt @@ -349,7 +349,7 @@ Sync Options[[SO]] databases are saved for every sync DB you download from, and are not deleted even if they are removed from the configuration file linkman:pacman.conf[5]. Use one '\--clean' switch to only remove - packages that are no longer installed; use two to remove all packages + packages that are no longer installed; use two to remove all files from the cache. In both cases, you will have a yes or no option to remove packages and/or unused downloaded databases. + 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-54-g00ecf 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-54-g00ecf 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-54-g00ecf 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-54-g00ecf 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 --- lib/libalpm/util.c | 6 +++--- src/pacman/util.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c index 2d0153e5..6834751f 100644 --- a/lib/libalpm/util.c +++ b/lib/libalpm/util.c @@ -381,7 +381,6 @@ int _alpm_rmrf(const char *path) int errflag = 0; struct dirent *dp; DIR *dirp; - char name[PATH_MAX]; struct stat st; if(_alpm_lstat(path, &st) == 0) { @@ -401,9 +400,10 @@ int _alpm_rmrf(const char *path) return 1; } for(dp = readdir(dirp); dp != NULL; dp = readdir(dirp)) { - if(dp->d_ino) { - 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]; + sprintf(name, "%s/%s", path, dp->d_name); errflag += _alpm_rmrf(name); } } 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-54-g00ecf 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 --- lib/libalpm/dload.c | 2 +- lib/libalpm/remove.c | 2 +- lib/libalpm/signing.c | 2 +- lib/libalpm/util.c | 2 +- scripts/makepkg.sh.in | 4 ++-- scripts/pacman-key.sh.in | 4 ++-- scripts/repo-add.sh.in | 4 ++-- src/pacman/pacman.c | 2 +- src/pacman/sync.c | 2 +- src/pacman/util.c | 2 +- src/pacman/util.h | 2 +- 11 files changed, 14 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/lib/libalpm/dload.c b/lib/libalpm/dload.c index 928324e8..6fe4a323 100644 --- a/lib/libalpm/dload.c +++ b/lib/libalpm/dload.c @@ -1,7 +1,7 @@ /* * download.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/lib/libalpm/remove.c b/lib/libalpm/remove.c index 41cee514..cc9e289d 100644 --- a/lib/libalpm/remove.c +++ b/lib/libalpm/remove.c @@ -1,7 +1,7 @@ /* * remove.c * - * Copyright (c) 2006-2011 Pacman Development Team + * Copyright (c) 2006-2012 Pacman Development Team * Copyright (c) 2002-2006 by Judd Vinet * Copyright (c) 2005 by Aurelien Foret * Copyright (c) 2005 by Christian Hamar diff --git a/lib/libalpm/signing.c b/lib/libalpm/signing.c index 1a53deaa..3ec957de 100644 --- a/lib/libalpm/signing.c +++ b/lib/libalpm/signing.c @@ -1,7 +1,7 @@ /* * signing.c * - * Copyright (c) 2008-2011 Pacman Development Team + * Copyright (c) 2008-2012 Pacman Development Team * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c index 6834751f..0e5e8a00 100644 --- a/lib/libalpm/util.c +++ b/lib/libalpm/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 * Copyright (c) 2005 by Aurelien Foret * Copyright (c) 2005 by Christian Hamar diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 797b8d78..169162ce 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -3,7 +3,7 @@ # makepkg - make packages compatible for use with pacman # @configure_input@ # -# Copyright (c) 2006-2011 Pacman Development Team +# Copyright (c) 2006-2012 Pacman Development Team # Copyright (c) 2002-2006 by Judd Vinet # Copyright (c) 2005 by Aurelien Foret # Copyright (c) 2006 by Miklos Vajna @@ -1866,7 +1866,7 @@ usage() { version() { printf "makepkg (pacman) %s\n" "$myver" printf "$(gettext "\ -Copyright (c) 2006-2011 Pacman Development Team .\n\ +Copyright (c) 2006-2012 Pacman Development Team .\n\ Copyright (C) 2002-2006 Judd Vinet .\n\n\ This is free software; see the source for copying conditions.\n\ There is NO WARRANTY, to the extent permitted by law.\n")" diff --git a/scripts/pacman-key.sh.in b/scripts/pacman-key.sh.in index b7c77d82..2159fdf1 100644 --- a/scripts/pacman-key.sh.in +++ b/scripts/pacman-key.sh.in @@ -4,7 +4,7 @@ # Based on apt-key, from Debian # @configure_input@ # -# Copyright (c) 2010-2011 Pacman Development Team +# Copyright (c) 2010-2012 Pacman Development Team # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -88,7 +88,7 @@ usage() { version() { printf "pacman-key (pacman) %s\n" "${myver}" printf "$(gettext "\ -Copyright (c) 2010-2011 Pacman Development Team .\n\ +Copyright (c) 2010-2012 Pacman Development Team .\n\ This is free software; see the source for copying conditions.\n\ There is NO WARRANTY, to the extent permitted by law.\n")" } diff --git a/scripts/repo-add.sh.in b/scripts/repo-add.sh.in index 6a10a684..8c1d53da 100644 --- a/scripts/repo-add.sh.in +++ b/scripts/repo-add.sh.in @@ -4,7 +4,7 @@ # repo-remove - remove a package entry from a given repo database file # @configure_input@ # -# Copyright (c) 2006-2011 Pacman Development Team +# Copyright (c) 2006-2012 Pacman Development Team # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -87,7 +87,7 @@ version() { cmd=${0##*/} printf "%s (pacman) %s\n\n" "$cmd" "$myver" printf "$(gettext "\ -Copyright (c) 2006-2011 Pacman Development Team \n\n\ +Copyright (c) 2006-2012 Pacman Development Team \n\n\ This is free software; see the source for copying conditions.\n\ There is NO WARRANTY, to the extent permitted by law.\n")" } 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-54-g00ecf