From 36a6bc270c6b0c2068ec6a66c2e6046c3e7f7ee7 Mon Sep 17 00:00:00 2001 From: Thomas Treffner Date: Mon, 22 Feb 2021 12:08:41 +0100 Subject: [PATCH] v symlink: fix for termux (#8896) --- cmd/tools/vsymlink.v | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/cmd/tools/vsymlink.v b/cmd/tools/vsymlink.v index 081044b428..805d15987b 100644 --- a/cmd/tools/vsymlink.v +++ b/cmd/tools/vsymlink.v @@ -24,23 +24,17 @@ fn cleanup_vtmp_folder() { } fn setup_symlink_unix(vexe string) { - link_dir := '/usr/local/bin' - if !os.exists(link_dir) { - os.mkdir_all(link_dir) or { panic(err) } + mut link_path := '/data/data/com.termux/files/usr/bin/v' + if os.system("uname -o | grep -q '[A/a]ndroid'") == 1 { + 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' - mut ret := os.exec('ln -sf $vexe $link_path') or { panic(err) } + ret := os.exec('ln -sf $vexe $link_path') or { panic(err) } if ret.exit_code == 0 { 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 { eprintln('Failed to create symlink "$link_path". Try again with sudo.') }