summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cady <d@jerkface.net>2020-05-29 21:49:21 -0400
committerAndrew Cady <d@jerkface.net>2020-05-29 21:49:21 -0400
commite52de73e8bc9a087e61db2cd5e77af61f78380f3 (patch)
tree38cd7d1c8d5166b2619b2a12ce5ea129c24460b7
parent889f4a144ff68ce1e10f7d94e1516e4f79062204 (diff)
allow binaries to be specified as absolute paths
-rw-r--r--fsmgr.hs5
1 files changed, 3 insertions, 2 deletions
diff --git a/fsmgr.hs b/fsmgr.hs
index 1f5af37..313af26 100644
--- a/fsmgr.hs
+++ b/fsmgr.hs
@@ -84,7 +84,7 @@ buildRoot config@DiskImageConfig{..} finalOut = do
84 {- 3. binaries -} 84 {- 3. binaries -}
85 let go b = do 85 let go b = do
86 p <- fromMaybe (fail $ "not found in ${PATH}: " ++ b) <$> liftIO (pathLocate b) 86 p <- fromMaybe (fail $ "not found in ${PATH}: " ++ b) <$> liftIO (pathLocate b)
87 cmd_ "cp -L" [p] [mountpoint </> "usr/local/bin" </> b] 87 cmd_ "cp -L" [p] [mountpoint </> "usr/local/bin" </> takeFileName b]
88 in do 88 in do
89 forM_ (unpack <$> binaries) go 89 forM_ (unpack <$> binaries) go
90 forM_ (unpack <$> optionalBinaries) $ ignoreErrors . go 90 forM_ (unpack <$> optionalBinaries) $ ignoreErrors . go
@@ -302,7 +302,8 @@ head1 = lines >>> \case
302 x:_ -> x 302 x:_ -> x
303 303
304pathLocate :: String -> IO (Maybe FilePath) 304pathLocate :: String -> IO (Maybe FilePath)
305pathLocate c = (getEnv "SUDO_USER" >>=) $ fmap (validatePath . head1 . fromStdout) <$> \case 305pathLocate c | elem '/' c = pure $ pure c
306pathLocate c | True = (getEnv "SUDO_USER" >>=) $ fmap (validatePath . head1 . fromStdout) <$> \case
306 "" -> cmd "which" [c] 307 "" -> cmd "which" [c]
307 u -> do 308 u -> do
308 path <- fromStdout <$> cmd "su -" [u] "-c" ["printf %s \"$PATH\""] 309 path <- fromStdout <$> cmd "su -" [u] "-c" ["printf %s \"$PATH\""]