!41 [sync] PR-39: make the lib-version option work

From: @openeuler-sync-bot 
Reviewed-by: @dillon_chen 
Signed-off-by: @dillon_chen
This commit is contained in:
openeuler-ci-bot 2024-01-05 07:16:32 +00:00 committed by Gitee
commit 140f1d1758
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 102 additions and 1 deletions

View File

@ -0,0 +1,94 @@
From e0dab4843ded8af172c2566b4d7313a1a13e7e26 Mon Sep 17 00:00:00 2001
From: Werner Koch <wk@gnupg.org>
Date: Wed, 5 Aug 2020 12:19:56 +0200
Subject: [PATCH] Make --lib-version work again.
* src/gpg-error.c (main): Add printing code.
--
This was lost while changing to the included option parser back in
2018. The new code also does some prettying of the output.
Fixes-commit: 11ce9bc3d6fe75859e18112824ae7ec3ca0fc8df
Signed-off-by: Werner Koch <wk@gnupg.org>
Conflict:NA
Reference:https://github.com/gpg/libgpg-error/commit/e0dab4843ded8af172c2566b4d7313a1a13e7e26
---
src/gpg-error.c | 39 ++++++++++++++++++++++++++++++++++++---
1 file changed, 36 insertions(+), 3 deletions(-)
diff --git a/src/gpg-error.c b/src/gpg-error.c
index cc92c10..4e8bd8b 100644
--- a/src/gpg-error.c
+++ b/src/gpg-error.c
@@ -571,9 +571,11 @@ main (int argc, char *argv[])
gpgrt_argparse_t pargs = { &argc, &argv };
int i;
+ int libversion = 0;
int listmode = 0;
int localemode = 0;
int desc = 0;
+ const char *s, *s2;
const char *source_sym;
const char *error_sym;
gpg_error_t err;
@@ -588,7 +590,7 @@ main (int argc, char *argv[])
{
switch (pargs.r_opt)
{
- case CMD_LIB_VERSION: break;
+ case CMD_LIB_VERSION: libversion = 1; break;
case CMD_LIST: listmode = 1; break;
case CMD_DEFINES: listmode = 2; break;
case CMD_LOCALE: localemode = 1; break;
@@ -598,7 +600,12 @@ main (int argc, char *argv[])
}
gpgrt_argparse (NULL, &pargs, NULL); /* Free internal memory. */
- if (localemode)
+ if (libversion)
+ {
+ if (argc)
+ gpgrt_usage (1);
+ }
+ else if (localemode)
{
if (argc > 1)
gpgrt_usage (1);
@@ -606,7 +613,33 @@ main (int argc, char *argv[])
else if ((argc && listmode) || (!argc && !listmode))
gpgrt_usage (1);
- if (localemode)
+
+ if (libversion)
+ {
+ argc--; argv++;
+ printf ("Version from header: %s (0x%06x)\n",
+ GPG_ERROR_VERSION, GPG_ERROR_VERSION_NUMBER);
+ printf ("Version from binary: %s\n", gpg_error_check_version (NULL));
+ s = gpg_error_check_version ("\x01\x01");
+ while (*s && *s == '\n')
+ s++;
+ fputs ("Copyright blurb ...: ", stdout);
+ for (; *s; s++)
+ {
+ if (*s == '\n')
+ {
+ for (s2=s+1; *s2 == '\n'; s2++)
+ ;
+ if (!*s2)
+ break; /* Cut off trailing LFs. */
+ fputs ("\n ", stdout);
+ }
+ else
+ putc (*s, stdout);
+ }
+ putc ('\n', stdout);
+ }
+ else if (localemode)
{
#if HAVE_W32_SYSTEM
if (argc)

View File

@ -1,6 +1,6 @@
Name: libgpg-error
Version: 1.38
Release: 2
Release: 3
Summary: Library for common error values and messages in GnuPG components.
License: LGPLv2+
URL: https://www.gnupg.org/ftp/gcrypt/libgpg-error
@ -10,6 +10,7 @@ Source1: https://www.gnupg.org/ftp/gcrypt/libgpg-error/%{name}-%{version}.tar.gz
Patch6000: libgpg-error-1.29-multilib.patch
Patch6001: bugfix-corss-build-into-a-seperate-build-dir.patch
Patch6002: bugfix-corss-build-detec-hosts-objdump.patch
Patch6003: backport-make-lib-version-work.patch
BuildRequires: gcc gawk, gettext, autoconf, automake, gettext-devel, libtool, texinfo, gettext-autopoint hostname
@ -75,6 +76,12 @@ make check
%{_mandir}/*
%changelog
* Fri Jan 05 2024 yanglu <yanglu72@h-partners.com> - 1.38-3
- Type:bugfix
- Id:NA
- SUG:NA
- DESC:make the lib-version option work
* Thu Sep 30 2021 zhanzhimin <zhanzhimin@huawei.com> - 1.38-2
- Type:bugfix
- Id:NA