summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cady <d@jerkface.net>2020-05-30 00:41:29 -0400
committerAndrew Cady <d@jerkface.net>2020-05-30 00:41:29 -0400
commit8a4224d366a3560a1a8b9780016c1ae899904eb2 (patch)
tree7054d85f3d7d258217c2088e274d87359565c494
parentbe7e755858e700aebb11f7533b8bd362e7a77656 (diff)
run losetup on parent seed images
currently using some rather brutal force here
-rw-r--r--fsmgr.hs8
1 files changed, 8 insertions, 0 deletions
diff --git a/fsmgr.hs b/fsmgr.hs
index 2f3e0f5..65797c4 100644
--- a/fsmgr.hs
+++ b/fsmgr.hs
@@ -106,6 +106,8 @@ buildRoot config@DiskImageConfig{..} finalOut = do
106 writeFileChanged (finalOut -<.> "pkgs.txt") pkgList 106 writeFileChanged (finalOut -<.> "pkgs.txt") pkgList
107 {- 5. create a backup snapshot -} 107 {- 5. create a backup snapshot -}
108 cmd_ "umount" [mountpoint] 108 cmd_ "umount" [mountpoint]
109
110 setupLoopDevices out
109 cmd_ "mount -t btrfs -o subvol=/" [out, mountpoint] 111 cmd_ "mount -t btrfs -o subvol=/" [out, mountpoint]
110 ignoreErrors $ cmd_ (EchoStderr False) "btrfs subvolume delete" [mountpoint </> "root~orig"] 112 ignoreErrors $ cmd_ (EchoStderr False) "btrfs subvolume delete" [mountpoint </> "root~orig"]
111 cmd_ "btrfs subvolume snapshot -r" [mountpoint </> "root", mountpoint </> "root~orig"] 113 cmd_ "btrfs subvolume snapshot -r" [mountpoint </> "root", mountpoint </> "root~orig"]
@@ -116,6 +118,12 @@ buildRoot config@DiskImageConfig{..} finalOut = do
116 cmd_ "btrfstune -S1" [out] 118 cmd_ "btrfstune -S1" [out]
117 cmd_ "mv" [out, finalOut] 119 cmd_ "mv" [out, finalOut]
118 120
121setupLoopDevices :: FilePath -> Action ()
122setupLoopDevices out = do
123 (Stdout devices) <- cmd "sh -c" ["if [ -e \"$0\" ]; then cat \"$0\"; fi ", out -<.> "devices.txt"]
124 cmd_ "losetup -D"
125 forM_ (lines devices) $ \d -> cmd_ "losetup -f" [d]
126
119absPath :: MonadIO m => FilePath -> m FilePath 127absPath :: MonadIO m => FilePath -> m FilePath
120absPath f@('/':_) = return f 128absPath f@('/':_) = return f
121absPath f = do 129absPath f = do