diff options
author | Andrew Cady <d@jerkface.net> | 2020-10-12 14:25:10 -0400 |
---|---|---|
committer | Andrew Cady <d@jerkface.net> | 2020-10-12 14:25:10 -0400 |
commit | b19d7bb1f5257cfd07c3389bc9b8bf728e00a9f5 (patch) | |
tree | 105f0fe60421b0e5700f6a901855ab2f9f8a6155 /fsmgr.hs | |
parent | 757e35df1bc571cbe414b62cce1d6d3b0eca93b5 (diff) |
build shrunken .seed.btrfs images internally
Diffstat (limited to 'fsmgr.hs')
-rw-r--r-- | fsmgr.hs | 14 |
1 files changed, 12 insertions, 2 deletions
@@ -241,7 +241,7 @@ buildInitialImage DiskImageConfig{..} mountpoint out = do | |||
241 | cmd_ "mount -t btrfs" [out] mountpoint | 241 | cmd_ "mount -t btrfs" [out] mountpoint |
242 | 242 | ||
243 | SeededImage n f -> do | 243 | SeededImage n f -> do |
244 | let parent = "_build" </> f -<.> "btrfs" | 244 | let parent = f -<.> "seed.btrfs" |
245 | need [parent] | 245 | need [parent] |
246 | 246 | ||
247 | devices <- either (const []) lines . readEither <$> liftIO (readFileOptional (parent <.> "devices.txt")) | 247 | devices <- either (const []) lines . readEither <$> liftIO (readFileOptional (parent <.> "devices.txt")) |
@@ -464,7 +464,17 @@ shakeRules = do | |||
464 | need [cfgFile] | 464 | need [cfgFile] |
465 | cfg <- readEither <$> readFile' cfgFile | 465 | cfg <- readEither <$> readFile' cfgFile |
466 | either (error . (("Error parsing file: " ++ cfgFile ++ ": ") ++)) (flip buildRoot out) cfg | 466 | either (error . (("Error parsing file: " ++ cfgFile ++ ": ") ++)) (flip buildRoot out) cfg |
467 | "*.btrfs" %> \out -> do | 467 | priority 2 $ "*.seed.btrfs" %> \out -> do |
468 | let tmp = out <.> "tmp" | ||
469 | inp = dropExtension out -<.> ".btrfs" | ||
470 | need [inp] | ||
471 | cmd_ "cp --reflink=always" [inp, tmp] | ||
472 | cmd_ "btrfstune -f -S0" [tmp] | ||
473 | cmd_ "btrfs-shrink" [tmp] | ||
474 | cmd_ "btrfstune -f -S1" [tmp] | ||
475 | cmd_ (WithStderr False) "mv -i" [tmp, out] | ||
476 | |||
477 | priority 1 $ "*.btrfs" %> \out -> do | ||
468 | need ["_build" </> out] | 478 | need ["_build" </> out] |
469 | -- WithStderr False needed for `cp` to interact with the tty | 479 | -- WithStderr False needed for `cp` to interact with the tty |
470 | cmd_ (WithStderr False) "cp --reflink=always -i" ["_build" </> out, out] | 480 | cmd_ (WithStderr False) "cp --reflink=always -i" ["_build" </> out, out] |