diff options
-rw-r--r-- | fsmgr.hs | 12 |
1 files changed, 7 insertions, 5 deletions
@@ -176,14 +176,14 @@ buildRoot config@DiskImageConfig{..} finalOut = do | |||
176 | forM_ (unpack <$> binaries) go | 176 | forM_ (unpack <$> binaries) go |
177 | forM_ (unpack <$> optionalBinaries) $ ignoreErrors . go | 177 | forM_ (unpack <$> optionalBinaries) $ ignoreErrors . go |
178 | {- 3.5 skel -} | 178 | {- 3.5 skel -} |
179 | let go f = do | 179 | let go f = when (not $ null f) $ do |
180 | homeDir <- getHomeDir | 180 | homeDir <- getHomeDir |
181 | target <- absPath mountpoint <&> (</> "etc/skel") | 181 | target <- absPath mountpoint <&> (</> "etc/skel") |
182 | cmd_ "mkdir -p" [target] | 182 | cmd_ "mkdir -p" [target] |
183 | cmd_ (Cwd homeDir) "cp -r --preserve=mode,timestamps -L --parents -t" [target] [f] | 183 | cmd_ (Cwd homeDir) "cp -r --preserve=mode,timestamps -L --parents -t" [target] f |
184 | in do | 184 | in do |
185 | forM_ (unpack <$> skelFiles) go | 185 | go $ toList (unpack <$> skelFiles) |
186 | forM_ (unpack <$> optionalSkelFiles) $ ignoreErrors . go | 186 | ignoreErrors . go $ toList (unpack <$> optionalSkelFiles) |
187 | {- 3.6 systemd unit files -} | 187 | {- 3.6 systemd unit files -} |
188 | let go s = do | 188 | let go s = do |
189 | target <- absPath mountpoint <&> (</> "etc/systemd/system") | 189 | target <- absPath mountpoint <&> (</> "etc/systemd/system") |
@@ -224,8 +224,10 @@ absPath f = do | |||
224 | 224 | ||
225 | getHomeDir :: Action FilePath | 225 | getHomeDir :: Action FilePath |
226 | getHomeDir = do | 226 | getHomeDir = do |
227 | Stdout homeDir <- cmd "sh -c" ["if [ \"$SUDO_USER\" ]; then getent passwd \"$SUDO_USER\" | cut -d: -f6; else printf \"%s\n\" \"$HOME\"; fi"] | 227 | Stdout homeDir <- cmd "sh -c" [script] |
228 | return homeDir | 228 | return homeDir |
229 | where | ||
230 | script = "if [ \"$SUDO_USER\" ]; then getent passwd \"$SUDO_USER\" | cut -z -d: -f6; else printf \"%s\\0\" \"$HOME\"; fi | xargs -0 printf %s" | ||
229 | 231 | ||
230 | readFileOptional :: FilePath -> IO (String) | 232 | readFileOptional :: FilePath -> IO (String) |
231 | readFileOptional f = IO.doesFileExist f >>= \case | 233 | readFileOptional f = IO.doesFileExist f >>= \case |