Skip to content

Commit 5ce3fc0

Browse files
committed
Remove accepting keys from the environment
1 parent 8d09cff commit 5ce3fc0

File tree

2 files changed

+17
-15
lines changed

2 files changed

+17
-15
lines changed

app/Foliage/Options.hs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ parseOptions =
1717
<> header "foliage - a builder for static Hackage repositories"
1818
)
1919

20-
newtype Options = Options
20+
data Options = Options
2121
{ optionsConfig :: FilePath
22+
, optionsKeys :: FilePath
2223
}
2324

2425
optionsParser :: Parser Options
@@ -31,3 +32,11 @@ optionsParser =
3132
<> showDefault
3233
<> value "config.toml"
3334
)
35+
<*> strOption
36+
( long "keys"
37+
<> metavar "KEYS"
38+
<> help "Keys folder"
39+
<> showDefault
40+
<> value "_keys"
41+
)
42+

app/Main.hs

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,18 @@ cabal = command1_ "cabal" []
2323

2424
main :: IO ()
2525
main = do
26-
Options {optionsConfig} <- parseOptions
26+
Options {optionsConfig, optionsKeys} <- parseOptions
2727

2828
eConfig <- readConfig optionsConfig
2929

3030
case eConfig of
3131
Left e ->
3232
hPutStrLn stderr e
3333
Right config ->
34-
makeRepository (configSources config)
34+
makeRepository (configSources config) optionsKeys
3535

36-
makeRepository :: MonadIO m => [Source] -> m ()
37-
makeRepository sources = shelly $ do
36+
makeRepository :: MonadIO m => [Source] -> FilePath -> m ()
37+
makeRepository sources keysPath = shelly $ do
3838
outDir <- absPath "_repo"
3939
idxDir <- absPath "_repo/index"
4040
pkgDir <- absPath "_repo/package"
@@ -44,7 +44,7 @@ makeRepository sources = shelly $ do
4444
mkdir outDir
4545
mkdir pkgDir
4646

47-
keysDir <- absPath "_keys"
47+
keysDir <- absPath keysPath
4848
ensureKeys keysDir
4949

5050
forM_ sources $ processSource pkgDir
@@ -89,15 +89,8 @@ ensureKeys keysDir = do
8989
if b
9090
then echo $ "Using existing keys in " <> toTextIgnore keysDir
9191
else do
92-
mKeys <- get_env "KEYS"
93-
case mKeys of
94-
Just _keys -> do
95-
echo "Using keys from environment"
96-
mkdir keysDir
97-
bash_ ("echo \"$KEYS\" | base64 -d | tar xvz -C " <> keysDir) []
98-
Nothing -> do
99-
echo $ "Creating new repository keys in " <> toTextIgnore keysDir
100-
liftIO $ createKeys keysDir
92+
echo $ "Creating new repository keys in " <> toTextIgnore keysDir
93+
liftIO $ createKeys keysDir
10194

10295
processSource :: FilePath -> Source -> Sh ()
10396
processSource pkgDir (Source url subdirs) = do

0 commit comments

Comments
 (0)