v symlink: fix for termux (#8896)

pull/8899/head
Thomas Treffner 2021-02-22 12:08:41 +01:00 committed by GitHub
parent 9dc770e29c
commit 36a6bc270c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 14 deletions

View File

@ -24,23 +24,17 @@ fn cleanup_vtmp_folder() {
} }
fn setup_symlink_unix(vexe string) { fn setup_symlink_unix(vexe string) {
link_dir := '/usr/local/bin' mut link_path := '/data/data/com.termux/files/usr/bin/v'
if !os.exists(link_dir) { if os.system("uname -o | grep -q '[A/a]ndroid'") == 1 {
os.mkdir_all(link_dir) or { panic(err) } link_dir := '/usr/local/bin'
if !os.exists(link_dir) {
os.mkdir_all(link_dir) or { panic(err) }
}
link_path = link_dir + '/v'
} }
mut link_path := link_dir + '/v' ret := os.exec('ln -sf $vexe $link_path') or { panic(err) }
mut ret := os.exec('ln -sf $vexe $link_path') or { panic(err) }
if ret.exit_code == 0 { if ret.exit_code == 0 {
println('Symlink "$link_path" has been created') println('Symlink "$link_path" has been created')
} else if os.system("uname -o | grep -q '[A/a]ndroid'") == 0 {
println('Failed to create symlink "$link_path". Trying again with Termux path for Android.')
link_path = '/data/data/com.termux/files/usr/bin/v'
ret = os.exec('ln -sf $vexe $link_path') or { panic(err) }
if ret.exit_code == 0 {
println('Symlink "$link_path" has been created')
} else {
eprintln('Failed to create symlink "$link_path". Try again with sudo.')
}
} else { } else {
eprintln('Failed to create symlink "$link_path". Try again with sudo.') eprintln('Failed to create symlink "$link_path". Try again with sudo.')
} }