New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add tests for install & uninstall #115
Conversation
$(xmake) is set to join(_PROGRAM_DIR, 'xmake') that is wrong when XMAKE_PROGRAM_DIR is set to another program dir (like developing dir) with no executable so use system-special ways to get absolution path of executable file always
@titansnow Using
So, I'm going to remove function main()
..
os.addenv("PATH", xmake._EXECUTABLE_DIR) I think it's easier to use, and users don't have to care about the path of xmake. |
to fix build on macos `sudo luarocks install` will install to global package tree that running as all users could find
This reverts commit f2e0d82.
Codecov Report
@@ Coverage Diff @@
## dev #115 +/- ##
==========================================
+ Coverage 68.13% 69.79% +1.65%
==========================================
Files 246 250 +4
Lines 10032 10424 +392
==========================================
+ Hits 6835 7275 +440
+ Misses 3197 3149 -48
Continue to review full report at Codecov.
|
Great! 👍 |
There is a situation that needs |
|
You can use Pass |
no use @waruqi $ xmake l
> os.getenv("PATH")
/home/ts/.local/share/xmake:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/ts/.local/bin
> os.sudo(os.exec,"sh -c 'echo $PATH'")
[sudo] password for ts:
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin
> os.exec("sudo -E sh -c 'echo $PATH'")
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin |
It works on my machine(macOS and archlinux). xmake l
> os.addenv("PATH", "/tmp/test")
> os.getenv("PATH")
/tmp/test:/Users/ruki/.cargo/bin:/Users/ruki/.rvm/gems/ruby-2.2.2/bin:/Users/ruki/.rvm/gems/ruby-2.2.2@global/bin:/Users/ruki/.rvm/rubies/ruby-2.2.2/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/ruki/.rvm/bin
> os.exec("sudo -E xmake l --root -c 'print(os.getenv(\"PATH\"))'")
/tmp/test:/Users/ruki/.cargo/bin:/Users/ruki/.rvm/gems/ruby-2.2.2/bin:/Users/ruki/.rvm/gems/ruby-2.2.2@global/bin:/Users/ruki/.rvm/rubies/ruby-2.2.2/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/ruki/.rvm/bin
> os.sudo(os.exec, "xmake l --root -c 'print(os.getenv(\"PATH\"))'")
/tmp/test:/Users/ruki/.cargo/bin:/Users/ruki/.rvm/gems/ruby-2.2.2/bin:/Users/ruki/.rvm/gems/ruby-2.2.2@global/bin:/Users/ruki/.rvm/rubies/ruby-2.2.2/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/ruki/.rvm/bin
> os.exec("sudo -E sh -c 'echo $PATH'")
/tmp/test:/Users/ruki/.cargo/bin:/Users/ruki/.rvm/gems/ruby-2.2.2/bin:/Users/ruki/.rvm/gems/ruby-2.2.2@global/bin:/Users/ruki/.rvm/rubies/ruby-2.2.2/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/ruki/.rvm/bin
> os.sudo(os.exec,"sh -c 'echo $PATH'")
/tmp/test:/Users/ruki/.cargo/bin:/Users/ruki/.rvm/gems/ruby-2.2.2/bin:/Users/ruki/.rvm/gems/ruby-2.2.2@global/bin:/Users/ruki/.rvm/rubies/ruby-2.2.2/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/ruki/.rvm/bin |
I found some info on stackoverflow. Seems ubuntu's behavior on As travis-ci uses ubuntu, we have no way to drop |
@titansnow I am going to try adding |
@titansnow I have removed the function main.init()
-- add the directory of the program file (xmake) to $PATH environment
local programfile = os.programfile()
if programfile and os.isfile(programfile) then
os.addenv("PATH", path.directory(programfile))
else
os.addenv("PATH", os.programdir())
end |
So how to deal with build error on travis-ci? The trouble is |
@titansnow Can you give me your failed travis-ci links? |
Below ⬇️ 😃 |
This seems like another problem about
I think xmake can find itself from |
That is because 962b99c 😓 |
@titansnow Ok, I will look at it. |
@titansnow I'm doing some tests on travis-ci The path of xmake already exists when running But xmake still not found,I don't know why. 😢 $ which xmake
/home/travis/bin/xmake
$ sudo sh -c "echo $PATH"
/home/travis/bin:/home/travis/.local/bin:/home/travis/.pyenv/shims:/home/travis/.phpenv/shims:/home/travis/gopath/bin:/home/travis/.gimme/versions/go1.7.linux.amd64/bin:/home/travis/.local/bin:/opt/pyenv/bin:/opt/python/2.7.12/bin:/opt/python/3.5.2/bin:/opt/python/2.6.9/bin:/opt/python/3.2.6/bin:/opt/python/3.3.6/bin:/opt/python/3.4.4/bin:/opt/python/pypy-5.4.1/bin:/opt/python/pypy3-2.4.0/bin:/usr/local/phantomjs/bin:/usr/local/phantomjs:/home/travis/perl5/perlbrew/bin:/home/travis/.nvm/versions/node/v4.1.2/bin:/usr/local/maven-3.1.1/bin:/home/travis/.kiex/elixirs/elixir-1.0.4/bin:/home/travis/.kiex/bin:/usr/local/gradle/bin:/usr/local/clang-3.5.0/bin:/home/travis/.rvm/gems/ruby-2.3.1/bin:/home/travis/.rvm/gems/ruby-2.3.1@global/bin:/home/travis/.rvm/rubies/ruby-2.3.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/jvm/java-9-oracle/bin:/usr/lib/jvm/java-9-oracle/db/bin:/home/travis/.phpenv/bin:/home/travis/.rvm/bin:/home/travis/.lua:/home/travis/.local/bin:/home/travis/build/tboox/xmake/install/luarocks/bin
$ sudo sh -c "xmake --root lua versioninfo"
sh: 1: xmake: not found |
@waruqi The problem is funny: double quote will expand the vars inside 😺 $ sudo sh -c 'echo $PATH'
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin
$ sudo sh -c "echo $PATH"
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/ts/.local/bin |
I have fixed it. |
core/src/xmake/machine.c
Outdated
lua_pushstring(impl -> lua, data); | ||
lua_setglobal(impl -> lua, "_EXECUTABLE_PATH"); | ||
|
||
if (!ok) | ||
{ | ||
// get the directory | ||
while (size-- > 0) | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it's necessary to write the following code three times.
while (size-- > 0)
{
if (data[size] == '/')
{
data[size] = '\0';
break;
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can use this implementation in dev to replace it directly. 😸
xmake/core/_xmake_main.lua
Outdated
xmake._PROJECT_DIR = _PROJECT_DIR | ||
xmake._CORE_DIR = _PROGRAM_DIR .. "/core" | ||
xmake._TOOLS_DIR = _PROGRAM_DIR .. "/tools" | ||
xmake._TEMPLATES_DIR = _PROGRAM_DIR .. "/templates" | ||
xmake._PROJECT_FILE = "xmake.lua" | ||
xmake._EXECUTABLE_PATH = _EXECUTABLE_PATH |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's enough to use xmake._PROGRAM_FILE = _PROGRAM_FILE
, There's no need to add a redundant variable
Done |
xmake/modules/privilege/sudo.lua
Outdated
-- run it with administrator permission and preserve parent environment | ||
runner(program .. " PATH=\"" .. os.getenv("PATH") .. "\" " .. cmd, ...) | ||
runner(program .. " env PATH=\"" .. os.getenv("PATH") .. "\" " .. cmd, ...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The effect that do not add env
seems to be the same, what is the difference?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$ ls ~/awd/build
awd
$ sudo PATH=$HOME/awd/build:$PATH awd
sudo: awd: command not found
$ sudo env PATH=$HOME/awd/build:$PATH awd
hello world!
And it makes the build pass
makefile
Outdated
@@ -61,15 +61,17 @@ install: | |||
@# install the xmake directory | |||
@cp -r xmake/* $(xmake_dir_install) | |||
@# make the xmake loader | |||
ifneq ($(PLAT),linux) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's this? Although we can get the executable path on linux, macOS and windows now. But maybe we cannot get it successfully on some linux distributions. So I think we still need export XMAKE_PROGRAM_DIR=/xxx
Great! 😄 |
@titansnow Can you help me to improve for example: $ ./scripts/get.sh __uninstall__ |
add tests for install & uninstall (cherry picked from commit 0c98817)
ok 👌 I'm also going to add a arg to specify install prefix |
See 8ffb52a I have impled $ scripts/get.sh __uninstall__
$ env prefix=/usr scripts/get.sh |
+ # uninstall
+ makefile=$(remote_get_content https://github.com/tboox/xmake/raw/master/makefile)
+ while which xmake >/dev/null 2>&1 I think we can check makefile in the current directory first to faster uninstalling. for example: $ cd xmake
$ ./scripts/get.sh __uninstall__ |
But how could we know the makefile found in local is xmake's not other's? And the size of |
@titansnow Ok. 👌 Can you create a new pr for this commit? |
Matte, I have a plan of remote rolling pre-build on installation on Windows. That is, the install script get pre-build binary from appveyor rolling build so that no need to build locally to get newest |
Good idea! 👍 But how can you get pre-build binary file from appveyor? |
You could have a look on that branch |
@titansnow Ok. 👍 😄 |
add tests for install & uninstall, with/without
sudo
I also fix the
$(xmake)
so that it will be always correct. See details at commit messageHave some problem on mac os on travis-ci