Adjusted design related to stackage-setup per #87 #88

This commit is contained in:
Dan Burton 2015-04-21 16:29:58 -07:00
parent c837587609
commit 1117ca93c9
8 changed files with 51 additions and 40 deletions

View File

@ -11,7 +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) import Handler.Download (getGhcMajorVersionR)
handleAliasR :: Slug -> Slug -> [Text] -> Handler () handleAliasR :: Slug -> Slug -> [Text] -> Handler ()
handleAliasR user name pieces = do handleAliasR user name pieces = do
@ -82,5 +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 GhcMajorVersionR -> getGhcMajorVersionR slug >>= sendResponse
_ -> notFound _ -> notFound

View File

@ -1,8 +1,7 @@
module Handler.Download module Handler.Download
( getDownloadR ( getDownloadR
, getDownloadStackageExecutableR
, getDownloadLtsSnapshotsJsonR , getDownloadLtsSnapshotsJsonR
, getDownloadEnvironmentJsonR , getGhcMajorVersionR
) where ) where
import Import import Import
@ -13,6 +12,10 @@ executableFor Win32 = StackageWindowsExecutable
executableFor Win64 = StackageWindowsExecutable executableFor Win64 = StackageWindowsExecutable
executableFor _ = StackageUnixExecutable executableFor _ = StackageUnixExecutable
executableLink :: SupportedArch -> StackageExecutable -> Route App
executableLink arch exe =
StaticR $ StaticRoute ["setup", toPathPiece arch, toPathPiece exe] []
downloadCandidates :: [(SupportedArch, StackageExecutable)] downloadCandidates :: [(SupportedArch, StackageExecutable)]
downloadCandidates = downloadCandidates =
map (\arch -> (arch, executableFor arch)) map (\arch -> (arch, executableFor arch))
@ -22,14 +25,6 @@ getDownloadR :: Handler Html
getDownloadR = defaultLayout $ do getDownloadR = defaultLayout $ do
$(widgetFile "download") $(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 :: Handler [Lts]
ltsMajorVersions = liftM (map entityVal) $ runDB $ do ltsMajorVersions = liftM (map entityVal) $ runDB $ do
mapWhileIsJustM [0..] $ \x -> do mapWhileIsJustM [0..] $ \x -> do
@ -53,21 +48,11 @@ getDownloadLtsSnapshotsJsonR = liftM reverse ltsMajorVersions >>= \case
printLts (Lts major minor _) = printLts (Lts major minor _) =
"lts-" ++ show major ++ "." ++ show minor "lts-" ++ show major ++ "." ++ show minor
getDownloadEnvironmentJsonR :: SnapSlug -> SupportedArch -> Handler Value -- TODO: add this to db
getDownloadEnvironmentJsonR _slug Linux64 = do ltsGhcMajorVersion :: Stackage -> Text
-- TODO: dynamic generation based on db entries ltsGhcMajorVersion _ = "7.8"
let ghc = object
[ "version" .= asText "7.8.4" getGhcMajorVersionR :: SnapSlug -> Handler Text
, "url" .= asText "http://www.haskell.org/ghc/dist/7.8.4/ghc-7.8.4-x86_64-unknown-linux-deb7.tar.xz" getGhcMajorVersionR slug = do
, "sha1" .= asText "11aec12d4bb27f6fa59dcc8535a7a3b3be8cb787" snapshot <- runDB $ getBy404 $ UniqueSnapshot slug
] return $ ltsGhcMajorVersion $ entityVal snapshot
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

View File

@ -109,11 +109,12 @@ data StackageExecutable
deriving (Show, Read, Eq) deriving (Show, Read, Eq)
instance PathPiece StackageExecutable where instance PathPiece StackageExecutable where
toPathPiece StackageWindowsExecutable = "stackage.exe" -- TODO: distribute stackage, not just stackage-setup
toPathPiece StackageUnixExecutable = "stackage" toPathPiece StackageWindowsExecutable = "stackage-setup.exe"
toPathPiece StackageUnixExecutable = "stackage-setup"
fromPathPiece "stackage" = Just StackageUnixExecutable fromPathPiece "stackage-setup" = Just StackageUnixExecutable
fromPathPiece "stackage.exe" = Just StackageWindowsExecutable fromPathPiece "stackage-setup.exe" = Just StackageWindowsExecutable
fromPathPiece _ = Nothing fromPathPiece _ = Nothing
data SupportedArch data SupportedArch

View File

@ -28,7 +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 /ghc-major-version GhcMajorVersionR GET
/aliases AliasesR PUT /aliases AliasesR PUT
/alias/#Slug/#Slug/*Texts AliasR /alias/#Slug/#Slug/*Texts AliasR
@ -60,5 +60,4 @@
/package-counts PackageCountsR GET /package-counts PackageCountsR GET
/download DownloadR GET /download DownloadR GET
/download/#SupportedArch/#StackageExecutable DownloadStackageExecutableR GET
/download/lts-snapshots.json DownloadLtsSnapshotsJsonR GET /download/lts-snapshots.json DownloadLtsSnapshotsJsonR GET

View 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

View File

@ -0,0 +1,3 @@
#! /bin/bash
echo "fake stackage setup"

View File

@ -1,5 +1,5 @@
$forall (arch, exe) <- downloadCandidates $forall (arch, exe) <- downloadCandidates
<ul .downloads> <ul .downloads>
<li> <li>
<a href=@{DownloadStackageExecutableR arch exe}> <a href=@{executableLink arch exe}>
#{toPathPiece arch}: #{toPathPiece exe} #{toPathPiece arch}: #{toPathPiece exe}

View File

@ -1,3 +0,0 @@
TODO: replace this with the file download.
#{toPathPiece arch}: #{toPathPiece exe}