diff options
author | Andrew Cady <d@jerkface.net> | 2020-05-30 11:23:05 -0400 |
---|---|---|
committer | Andrew Cady <d@jerkface.net> | 2020-05-30 11:23:17 -0400 |
commit | da79ab440b5d672b011859beaa11b4325aa69294 (patch) | |
tree | 9f10d2be8ec19d029c110735520a438276004b8b | |
parent | 41d5d8bfe3104f0a05bcb77999bac99f182d4eba (diff) |
Do not hardcode "stretch"
Instead, get codename (used to determine versions for all the packages)
from '/etc/os-release'
This should be specifiable (and inherited) in the yaml config file too.
The *.devices mechanism shows the need to create inheritable "settings."
Perhaps they should be in Haskell not through the filesystem.
-rw-r--r-- | fsmgr.hs | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -53,8 +53,8 @@ uname = unsafePerformIO $ do | |||
53 | Stdout out <- cmd "uname -r" | 53 | Stdout out <- cmd "uname -r" |
54 | return $ last . wordsBy '-' . head . lines $ out | 54 | return $ last . wordsBy '-' . head . lines $ out |
55 | 55 | ||
56 | aptListFiles :: [FilePath] | 56 | aptListFiles :: String -> [FilePath] |
57 | aptListFiles = ("/var/lib/apt/lists" </>) <$> observedCorrectListForStretch | 57 | aptListFiles codename = ("/var/lib/apt/lists" </>) . (replace "stretch" codename) <$> observedCorrectListForStretch |
58 | where | 58 | where |
59 | observedCorrectListForStretch = | 59 | observedCorrectListForStretch = |
60 | [ "httpredir.debian.org_debian_dists_stretch_main_binary-amd64_Packages" | 60 | [ "httpredir.debian.org_debian_dists_stretch_main_binary-amd64_Packages" |
@@ -95,7 +95,8 @@ buildRoot config@DiskImageConfig{..} finalOut = do | |||
95 | ["dpkg"] [if unpackOnly then "--unpack" else "--install"] (dynamicNames <$> debs) | 95 | ["dpkg"] [if unpackOnly then "--unpack" else "--install"] (dynamicNames <$> debs) |
96 | {- 2.5. install apt package cache -} | 96 | {- 2.5. install apt package cache -} |
97 | when installAptLists $ do | 97 | when installAptLists $ do |
98 | cmd_ "rsync -Ra" (("/./" ++) <$> aptListFiles) (mountpoint ++ "/") | 98 | (Stdout codename) <- cmd "sh -c" [". /etc/os-release && [ \"$VERSION_CODENAME\" ] && echo -n $VERSION_CODENAME"] |
99 | cmd_ "rsync -Ra" (("/./" ++) <$> aptListFiles codename) (mountpoint ++ "/") | ||
99 | {- 3. binaries -} | 100 | {- 3. binaries -} |
100 | let go b = do | 101 | let go b = do |
101 | p <- fromMaybe (fail $ "not found in ${PATH}: " ++ b) <$> liftIO (pathLocate b) | 102 | p <- fromMaybe (fail $ "not found in ${PATH}: " ++ b) <$> liftIO (pathLocate b) |