diff options
-rw-r--r-- | fsmgr.hs | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -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 | ||
121 | setupLoopDevices :: FilePath -> Action () | ||
122 | setupLoopDevices 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 | |||
119 | absPath :: MonadIO m => FilePath -> m FilePath | 127 | absPath :: MonadIO m => FilePath -> m FilePath |
120 | absPath f@('/':_) = return f | 128 | absPath f@('/':_) = return f |
121 | absPath f = do | 129 | absPath f = do |