import popt-1.18-1.el8

This commit is contained in:
CentOS Sources 2021-03-30 08:45:42 -04:00 committed by Stepan Oksanichenko
parent faed422970
commit 83130ff885
9 changed files with 16 additions and 421 deletions

2
.gitignore vendored
View File

@ -1 +1 @@
SOURCES/popt-1.16.tar.gz
SOURCES/popt-1.18.tar.gz

View File

@ -1 +1 @@
cfe94a15a2404db85858a81ff8de27c8ff3e235e SOURCES/popt-1.16.tar.gz
0bf05488e151228fce9c0c9601162a9f432f69d9 SOURCES/popt-1.18.tar.gz

View File

@ -1,71 +0,0 @@
Patch by Panu Matilainen <pmatilai@redhat.com> for popt <= 1.16 which kludges
poptBadOption() to return something semi-meaningful on exec alias fail:
- poptBadOption() is totally unaware of exec alias failures, and will return
either the first argument or last option, giving wonderfully misleading error
messages (#697435, #710267).
- Remember execvp() first argument on failure and return that from
poptBadOption() if present to give the user a reasonable clue what exactly
went wrong.
This patch was proposed to upstream: http://rpm5.org/community/popt-devel/0264.html
--- popt-1.16/popt.c 2010-01-19 01:39:10.000000000 +0100
+++ popt-1.16/popt.c.execfail 2013-11-24 15:50:06.000000000 +0100
@@ -192,6 +192,7 @@
con->flags = flags;
con->execs = NULL;
con->numExecs = 0;
+ con->execFail = NULL;
con->finalArgvAlloced = argc * 2;
con->finalArgv = calloc( (size_t)con->finalArgvAlloced, sizeof(*con->finalArgv) );
con->execAbsolute = 1;
@@ -236,6 +237,7 @@
con->nextLeftover = 0;
con->restLeftover = 0;
con->doExec = NULL;
+ con->execFail = _free(con->execFail);
if (con->finalArgv != NULL)
for (i = 0; i < con->finalArgvCount; i++) {
@@ -564,6 +566,7 @@
/*@-nullstate@*/
rc = execvp(argv[0], (char *const *)argv);
/*@=nullstate@*/
+ con->execFail = xstrdup(argv[0]);
exit:
if (argv) {
@@ -1697,11 +1700,19 @@
const char * poptBadOption(poptContext con, unsigned int flags)
{
struct optionStackEntry * os = NULL;
+ const char *badOpt = NULL;
- if (con != NULL)
- os = (flags & POPT_BADOPTION_NOALIAS) ? con->optionStack : con->os;
+ if (con != NULL) {
+ /* Stupid hack to return something semi-meaningful from exec failure */
+ if (con->execFail) {
+ badOpt = con->execFail;
+ } else {
+ os = (flags & POPT_BADOPTION_NOALIAS) ? con->optionStack : con->os;
+ badOpt = os->argv[os->next - 1];
+ }
+ }
- return (os != NULL && os->argv != NULL ? os->argv[os->next - 1] : NULL);
+ return badOpt;
}
const char * poptStrerror(const int error)
--- popt-1.16/poptint.h 2010-01-19 01:39:10.000000000 +0100
+++ popt-1.16/poptint.h.execfail 2013-11-24 15:50:38.000000000 +0100
@@ -132,6 +132,7 @@
/*@owned@*/ /*@null@*/
poptItem execs;
int numExecs;
+ char * execFail;
/*@only@*/ /*@null@*/
poptArgv finalArgv;
int finalArgvCount;

View File

@ -1,24 +0,0 @@
Backport of upstream http://rpm5.org/cvs/chngview?cn=19258
--- popt-1.16/poptconfig.c 2009-05-20 15:18:07.000000000 +0200
+++ popt-1.16/poptconfig.c.glob-error 2017-10-12 23:33:28.868435647 +0200
@@ -108,7 +108,7 @@
if (glob_pattern_p(pat, 0)) {
glob_t _g, *pglob = &_g;
- if (!glob(pat, poptGlobFlags, poptGlob_error, pglob)) {
+ if (!(rc = glob(pat, poptGlobFlags, poptGlob_error, pglob))) {
if (acp) {
*acp = (int) pglob->gl_pathc;
pglob->gl_pathc = 0;
@@ -122,6 +122,10 @@
/*@-nullstate@*/
globfree(pglob);
/*@=nullstate@*/
+ } else if (rc == GLOB_NOMATCH) {
+ *avp = NULL;
+ *acp = 0;
+ rc = 0;
} else
rc = POPT_ERROR_ERRNO;
} else

View File

@ -1,107 +0,0 @@
Patch initially by Miloslav Trmač <mitr@redhat.com> and revised by Akira Tagoh
<tagoh@redhat.com> for popt <= 1.16 which fixes the problem that help messages
for --help and --usage seem not translatable. There already was some i18n support
for autohelp in popt.c, but not in popthelp.c, where it actually matters.
See https://bugzilla.redhat.com/show_bug.cgi?id=734434 for further details, please.
This patch was proposed to upstream: http://rpm5.org/community/popt-devel/0287.html
--- popt-1.16/popthelp.c 2009-08-28 09:06:33.000000000 +0900
+++ popt-1.16/popthelp.c.help 2014-01-08 12:04:00.888260244 +0900
@@ -89,7 +89,7 @@ static struct poptOption poptHelpOptions
{ "defaults", '\0', POPT_ARG_NONE, &show_option_defaults, 0,
N_("Display option defaults in message"), NULL },
#endif
- { "", '\0', 0, NULL, 0, N_("Terminate options"), NULL },
+ { NULL, '\0', 0, NULL, 0, N_("Terminate options"), NULL },
POPT_TABLEEND
} ;
@@ -527,8 +527,11 @@ static size_t maxArgWidth(const struct p
if (opt != NULL)
while (opt->longName || opt->shortName || opt->arg) {
if (poptArgType(opt) == POPT_ARG_INCLUDE_TABLE) {
- if (opt->arg) /* XXX program error */
- len = maxArgWidth(opt->arg, translation_domain);
+ void * arg = opt->arg;
+ /* XXX sick hack to preserve pretense of ABI. */
+ if (arg == poptHelpOptions) arg = poptHelpOptionsI18N;
+ if (arg) /* XXX program error */
+ len = maxArgWidth(arg, translation_domain);
if (len > max) max = len;
} else if (!F_ISSET(opt, DOC_HIDDEN)) {
len = sizeof(" ")-1;
@@ -619,19 +622,22 @@ static void singleTableHelp(poptContext
if (table != NULL)
for (opt = table; opt->longName || opt->shortName || opt->arg; opt++) {
+ void * arg = opt->arg;
if (poptArgType(opt) != POPT_ARG_INCLUDE_TABLE)
continue;
- sub_transdom = getTableTranslationDomain(opt->arg);
+ /* XXX sick hack to preserve pretense of ABI. */
+ if (arg == poptHelpOptions) arg = poptHelpOptionsI18N;
+ sub_transdom = getTableTranslationDomain(arg);
if (sub_transdom == NULL)
sub_transdom = translation_domain;
/* If no popt aliases/execs, skip poptAliasOption processing. */
- if (opt->arg == poptAliasOptions && !(con->numAliases || con->numExecs))
+ if (arg == poptAliasOptions && !(con->numAliases || con->numExecs))
continue;
if (opt->descrip)
xx = POPT_fprintf(fp, "\n%s\n", D_(sub_transdom, opt->descrip));
- singleTableHelp(con, fp, opt->arg, columns, sub_transdom);
+ singleTableHelp(con, fp, arg, columns, sub_transdom);
}
}
@@ -808,22 +814,25 @@ static size_t singleTableUsage(poptConte
translation_domain = (const char *)opt->arg;
} else
if (poptArgType(opt) == POPT_ARG_INCLUDE_TABLE) {
+ void * arg = opt->arg;
+ /* XXX sick hack to preserve pretense of ABI. */
+ if (arg == poptHelpOptions) arg = poptHelpOptionsI18N;
if (done) {
int i = 0;
if (done->opts != NULL)
for (i = 0; i < done->nopts; i++) {
const void * that = done->opts[i];
- if (that == NULL || that != opt->arg)
+ if (that == NULL || that != arg)
/*@innercontinue@*/ continue;
/*@innerbreak@*/ break;
}
/* Skip if this table has already been processed. */
- if (opt->arg == NULL || i < done->nopts)
+ if (arg == NULL || i < done->nopts)
continue;
if (done->opts != NULL && done->nopts < done->maxopts)
- done->opts[done->nopts++] = (const void *) opt->arg;
+ done->opts[done->nopts++] = (const void *) arg;
}
- columns->cur = singleTableUsage(con, fp, columns, opt->arg,
+ columns->cur = singleTableUsage(con, fp, columns, arg,
translation_domain, done);
} else
if ((opt->longName || opt->shortName) && !F_ISSET(opt, DOC_HIDDEN)) {
@@ -864,9 +873,13 @@ static size_t showShortOptions(const str
if (!strchr(s, opt->shortName) && isprint((int)opt->shortName)
&& opt->shortName != ' ')
s[strlen(s)] = opt->shortName;
- } else if (poptArgType(opt) == POPT_ARG_INCLUDE_TABLE)
- if (opt->arg) /* XXX program error */
- len = showShortOptions(opt->arg, fp, s);
+ } else if (poptArgType(opt) == POPT_ARG_INCLUDE_TABLE) {
+ void * arg = opt->arg;
+ /* XXX sick hack to preserve pretense of ABI. */
+ if (arg == poptHelpOptions) arg = poptHelpOptionsI18N;
+ if (arg) /* XXX program error */
+ len = showShortOptions(arg, fp, s);
+ }
}
/* On return to top level, print the short options, return print length. */

View File

@ -1,66 +0,0 @@
Patch by John Bradshaw <john@johnbradshaw.org> for popt <= 1.16 which fixes some
spelling mistakes in popt man page.
See https://bugzilla.redhat.com/show_bug.cgi?id=675567 for further details, please.
This patch was proposed to upstream: http://rpm5.org/community/popt-devel/0263.html
Upstream already corrected some issues with http://rpm5.org/cvs/chngview?cn=16879
and solved the last ones with http://rpm5.org/cvs/chngview?cn=17375 now. Thus popt
1.17 should make this patch completely obsolete.
--- popt-1.16/popt.3 2009-07-25 20:52:36.000000000 +0200
+++ popt-1.16/popt.3.man-page 2013-11-24 15:59:58.000000000 +0100
@@ -200,7 +200,7 @@
.RB "This macro includes another option table (via " POPT_ARG_INCLUDE_TABLE
; see below) in the main one which provides the table entries for these
.RB "arguments. When " --usage " or " --help " are passed to programs which
-use popt's automatical help, popt displays the appropriate message on
+use popt's automatic help, popt displays the appropriate message on
stderr as soon as it finds the option, and exits the program with a
return code of 0. If you want to use popt's automatic help generation in
a different way, you need to explicitly add the option entries to your programs
@@ -210,7 +210,7 @@
the argument will not be shown in help output.
.sp
If the \fIargInfo\fR value is bitwise or'd with \fBPOPT_ARGFLAG_SHOW_DEFAULT\fR,
-the inital value of the arg will be shown in help output.
+the initial value of the arg will be shown in help output.
.sp
The final structure in the table should have all the pointer values set
.RB "to " NULL " and all the arithmetic values set to 0, marking the "
@@ -233,7 +233,7 @@
contain a overall description of the option table being included.
.sp
The other special option table entry type tells popt to call a function (a
-callback) when any option in that table is found. This is especially usefull
+callback) when any option in that table is found. This is especially useful
when included option tables are being used, as the program which provides
the top-level option table doesn't need to be aware of the other options
which are provided by the included table. When a callback is set for
@@ -473,7 +473,7 @@
.TP
.B POPT_ERROR_BADNUMBER
A conversion from a string to a number (int or long) failed due
-to the string containing nonnumeric characters. This occurs when
+to the string containing non-numeric characters. This occurs when
.BR poptGetNextOpt() " is processing an argument of type "
.BR POPT_ARG_INT ", " POPT_ARG_SHORT ", " POPT_ARG_LONG ", " POPT_ARG_LONGLONG ", "
.RB POPT_ARG_FLOAT ", or " POPT_ARG_DOUBLE "."
@@ -517,7 +517,7 @@
applications. When an error is detected from most of the functions,
an error message is printed along with the error string from
.BR poptStrerror() ". When an error occurs during argument parsing, "
-code similiar to the following displays a useful error message:
+code similar to the following displays a useful error message:
.sp
.nf
fprintf(stderr, "%s: %s\\n",
@@ -608,7 +608,7 @@
.RI "an " argv "-style array, some programs need to parse strings that "
are formatted identically to command lines. To facilitate this, popt
provides a function that parses a string into an array of strings,
-using rules similiar to normal shell parsing.
+using rules similar to normal shell parsing.
.sp
.nf
.B "#include <popt.h>"

View File

@ -1,79 +0,0 @@
From 6fcb24d785a2c2d626bac6999aee6b3ab368be15 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Fri, 28 Jul 2017 16:11:40 -0400
Subject: [PATCH] Don't leak the last argument expanded by expandNextArg()
While using POPT_ARG_ARGV, I noticed this in valgrind's leak checker:
==1738== HEAP SUMMARY:
==1738== in use at exit: 8 bytes in 1 blocks
==1738== total heap usage: 94 allocs, 93 frees, 42,319 bytes allocated
==1738==
==1738== 8 bytes in 1 blocks are definitely lost in loss record 1 of 1
==1738== at 0x4C2EB6B: malloc (vg_replace_malloc.c:299)
==1738== by 0x4E3DF47: expandNextArg (popt.c:699)
==1738== by 0x4E3F681: poptGetNextOpt (popt.c:1501)
==1738== by 0x401F72: main (bingrep.c:433)
==1738==
==1738== LEAK SUMMARY:
==1738== definitely lost: 8 bytes in 1 blocks
==1738== indirectly lost: 0 bytes in 0 blocks
==1738== possibly lost: 0 bytes in 0 blocks
==1738== still reachable: 0 bytes in 0 blocks
==1738== suppressed: 0 bytes in 0 blocks
My command line argument is a 7-byte string, and on first glance, it
appears this is because both expandNextArg() and poptSaveString()
duplicate the string. The copy from poptSaveString() is the consuming
program's responsibility to free, but the intermediate pointer is popt's
responsibility.
Upon further examination, it appears popt normally does free this
string, but it only does it on the next entry to poptGetNextOpt(), and
on cleanOSE() in the case if we're not already at the bottom of
con->OptionStack.
This patch modifies poptResetContext() to ensure we'll always attempt to
free con->os->nextArg regardless of our position in the OptionStack, and
removes the duplicate free of con->os->argb in poptFreeContext(), as
it's called unconditionally by the poptResetContext() call on the
previous line.
This ensures that if poptGetNextOpt() isn't re-intered, poptFreeContext()
will free the memory that was allocated. Now valgrind tells me:
==31734== HEAP SUMMARY:
==31734== in use at exit: 0 bytes in 0 blocks
==31734== total heap usage: 94 allocs, 94 frees, 42,319 bytes allocated
==31734==
==31734== All heap blocks were freed -- no leaks are possible
Signed-off-by: Peter Jones <pjones@redhat.com>
---
popt.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/popt.c b/popt.c
index 1a53f40..72fbf5c 100644
--- a/popt.c
+++ b/popt.c
@@ -230,7 +230,7 @@ void poptResetContext(poptContext con)
con->os->argb = PBM_FREE(con->os->argb);
con->os->currAlias = NULL;
con->os->nextCharArg = NULL;
- con->os->nextArg = NULL;
+ con->os->nextArg = _free(con->os->nextArg);
con->os->next = 1; /* skip argv[0] */
con->numLeftovers = 0;
@@ -1617,7 +1617,6 @@ poptContext poptFreeContext(poptContext con)
{
if (con == NULL) return con;
poptResetContext(con);
- con->os->argb = _free(con->os->argb);
con->aliases = poptFreeItems(con->aliases, con->numAliases);
con->numAliases = 0;
--
2.13.3

View File

@ -1,31 +0,0 @@
Patch by Robert Scheck <robert@fedoraproject.org> for popt <= 1.16 which changes
$(pkgconfigdir) on 64 bit systems from /usr/lib/pkgconfig to /usr/lib64/pkgconfig.
Using $(libdir)/pkgconfig rather $(prefix)/lib/pkgconfig seems to be common when
searching on the Internet. This patch however is not really compliant with Fedora
/%{_lib} vs. %{_libdir} handling before the UsrMove with Fedora 17. Alternatively
--with-pkgconfigdir or similar should be implemented.
This patch was proposed to upstream: http://rpm5.org/community/popt-devel/0265.html
--- popt-1.16/Makefile.in 2010-05-04 22:55:59.000000000 +0200
+++ popt-1.16/Makefile.in.pkgconfig 2013-11-24 15:06:43.000000000 +0100
@@ -370,7 +370,7 @@
libpopt_la_SOURCES = popt.c poptparse.c poptconfig.c popthelp.c poptint.c
libpopt_la_LDFLAGS = -no-undefined @LTLIBINTL@ @LTLIBICONV@ \
$(am__append_1)
-pkgconfigdir = $(prefix)/lib/pkgconfig
+pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = popt.pc
man_MANS = popt.3
BUILT_SOURCES = popt.pc # popt.lcd
--- popt-1.16/Makefile.am 2010-05-04 22:55:54.000000000 +0200
+++ popt-1.16/Makefile.am.pkgconfig 2013-11-24 15:02:21.000000000 +0100
@@ -47,7 +47,7 @@
libpopt_la_SOURCES = popt.c poptparse.c poptconfig.c popthelp.c poptint.c
libpopt_la_LDFLAGS = -no-undefined @LTLIBINTL@ @LTLIBICONV@
-pkgconfigdir = $(prefix)/lib/pkgconfig
+pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = popt.pc
if HAVE_LD_VERSION_SCRIPT

View File

@ -1,17 +1,11 @@
Summary: C library for parsing command line parameters
Name: popt
Version: 1.16
Release: 14%{?dist}
Version: 1.18
Release: 1%{?dist}
License: MIT
Group: System Environment/Libraries
URL: http://www.rpm5.org/
Source: http://www.rpm5.org/files/%{name}/%{name}-%{version}.tar.gz
Patch0: popt-1.16-pkgconfig.patch
Patch1: popt-1.16-execfail.patch
Patch2: popt-1.16-man-page.patch
Patch3: popt-1.16-help.patch
Patch4: popt-1.16-nextarg-memleak.patch
Patch5: popt-1.16-glob-error.patch
URL: https://github.com/rpm-software-management/popt/
Source: http://ftp.rpm.org/popt/releases/popt-1.x/popt-%{version}.tar.gz
BuildRequires: gcc gettext
%description
@ -44,42 +38,20 @@ The popt-static package includes static libraries of the popt library.
Install it if you need to link statically with libpopt.
%prep
%setup -q
%patch0 -p1 -b .pkgconfig
%patch1 -p1 -b .execfail
%patch2 -p1 -b .man-page
%patch3 -p1 -b .help
%patch4 -p1 -b .nextarg-memleak
%patch5 -p1 -b .glob-error
%autosetup
%build
%if 0%{?fedora} < 17 && 0%{?rhel} < 7
%configure --libdir=/%{_lib}
%else
%configure
%endif
make %{?_smp_mflags}
%make_build
%install
rm -rf $RPM_BUILD_ROOT
make DESTDIR=$RPM_BUILD_ROOT install
%if 0%{?fedora} < 17 && 0%{?rhel} < 7
# Move libpopt.{so,a} to %{_libdir}
rm -f $RPM_BUILD_ROOT/%{_lib}/libpopt.{la,so}
pushd $RPM_BUILD_ROOT/%{_lib}
mkdir -p $RPM_BUILD_ROOT%{_libdir}
ln -sf ../../%{_lib}/$(ls libpopt.so.?.?.?) $RPM_BUILD_ROOT%{_libdir}/libpopt.so
popd
mv -f $RPM_BUILD_ROOT/%{_lib}/libpopt.a $RPM_BUILD_ROOT%{_libdir}/libpopt.a
mv -f $RPM_BUILD_ROOT/%{_lib}/pkgconfig $RPM_BUILD_ROOT%{_libdir}/pkgconfig
%else
rm -f $RPM_BUILD_ROOT/%{_libdir}/libpopt.la
%endif
%make_install
# Multiple popt configurations are possible
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/popt.d
rm -f $RPM_BUILD_ROOT/%{_libdir}/libpopt.la
%find_lang %{name}
%check
@ -91,11 +63,7 @@ make check
%license COPYING
%doc CHANGES
%{_sysconfdir}/popt.d
%if 0%{?fedora} < 17 && 0%{?rhel} < 7
/%{_lib}/libpopt.so.*
%else
%{_libdir}/libpopt.so.*
%endif
%files devel
%doc README
@ -108,6 +76,11 @@ make check
%{_libdir}/libpopt.a
%changelog
* Thu Jan 07 2021 Panu Matilainen <pmatilai@redhat.com> - 1.18-1
- Rebase to popt 1.18 (https://github.com/rpm-software-management/popt/releases/tag/popt-1.18-release)
- Update URLs to rebooted upstream
- Clean up ancient cruft from spec, use modern build macros
* Fri Feb 09 2018 Fedora Release Engineering <releng@fedoraproject.org> - 1.16-14
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild