diff options
| author | ruki <[email protected]> | 2017-08-25 18:31:51 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2017-08-25 18:31:51 +0800 |
| commit | 096430694f6b106d9a3e73093e1355062f068c36 (patch) | |
| tree | 71775edbb53e6b7c242c1360d18189c16fbcd9ce | |
| parent | eaeabe2f6166df2049db4dde01a77726e64e66ee (diff) | |
fix os.tmpdir bug in fakeroot
| -rw-r--r-- | CHANGELOG.md | 2 | ||||
| -rw-r--r-- | xmake/core/base/os.lua | 13 |
2 files changed, 14 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index c42fa9f47..360a06c52 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ ### Bugs fixed * Fix `set_pcxxheader` bug +* [#140](https://github.com/tboox/xmake/issues/140): Fix `os.tmpdir()` in fakeroot ## v2.1.6 @@ -357,6 +358,7 @@ ### Bugs修复 * 修复`set_pcxxheader`编译没有继承flags配置问题 +* [#140](https://github.com/tboox/xmake/issues/140): 修复`os.tmpdir()`在fakeroot下的冲突问题 ## v2.1.6 diff --git a/xmake/core/base/os.lua b/xmake/core/base/os.lua index fbe208b9b..27b909117 100644 --- a/xmake/core/base/os.lua +++ b/xmake/core/base/os.lua @@ -454,8 +454,19 @@ end -- get the temporary directory function os.tmpdir() + -- is in fakeroot? @note: uid always be 0 in root and fakeroot + if os._FAKEROOT == nil then + local ldpath = os.getenv("LD_LIBRARY_PATH") + if ldpath and ldpath:find("libfakeroot", 1, true) then + os._FAKEROOT = true + end + end + + -- make sub-directory name + local subdir = utils.ifelse(os._FAKEROOT, ".xmakefake", ".xmake") + -- get a temporary directory for each user - local tmpdir = path.join(os._tmpdir(), ".xmake" .. (os.uid().euid or "")) + local tmpdir = path.join(os._tmpdir(), subdir .. (os.uid().euid or "")) -- ensure this directory exist if not os.isdir(tmpdir) then |
