diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d18585c --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +SOURCES/popt-1.13.tar.gz diff --git a/.popt.metadata b/.popt.metadata new file mode 100644 index 0000000..9fd0252 --- /dev/null +++ b/.popt.metadata @@ -0,0 +1 @@ +658bf2d2ec25e97816f5920bb24048cf252d053a SOURCES/popt-1.13.tar.gz diff --git a/SOURCES/popt-1.13-alias-equal-arg.patch b/SOURCES/popt-1.13-alias-equal-arg.patch new file mode 100644 index 0000000..64a5460 --- /dev/null +++ b/SOURCES/popt-1.13-alias-equal-arg.patch @@ -0,0 +1,121 @@ +diff -up popt-1.13/popt.c.alias-equal-arg popt-1.13/popt.c +--- popt-1.13/popt.c.alias-equal-arg 2007-12-11 20:04:06.000000000 +0200 ++++ popt-1.13/popt.c 2011-06-14 11:57:21.000000000 +0300 +@@ -308,8 +308,9 @@ static int handleExec(/*@special@*/ popt + + /* Only one of longName, shortName may be set at a time */ + static int handleAlias(/*@special@*/ poptContext con, +- /*@null@*/ const char * longName, char shortName, +- /*@exposed@*/ /*@null@*/ const char * nextCharArg) ++ /*@null@*/ const char * longName, size_t longNameLen, ++ char shortName, ++ /*@exposed@*/ /*@null@*/ const char * nextArg) + /*@uses con->aliases, con->numAliases, con->optionStack, con->os, + con->os->currAlias, con->os->currAlias->option.longName @*/ + /*@modifies con @*/ +@@ -319,9 +320,11 @@ static int handleAlias(/*@special@*/ pop + int i; + + if (item) { +- if (longName && (item->option.longName && +- !strcmp(longName, item->option.longName))) ++ if (longName && item->option.longName ++ && longNameLen == strlen(item->option.longName) ++ && !strncmp(longName, item->option.longName, longNameLen)) + return 0; ++ else + if (shortName && shortName == item->option.shortName) + return 0; + } +@@ -331,10 +334,14 @@ static int handleAlias(/*@special@*/ pop + + for (i = con->numAliases - 1; i >= 0; i--) { + item = con->aliases + i; +- if (longName && !(item->option.longName && +- !strcmp(longName, item->option.longName))) +- continue; +- else if (shortName != item->option.shortName) ++ if (longName) { ++ if (item->option.longName == NULL) ++ continue; ++ if (longNameLen != strlen(item->option.longName)) ++ continue; ++ if (strncmp(longName, item->option.longName, longNameLen)) ++ continue; ++ } else if (shortName != item->option.shortName) + continue; + break; + } +@@ -343,8 +350,8 @@ static int handleAlias(/*@special@*/ pop + if ((con->os - con->optionStack + 1) == POPT_OPTION_DEPTH) + return POPT_ERROR_OPTSTOODEEP; + +- if (nextCharArg && *nextCharArg) +- con->os->nextCharArg = nextCharArg; ++ if (longName == NULL && nextArg && *nextArg) ++ con->os->nextCharArg = nextArg; + + con->os++; + con->os->next = 0; +@@ -352,8 +359,20 @@ static int handleAlias(/*@special@*/ pop + con->os->nextArg = NULL; + con->os->nextCharArg = NULL; + con->os->currAlias = con->aliases + i; +- rc = poptDupArgv(con->os->currAlias->argc, con->os->currAlias->argv, +- &con->os->argc, &con->os->argv); ++ { const char ** av; ++ int ac = con->os->currAlias->argc; ++ /* Append --foo=bar arg to alias argv array (if present). */ ++ if (longName && nextArg && *nextArg) { ++ int i; ++ av = alloca((ac + 1 + 1) * sizeof(*av)); ++ for (i = 0; i < ac; i++) ++ av[i] = con->os->currAlias->argv[i]; ++ av[ac++] = nextArg; ++ av[ac] = NULL; ++ } else ++ av = con->os->currAlias->argv; ++ rc = poptDupArgv(ac, av, &con->os->argc, &con->os->argv); ++ } + con->os->argb = NULL; + + return (rc ? rc : 1); +@@ -795,13 +814,6 @@ int poptGetNextOpt(poptContext con) + else + singleDash = 1; + +- /* XXX aliases with arg substitution need "--alias=arg" */ +- if (handleAlias(con, optString, '\0', NULL)) +- continue; +- +- if (handleExec(con, optString, '\0')) +- continue; +- + /* Check for "--long=arg" option. */ + for (oe = optString; *oe && *oe != '='; oe++) + {}; +@@ -809,6 +821,15 @@ int poptGetNextOpt(poptContext con) + if (*oe == '=') + longArg = oe + 1; + ++ /* XXX aliases with arg substitution need "--alias=arg" */ ++ if (handleAlias(con, optString, optStringLen, '\0', longArg)) { ++ longArg = NULL; ++ continue; ++ } ++ ++ if (handleExec(con, optString, '\0')) ++ continue; ++ + opt = findOption(con->options, optString, optStringLen, '\0', &cb, &cbData, + singleDash); + if (!opt && !singleDash) +@@ -834,7 +855,7 @@ int poptGetNextOpt(poptContext con) + + con->os->nextCharArg = NULL; + +- if (handleAlias(con, NULL, *origOptString, origOptString + 1)) ++ if (handleAlias(con, NULL, 0, *origOptString, origOptString + 1)) + continue; + + if (handleExec(con, NULL, *origOptString)) { diff --git a/SOURCES/popt-1.13-execfail.patch b/SOURCES/popt-1.13-execfail.patch new file mode 100644 index 0000000..83b58dc --- /dev/null +++ b/SOURCES/popt-1.13-execfail.patch @@ -0,0 +1,70 @@ +Kludge 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. + +diff -up popt-1.13/popt.c.execfail popt-1.13/popt.c +--- popt-1.13/popt.c.execfail 2012-08-02 16:08:34.762315304 +0300 ++++ popt-1.13/popt.c 2012-08-02 16:11:41.352683721 +0300 +@@ -186,6 +186,7 @@ poptContext poptGetContext(const char * + con->flags = flags; + con->execs = NULL; + con->numExecs = 0; ++ con->execFail = NULL; + con->finalArgvAlloced = argc * 2; + con->finalArgv = calloc( con->finalArgvAlloced, sizeof(*con->finalArgv) ); + con->execAbsolute = 1; +@@ -234,6 +235,7 @@ void poptResetContext(poptContext con) + 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++) { +@@ -468,6 +470,7 @@ if (_popt_debug) + /*@-nullstate@*/ + rc = execvp(argv[0], (char *const *)argv); + /*@=nullstate@*/ ++ con->execFail = xstrdup(argv[0]); + + exit: + if (argv) { +@@ -1194,11 +1197,19 @@ int poptAddItem(poptContext con, poptIte + 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) +diff -up popt-1.13/poptint.h.execfail popt-1.13/poptint.h +--- popt-1.13/poptint.h.execfail 2012-08-02 16:08:34.000000000 +0300 ++++ popt-1.13/poptint.h 2012-08-02 16:12:35.796500122 +0300 +@@ -78,6 +78,7 @@ struct poptContext_s { + /*@owned@*/ /*@null@*/ + poptItem execs; + int numExecs; ++ char * execFail; + /*@only@*/ /*@null@*/ + const char ** finalArgv; + int finalArgvCount; diff --git a/SOURCES/popt-1.13-popt_fprintf.patch b/SOURCES/popt-1.13-popt_fprintf.patch new file mode 100644 index 0000000..a4f972b --- /dev/null +++ b/SOURCES/popt-1.13-popt_fprintf.patch @@ -0,0 +1,119 @@ +Patch by Jeff Johnson for popt >= 1.13, which reverts all POPT_fprintf() +usage cases to avoid broken umlauts in --help output at some non-UTF8 locales. It should +not break anything, just restore the behaviour of popt 1.12 again to not introduce a new +regression. Clueless modified by Robert Scheck to hide the last found +two locale regression as well. + +--- popt-1.13/popthelp.c 2007-11-04 16:46:25.000000000 +0100 ++++ popt-1.13/popthelp.c.popt_fprintf 2007-12-30 22:10:24.000000000 +0100 +@@ -281,7 +281,6 @@ + char * left; + size_t nb = maxLeftCol + 1; + int displaypad = 0; +- int xx; + + /* Make sure there's more than enough room in target buffer. */ + if (opt->longName) nb += strlen(opt->longName); +@@ -406,9 +405,9 @@ + } + + if (help) +- xx = POPT_fprintf(fp," %-*s ", (int)(maxLeftCol+displaypad), left); ++ fprintf(fp," %-*s ", (int)(maxLeftCol+displaypad), left); + else { +- xx = POPT_fprintf(fp," %s\n", left); ++ fprintf(fp," %s\n", left); + goto out; + } + +@@ -428,18 +427,19 @@ + if (ch == help) break; /* give up */ + while (ch > (help + 1) && _isspaceptr(ch)) + ch = POPT_prev_char (ch); +- ch++; ++ ch = POPT_next_char(ch); + + sprintf(format, "%%.%ds\n%%%ds", (int) (ch - help), (int) indentLength); + /*@-formatconst@*/ +- xx = POPT_fprintf(fp, format, help, " "); ++ fprintf(fp, format, help, " "); + /*@=formatconst@*/ + help = ch; +- while (_isspaceptr(help) && *help) help++; ++ while (_isspaceptr(help) && *help) ++ help = POPT_next_char(help); + helpLength = strlen(help); + } + +- if (helpLength) xx = POPT_fprintf(fp, "%s\n", help); ++ if (helpLength) fprintf(fp, "%s\n", help); + help = NULL; + + out: +@@ -553,7 +553,6 @@ + { + const struct poptOption * opt; + const char *sub_transdom; +- int xx; + + if (table == poptAliasOptions) { + itemHelp(fp, con->aliases, con->numAliases, columns, NULL); +@@ -577,7 +576,7 @@ + sub_transdom = translation_domain; + + if (opt->descrip) +- xx = POPT_fprintf(fp, "\n%s\n", D_(sub_transdom, opt->descrip)); ++ fprintf(fp, "\n%s\n", D_(sub_transdom, opt->descrip)); + + singleTableHelp(con, fp, opt->arg, columns, sub_transdom); + } +@@ -767,7 +766,7 @@ + translation_domain = (const char *)opt->arg; + } else if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_INCLUDE_TABLE) { + if (done) { +- int i; ++ int i = done->nopts; + if (done->opts != NULL) + for (i = 0; i < done->nopts; i++) { + const void * that = done->opts[i]; +--- popt-1.13/poptint.c 2007-11-04 16:56:24.000000000 +0100 ++++ popt-1.13/poptint.c.popt_fprintf 2007-12-30 22:10:24.000000000 +0100 +@@ -124,6 +124,18 @@ + } + } + ++char * ++POPT_next_char (const char *str) ++{ ++ char *p = (char *)str; ++ ++ while (1) { ++ p++; ++ if ((*p & 0xc0) != (char)0x80) ++ return (char *)p; ++ } ++} ++ + int + POPT_fprintf (FILE* stream, const char *format, ...) + { +--- popt-1.13/poptint.h 2007-12-11 19:02:29.000000000 +0100 ++++ popt-1.13/poptint.h.popt_fprintf 2007-12-30 22:10:24.000000000 +0100 +@@ -144,11 +144,14 @@ + #endif + #endif + ++char *POPT_prev_char (/*@returned@*/ const char *str) ++ /*@*/; ++ ++char *POPT_next_char (/*@returned@*/ const char *str) ++ /*@*/; ++ + int POPT_fprintf (FILE* stream, const char *format, ...) + /*@globals fileSystem @*/ + /*@modifies stream, fileSystem @*/; + +-char *POPT_prev_char (/*@returned@*/ const char *str) +- /*@*/; +- + #endif diff --git a/SPECS/popt.spec b/SPECS/popt.spec new file mode 100644 index 0000000..ee0619b --- /dev/null +++ b/SPECS/popt.spec @@ -0,0 +1,177 @@ +Summary: C library for parsing command line parameters +Name: popt +Version: 1.13 +Release: 16%{?dist} +License: MIT +Group: System Environment/Libraries +URL: http://www.rpm5.org/ +Source: http://www.rpm5.org/files/%{name}/%{name}-%{version}.tar.gz +Patch1: popt-1.13-popt_fprintf.patch +Patch2: popt-1.13-alias-equal-arg.patch +Patch3: popt-1.13-execfail.patch +BuildRequires: gettext +BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) + +%description +Popt is a C library for parsing command line parameters. Popt was +heavily influenced by the getopt() and getopt_long() functions, but +it improves on them by allowing more powerful argument expansion. +Popt can parse arbitrary argv[] style arrays and automatically set +variables based on command line arguments. Popt allows command line +arguments to be aliased via configuration files and includes utility +functions for parsing arbitrary strings into argv[] arrays using +shell-like rules. + +%package devel +Summary: Development files for the popt library +Group: Development/Libraries +Requires: %{name} = %{version}-%{release} + +%description devel +The popt-devel package includes header files and libraries necessary +for developing programs which use the popt C library. It contains the +API documentation of the popt library, too. + +%package static +Summary: Static library for parsing command line parameters +Group: Development/Libraries +Requires: %{name}-devel = %{version}-%{release} + +%description static +The popt-static package includes static libraries of the popt library. +Install it if you need to link statically with libpopt. + +%prep +%setup -q +%patch1 -p1 -b .popt_fprintf +%patch2 -p1 -b .alias-equal-arg +%patch3 -p1 -b .execfail + +%build +%configure --libdir=/%{_lib} +make %{?_smp_mflags} + +%install +rm -rf $RPM_BUILD_ROOT +make DESTDIR=$RPM_BUILD_ROOT install + +# 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 + +# Multiple popt configurations are possible +mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/popt.d + +%find_lang %{name} + +%clean +rm -rf $RPM_BUILD_ROOT + +%check +make check + +%post -p /sbin/ldconfig + +%postun -p /sbin/ldconfig + +%files -f %{name}.lang +%defattr(-,root,root) +%doc CHANGES COPYING +%{_sysconfdir}/popt.d +/%{_lib}/libpopt.so.* + +%files devel +%defattr(-,root,root) +%doc README +%{_libdir}/libpopt.so +%{_includedir}/popt.h +%{_mandir}/man3/popt.3* + +%files static +%defattr(-,root,root) +%{_libdir}/libpopt.a + +%changelog +* Fri Jan 24 2014 Daniel Mach - 1.13-16 +- Mass rebuild 2014-01-24 + +* Fri Dec 27 2013 Daniel Mach - 1.13-15 +- Mass rebuild 2013-12-27 + +* Thu Feb 14 2013 Fedora Release Engineering - 1.13-14 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild + +* Fri Dec 14 2012 Panu Matilainen - 1.13-13 +- Remove useless doxygen docs to eliminate multilib conflicts (#533829) + +* Thu Aug 02 2012 Panu Matilainen - 1.13-12 +- Hack poptBadOption() to return something semi-meaningful on exec alias + failures (#697435, #710267) +- Run internal test-suite on build, minimal as it might be + +* Sat Jul 21 2012 Fedora Release Engineering - 1.13-11 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild + +* Sat Jan 14 2012 Fedora Release Engineering - 1.13-10 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild + +* Tue Jun 14 2011 Panu Matilainen +- Backport upstream patch to fix --opt= syntax for aliases (#293531) + +* Wed Feb 09 2011 Fedora Release Engineering - 1.13-8 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild + +* Tue Feb 16 2010 Robert Scheck 1.13-7 +- Solved multilib problems at doxygen generated files (#517509) + +* Sun Jul 26 2009 Fedora Release Engineering - 1.13-6 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild + +* Mon Feb 23 2009 Robert Scheck 1.13-5 +- Rebuilt against gcc 4.4 and rpm 4.6 + +* Sun May 25 2008 Robert Scheck 1.13-4 +- Solved multilib problems at doxygen generated files (#342921) + +* Wed Feb 20 2008 Robert Scheck 1.13-3 +- Revert the broken bind_textdomain_codeset() patch (#433324) + +* Thu Feb 14 2008 Robert Scheck 1.13-2 +- Added patch to work around missing bind_textdomain_codeset() + +* Sun Dec 30 2007 Robert Scheck 1.13-1 +- Upgrade to 1.13 (#290531, #332201, #425803) +- Solved multilib problems at doxygen generated files (#342921) + +* Thu Aug 23 2007 Robert Scheck 1.12-3 +- Added buildrequirement to graphviz (#249352) +- Backported bugfixes from CVS (#102254, #135428 and #178413) + +* Sun Aug 12 2007 Robert Scheck 1.12-2 +- Move libpopt to /lib[64] (#249814) +- Generate API documentation, added buildrequirement to doxygen + +* Mon Jul 23 2007 Robert Scheck 1.12-1 +- Changes to match with Fedora Packaging Guidelines (#249352) + +* Tue Jul 10 2007 Jeff Johnson +- release popt-1.12 through rpm5.org. + +* Sat Jun 9 2007 Jeff Johnson +- release popt-1.11 through rpm5.org. + +* Thu Dec 10 1998 Michael Johnson +- released 1.2.2; see CHANGES + +* Tue Nov 17 1998 Michael K. Johnson +- added man page to default install + +* Thu Oct 22 1998 Erik Troan +- see CHANGES file for 1.2 + +* Thu Apr 09 1998 Erik Troan +- added ./configure step to spec file