summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGordon GECOS <u@adam>2023-11-22 14:30:15 -0500
committerGordon GECOS <u@adam>2023-11-22 14:30:15 -0500
commit486fb62abd0ac5a87a85ca18beb939d21323fad1 (patch)
tree0fbac935c23ab68f0d4ac5643c2bae3be3d8f1bb
parent7eda6b846463c19411efd2747d3c6c3b3b9d3566 (diff)
support for separate _filesystem build dir
-rw-r--r--fsmgr.hs27
1 files changed, 7 insertions, 20 deletions
diff --git a/fsmgr.hs b/fsmgr.hs
index d2c7100..862a5bf 100644
--- a/fsmgr.hs
+++ b/fsmgr.hs
@@ -296,7 +296,7 @@ buildInitialImage DiskImageConfig{..} mountpoint out = do
296 cmd_ "mount -t btrfs" [out] mountpoint 296 cmd_ "mount -t btrfs" [out] mountpoint
297 297
298 SeededImage n f -> do 298 SeededImage n f -> do
299 let parent = f -<.> "seed.btrfs" 299 let parent = "_filesystem" </> f -<.> "seed.btrfs"
300 need [parent] 300 need [parent]
301 301
302 copyParentDevices parent out 302 copyParentDevices parent out
@@ -514,39 +514,26 @@ needSubvolume path = ioUnless (IO.doesDirectoryExist path) $ do
514 514
515shakeRules :: Rules () 515shakeRules :: Rules ()
516shakeRules = do 516shakeRules = do
517 "_build/*.yaml.canon" %> \out -> do 517 ["_build/*.yaml.canon", "_filesystem/*.yaml.canon"] |%> \out -> do
518 needSubvolume "_build" 518 needSubvolume "_build"
519 let yaml = dropDirectory1 $ dropExtension out 519 let yaml = dropDirectory1 $ dropExtension out
520 need [yaml] 520 need [yaml]
521 cfg <- readCfg yaml 521 cfg <- readCfg yaml
522 writeFileChanged out (show cfg) 522 writeFileChanged out (show cfg)
523 "_build/*.btrfs" %> \out -> do 523 ["_build/*.btrfs", "_filesystem/*.patch.btrfs"] |%> \out -> do
524 needSubvolume "_build" 524 needSubvolume "_build"
525 let cfgFile = (out -<.> "yaml.canon") 525 let cfgFile = (out -<.> "yaml.canon")
526 need [cfgFile] 526 need [cfgFile]
527 cfg <- readEither <$> readFile' cfgFile 527 cfg <- readEither <$> readFile' cfgFile
528 either (error . (("Error parsing file: " ++ cfgFile ++ ": ") ++)) (flip buildRoot out) cfg 528 either (error . (("Error parsing file: " ++ cfgFile ++ ": ") ++)) (flip buildRoot out) cfg
529 529
530 priority 2 $ "*.seed.btrfs" %> \out -> do 530 priority 2 $ "_filesystem/*.seed.btrfs" %> \out -> do
531 needSubvolume "_build"
532 needSubvolume "_filesystem" 531 needSubvolume "_filesystem"
533 let inp = dropExtension out -<.> ".btrfs" 532 let inp = ("_build" </>) $ dropDirectory1 $ dropExtension out -<.> ".btrfs"
534 fso = "_filesystem" </> out 533 tmp = out <.> "tmp"
535 tmp = fso <.> "tmp"
536 need [inp] 534 need [inp]
537 cmd_ "cp --reflink=always" [inp, tmp] 535 cmd_ "cp --reflink=always" [inp, tmp]
538 setupLoopDevices ("_build" </> inp <.> "btrfs") 536 setupLoopDevices ("_build" </> inp <.> "btrfs")
539 cmd_ "btrfs-shrink" [tmp] 537 cmd_ "btrfs-shrink" [tmp]
540 cmd_ "btrfstune -f -S1" [tmp] 538 cmd_ "btrfstune -f -S1" [tmp]
541 cmd_ (WithStderr False) "mv -i" [tmp, fso] 539 cmd_ (WithStderr False) "mv -i" [tmp, out]
542 cmd_ (WithStderr False) "ln -s -i" [fso, out]
543
544 priority 1 $ "*.btrfs" %> \out -> do
545 needSubvolume "_build"
546 needSubvolume "_filesystem"
547 let b = "_build" </> out
548 f = "_filesystem" </> out
549 need [b]
550 -- WithStderr False needed for `cp` to interact with the tty
551 cmd_ (WithStderr False) "cp --reflink=always -i" [b, f]
552 cmd_ (WithStderr False) "ln -s -i" [f, out]