From 4c8ca387f7557267e9996c8cff54192f0dfb4f70 Mon Sep 17 00:00:00 2001 From: brandon s allbery kf8nh Date: Tue, 31 Dec 2024 09:45:07 -0500 Subject: [PATCH 1/3] try to figure out why static builds lack git info --- .github/workflows/validate.yml | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index daa0811440d..c98913de8f7 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -336,7 +336,11 @@ jobs: apk add bash curl sudo jq pkgconfig \ zlib-dev zlib-static binutils-gold curl \ gcc g++ gmp-dev libc-dev libffi-dev make \ - musl-dev ncurses-dev perl tar xz + musl-dev ncurses-dev perl tar xz git + + # Apparently there's some permissions thing inside vs. outside the container + # that Alpine's git doesn't like. Hack around it. + - run: git config --global --add safe.directory $(pwd) - uses: actions/checkout@v4 @@ -368,9 +372,18 @@ jobs: run: | echo 'executable-static: true' >> cabal.validate.project + # Try to figure out why we have no git info, part 1 + - run: git status + - name: Build run: sh validate.sh $FLAGS -s build + # Try to figure out why we have no git info, part 2 + - run: | + if $(cabal list-bin --builddir=dist-newstyle-validate-ghc-${{ env.GHC_FOR_RELEASE }} --project-file=cabal.validate.project cabal-install:exe:cabal) --version 2>&1 | grep ' , '; then + exit 1 + fi + - name: Tar cabal head executable run: | CABAL_EXEC=$(cabal list-bin --builddir=dist-newstyle-validate-ghc-${{ env.GHC_FOR_RELEASE }} --project-file=cabal.validate.project cabal-install:exe:cabal) From 7ceac059a66bc11dda10defce97cfeafca5e3ee4 Mon Sep 17 00:00:00 2001 From: brandon s allbery kf8nh Date: Tue, 31 Dec 2024 10:36:01 -0500 Subject: [PATCH 2/3] degrade gracefully if no git information available --- Cabal/src/Distribution/Simple/Utils.hs | 18 ++++++++++-------- .../src/Distribution/Client/Version.hs | 16 +++++++++------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/Cabal/src/Distribution/Simple/Utils.hs b/Cabal/src/Distribution/Simple/Utils.hs index bdbb72435a3..81763cca8fd 100644 --- a/Cabal/src/Distribution/Simple/Utils.hs +++ b/Cabal/src/Distribution/Simple/Utils.hs @@ -311,16 +311,18 @@ cabalVersion = mkVersion [3,0] --used when bootstrapping -- | -- `Cabal` Git information. Only filled in if built in a Git tree in --- developmnent mode and Template Haskell is available. +-- development mode and Template Haskell is available. cabalGitInfo :: String #ifdef GIT_REV -cabalGitInfo = concat [ "(commit " - , giHash' - , branchInfo - , ", " - , either (const "") giCommitDate gi' - , ")" - ] +cabalGitInfo = if giHash' == "" + then "" + else concat [ "(commit " + , giHash' + , branchInfo + , ", " + , either (const "") giCommitDate gi' + , ")" + ] where gi' = $$tGitInfoCwdTry giHash' = take 7 . either (const "") giHash $ gi' diff --git a/cabal-install/src/Distribution/Client/Version.hs b/cabal-install/src/Distribution/Client/Version.hs index e50f4231090..14a3c166f63 100644 --- a/cabal-install/src/Distribution/Client/Version.hs +++ b/cabal-install/src/Distribution/Client/Version.hs @@ -33,13 +33,15 @@ cabalInstallVersion = mkVersion' PackageInfo.version -- developmnent mode and Template Haskell is available. cabalInstallGitInfo :: String #ifdef GIT_REV -cabalInstallGitInfo = concat [ "(commit " - , giHash' - , branchInfo - , ", " - , either (const "") giCommitDate gi' - , ")" - ] +cabalInstallGitInfo = if giHash' == "" + then "" + else concat [ "(commit " + , giHash' + , branchInfo + , ", " + , either (const "") giCommitDate gi' + , ")" + ] where gi' = $$tGitInfoCwdTry giHash' = take 7 . either (const "") giHash $ gi' From 78f5dc52e11ef7ebd48f7f925852413fff15cb49 Mon Sep 17 00:00:00 2001 From: brandon s allbery kf8nh Date: Tue, 31 Dec 2024 11:28:14 -0500 Subject: [PATCH 3/3] amend! try to figure out why static builds lack git info try to figure out why static builds lack git info --- .github/workflows/validate.yml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index c98913de8f7..eee95cba005 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -372,18 +372,9 @@ jobs: run: | echo 'executable-static: true' >> cabal.validate.project - # Try to figure out why we have no git info, part 1 - - run: git status - - name: Build run: sh validate.sh $FLAGS -s build - # Try to figure out why we have no git info, part 2 - - run: | - if $(cabal list-bin --builddir=dist-newstyle-validate-ghc-${{ env.GHC_FOR_RELEASE }} --project-file=cabal.validate.project cabal-install:exe:cabal) --version 2>&1 | grep ' , '; then - exit 1 - fi - - name: Tar cabal head executable run: | CABAL_EXEC=$(cabal list-bin --builddir=dist-newstyle-validate-ghc-${{ env.GHC_FOR_RELEASE }} --project-file=cabal.validate.project cabal-install:exe:cabal)