mirror of
https://github.com/commercialhaskell/stackage-server.git
synced 2026-01-30 21:00:24 +01:00
Add sketch of 'environment.json' and 'lts-snapshots.json'
This commit is contained in:
parent
80cb890dad
commit
c837587609
@ -11,6 +11,7 @@ import Handler.StackageIndex (getStackageIndexR)
|
|||||||
import Handler.StackageSdist (getStackageSdistR)
|
import Handler.StackageSdist (getStackageSdistR)
|
||||||
import Handler.Hoogle (getHoogleR, getHoogleDatabaseR)
|
import Handler.Hoogle (getHoogleR, getHoogleDatabaseR)
|
||||||
import Handler.BuildPlan (getBuildPlanR)
|
import Handler.BuildPlan (getBuildPlanR)
|
||||||
|
import Handler.Download (getDownloadEnvironmentJsonR)
|
||||||
|
|
||||||
handleAliasR :: Slug -> Slug -> [Text] -> Handler ()
|
handleAliasR :: Slug -> Slug -> [Text] -> Handler ()
|
||||||
handleAliasR user name pieces = do
|
handleAliasR user name pieces = do
|
||||||
@ -81,4 +82,5 @@ goSid sid pieces = do
|
|||||||
HoogleR -> getHoogleR slug >>= sendResponse
|
HoogleR -> getHoogleR slug >>= sendResponse
|
||||||
HoogleDatabaseR -> getHoogleDatabaseR slug >>= sendResponse
|
HoogleDatabaseR -> getHoogleDatabaseR slug >>= sendResponse
|
||||||
BuildPlanR -> getBuildPlanR slug >>= sendResponse
|
BuildPlanR -> getBuildPlanR slug >>= sendResponse
|
||||||
|
DownloadEnvironmentJsonR arch -> getDownloadEnvironmentJsonR slug arch >>= sendResponse
|
||||||
_ -> notFound
|
_ -> notFound
|
||||||
|
|||||||
@ -1,9 +1,12 @@
|
|||||||
module Handler.Download
|
module Handler.Download
|
||||||
( getDownloadR
|
( getDownloadR
|
||||||
, getDownloadStackageExecutableR
|
, getDownloadStackageExecutableR
|
||||||
|
, getDownloadLtsSnapshotsJsonR
|
||||||
|
, getDownloadEnvironmentJsonR
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Import
|
import Import
|
||||||
|
import Data.Slug (SnapSlug)
|
||||||
|
|
||||||
executableFor :: SupportedArch -> StackageExecutable
|
executableFor :: SupportedArch -> StackageExecutable
|
||||||
executableFor Win32 = StackageWindowsExecutable
|
executableFor Win32 = StackageWindowsExecutable
|
||||||
@ -12,17 +15,59 @@ executableFor _ = StackageUnixExecutable
|
|||||||
|
|
||||||
downloadCandidates :: [(SupportedArch, StackageExecutable)]
|
downloadCandidates :: [(SupportedArch, StackageExecutable)]
|
||||||
downloadCandidates =
|
downloadCandidates =
|
||||||
map (\arch -> (arch, executableFor arch))
|
map (\arch -> (arch, executableFor arch))
|
||||||
[minBound .. maxBound]
|
[minBound .. maxBound]
|
||||||
|
|
||||||
getDownloadR :: Handler Html
|
getDownloadR :: Handler Html
|
||||||
getDownloadR = defaultLayout $ do
|
getDownloadR = defaultLayout $ do
|
||||||
$(widgetFile "download")
|
$(widgetFile "download")
|
||||||
|
|
||||||
getDownloadStackageExecutableR
|
getDownloadStackageExecutableR
|
||||||
:: SupportedArch -> StackageExecutable -> Handler Html
|
:: SupportedArch -> StackageExecutable -> Handler Html
|
||||||
getDownloadStackageExecutableR arch exe = do
|
getDownloadStackageExecutableR arch exe = do
|
||||||
-- TODO: send exeutable file instead
|
-- TODO: send exeutable file instead
|
||||||
when (executableFor arch /= exe) notFound
|
when (executableFor arch /= exe) notFound
|
||||||
defaultLayout $ do
|
defaultLayout $ do
|
||||||
$(widgetFile "downloadExe")
|
$(widgetFile "downloadExe")
|
||||||
|
|
||||||
|
ltsMajorVersions :: Handler [Lts]
|
||||||
|
ltsMajorVersions = liftM (map entityVal) $ runDB $ do
|
||||||
|
mapWhileIsJustM [0..] $ \x -> do
|
||||||
|
selectFirst [LtsMajor ==. x] [Desc LtsMinor]
|
||||||
|
|
||||||
|
mapWhileIsJustM :: Monad m => [a] -> (a -> m (Maybe b)) -> m [b]
|
||||||
|
mapWhileIsJustM [] _f = return []
|
||||||
|
mapWhileIsJustM (x:xs) f = f x >>= \case
|
||||||
|
Nothing -> return []
|
||||||
|
Just y -> (y:) `liftM` mapWhileIsJustM xs f
|
||||||
|
|
||||||
|
getDownloadLtsSnapshotsJsonR :: Handler Value
|
||||||
|
getDownloadLtsSnapshotsJsonR = liftM reverse ltsMajorVersions >>= \case
|
||||||
|
[] -> return $ object []
|
||||||
|
majorVersions@(latest:_) -> return $ object
|
||||||
|
$ ["lts" .= printLts latest]
|
||||||
|
++ map toObj majorVersions
|
||||||
|
where
|
||||||
|
toObj lts@(Lts major _ _) =
|
||||||
|
pack ("lts-" ++ show major) .= printLts lts
|
||||||
|
printLts (Lts major minor _) =
|
||||||
|
"lts-" ++ show major ++ "." ++ show minor
|
||||||
|
|
||||||
|
getDownloadEnvironmentJsonR :: SnapSlug -> SupportedArch -> Handler Value
|
||||||
|
getDownloadEnvironmentJsonR _slug Linux64 = do
|
||||||
|
-- TODO: dynamic generation based on db entries
|
||||||
|
let ghc = object
|
||||||
|
[ "version" .= asText "7.8.4"
|
||||||
|
, "url" .= asText "http://www.haskell.org/ghc/dist/7.8.4/ghc-7.8.4-x86_64-unknown-linux-deb7.tar.xz"
|
||||||
|
, "sha1" .= asText "11aec12d4bb27f6fa59dcc8535a7a3b3be8cb787"
|
||||||
|
]
|
||||||
|
cabal = object
|
||||||
|
[ "version" .= asText "1.20.0.3"
|
||||||
|
, "url" .= asText "http://www.haskell.org/cabal/release/cabal-install-1.20.0.3/cabal-1.20.0.3-i386-unknown-linux.tar.gz"
|
||||||
|
, "sha1" .= asText "647ae3e561343a709b09ed70fa6bc7b1ce39e25b"
|
||||||
|
]
|
||||||
|
return $ object
|
||||||
|
[ "ghc" .= ghc
|
||||||
|
, "cabal" .= cabal
|
||||||
|
]
|
||||||
|
getDownloadEnvironmentJsonR _slug _arch = notFound
|
||||||
|
|||||||
@ -13,6 +13,8 @@ getSitemapR = sitemap $ do
|
|||||||
priority 1.0 $ HomeR
|
priority 1.0 $ HomeR
|
||||||
|
|
||||||
priority 0.9 $ LtsR []
|
priority 0.9 $ LtsR []
|
||||||
|
-- TODO: uncomment when this is presentable
|
||||||
|
--priority 0.9 $ DownloadR
|
||||||
priority 0.8 $ NightlyR []
|
priority 0.8 $ NightlyR []
|
||||||
|
|
||||||
priority 0.7 $ AllSnapshotsR
|
priority 0.7 $ AllSnapshotsR
|
||||||
|
|||||||
@ -28,6 +28,7 @@
|
|||||||
/hoogle HoogleR GET
|
/hoogle HoogleR GET
|
||||||
/db.hoo HoogleDatabaseR GET
|
/db.hoo HoogleDatabaseR GET
|
||||||
/build-plan BuildPlanR GET
|
/build-plan BuildPlanR GET
|
||||||
|
/download/#SupportedArch/environment.json DownloadEnvironmentJsonR GET
|
||||||
|
|
||||||
/aliases AliasesR PUT
|
/aliases AliasesR PUT
|
||||||
/alias/#Slug/#Slug/*Texts AliasR
|
/alias/#Slug/#Slug/*Texts AliasR
|
||||||
@ -60,3 +61,4 @@
|
|||||||
|
|
||||||
/download DownloadR GET
|
/download DownloadR GET
|
||||||
/download/#SupportedArch/#StackageExecutable DownloadStackageExecutableR GET
|
/download/#SupportedArch/#StackageExecutable DownloadStackageExecutableR GET
|
||||||
|
/download/lts-snapshots.json DownloadLtsSnapshotsJsonR GET
|
||||||
|
|||||||
@ -91,6 +91,7 @@ library
|
|||||||
DeriveFunctor
|
DeriveFunctor
|
||||||
DeriveFoldable
|
DeriveFoldable
|
||||||
DeriveTraversable
|
DeriveTraversable
|
||||||
|
LambdaCase
|
||||||
|
|
||||||
build-depends:
|
build-depends:
|
||||||
base >= 4
|
base >= 4
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user