RPM Package Manager, CVS Repository http://rpm5.org/cvs/ ____________________________________________________________________________
Server: rpm5.org Name: Ralf S. Engelschall Root: /v/rpm/cvs Email: [EMAIL PROTECTED] Module: rpm Date: 12-Dec-2007 17:12:05 Branch: HEAD Handle: 2007121216120500 Modified files: rpm VENDOR rpm/rpmio macro.c Log: Add two new OpenPKG-specifics (but both are could be useful for non-OpenPKG environment, too): the support for %{macrosfile} and %{realpath:<path>}. This allows one to use local .rpmmacros files (staying side-by-side to package sources) containing constructs like "%_specdir %{dirname:%{realpath:%{macrosfile}}}/%{name}" in order to allow relocatable build environments (one can just move around the directory containing the .rpmmacros and the package sources). Summary: Revision Changes Path 2.7 +22 -0 rpm/VENDOR 2.156 +38 -0 rpm/rpmio/macro.c ____________________________________________________________________________ patch -p0 <<'@@ .' Index: rpm/VENDOR ============================================================================ $ cvs diff -u -r2.6 -r2.7 VENDOR --- rpm/VENDOR 6 Dec 2007 21:26:44 -0000 2.6 +++ rpm/VENDOR 12 Dec 2007 16:12:05 -0000 2.7 @@ -256,4 +256,26 @@ let RPM try(!) to remove the two directories (if they are empty) and just ignore removal failures (if they are still not empty). + ________________________________________________________________________ + + Change: expand-macrosfile-macro + Purpose: Provide special pseudo-macro %{macrosfile} + Reason: In order to support local .rpmmacros (those + which stay directly inside a development area) + which redefine %{_specdir}/%{_sourcedir}/etc to + point to local directories, it is necessary to be + able to override those macros with absolute paths + relative to the .rpmmacros file itself. For this + it is necessary that one can expand a macro which + results in the pathname of the .rpmmacros file + itself. Together with %{dirname:...} and other + macro constructs this way one can allow arbitrarily + relocatable development environments. + ________________________________________________________________________ + + Change: support-realpath-macro + Purpose: Provide macro %{realpath:<path>} + Reason: This is a macro-frontend to realpath(3) and + allows one to resolve a (relative) path into + an absolute path. @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/macro.c ============================================================================ $ cvs diff -u -r2.155 -r2.156 macro.c --- rpm/rpmio/macro.c 6 Dec 2007 14:47:51 -0000 2.155 +++ rpm/rpmio/macro.c 12 Dec 2007 16:12:05 -0000 2.156 @@ -1208,6 +1208,19 @@ if ((b = strrchr(buf, '/')) != NULL) *b = '\0'; b = buf; +#if defined(RPM_VENDOR_OPENPKG) /* support-realpath-macro */ + } else if (STREQ("realpath", f, fn)) { + char rp[PATH_MAX]; + char *cp; + size_t l; + if ((cp = realpath(buf, rp)) != NULL) { + l = strlen(cp); + if (l+1 <= bufn) { + memcpy(buf, cp, l+1); + b = buf; + } + } +#endif } else if (STREQ("suffix", f, fn)) { if ((b = strrchr(buf, '.')) != NULL) b++; @@ -1581,6 +1594,9 @@ /* XXX necessary but clunky */ if (STREQ("basename", f, fn) || STREQ("dirname", f, fn) || +#if defined(RPM_VENDOR_OPENPKG) /* support-realpath-macro */ + STREQ("realpath", f, fn) || +#endif STREQ("suffix", f, fn) || STREQ("expand", f, fn) || STREQ("verbose", f, fn) || @@ -2083,6 +2099,25 @@ } } +#if defined(RPM_VENDOR_OPENPKG) /* expand-macrosfile-macro */ +static void expand_macrosfile_macro(const char *file_name, const char *buf, size_t bufn) +{ + char *cp; + size_t l, k; + static const char *macro_name = "%{macrosfile}"; + + l = strlen(macro_name); + k = strlen(file_name); + while ((cp = strstr(buf, macro_name)) != NULL) { + if (((strlen(buf) - l) + k) < bufn) { + memmove(cp+k, cp+l, strlen(cp+l)+1); + memcpy(cp, file_name, k); + } + } + return; +} +#endif + int rpmLoadMacroFile(MacroContext mc, const char * fn) { @@ -2112,6 +2147,9 @@ if (c != (int) '%') continue; n++; /* skip % */ +#if defined(RPM_VENDOR_OPENPKG) /* expand-macro-source */ + expand_macrosfile_macro(fn, buf, bufn); +#endif rc = rpmDefineMacro(mc, n, RMIL_MACROFILES); } rc = Fclose(fd); @@ . ______________________________________________________________________ RPM Package Manager http://rpm5.org CVS Sources Repository rpm-cvs@rpm5.org