Skip to content

Commit

Permalink
Use commit sha in stack-bootstrap.yaml
Browse files Browse the repository at this point in the history
Latest stack doesn't seem to support named commits such as 'master'.

Get the commit sha from `git rev-parse` and append it to the yaml file.

This doesn't fix google#391 but
goes one step further. We still get an error like:

$ stack runghc -- bootstrap.hs
Cloning 0bef8c2 from https://github.com/google/proto-lens
Unsupported tarball from /tmp/with-repo-archive189930/foo.tar: Symbolic link dest not found from proto-lens/proto-lens-imports/google to ../../google/protobuf/src/google, looking for proto-lens/../google/protobuf/src/google.
This may indicate that the source is a git archive which uses git-annex.
See commercialhaskell/stack#4579 for further information.
bootstrap.hs: readCreateProcess: stack "--stack-yaml=stack-bootstrap.yaml" "path" "--local-install-root" (exit 1): failed
  • Loading branch information
jinwoo committed Jun 3, 2020
1 parent 0bef8c2 commit 0b86bd0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
19 changes: 17 additions & 2 deletions bootstrap.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,35 @@
-- Note: if this doesn't work, you may need to edit the "location" field in
-- stack-boostrap.yaml.
import Control.Applicative ((<$>))
import Control.Exception (bracket_)
import System.FilePath ((</>))
import System.Process (callProcess, readProcess)

protoRoot :: String
protoRoot = "google/protobuf/src"

protoc :: String
protoc = "protoc"

bootstrapModuleRoot :: String
bootstrapModuleRoot = "proto-lens-protoc/app"
useBootstrappingYaml = "--stack-yaml=stack-bootstrap.yaml"

bootstrappingYaml :: FilePath
bootstrappingYaml = "stack-bootstrap.yaml"

useBootstrappingYaml :: String
useBootstrappingYaml = "--stack-yaml=" ++ bootstrappingYaml

-- Change this to build with an older version of stack.
-- TODO: remove this after we can use stack v2 (#332).
stack :: String
stack = "stack"

-- This should match (or at least be API-compatible with) the value of bootstrapCommit
-- in stack-bootstrap.yaml.
bootstrapCommit :: String
bootstrapCommit = "master"

main :: IO ()
main = do
-- 1. Temporarily replace the bootstrap proto bindings in proto-lens-protoc
-- with an older version that's compatible with the bootstrap version of
Expand All @@ -35,6 +47,9 @@ main = do
-- overwriting the previous versions.
callProcess "git" ["checkout", bootstrapCommit, "--",
bootstrapModuleRoot </> "Proto"]
[sha] <- lines <$> readProcess "git" ["rev-parse", bootstrapCommit] ""
-- Append the bootstrapping commit hash to the yaml file.
appendFile bootstrappingYaml (" commit: " ++ sha ++ "\n")
[installRoot] <- lines <$> readProcess stack
[useBootstrappingYaml, "path", "--local-install-root"] ""
let protocGenHaskell = installRoot </> "bin/proto-lens-protoc"
Expand Down
6 changes: 2 additions & 4 deletions stack-bootstrap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ packages:
extra-deps:
- ghc-source-gen-0.4.0.0
- git: https://github.com/google/proto-lens
# To use the current repository:
# git: ../.. # stack runs 'git clone' in a subdirectory
# Note: this commit should match the value of bootstrapCommit in bootstrap.hs
commit: master
subdirs:
- proto-lens
- proto-lens-runtime
# A line like below will be appended by bootstrap.hs.
# commit: 0bef8c2f3da645f068b8a26ac168c1da41608182

0 comments on commit 0b86bd0

Please sign in to comment.