Add getenv macro, use instead of $(echo $HOME) for defauls

- inspired by http://lists.rpm.org/pipermail/rpm-maint/2009-January/002332.html
This commit is contained in:
Panu Matilainen 2009-01-16 09:09:40 +02:00
parent 91e0004f0b
commit 947ad7acb3
3 changed files with 5 additions and 2 deletions

View File

@ -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",

View File

@ -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}

View File

@ -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)) {