diff options
-rw-r--r-- | fsmgr.hs | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -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 | ||
223 | copyParentDevices :: FilePath -> FilePath -> Action () | ||
224 | copyParentDevices parent out = do | ||
225 | devices <- either (const []) lines . readEither <$> liftIO (readFileOptional (parent <.> "devices.txt")) | ||
226 | writeFile' (out -<.> "devices.txt") (unlines $ parent:devices) | ||
227 | |||
223 | buildInitialImage :: DiskImageConfig -> FilePath -> FilePath -> Action () | 228 | buildInitialImage :: DiskImageConfig -> FilePath -> FilePath -> Action () |
224 | buildInitialImage DiskImageConfig{..} mountpoint out = do | 229 | buildInitialImage 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] |