From 0d14a9caaa9f3fee06c55f9e10acf6ce46b3389d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Wed, 4 Jan 2023 22:12:44 +0100 Subject: Look for core binary in the directory containing wrapper --- erebos-tester.cabal | 1 + src/Wrapper.hs | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/erebos-tester.cabal b/erebos-tester.cabal index 1819223..3bd3d6c 100644 --- a/erebos-tester.cabal +++ b/erebos-tester.cabal @@ -23,6 +23,7 @@ executable erebos-tester -- other-modules: -- other-extensions: build-depends: base >=4.13 && <5, + directory >=1.3 && <1.4, filepath ^>=1.4.2.1, linux-namespaces ^>=0.1.3, process ^>=1.6.9, 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" -- cgit v1.2.3