mirror of
https://github.com/commercialhaskell/stackage-server.git
synced 2026-01-11 19:58:28 +01:00
parent
c837587609
commit
1117ca93c9
@ -11,7 +11,7 @@ import Handler.StackageIndex (getStackageIndexR)
|
||||
import Handler.StackageSdist (getStackageSdistR)
|
||||
import Handler.Hoogle (getHoogleR, getHoogleDatabaseR)
|
||||
import Handler.BuildPlan (getBuildPlanR)
|
||||
import Handler.Download (getDownloadEnvironmentJsonR)
|
||||
import Handler.Download (getGhcMajorVersionR)
|
||||
|
||||
handleAliasR :: Slug -> Slug -> [Text] -> Handler ()
|
||||
handleAliasR user name pieces = do
|
||||
@ -82,5 +82,5 @@ goSid sid pieces = do
|
||||
HoogleR -> getHoogleR slug >>= sendResponse
|
||||
HoogleDatabaseR -> getHoogleDatabaseR slug >>= sendResponse
|
||||
BuildPlanR -> getBuildPlanR slug >>= sendResponse
|
||||
DownloadEnvironmentJsonR arch -> getDownloadEnvironmentJsonR slug arch >>= sendResponse
|
||||
GhcMajorVersionR -> getGhcMajorVersionR slug >>= sendResponse
|
||||
_ -> notFound
|
||||
|
||||
@ -1,8 +1,7 @@
|
||||
module Handler.Download
|
||||
( getDownloadR
|
||||
, getDownloadStackageExecutableR
|
||||
, getDownloadLtsSnapshotsJsonR
|
||||
, getDownloadEnvironmentJsonR
|
||||
, getGhcMajorVersionR
|
||||
) where
|
||||
|
||||
import Import
|
||||
@ -13,6 +12,10 @@ executableFor Win32 = StackageWindowsExecutable
|
||||
executableFor Win64 = StackageWindowsExecutable
|
||||
executableFor _ = StackageUnixExecutable
|
||||
|
||||
executableLink :: SupportedArch -> StackageExecutable -> Route App
|
||||
executableLink arch exe =
|
||||
StaticR $ StaticRoute ["setup", toPathPiece arch, toPathPiece exe] []
|
||||
|
||||
downloadCandidates :: [(SupportedArch, StackageExecutable)]
|
||||
downloadCandidates =
|
||||
map (\arch -> (arch, executableFor arch))
|
||||
@ -22,14 +25,6 @@ getDownloadR :: Handler Html
|
||||
getDownloadR = defaultLayout $ do
|
||||
$(widgetFile "download")
|
||||
|
||||
getDownloadStackageExecutableR
|
||||
:: SupportedArch -> StackageExecutable -> Handler Html
|
||||
getDownloadStackageExecutableR arch exe = do
|
||||
-- TODO: send exeutable file instead
|
||||
when (executableFor arch /= exe) notFound
|
||||
defaultLayout $ do
|
||||
$(widgetFile "downloadExe")
|
||||
|
||||
ltsMajorVersions :: Handler [Lts]
|
||||
ltsMajorVersions = liftM (map entityVal) $ runDB $ do
|
||||
mapWhileIsJustM [0..] $ \x -> do
|
||||
@ -53,21 +48,11 @@ getDownloadLtsSnapshotsJsonR = liftM reverse ltsMajorVersions >>= \case
|
||||
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
|
||||
-- TODO: add this to db
|
||||
ltsGhcMajorVersion :: Stackage -> Text
|
||||
ltsGhcMajorVersion _ = "7.8"
|
||||
|
||||
getGhcMajorVersionR :: SnapSlug -> Handler Text
|
||||
getGhcMajorVersionR slug = do
|
||||
snapshot <- runDB $ getBy404 $ UniqueSnapshot slug
|
||||
return $ ltsGhcMajorVersion $ entityVal snapshot
|
||||
|
||||
9
Types.hs
9
Types.hs
@ -109,11 +109,12 @@ data StackageExecutable
|
||||
deriving (Show, Read, Eq)
|
||||
|
||||
instance PathPiece StackageExecutable where
|
||||
toPathPiece StackageWindowsExecutable = "stackage.exe"
|
||||
toPathPiece StackageUnixExecutable = "stackage"
|
||||
-- TODO: distribute stackage, not just stackage-setup
|
||||
toPathPiece StackageWindowsExecutable = "stackage-setup.exe"
|
||||
toPathPiece StackageUnixExecutable = "stackage-setup"
|
||||
|
||||
fromPathPiece "stackage" = Just StackageUnixExecutable
|
||||
fromPathPiece "stackage.exe" = Just StackageWindowsExecutable
|
||||
fromPathPiece "stackage-setup" = Just StackageUnixExecutable
|
||||
fromPathPiece "stackage-setup.exe" = Just StackageWindowsExecutable
|
||||
fromPathPiece _ = Nothing
|
||||
|
||||
data SupportedArch
|
||||
|
||||
@ -28,7 +28,7 @@
|
||||
/hoogle HoogleR GET
|
||||
/db.hoo HoogleDatabaseR GET
|
||||
/build-plan BuildPlanR GET
|
||||
/download/#SupportedArch/environment.json DownloadEnvironmentJsonR GET
|
||||
/ghc-major-version GhcMajorVersionR GET
|
||||
|
||||
/aliases AliasesR PUT
|
||||
/alias/#Slug/#Slug/*Texts AliasR
|
||||
@ -60,5 +60,4 @@
|
||||
/package-counts PackageCountsR GET
|
||||
|
||||
/download DownloadR GET
|
||||
/download/#SupportedArch/#StackageExecutable DownloadStackageExecutableR GET
|
||||
/download/lts-snapshots.json DownloadLtsSnapshotsJsonR GET
|
||||
|
||||
26
static/setup/linux64/ghc-7.8-links.yaml
Normal file
26
static/setup/linux64/ghc-7.8-links.yaml
Normal file
@ -0,0 +1,26 @@
|
||||
-
|
||||
name: ghc
|
||||
version: 7.8.4
|
||||
url: http://www.haskell.org/ghc/dist/7.8.4/ghc-7.8.4-x86_64-unknown-linux-deb7.tar.xz
|
||||
sha1: 11aec12d4bb27f6fa59dcc8535a7a3b3be8cb787
|
||||
instructions:
|
||||
- tar xJf ghc-7.8.4-x86_64-unknown-linux-deb7.tar.xz
|
||||
- cd ghc-7.8.4
|
||||
- ./configure --prefix=`pwd`
|
||||
- make install
|
||||
- cd ..
|
||||
- rm ghc-7.8.4-x86_64-unknown-linux-deb7.tar.xz
|
||||
-
|
||||
name: cabal
|
||||
version: 1.20.0.3
|
||||
url: https://www.haskell.org/cabal/release/cabal-install-1.20.0.3/cabal-install-1.20.0.3.tar.gz
|
||||
sha1: 444448b0f704420e329e8fc1989b6743c1c8546d
|
||||
instructions:
|
||||
- tar xzf cabal-install-1.20.0.3.tar.gz
|
||||
- cd cabal-install-1.20.0.3
|
||||
- ./bootstrap.sh
|
||||
- cd ..
|
||||
- rm -r cabal-install-1.20.0.3
|
||||
- rm cabal-install-1.20.0.3.tar.gz
|
||||
- mkdir cabal-1.20.0.3
|
||||
- mv $HOME/.cabal/bin/cabal cabal-1.20.0.3/bin/cabal
|
||||
3
static/setup/linux64/stackage-setup
Executable file
3
static/setup/linux64/stackage-setup
Executable file
@ -0,0 +1,3 @@
|
||||
#! /bin/bash
|
||||
|
||||
echo "fake stackage setup"
|
||||
@ -1,5 +1,5 @@
|
||||
$forall (arch, exe) <- downloadCandidates
|
||||
<ul .downloads>
|
||||
<li>
|
||||
<a href=@{DownloadStackageExecutableR arch exe}>
|
||||
<a href=@{executableLink arch exe}>
|
||||
#{toPathPiece arch}: #{toPathPiece exe}
|
||||
|
||||
@ -1,3 +0,0 @@
|
||||
TODO: replace this with the file download.
|
||||
|
||||
#{toPathPiece arch}: #{toPathPiece exe}
|
||||
Loading…
Reference in New Issue
Block a user