summaryrefslogtreecommitdiff
path: root/src/Wrapper.hs
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2023-01-04 22:12:44 +0100
committerRoman Smrž <roman.smrz@seznam.cz>2023-01-04 22:12:44 +0100
commit0d14a9caaa9f3fee06c55f9e10acf6ce46b3389d (patch)
tree84edd0aceae573670ea7070e35fd1d707f0cd98f /src/Wrapper.hs
parent433c3f0a80784a5e529b9268891ed2fddf0f2627 (diff)
Look for core binary in the directory containing wrapper
Diffstat (limited to 'src/Wrapper.hs')
-rw-r--r--src/Wrapper.hs19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/Wrapper.hs b/src/Wrapper.hs
index c97d242..64a2e0f 100644
--- a/src/Wrapper.hs
+++ b/src/Wrapper.hs
@@ -1,5 +1,8 @@
module Main where
+import GHC.Environment
+
+import System.Directory
import System.Environment
import System.FilePath
import System.Linux.Namespaces
@@ -20,6 +23,18 @@ main = do
-- needed for creating /run/netns
callCommand "mount -t tmpfs tmpfs /run"
- path <- getExecutablePath
+ epath <- takeDirectory <$> getExecutablePath -- directory containing executable
+ fpath <- map takeDirectory . take 1 <$> getFullArgs
+ -- directory used for invocation, can differ from above for symlinked executable
+
+ let dirs = concat
+ [ [ epath ]
+ , [ epath </> "../../../erebos-tester-core/build/erebos-tester-core" ]
+ , fpath
+ ]
+
args <- getArgs
- executeFile (takeDirectory path </> "../../../erebos-tester-core/build/erebos-tester-core/erebos-tester-core") False args Nothing
+ mapM_ (\file -> executeFile file False args Nothing) =<<
+ findExecutablesInDirectories dirs "erebos-tester-core"
+
+ fail "core binary not found"