From: Panu Matilainen Date: Fri, 16 Jan 2009 07:09:40 +0000 (+0200) Subject: Add getenv macro, use instead of $(echo $HOME) for defauls X-Git-Tag: rpm-4.7.0-beta1~68 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=947ad7acb3e237446f0e20c0009e9ae07e0f26dc;p=platform%2Fupstream%2Frpm.git Add getenv macro, use instead of $(echo $HOME) for defauls - inspired by http://lists.rpm.org/pipermail/rpm-maint/2009-January/002332.html --- diff --git a/lib/rpmrc.c b/lib/rpmrc.c index f478a24..b7fdd2c 100644 --- a/lib/rpmrc.c +++ b/lib/rpmrc.c @@ -475,7 +475,7 @@ static void setDefaults(void) addMacro(NULL, "_preScriptEnvironment",NULL, prescriptenviron,RMIL_DEFAULT); addMacroDefault("_topdir", - "/usr/src/packages", "%(echo $HOME)/rpmbuild"); + "/usr/src/packages", "%{getenv:HOME}/rpmbuild"); addMacroDefault("_tmppath", LOCALSTATEDIR "/tmp", "%{_var}/tmp"); addMacroDefault("_dbpath", diff --git a/macros.in b/macros.in index c3c5025..c597399 100644 --- a/macros.in +++ b/macros.in @@ -229,7 +229,7 @@ package or when debugging this package.\ %_tmppath %{_var}/tmp # Path to top of build area. -%_topdir %(echo $HOME)/rpmbuild +%_topdir %{getenv:HOME}/rpmbuild # The path to the unzip executable (legacy, use %{__unzip} instead). %_unzipbin %{__unzip} diff --git a/rpmio/macro.c b/rpmio/macro.c index afe41cb..c9b6259 100644 --- a/rpmio/macro.c +++ b/rpmio/macro.c @@ -983,6 +983,8 @@ doFoo(MacroBuf mb, int negate, const char * f, size_t fn, break; } b = be; + } else if (STREQ("getenv", f, fn)) { + b = getenv(buf); } else if (STREQ("S", f, fn)) { for (b = buf; (c = *b) && risdigit(c);) b++; @@ -1253,6 +1255,7 @@ expandMacro(MacroBuf mb) STREQ("uncompress", f, fn) || STREQ("url2path", f, fn) || STREQ("u2p", f, fn) || + STREQ("getenv", f, fn) || STREQ("S", f, fn) || STREQ("P", f, fn) || STREQ("F", f, fn)) {