From 757e35df1bc571cbe414b62cce1d6d3b0eca93b5 Mon Sep 17 00:00:00 2001 From: Andrew Cady Date: Mon, 12 Oct 2020 13:08:14 -0400 Subject: hacks and fixes, features and fixtures, axes and fackses --- fsmgr.hs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'fsmgr.hs') 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 noParent (SeededImage _ _) = False dynamicNames :: FilePath -> FilePath -dynamicNames = replace "$(karch)" uname . replace "$(debarch)" debarch +dynamicNames = replace "$(kver)" (snd uname) . replace "$(karch)" (fst uname) . replace "$(debarch)" debarch chomp :: String -> String chomp = takeWhile (/= '\n') @@ -53,10 +53,10 @@ getDebianCodename = unsafePerformIO $ do (Stdout codename) <- cmd "sh -c" [". /etc/os-release && printf '%s' \"$VERSION_CODENAME\""] return codename -uname :: String +uname :: (String, String) uname = unsafePerformIO $ do Stdout out <- cmd "uname -r" - return $ last . wordsBy '-' . head . lines $ out + pure $ (reverse *** reverse . tail) . break (== '-') . reverse . head . lines $ out data AptListCfg = AptListCfg @@ -225,8 +225,13 @@ buildInitialImage :: DiskImageConfig -> FilePath -> FilePath -> Action () buildInitialImage DiskImageConfig{..} mountpoint out = do case initialImage of ParentImageConfigFile f -> do - let parent = "_build" f -<.> "btrfs" - need [parent] + let cwdParent = f -<.> "btrfs" + buildDirParent = "_build" cwdParent + parent <- liftIO (IO.doesFileExist cwdParent) >>= \case + True -> return cwdParent + False -> do + need [buildDirParent] + return buildDirParent cmd_ "cp --reflink" [parent, out] cmd_ "btrfstune -f -S0" [out] cmd_ "btrfstune -fu" [out] @@ -437,7 +442,7 @@ cgroupChroot groupName mnt args = do -- TODO: unshare hostname & set from /etc/hostname inside root cmd_ (Cwd mnt) (WithStderr False) "unshare --ipc --uts --cgroup --mount --pid --fork chroot ." - "sh -exc" ["mount -t proc proc /proc; mount -t devpts devpts /dev/pts; hostname -F /etc/hostname; exec \"$@\""] + "sh -exc" ["mount -t proc proc /proc; mount -t devpts devpts /dev/pts; if [ -e /etc/hostname ]; then hostname -F /etc/hostname; fi; exec \"$@\""] "sh" args earlyFail :: IO () -- cgit v1.2.3