From 0b86bd081fceca4e0af8f747eb9d3fe2806964ed Mon Sep 17 00:00:00 2001 From: Jinwoo Lee Date: Wed, 3 Jun 2020 13:44:06 -0700 Subject: [PATCH] Use commit sha in stack-bootstrap.yaml 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 https://github.com/google/proto-lens/issues/391 but goes one step further. We still get an error like: $ stack runghc -- bootstrap.hs Cloning 0bef8c2f3da645f068b8a26ac168c1da41608182 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 https://github.com/commercialhaskell/stack/issues/4579 for further information. bootstrap.hs: readCreateProcess: stack "--stack-yaml=stack-bootstrap.yaml" "path" "--local-install-root" (exit 1): failed --- bootstrap.hs | 19 +++++++++++++++++-- stack-bootstrap.yaml | 6 ++---- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/bootstrap.hs b/bootstrap.hs index fc400935..1d55ed4f 100755 --- a/bootstrap.hs +++ b/bootstrap.hs @@ -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 @@ -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" diff --git a/stack-bootstrap.yaml b/stack-bootstrap.yaml index b729a885..a30c62ce 100644 --- a/stack-bootstrap.yaml +++ b/stack-bootstrap.yaml @@ -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