diff options
author | Andrew Cady <d@jerkface.net> | 2020-05-29 21:49:21 -0400 |
---|---|---|
committer | Andrew Cady <d@jerkface.net> | 2020-05-29 21:49:21 -0400 |
commit | e52de73e8bc9a087e61db2cd5e77af61f78380f3 (patch) | |
tree | 38cd7d1c8d5166b2619b2a12ce5ea129c24460b7 | |
parent | 889f4a144ff68ce1e10f7d94e1516e4f79062204 (diff) |
allow binaries to be specified as absolute paths
-rw-r--r-- | fsmgr.hs | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -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 | ||
304 | pathLocate :: String -> IO (Maybe FilePath) | 304 | pathLocate :: String -> IO (Maybe FilePath) |
305 | pathLocate c = (getEnv "SUDO_USER" >>=) $ fmap (validatePath . head1 . fromStdout) <$> \case | 305 | pathLocate c | elem '/' c = pure $ pure c |
306 | pathLocate 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\""] |