summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cady <d@jerkface.net>2020-10-12 15:35:28 -0400
committerAndrew Cady <d@jerkface.net>2020-10-12 15:39:20 -0400
commit20a3246bc8df700423f27f6baa54596290747c5c (patch)
treea001f9355e90e2c5d74130e92cb798df7e42dd3d
parenta41ae37697de646d0aad98be67e463f1c5e394fd (diff)
factor
-rw-r--r--fsmgr.hs8
1 files changed, 6 insertions, 2 deletions
diff --git a/fsmgr.hs b/fsmgr.hs
index 00f840b..890064d 100644
--- a/fsmgr.hs
+++ b/fsmgr.hs
@@ -220,6 +220,11 @@ readFileOptional f = IO.doesFileExist f >>= \case
220 True -> readFile f 220 True -> readFile f
221 False -> return "" 221 False -> return ""
222 222
223copyParentDevices :: FilePath -> FilePath -> Action ()
224copyParentDevices parent out = do
225 devices <- either (const []) lines . readEither <$> liftIO (readFileOptional (parent <.> "devices.txt"))
226 writeFile' (out -<.> "devices.txt") (unlines $ parent:devices)
227
223buildInitialImage :: DiskImageConfig -> FilePath -> FilePath -> Action () 228buildInitialImage :: DiskImageConfig -> FilePath -> FilePath -> Action ()
224buildInitialImage DiskImageConfig{..} mountpoint out = do 229buildInitialImage DiskImageConfig{..} mountpoint out = do
225 case initialImage of 230 case initialImage of
@@ -241,8 +246,7 @@ buildInitialImage DiskImageConfig{..} mountpoint out = do
241 let parent = f -<.> "seed.btrfs" 246 let parent = f -<.> "seed.btrfs"
242 need [parent] 247 need [parent]
243 248
244 devices <- either (const []) lines . readEither <$> liftIO (readFileOptional (parent <.> "devices.txt")) 249 copyParentDevices parent out
245 writeFile' (out -<.> "devices.txt") (unlines $ parent:devices)
246 250
247 -- allocate new image file 251 -- allocate new image file
248 cmd_ "rm -f" [out] 252 cmd_ "rm -f" [out]