summaryrefslogtreecommitdiff
path: root/fsmgr.hs
diff options
context:
space:
mode:
authorAndrew Cady <d@jerkface.net>2020-10-12 13:08:14 -0400
committerAndrew Cady <d@jerkface.net>2020-10-12 13:08:14 -0400
commit757e35df1bc571cbe414b62cce1d6d3b0eca93b5 (patch)
tree448935636abdbf2ea582869c98d74f726fe282b4 /fsmgr.hs
parent996c430fd798598e1ba4d492741fc2fadf1a3a1e (diff)
hacks and fixes, features and fixtures, axes and fackses
Diffstat (limited to 'fsmgr.hs')
-rw-r--r--fsmgr.hs17
1 files changed, 11 insertions, 6 deletions
diff --git a/fsmgr.hs b/fsmgr.hs
index bd4e303..dca488e 100644
--- a/fsmgr.hs
+++ b/fsmgr.hs
@@ -38,7 +38,7 @@ noParent (ParentImageConfigFile _) = False
38noParent (SeededImage _ _) = False 38noParent (SeededImage _ _) = False
39 39
40dynamicNames :: FilePath -> FilePath 40dynamicNames :: FilePath -> FilePath
41dynamicNames = replace "$(karch)" uname . replace "$(debarch)" debarch 41dynamicNames = replace "$(kver)" (snd uname) . replace "$(karch)" (fst uname) . replace "$(debarch)" debarch
42 42
43chomp :: String -> String 43chomp :: String -> String
44chomp = takeWhile (/= '\n') 44chomp = takeWhile (/= '\n')
@@ -53,10 +53,10 @@ getDebianCodename = unsafePerformIO $ do
53 (Stdout codename) <- cmd "sh -c" [". /etc/os-release && printf '%s' \"$VERSION_CODENAME\""] 53 (Stdout codename) <- cmd "sh -c" [". /etc/os-release && printf '%s' \"$VERSION_CODENAME\""]
54 return codename 54 return codename
55 55
56uname :: String 56uname :: (String, String)
57uname = unsafePerformIO $ do 57uname = unsafePerformIO $ do
58 Stdout out <- cmd "uname -r" 58 Stdout out <- cmd "uname -r"
59 return $ last . wordsBy '-' . head . lines $ out 59 pure $ (reverse *** reverse . tail) . break (== '-') . reverse . head . lines $ out
60 60
61data AptListCfg = 61data AptListCfg =
62 AptListCfg 62 AptListCfg
@@ -225,8 +225,13 @@ buildInitialImage :: DiskImageConfig -> FilePath -> FilePath -> Action ()
225buildInitialImage DiskImageConfig{..} mountpoint out = do 225buildInitialImage DiskImageConfig{..} mountpoint out = do
226 case initialImage of 226 case initialImage of
227 ParentImageConfigFile f -> do 227 ParentImageConfigFile f -> do
228 let parent = "_build" </> f -<.> "btrfs" 228 let cwdParent = f -<.> "btrfs"
229 need [parent] 229 buildDirParent = "_build" </> cwdParent
230 parent <- liftIO (IO.doesFileExist cwdParent) >>= \case
231 True -> return cwdParent
232 False -> do
233 need [buildDirParent]
234 return buildDirParent
230 cmd_ "cp --reflink" [parent, out] 235 cmd_ "cp --reflink" [parent, out]
231 cmd_ "btrfstune -f -S0" [out] 236 cmd_ "btrfstune -f -S0" [out]
232 cmd_ "btrfstune -fu" [out] 237 cmd_ "btrfstune -fu" [out]
@@ -437,7 +442,7 @@ cgroupChroot groupName mnt args = do
437 -- TODO: unshare hostname & set from /etc/hostname inside root 442 -- TODO: unshare hostname & set from /etc/hostname inside root
438 cmd_ (Cwd mnt) (WithStderr False) 443 cmd_ (Cwd mnt) (WithStderr False)
439 "unshare --ipc --uts --cgroup --mount --pid --fork chroot ." 444 "unshare --ipc --uts --cgroup --mount --pid --fork chroot ."
440 "sh -exc" ["mount -t proc proc /proc; mount -t devpts devpts /dev/pts; hostname -F /etc/hostname; exec \"$@\""] 445 "sh -exc" ["mount -t proc proc /proc; mount -t devpts devpts /dev/pts; if [ -e /etc/hostname ]; then hostname -F /etc/hostname; fi; exec \"$@\""]
441 "sh" args 446 "sh" args
442 447
443earlyFail :: IO () 448earlyFail :: IO ()