mirror of
https://github.com/input-output-hk/foliage.git
synced 2024-11-25 07:44:24 +03:00
Remove accepting keys from the environment
This commit is contained in:
parent
8d09cfffcf
commit
5ce3fc0501
@ -17,8 +17,9 @@ parseOptions =
|
||||
<> header "foliage - a builder for static Hackage repositories"
|
||||
)
|
||||
|
||||
newtype Options = Options
|
||||
data Options = Options
|
||||
{ optionsConfig :: FilePath
|
||||
, optionsKeys :: FilePath
|
||||
}
|
||||
|
||||
optionsParser :: Parser Options
|
||||
@ -31,3 +32,11 @@ optionsParser =
|
||||
<> showDefault
|
||||
<> value "config.toml"
|
||||
)
|
||||
<*> strOption
|
||||
( long "keys"
|
||||
<> metavar "KEYS"
|
||||
<> help "Keys folder"
|
||||
<> showDefault
|
||||
<> value "_keys"
|
||||
)
|
||||
|
||||
|
21
app/Main.hs
21
app/Main.hs
@ -23,7 +23,7 @@ cabal = command1_ "cabal" []
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
Options {optionsConfig} <- parseOptions
|
||||
Options {optionsConfig, optionsKeys} <- parseOptions
|
||||
|
||||
eConfig <- readConfig optionsConfig
|
||||
|
||||
@ -31,10 +31,10 @@ main = do
|
||||
Left e ->
|
||||
hPutStrLn stderr e
|
||||
Right config ->
|
||||
makeRepository (configSources config)
|
||||
makeRepository (configSources config) optionsKeys
|
||||
|
||||
makeRepository :: MonadIO m => [Source] -> m ()
|
||||
makeRepository sources = shelly $ do
|
||||
makeRepository :: MonadIO m => [Source] -> FilePath -> m ()
|
||||
makeRepository sources keysPath = shelly $ do
|
||||
outDir <- absPath "_repo"
|
||||
idxDir <- absPath "_repo/index"
|
||||
pkgDir <- absPath "_repo/package"
|
||||
@ -44,7 +44,7 @@ makeRepository sources = shelly $ do
|
||||
mkdir outDir
|
||||
mkdir pkgDir
|
||||
|
||||
keysDir <- absPath "_keys"
|
||||
keysDir <- absPath keysPath
|
||||
ensureKeys keysDir
|
||||
|
||||
forM_ sources $ processSource pkgDir
|
||||
@ -89,15 +89,8 @@ ensureKeys keysDir = do
|
||||
if b
|
||||
then echo $ "Using existing keys in " <> toTextIgnore keysDir
|
||||
else do
|
||||
mKeys <- get_env "KEYS"
|
||||
case mKeys of
|
||||
Just _keys -> do
|
||||
echo "Using keys from environment"
|
||||
mkdir keysDir
|
||||
bash_ ("echo \"$KEYS\" | base64 -d | tar xvz -C " <> keysDir) []
|
||||
Nothing -> do
|
||||
echo $ "Creating new repository keys in " <> toTextIgnore keysDir
|
||||
liftIO $ createKeys keysDir
|
||||
echo $ "Creating new repository keys in " <> toTextIgnore keysDir
|
||||
liftIO $ createKeys keysDir
|
||||
|
||||
processSource :: FilePath -> Source -> Sh ()
|
||||
processSource pkgDir (Source url subdirs) = do
|
||||
|
Loading…
Reference in New Issue
Block a user