diff options
Diffstat (limited to 'fsmgr.hs')
-rw-r--r-- | fsmgr.hs | 17 |
1 files changed, 11 insertions, 6 deletions
@@ -38,7 +38,7 @@ noParent (ParentImageConfigFile _) = False | |||
38 | noParent (SeededImage _ _) = False | 38 | noParent (SeededImage _ _) = False |
39 | 39 | ||
40 | dynamicNames :: FilePath -> FilePath | 40 | dynamicNames :: FilePath -> FilePath |
41 | dynamicNames = replace "$(karch)" uname . replace "$(debarch)" debarch | 41 | dynamicNames = replace "$(kver)" (snd uname) . replace "$(karch)" (fst uname) . replace "$(debarch)" debarch |
42 | 42 | ||
43 | chomp :: String -> String | 43 | chomp :: String -> String |
44 | chomp = takeWhile (/= '\n') | 44 | chomp = 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 | ||
56 | uname :: String | 56 | uname :: (String, String) |
57 | uname = unsafePerformIO $ do | 57 | uname = 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 | ||
61 | data AptListCfg = | 61 | data AptListCfg = |
62 | AptListCfg | 62 | AptListCfg |
@@ -225,8 +225,13 @@ buildInitialImage :: DiskImageConfig -> FilePath -> FilePath -> Action () | |||
225 | buildInitialImage DiskImageConfig{..} mountpoint out = do | 225 | buildInitialImage 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 | ||
443 | earlyFail :: IO () | 448 | earlyFail :: IO () |