RPM Package Manager, CVS Repository http://rpm5.org/cvs/ ____________________________________________________________________________
Server: rpm5.org Name: Jeff Johnson Root: /v/rpm/cvs Email: j...@rpm5.org Module: rpm Date: 21-Aug-2009 05:18:38 Branch: HEAD Handle: 2009082103183602 Modified files: rpm Makefile.am rpm/macros macros.in perl.in php.in python.in rpm/perl RPM.xs rpm/rpmio librpmio.vers macro.c rpmlua.c rpmmacro.h Removed files: rpm macros.in Log: - macros: refactor perl/php/python peculier config into separate file. - macros: expand %{load:...} immediiately/recursively when loading. Summary: Revision Changes Path 2.242 +7 -2 rpm/Makefile.am 1.291 +0 -1765 rpm/macros.in 1.2 +7 -50 rpm/macros/macros.in 1.2 +31 -7 rpm/macros/perl.in 1.2 +3 -5 rpm/macros/php.in 1.2 +24 -9 rpm/macros/python.in 1.32 +1 -1 rpm/perl/RPM.xs 2.136 +1 -0 rpm/rpmio/librpmio.vers 2.237 +48 -12 rpm/rpmio/macro.c 2.75 +2 -1 rpm/rpmio/rpmlua.c 2.54 +2 -1 rpm/rpmio/rpmmacro.h ____________________________________________________________________________ patch -p0 <<'@@ .' Index: rpm/Makefile.am ============================================================================ $ cvs diff -u -r2.241 -r2.242 Makefile.am --- rpm/Makefile.am 21 Aug 2009 00:11:23 -0000 2.241 +++ rpm/Makefile.am 21 Aug 2009 03:18:36 -0000 2.242 @@ -116,8 +116,13 @@ endif pkglibdir = @USRLIBRPM@ -pkglib_DATA = rpmpopt macros/macros cpuinfo.yaml -pkglib_SCRIPTS = install-sh mkinstalldirs +pkglib_DATA = rpmpopt macros/macros cpuinfo.yaml + +pkgbindir = $(pkglibdir)/bin +pkgbin_SCRIPTS = install-sh mkinstalldirs + +pkgcfgdir = $(pkglibdir)/macros.d +pkgcfg_DATA = macros/perl macros/php macros/python noinst_HEADERS = build.h debug.h system.h @@ . rm -f rpm/macros.in <<'@@ .' Index: rpm/macros.in ============================================================================ [NO CHANGE SUMMARY BECAUSE FILE AS A WHOLE IS JUST REMOVED] @@ . patch -p0 <<'@@ .' Index: rpm/macros/macros.in ============================================================================ $ cvs diff -u -r1.1 -r1.2 macros.in --- rpm/macros/macros.in 21 Aug 2009 00:11:24 -0000 1.1 +++ rpm/macros/macros.in 21 Aug 2009 03:18:37 -0000 1.2 @@ -1,7 +1,7 @@ #/*! \page config_macros Default configuration: @USRLIBRPM@/macros # \verbatim # -# $Id: macros.in,v 1.1 2009/08/21 00:11:24 jbj Exp $ +# $Id: macros.in,v 1.2 2009/08/21 03:18:37 jbj Exp $ # # This is a global RPM configuration file. All changes made here will # be lost when the rpm package is upgraded. Any per-system configuration @@ -77,10 +77,7 @@ %__mv @__MV@ %__patch @__PATCH@ %__pax @__PAX@ -%__perl @__PERL@ %__pgp @__PGP@ -%__php @__PHP@ -%__python @__PYTHON@ %__rm @__RM@ %__rsh @__RSH@ %__sed @__SED@ @@ -1616,6 +1613,8 @@ # %find_lang %{_rpmhome}/find-lang.sh %{buildroot} +%requires_eq() %(echo '%*' | LC_ALL="C" xargs -r rpm -q --qf 'Requires: %%{name} = %%{epoch}:%%{version}\\n' | sed -e 's/ (none):/ /' -e 's/ 0:/ /' | grep -v "is not") + #------------------------------------------------------------------------ # lua macros # @@ -1640,38 +1639,7 @@ %__perl_provides %{_rpmhome}/perl.prov %__perl_requires %{_rpmhome}/perl.req -# Useful macros for building *.rpm perl packages. -# (from Artur Frysiak <wi...@t17.ds.pwr.wroc.pl>) -# -# For example, these can be used as (from ImageMagick.spec from PLD site) -# [...] -# BuildPrereq: perl -# [...] -# %package perl -# Summary: libraries and modules for access to ImageMagick from perl -# Group: Development/Languages/Perl -# Requires: %{name} = %{version} -# %requires_eq perl -# [...] -# %install -# rm -fr $RPM_BUILD_ROOT -# install -d $RPM_BUILD_ROOT/%{perl_sitearch} -# [...] -# %files perl -# %defattr(644,root,root,755) -# %{perl_sitearch}/Image -# %dir %{perl_sitearch}/auto/Image -# - -%requires_eq() %(echo '%*' | LC_ALL="C" xargs -r rpm -q --qf 'Requires: %%{name} = %%{epoch}:%%{version}\\n' | sed -e 's/ (none):/ /' -e 's/ 0:/ /' | grep -v "is not") - -%perl_sitearch %(eval "`%{__perl} -V:installsitearch`"; echo $installsitearch) -%perl_sitelib %(eval "`%{__perl} -V:installsitelib`"; echo $installsitelib) -%perl_vendorarch %(eval "`%{__perl} -V:installvendorarch`"; echo $installvendorarch) -%perl_vendorlib %(eval "`%{__perl} -V:installvendorlib`"; echo $installvendorlib) -%perl_archlib %(eval "`%{__perl} -V:installarchlib`"; echo $installarchlib) -%perl_privlib %(eval "`%{__perl} -V:installprivlib`"; echo $installprivlib) -%perl_version %(eval "`%{__perl} -V:version`"; echo $version) +%{load:%{_usrlibrpm}/macros.d/perl} #------------------------------------------------------------------------ # python(...) configuration. @@ -1683,20 +1651,7 @@ %__python_provides %{_rpmhome}/pythondeps.sh --provides %__python_requires %{_rpmhome}/pythondeps.sh --requires -# Useful macros for building *.rpm python packages (for python > 1.6). -# -%python_sitearch %(%{__python} -c "import os; from distutils.sysconfig import get_python_lib; lib=get_python_lib(1); print os.path.islink(lib) and os.path.abspath(os.path.join(os.path.dirname(lib),os.readlink(lib))) or lib") -%python_sitelib %(%{__python} -c "import os; from distutils.sysconfig import get_python_lib; lib=get_python_lib(); print os.path.islink(lib) and os.path.abspath(os.path.join(os.path.dirname(lib),os.readlink(lib))) or lib") -%python_version %(%{__python} -c "import sys; print(sys.version[0:3])") - -%py_compile(O) \ -find %1 -name '*.pyc' -name '*.pyo' -exec rm -f {} \\; \ -%{__python} %{?O:-O} -c "import sys, os, compileall; br='%{buildroot}'; compileall.compile_dir(sys.argv[1], ddir=br and (sys.argv[1][len(os.path.abspath(br)):]+'/') or None)" %1 \ - -%py_requires(d) \ -%define maxver %(%{__python} -c "import sys; a,b=sys.version_info[:2]; print '%%d.%%d'%%(a,b+1)" 2>/dev/null || echo PYTHON-NOT-FOUND) \ -BuildRequires: python %{-d:python-devel} \ -PreReq: python >= %{python_version}, python < %{maxver} +%{load:%{_usrlibrpm}/macros.d/python} #------------------------------------------------------------------------ # php(...) configuration. @@ -1710,6 +1665,8 @@ #%__php_provides %{_rpmhome}/php.prov #%__php_requires %{_rpmhome}/php.req +%{load:%{_usrlibrpm}/macros.d/php} + #------------------------------------------------------------------------ # java(...) configuration. # @@ . patch -p0 <<'@@ .' Index: rpm/macros/perl.in ============================================================================ $ cvs diff -u -r1.1 -r1.2 perl.in --- rpm/macros/perl.in 21 Aug 2009 00:11:24 -0000 1.1 +++ rpm/macros/perl.in 21 Aug 2009 03:18:37 -0000 1.2 @@ -1,12 +1,36 @@ # Perl specific macro definitions. # To make use of these macros insert the following line into your spec file: -# %include %{_usrlibrpm}/macros.perl +# %{load:%{_usrlibrpm}/macros.d/perl} +# -%define __find_requires %{_usrlibrpm}/find-perl-requires -%define __find_provides %{_usrlibrpm}/find-perl-provides +%__perl @__PERL@ -%define perl_sitelib %(eval "`perl -V:installsitelib`"; echo $installsitelib) -%define perl_sitearch %(eval "`perl -V:installsitearch`"; echo $installsitearch) -%define perl_archlib %(eval "`perl -V:installarchlib`"; echo $installarchlib) -%define perl_privlib %(eval "`perl -V:installprivlib`"; echo $installprivlib) +# Useful macros for building *.rpm perl packages. +# (from Artur Frysiak <wi...@t17.ds.pwr.wroc.pl>) +# +# For example, these can be used as (from ImageMagick.spec from PLD site) +# [...] +# BuildPrereq: perl +# [...] +# %package perl +# Summary: libraries and modules for access to ImageMagick from perl +# Group: Development/Languages/Perl +# Requires: %{name} = %{version} +# [...] +# %install +# rm -fr $RPM_BUILD_ROOT +# install -d $RPM_BUILD_ROOT/%{perl_sitearch} +# [...] +# %files perl +# %defattr(644,root,root,755) +# %{perl_sitearch}/Image +# %dir %{perl_sitearch}/auto/Image +# +%perl_sitearch %(eval "`%{__perl} -V:installsitearch`"; echo $installsitearch) +%perl_sitelib %(eval "`%{__perl} -V:installsitelib`"; echo $installsitelib) +%perl_vendorarch %(eval "`%{__perl} -V:installvendorarch`"; echo $installvendorarch) +%perl_vendorlib %(eval "`%{__perl} -V:installvendorlib`"; echo $installvendorlib) +%perl_archlib %(eval "`%{__perl} -V:installarchlib`"; echo $installarchlib) +%perl_privlib %(eval "`%{__perl} -V:installprivlib`"; echo $installprivlib) +%perl_version %(eval "`%{__perl} -V:version`"; echo $version) @@ . patch -p0 <<'@@ .' Index: rpm/macros/php.in ============================================================================ $ cvs diff -u -r1.1 -r1.2 php.in --- rpm/macros/php.in 21 Aug 2009 00:11:24 -0000 1.1 +++ rpm/macros/php.in 21 Aug 2009 03:18:37 -0000 1.2 @@ -1,9 +1,7 @@ # Perl specific macro definitions. # To make use of these macros insert the following line into your spec file: -# %include %{_usrlibrpm}/macros.php +# %{load:%{_usrlibrpm}/macros.d/php} -%define __find_requires %{_usrlibrpm}/find-php-requires -%define __find_provides %{_usrlibrpm}/find-php-provides - -%define php_pear_dir %{_datadir}/pear +%__php @__PHP@ +%php_pear_dir %{_datadir}/pear @@ . patch -p0 <<'@@ .' Index: rpm/macros/python.in ============================================================================ $ cvs diff -u -r1.1 -r1.2 python.in --- rpm/macros/python.in 21 Aug 2009 00:11:24 -0000 1.1 +++ rpm/macros/python.in 21 Aug 2009 03:18:37 -0000 1.2 @@ -1,18 +1,33 @@ # Python specific macro definitions. # To make use of these macros insert the following line into your spec file: -# %include %{_usrlibrpm}/macros.python +# %{load:%{_usrlibrpm}/macros.d/python} + +%__python @__PYTHON@ # python main version -%define py_ver %(echo `python -c "import sys; print sys.version[:3]"`) +%py_ver %(echo `python -c "import sys; print sys.version[:3]"`) # directories -%define py_prefix %(echo `python -c "import sys; print sys.prefix"`) -%define py_libdir %{py_prefix}/lib/python%{py_ver} -%define py_incdir /usr/include/python%{py_ver} -%define py_sitedir %{py_libdir}/site-packages -%define py_dyndir %{py_libdir}/lib-dynload +%py_prefix %(echo `python -c "import sys; print sys.prefix"`) +%py_libdir %{py_prefix}/lib/python%{py_ver} +%py_incdir @oldincludedir@/python%{py_ver} +%py_sitedir %{py_libdir}/site-packages +%py_dyndir %{py_libdir}/lib-dynload # pure python modules compilation -%define py_comp python -c "import compileall; import sys; compileall.compile_dir(sys.argv[1], ddir=sys.argv[1][len('$RPM_BUILD_ROOT'):])" +%py_comp %{__python} -c "import compileall; import sys; compileall.compile_dir(sys.argv[1], ddir=sys.argv[1][len('$RPM_BUILD_ROOT'):])" + +%py_ocomp %{__python} -O -c "import compileall; import sys; compileall.compile_dir(sys.argv[1], ddir=sys.argv[1][len('$RPM_BUILD_ROOT'):])" + +%python_sitearch %(%{__python} -c "import os; from distutils.sysconfig import get_python_lib; lib=get_python_lib(1); print os.path.islink(lib) and os.path.abspath(os.path.join(os.path.dirname(lib),os.readlink(lib))) or lib") +%python_sitelib %(%{__python} -c "import os; from distutils.sysconfig import get_python_lib; lib=get_python_lib(); print os.path.islink(lib) and os.path.abspath(os.path.join(os.path.dirname(lib),os.readlink(lib))) or lib") +%python_version %(%{__python} -c "import sys; print(sys.version[0:3])") + +%py_compile(O) \ +find %1 -name '*.pyc' -name '*.pyo' -exec rm -f {} \\; \ +%{__python} %{?O:-O} -c "import sys, os, compileall; br='%{buildroot}'; compileall.compile_dir(sys.argv[1], ddir=br and (sys.argv[1][len(os.path.abspath(br)):]+'/') or None)" %1 \ -%define py_ocomp python -O -c "import compileall; import sys; compileall.compile_dir(sys.argv[1], ddir=sys.argv[1][len('$RPM_BUILD_ROOT'):])" +%py_requires(d) \ +%define maxver %(%{__python} -c "import sys; a,b=sys.version_info[:2]; print '%%d.%%d'%%(a,b+1)" 2>/dev/null || echo PYTHON-NOT-FOUND) \ +BuildRequires: python %{-d:python-devel} \ +PreReq: python >= %{python_version}, python < %{maxver} @@ . patch -p0 <<'@@ .' Index: rpm/perl/RPM.xs ============================================================================ $ cvs diff -u -r1.31 -r1.32 RPM.xs --- rpm/perl/RPM.xs 26 Mar 2009 18:07:32 -0000 1.31 +++ rpm/perl/RPM.xs 21 Aug 2009 03:18:37 -0000 1.32 @@ -110,7 +110,7 @@ load_macro_file(filename) char * filename CODE: - RETVAL= ! rpmLoadMacroFile(NULL, filename); /* return False on error */ + RETVAL= ! rpmLoadMacroFile(NULL, filename, 0); /* return False on error */ OUTPUT: RETVAL @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/librpmio.vers ============================================================================ $ cvs diff -u -r2.135 -r2.136 librpmio.vers --- rpm/rpmio/librpmio.vers 14 Aug 2009 22:24:17 -0000 2.135 +++ rpm/rpmio/librpmio.vers 21 Aug 2009 03:18:38 -0000 2.136 @@ -169,6 +169,7 @@ _Lstat; lzdio; max_macro_depth; + _max_load_depth; _mire_debug; _mirePool; mireAppend; @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/macro.c ============================================================================ $ cvs diff -u -r2.236 -r2.237 macro.c --- rpm/rpmio/macro.c 20 Aug 2009 15:53:09 -0000 2.236 +++ rpm/rpmio/macro.c 21 Aug 2009 03:18:38 -0000 2.237 @@ -150,6 +150,10 @@ #define _PRINT_EXPAND_TRACE 0 /*...@unchecked@*/ int print_expand_trace = _PRINT_EXPAND_TRACE; + +#define _MAX_LOAD_DEPTH 2 +/*...@unchecked@*/ +int _max_load_depth = _MAX_LOAD_DEPTH; /*...@=exportlocal =exportheader...@*/ #define MACRO_CHUNK_SIZE 16 @@ -1792,7 +1796,7 @@ char * mfn = strncpy(alloca(gn + 1), g, gn); int xx; mfn[gn] = '\0'; - xx = rpmLoadMacroFile(NULL, mfn); + xx = rpmLoadMacroFile(NULL, mfn, _max_load_depth); /* Print failure iff %{load:...} or %{!?load:...} */ if (xx != 0 && chkexist == negate) rpmlog(RPMLOG_ERR, _("%s: load macros failed\n"), mfn); @@ -2580,14 +2584,17 @@ #endif int -rpmLoadMacroFile(MacroContext mc, const char * fn) +rpmLoadMacroFile(MacroContext mc, const char * fn, int nesting) { - /* XXX TODO: teach rdcl() to read through a URI, eliminate ".fpio". */ - FD_t fd = Fopen(fn, "r.fpio"); size_t bufn = _macro_BUFSIZ; char *buf = alloca(bufn); + int lineno = 0; int rc = -1; + FD_t fd; + int xx; + /* XXX TODO: teach rdcl() to read through a URI, eliminate ".fpio". */ + fd = Fopen(fn, "r.fpio"); if (fd == NULL || Ferror(fd)) { if (fd) (void) Fclose(fd); return rc; @@ -2600,21 +2607,50 @@ buf[0] = '\0'; while(rdcl(buf, bufn, fd) != NULL) { - char *n; + char * s; int c; - n = buf; - SKIPBLANK(n, c); + lineno++; + s = buf; + SKIPBLANK(s, c); if (c != (int) '%') + continue; + + /* Parse %{load:...} immediately recursively. */ + if (s[1] == '{' && !strncmp(s+2, "load:", sizeof("load:")-1)) { + char * se = matchchar(s, '{', '}'); + if (se == NULL) { + rpmlog(RPMLOG_WARNING, + _("%s:%u Missing '}' in \"%s\", skipping.\n"), + fn, lineno, buf); continue; - n++; /* skip % */ + } + s += sizeof("%{load:") - 1; + SKIPBLANK(s, c); + *se = '\0'; + if (nesting <= 0) { + rpmlog(RPMLOG_WARNING, + _("%s:%u load depth exceeded, \"%s\" ignored.\n"), + fn, lineno, buf); + continue; + } + se = rpmMCExpand(mc, s, NULL); + rc = rpmLoadMacroFile(mc, se, nesting - 1); + se = _free(se); + if (rc != 0) + goto exit; + } else { #if defined(RPM_VENDOR_OPENPKG) /* expand-macro-source */ - expand_macrosfile_macro(fn, buf, bufn); + expand_macrosfile_macro(fn, buf, bufn); #endif - rc = rpmDefineMacro(mc, n, RMIL_MACROFILES); + if (*s == '%') s++; + rc = rpmDefineMacro(mc, s, RMIL_MACROFILES); + } } - rc = Fclose(fd); + rc = 0; +exit: + xx = Fclose(fd); return rc; } @@ -2688,7 +2724,7 @@ || _suffix(fn, ".rpmorig") || _suffix(fn, ".rpmsave")) ) - (void) rpmLoadMacroFile(mc, fn); + (void) rpmLoadMacroFile(mc, fn, _max_load_depth); #undef _suffix av[i] = _free(av[i]); @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/rpmlua.c ============================================================================ $ cvs diff -u -r2.74 -r2.75 rpmlua.c --- rpm/rpmio/rpmlua.c 19 May 2009 12:44:15 -0000 2.74 +++ rpm/rpmio/rpmlua.c 21 Aug 2009 03:18:38 -0000 2.75 @@ -1053,6 +1053,7 @@ return 0; } +extern int _max_load_depth; /* Maximum load nesting depth. */ static int rpm_load(lua_State *L) /*...@globals rpmGlobalMacroContext, fileSystem, internalState @*/ /*...@modifies L, rpmGlobalMacroContext, fileSystem, internalState @*/ @@ -1062,7 +1063,7 @@ } else { const char *filename = lua_tostring(L, 1); /*...@-globs@*/ - (void)rpmLoadMacroFile(NULL, filename); + (void)rpmLoadMacroFile(NULL, filename, _max_load_depth); /*...@=globs@*/ } return 0; @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/rpmmacro.h ============================================================================ $ cvs diff -u -r2.53 -r2.54 rpmmacro.h --- rpm/rpmio/rpmmacro.h 28 Apr 2009 23:15:36 -0000 2.53 +++ rpm/rpmio/rpmmacro.h 21 Aug 2009 03:18:38 -0000 2.54 @@ -176,8 +176,9 @@ * Load macro context from a macro file. * @param mc (unused) * @param fn macro file name + * @param nesting max load recursion depth, 0 disables. */ -int rpmLoadMacroFile(/*...@null@*/ MacroContext mc, const char * fn) +int rpmLoadMacroFile(/*...@null@*/ MacroContext mc, const char * fn, int nesting) /*...@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/ /*...@modifies mc, rpmGlobalMacroContext, fileSystem, internalState @*/; @@ . ______________________________________________________________________ RPM Package Manager http://rpm5.org CVS Sources Repository rpm-cvs@rpm5.org