Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall/lib/general.py
diff options
context:
space:
mode:
authorAnton Hvornum <anton.feeds+github@gmail.com>2020-07-08 13:38:15 +0000
committerAnton Hvornum <anton.feeds+github@gmail.com>2020-07-08 13:38:15 +0000
commit3e97b1e93c0ccb618c9b996acc0fc93837bf358e (patch)
tree91dfe76e55e38eb47bfa5e0442caa93539b7f33d /archinstall/lib/general.py
parentfc4790b33c98ca14469e88c00544701a85365d3a (diff)
rc6: Fixed an issue where 'which' doesn't return the binary absolute path. This due to which being a builtin bash thing, and for whatever reason that stopped working when running as a module, so created locate_binary(name:str) which uses the PATH variable just as which does to find the binary's absolute path
Diffstat (limited to 'archinstall/lib/general.py')
-rw-r--r--archinstall/lib/general.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/archinstall/lib/general.py b/archinstall/lib/general.py
index f32f85c7..508a2f89 100644
--- a/archinstall/lib/general.py
+++ b/archinstall/lib/general.py
@@ -65,6 +65,14 @@ def supports_color():
is_a_tty = hasattr(sys.stdout, 'isatty') and sys.stdout.isatty()
return supported_platform and is_a_tty
+def locate_binary(name):
+ for PATH in os.environ['PATH']:
+ for root, folders, files in os.walk(PATH):
+ for file in files:
+ if file == name:
+ return os.path.join(root, file)
+ break # Don't recurse
+
class sys_command():#Thread):
"""
Stolen from archinstall_gui
@@ -97,10 +105,12 @@ class sys_command():#Thread):
self.exec_dir = f'{self.cwd}/{os.path.basename(self.cmd[0])}_workingdir'
if not self.cmd[0][0] == '/':
+ # "which" doesn't work as it's a builin to bash.
+ # It used to work, but for whatever reason it doesn't anymore. So back to square one..
+
#log('Worker command is not executed with absolute path, trying to find: {}'.format(self.cmd[0]), origin='spawn', level=5)
- o = check_output(['/usr/bin/which', self.cmd[0]])
#log('This is the binary {} for {}'.format(o.decode('UTF-8'), self.cmd[0]), origin='spawn', level=5)
- self.cmd[0] = o.decode('UTF-8').strip()
+ self.cmd[0] = locate_binary(self.cmd[0])
if not os.path.isdir(self.exec_dir):
os.makedirs(self.exec_dir)