[pacman-dev] [PATCH] Display old and new version in pacman -Qu output
This changes the output from "foo 1.0" to "foo 1.0 -> 1.1" which makes cronjobs that mail the -Qu output way more helpful. Signed-off-by: Florian Pritz <bluewind@xinu.at> --- src/pacman/query.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/pacman/query.c b/src/pacman/query.c index c9c82b9..a8499c0 100644 --- a/src/pacman/query.c +++ b/src/pacman/query.c @@ -318,8 +318,11 @@ static int display(alpm_pkg_t *pkg) && !config->op_q_changelog && !config->op_q_check) { if(!config->quiet) { const colstr_t *colstr = &config->colstr; - printf("%s%s %s%s%s\n", colstr->title, alpm_pkg_get_name(pkg), - colstr->version, alpm_pkg_get_version(pkg), colstr->nocolor); + alpm_pkg_t *newpkg = alpm_sync_newversion(pkg, alpm_get_syncdbs(config->handle)); + + printf("%s%s %s%s%s -> %s%s%s\n", colstr->title, alpm_pkg_get_name(pkg), + colstr->version, alpm_pkg_get_version(pkg), colstr->nocolor, + colstr->version, alpm_pkg_get_version(newpkg), colstr->nocolor); } else { printf("%s\n", alpm_pkg_get_name(pkg)); } -- 1.8.4
On 09/21/13 at 05:28pm, Florian Pritz wrote:
This changes the output from "foo 1.0" to "foo 1.0 -> 1.1" which makes cronjobs that mail the -Qu output way more helpful.
Signed-off-by: Florian Pritz <bluewind@xinu.at> --- src/pacman/query.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/pacman/query.c b/src/pacman/query.c index c9c82b9..a8499c0 100644 --- a/src/pacman/query.c +++ b/src/pacman/query.c @@ -318,8 +318,11 @@ static int display(alpm_pkg_t *pkg) && !config->op_q_changelog && !config->op_q_check) { if(!config->quiet) { const colstr_t *colstr = &config->colstr; - printf("%s%s %s%s%s\n", colstr->title, alpm_pkg_get_name(pkg), - colstr->version, alpm_pkg_get_version(pkg), colstr->nocolor); + alpm_pkg_t *newpkg = alpm_sync_newversion(pkg, alpm_get_syncdbs(config->handle));
Stray tab between arguments.
+ + printf("%s%s %s%s%s -> %s%s%s\n", colstr->title, alpm_pkg_get_name(pkg), + colstr->version, alpm_pkg_get_version(pkg), colstr->nocolor, + colstr->version, alpm_pkg_get_version(newpkg), colstr->nocolor);
Qu isn't the only operation to use this function. Running `pacman -Q pacman` gives me: pacman 4.1.2-1 -> (null) I think we should probably limit the new version to Qu output, but we definitely need to at least do a NULL check for newpkg.
} else { printf("%s\n", alpm_pkg_get_name(pkg)); } -- 1.8.4
This changes the output from "foo 1.0" to "foo 1.0 -> 1.1" which makes cronjobs that mail the -Qu output way more helpful. Signed-off-by: Florian Pritz <bluewind@xinu.at> --- v2: - add NULL check - only display for -Qu, not for -Q src/pacman/query.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/pacman/query.c b/src/pacman/query.c index c9c82b9..3a0b4ea 100644 --- a/src/pacman/query.c +++ b/src/pacman/query.c @@ -318,8 +318,16 @@ static int display(alpm_pkg_t *pkg) && !config->op_q_changelog && !config->op_q_check) { if(!config->quiet) { const colstr_t *colstr = &config->colstr; - printf("%s%s %s%s%s\n", colstr->title, alpm_pkg_get_name(pkg), + alpm_pkg_t *newpkg = alpm_sync_newversion(pkg, alpm_get_syncdbs(config->handle)); + + printf("%s%s %s%s%s", colstr->title, alpm_pkg_get_name(pkg), colstr->version, alpm_pkg_get_version(pkg), colstr->nocolor); + + if(config->op_q_upgrade && newpkg) { + printf(" -> %s%s%s", colstr->version, alpm_pkg_get_version(newpkg), colstr->nocolor); + } + + printf("\n"); } else { printf("%s\n", alpm_pkg_get_name(pkg)); } -- 1.8.4
On 22/09/13 04:50, Florian Pritz wrote:
This changes the output from "foo 1.0" to "foo 1.0 -> 1.1" which makes cronjobs that mail the -Qu output way more helpful.
Signed-off-by: Florian Pritz <bluewind@xinu.at> --- v2: - add NULL check - only display for -Qu, not for -Q
src/pacman/query.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/src/pacman/query.c b/src/pacman/query.c index c9c82b9..3a0b4ea 100644 --- a/src/pacman/query.c +++ b/src/pacman/query.c @@ -318,8 +318,16 @@ static int display(alpm_pkg_t *pkg) && !config->op_q_changelog && !config->op_q_check) { if(!config->quiet) { const colstr_t *colstr = &config->colstr; - printf("%s%s %s%s%s\n", colstr->title, alpm_pkg_get_name(pkg), + alpm_pkg_t *newpkg = alpm_sync_newversion(pkg, alpm_get_syncdbs(config->handle));
This does not need found unless we are doing -Qu so move it...
+ + printf("%s%s %s%s%s", colstr->title, alpm_pkg_get_name(pkg), colstr->version, alpm_pkg_get_version(pkg), colstr->nocolor); + + if(config->op_q_upgrade && newpkg) {
Here. I say we can kill the null check given we know this package has an update available and we do not do those checks in the (e.g.) alpm_pkg_get_version above.
+ printf(" -> %s%s%s", colstr->version, alpm_pkg_get_version(newpkg), colstr->nocolor); + } + + printf("\n"); } else { printf("%s\n", alpm_pkg_get_name(pkg)); }
This changes the output from "foo 1.0" to "foo 1.0 -> 1.1" which makes cronjobs that mail the -Qu output way more helpful. Signed-off-by: Florian Pritz <bluewind@xinu.at> --- v3: - Move newpkg definition into if block - Remove null check src/pacman/query.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/pacman/query.c b/src/pacman/query.c index c9c82b9..518b76a 100644 --- a/src/pacman/query.c +++ b/src/pacman/query.c @@ -318,8 +318,15 @@ static int display(alpm_pkg_t *pkg) && !config->op_q_changelog && !config->op_q_check) { if(!config->quiet) { const colstr_t *colstr = &config->colstr; - printf("%s%s %s%s%s\n", colstr->title, alpm_pkg_get_name(pkg), + printf("%s%s %s%s%s", colstr->title, alpm_pkg_get_name(pkg), colstr->version, alpm_pkg_get_version(pkg), colstr->nocolor); + + if(config->op_q_upgrade) { + alpm_pkg_t *newpkg = alpm_sync_newversion(pkg, alpm_get_syncdbs(config->handle)); + printf(" -> %s%s%s", colstr->version, alpm_pkg_get_version(newpkg), colstr->nocolor); + } + + printf("\n"); } else { printf("%s\n", alpm_pkg_get_name(pkg)); } -- 1.8.4
participants (3)
-
Allan McRae
-
Andrew Gregory
-
Florian Pritz