Skip to content

Commit f6b699c

Browse files
committed
Include documentation in binary tarballs/zips
1 parent 6736b46 commit f6b699c

File tree

2 files changed

+52
-14
lines changed

2 files changed

+52
-14
lines changed

doc/install_and_upgrade.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@ Binaries are signed with this [[Signing key]].
55
## Windows
66

77
* Download [the latest release](https://github.com/commercialhaskell/stack/releases/latest). Note: while generally i386/32-bit GHC is better tested on Windows, there are reports that recent versions of Windows only work with the 64-bit version of stack (see [issue #393](https://github.com/commercialhaskell/stack/issues/393)).
8-
* Unpack the archive (you may need to rename the contents to `stack.exe`) and place `stack.exe` somewhere on your `%PATH%` (see [Path section below](#path)) and you can then run `stack` on the command line.
8+
* Unpack the archive and place `stack.exe` somewhere on your `%PATH%` (see [Path section below](#path)) and you can then run `stack` on the command line.
9+
* Now you can run `stack` from the terminal.
910

1011
NOTE: These executables have been built and tested on a Windows 7, 8.1, and 10 64-bit machines. They should run on older Windows installs as well, but have not been tested. If you do test, please edit and update this page to indicate as such.
1112

1213
## OS X
1314

1415
* Download [the latest release](https://github.com/commercialhaskell/stack/releases/latest)
15-
* Extract the `stack` executable and put it somewhere on your `$PATH` (see [Path section below](#path))
16+
* Extract the archive and place `stack` somewhere on your `$PATH` (see [Path section below](#path))
17+
* Now you can run `stack` from the terminal.
1618

1719
We generally test on the current version of OS X, but stack is known to work on Mavericks as well, and may also work on older versions (YMMV).
1820

@@ -153,7 +155,7 @@ Alternatively, the package can be built from source as follows.
153155
(64-bit and 32-bit options available)
154156

155157
* Download [the latest release](https://github.com/commercialhaskell/stack/releases/latest). Note: the `-gmp4` variants are for older distributions (such as CentOS 6.x) that only include libgmp4 (libgmp.so.3).
156-
* The download is compressed. Extract the compressed file somewhere on your PATH (see [PATH section below](#path)).
158+
* Extract the archive and place `stack` somewhere on your `$PATH` (see [Path section below](#path))
157159
* Now you can run `stack` from the terminal.
158160

159161
Tested on Fedora 20: make sure to install the following packages `sudo yum install perl make automake gcc gmp-devel`.

scripts/release/release.hs

Lines changed: 47 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -158,28 +158,41 @@ rules global@Global{..} args = do
158158
(do opt <- addPath [installBinDir] []
159159
() <- cmd opt stackProgName (stackArgs global) "build --pedantic --haddock --no-haddock-deps"
160160
() <- cmd opt stackProgName (stackArgs global) "clean"
161-
() <- cmd opt stackProgName (stackArgs global) "build"
162-
() <- cmd opt stackProgName (stackArgs global) "test --flag stack:integration-tests"
161+
() <- cmd opt stackProgName (stackArgs global) "build --pedantic"
162+
() <- cmd opt stackProgName (stackArgs global) "test --pedantic --flag stack:integration-tests"
163163
return ())
164164
(renameFile tmpExeFile instExeFile)
165165
copyFileChanged (installBinDir </> stackOrigExeFileName) out
166166

167167
releaseDir </> binaryExeZipFileName %> \out -> do
168-
need [releaseDir </> binaryExeFileName]
169-
putNormal $ "zip " ++ (releaseDir </> binaryExeFileName)
168+
stageFiles <- getStageFiles
169+
putNormal $ "zip " ++ out
170170
liftIO $ do
171-
entry <- Zip.readEntry [] (releaseDir </> binaryExeFileName)
172-
let entry' = entry{Zip.eRelativePath = binaryExeFileName}
173-
archive = Zip.addEntryToArchive entry' Zip.emptyArchive
171+
entries <- forM stageFiles $ \stageFile -> do
172+
Zip.readEntry
173+
[Zip.OptLocation
174+
(dropDirectoryPrefix (releaseDir </> binaryExeStageDirName) stageFile)
175+
False]
176+
stageFile
177+
let archive = foldr Zip.addEntryToArchive Zip.emptyArchive entries
174178
L8.writeFile out (Zip.fromArchive archive)
175179

176180
releaseDir </> binaryExeTarGzFileName %> \out -> do
177-
need [releaseDir </> binaryExeFileName]
178-
putNormal $ "tar gzip " ++ (releaseDir </> binaryExeFileName)
181+
stageFiles <- getStageFiles
182+
putNormal $ "tar gzip " ++ out
179183
liftIO $ do
180-
content <- Tar.pack releaseDir [binaryExeFileName]
184+
content <- Tar.pack releaseDir $
185+
map (dropDirectoryPrefix releaseDir) stageFiles
181186
L8.writeFile out $ GZip.compress $ Tar.write content
182187

188+
releaseDir </> binaryExeStageDirName </> binaryExeFileName %> \out -> do
189+
copyFile' (releaseDir </> binaryExeFileName) out
190+
191+
releaseDir </> (binaryExeStageDirName ++ "//*") %> \out -> do
192+
copyFile'
193+
(dropDirectoryPrefix (releaseDir </> binaryExeStageDirName) out)
194+
out
195+
183196
releaseDir </> binaryExeFileName %> \out -> do
184197
need [installBinDir </> stackOrigExeFileName]
185198
case platformOS of
@@ -202,7 +215,7 @@ rules global@Global{..} args = do
202215

203216
installBinDir </> stackOrigExeFileName %> \_ -> do
204217
alwaysRerun
205-
cmd stackProgName (stackArgs global) "build"
218+
cmd stackProgName (stackArgs global) "build --pedantic"
206219

207220
forM_ distros $ \distro0 -> do
208221

@@ -256,6 +269,16 @@ rules global@Global{..} args = do
256269
writeFileChanged out =<< readTemplate (distroTemplateDir dvDistro </> "docker/run.sh")
257270

258271
where
272+
273+
getStageFiles = do
274+
docs <- getDirectoryFiles rootDir
275+
["LICENSE", "*.md", "doc//*"]
276+
let stageFiles = concat
277+
[[releaseDir </> binaryExeStageDirName </> binaryExeFileName]
278+
,map ((releaseDir </> binaryExeStageDirName) </>) docs]
279+
need stageFiles
280+
return stageFiles
281+
259282
distroVersionFromPath path =
260283
case stripPrefix (releaseDir ++ "/") path of
261284
Nothing -> error ("Cannot determine Ubuntu version from path: " ++ path)
@@ -284,6 +307,7 @@ rules global@Global{..} args = do
284307
_ -> binaryExeTarGzFileName
285308
binaryExeZipFileName = binaryName global <.> zipExt
286309
binaryExeTarGzFileName = binaryName global <.> tarGzExt
310+
binaryExeStageDirName = binaryName global
287311
binaryExeFileName = stackOrigExeFileName
288312
stackOrigExeFileName = stackProgName <.> exe
289313
distroPackageFileName distro
@@ -457,6 +481,14 @@ callGithubApi Global{..} headers mpostFile url = do
457481
res <- http req manager
458482
responseBody res $$+- CC.sinkLazy
459483

484+
-- | Drops a directory prefix from a path. The prefix automatically has a path
485+
-- separator character appended. Fails if the path does not begin with the prefix.
486+
dropDirectoryPrefix :: FilePath -> FilePath -> FilePath
487+
dropDirectoryPrefix prefix path =
488+
case stripPrefix (prefix ++ "/") path of
489+
Nothing -> error ("dropDirectoryPrefix: cannot drop " ++ show prefix ++ " from " ++ show path)
490+
Just stripped -> stripped
491+
460492
-- | Build a Docker image and write its ID to a file if changed.
461493
buildDockerImage :: FilePath -> String -> FilePath -> Action String
462494
buildDockerImage buildDir imageTag out = do
@@ -497,6 +529,10 @@ platformOS =
497529
releaseDir :: FilePath
498530
releaseDir = "_release"
499531

532+
-- | Root directory of the project
533+
rootDir :: FilePath
534+
rootDir = "."
535+
500536
-- | @GITHUB_AUTH_TOKEN@ environment variale name.
501537
githubAuthTokenEnvVar :: String
502538
githubAuthTokenEnvVar = "GITHUB_AUTH_TOKEN"

0 commit comments

Comments
 (0)