diff options
author | Andrew Cady <d@cryptonomic.net> | 2021-02-28 07:37:01 -0500 |
---|---|---|
committer | Andrew Cady <d@cryptonomic.net> | 2021-02-28 07:37:01 -0500 |
commit | da4c955eeb534c799b1a7378dc4d5dfaad2d21c2 (patch) | |
tree | 54aaa722a1925501c9b6dd129c6c342c70a497ad | |
parent | 4ae45ba0bdc988499e8fd71984b4a0ba65080d81 (diff) |
config option "unit-files:" for systemd unit files
-rw-r--r-- | fsmgr.hs | 7 | ||||
-rw-r--r-- | src/ConfigFile.hs | 4 |
2 files changed, 10 insertions, 1 deletions
@@ -178,6 +178,13 @@ buildRoot config@DiskImageConfig{..} finalOut = do | |||
178 | in do | 178 | in do |
179 | forM_ (unpack <$> skelFiles) go | 179 | forM_ (unpack <$> skelFiles) go |
180 | forM_ (unpack <$> optionalSkelFiles) $ ignoreErrors . go | 180 | forM_ (unpack <$> optionalSkelFiles) $ ignoreErrors . go |
181 | {- 3.6 systemd unit files -} | ||
182 | let go s = do | ||
183 | target <- absPath mountpoint <&> (</> "etc/systemd/system") | ||
184 | cmd_ "mkdir -p" [target] | ||
185 | cmd_ "install --preserve-timestamps -m644 -t" [target] [s] | ||
186 | go :: String -> Action () | ||
187 | in forM_ (unpack <$> unitFiles) go | ||
181 | {- 4. custom setup commands -} | 188 | {- 4. custom setup commands -} |
182 | forM_ chrootCommands $ \c -> do | 189 | forM_ chrootCommands $ \c -> do |
183 | cmd_ "chroot" [mountpoint] "/bin/sh -c" [unpack c] | 190 | cmd_ "chroot" [mountpoint] "/bin/sh -c" [unpack c] |
diff --git a/src/ConfigFile.hs b/src/ConfigFile.hs index a5b5989..d7fe60d 100644 --- a/src/ConfigFile.hs +++ b/src/ConfigFile.hs | |||
@@ -56,6 +56,7 @@ data DiskImageConfig = DiskImageConfig { | |||
56 | , packages :: Set Package | 56 | , packages :: Set Package |
57 | , debconfConfig :: Maybe FilePath | 57 | , debconfConfig :: Maybe FilePath |
58 | , unpackOnly :: Bool | 58 | , unpackOnly :: Bool |
59 | , unitFiles :: Vector Text | ||
59 | , binaries :: Vector Text | 60 | , binaries :: Vector Text |
60 | , optionalBinaries :: Vector Text | 61 | , optionalBinaries :: Vector Text |
61 | , chrootCommands :: Vector Text | 62 | , chrootCommands :: Vector Text |
@@ -75,6 +76,7 @@ diskImageConfigParser = object $ | |||
75 | <*> (Set.fromList . toList . fmap parsePackageName <$> defaultField "packages" Vector.empty (array string)) | 76 | <*> (Set.fromList . toList . fmap parsePackageName <$> defaultField "packages" Vector.empty (array string)) |
76 | <*> (fmap unpack <$> optField "debconf" string) | 77 | <*> (fmap unpack <$> optField "debconf" string) |
77 | <*> defaultField "unpack-only" False bool | 78 | <*> defaultField "unpack-only" False bool |
79 | <*> defaultField "unit-files" Vector.empty (array string) | ||
78 | <*> defaultField "binaries" Vector.empty (array string) | 80 | <*> defaultField "binaries" Vector.empty (array string) |
79 | <*> defaultField "binaries-optional" Vector.empty (array string) | 81 | <*> defaultField "binaries-optional" Vector.empty (array string) |
80 | <*> defaultField "chroot-commands" Vector.empty (array string) | 82 | <*> defaultField "chroot-commands" Vector.empty (array string) |
@@ -84,7 +86,7 @@ diskImageConfigParser = object $ | |||
84 | <*> defaultField "apt-update" False bool | 86 | <*> defaultField "apt-update" False bool |
85 | 87 | ||
86 | convSeeded :: DiskImageConfig -> DiskImageConfig | 88 | convSeeded :: DiskImageConfig -> DiskImageConfig |
87 | convSeeded x@(DiskImageConfig (ParentImageConfigFile f) _ _ _ _ _ _ _ _ (Just size) _) = x { initialImage = SeededImage size f } | 89 | convSeeded x@(DiskImageConfig (ParentImageConfigFile f) _ _ _ _ _ _ _ _ _ (Just size) _) = x { initialImage = SeededImage size f } |
88 | convSeeded x = x | 90 | convSeeded x = x |
89 | 91 | ||
90 | readCfg :: FilePath -> Action DiskImageConfig | 92 | readCfg :: FilePath -> Action DiskImageConfig |