diff options
author | Andrew Cady <d@jerkface.net> | 2020-05-30 00:41:29 -0400 |
---|---|---|
committer | Andrew Cady <d@jerkface.net> | 2020-05-30 00:41:29 -0400 |
commit | 8a4224d366a3560a1a8b9780016c1ae899904eb2 (patch) | |
tree | 7054d85f3d7d258217c2088e274d87359565c494 | |
parent | be7e755858e700aebb11f7533b8bd362e7a77656 (diff) |
run losetup on parent seed images
currently using some rather brutal force here
-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 |