Opened 13 months ago

Last modified 11 months ago

#15538 patch bug

GHC boot script can't handle Git remote not named origin

Reported by: ChaiTRex Owned by: ChaiTRex
Priority: normal Milestone: 8.6.1
Component: Build System (make) Version:
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Building GHC failed Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s): Phab:D5077
Wiki Page:

Description (last modified by ChaiTRex)

Problem

I ran the following to get the sources for GHC to build them:

git clone -o ghc --recursive http://git.haskell.org/ghc.git

Note especially the -o ghc part, which uses the Git remote name ghc instead of the default origin. When a custom remote name is used, ./boot fails:

$ ./boot
Traceback (most recent call last):
  File "./boot", line 193, in <module>
    check_for_url_rewrites()
  File "./boot", line 29, in check_for_url_rewrites
    subprocess.check_output('git config remote.origin.url'.split()).find(b'github.com') != -1 and \
  File "/usr/lib/python3.5/subprocess.py", line 626, in check_output
    **kwargs).stdout
  File "/usr/lib/python3.5/subprocess.py", line 708, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['git', 'config', 'remote.origin.url']' returned non-zero exit status 1

$ git config remote.origin.url

$ echo $?
1

Solution

git config remote.origin.url can be used first. Whenever git config remote.origin.url fails, a git rev-parse command (thanks to freenode/#git/_ikke_ for it) can be used to get the remote name and branch that would be pushed to:

$ git rev-parse --symbolic-full-name --abbrev-ref @{upstream}
ghc/coercible

$ git rev-parse --symbolic-full-name --abbrev-ref @{upstream} | sed 's/\/.*$//'
ghc

$ git config "remote.$( git rev-parse --symbolic-full-name --abbrev-ref @{upstream} | sed 's/\/.*$//' ).url"
http://git.haskell.org/ghc.git

Workaround

Rename the remote to origin:

$ git remote rename "$( git config branch.master.remote )" origin
$ ./boot
Creating libraries/mtl/ghc.mk
Creating libraries/unix/ghc.mk
Creating libraries/text/ghc.mk
⋮

Change History (7)

comment:1 Changed 13 months ago by ChaiTRex

Description: modified (diff)

comment:2 Changed 13 months ago by ChaiTRex

Description: modified (diff)
Summary: GHC boot script can't handle Git origin not named originGHC boot script can't handle Git remote not named origin

[Solution in report above fixed for custom branch selection]

comment:3 Changed 13 months ago by ChaiTRex

Description: modified (diff)

comment:4 Changed 13 months ago by ChaiTRex

Owner: set to ChaiTRex

comment:5 Changed 13 months ago by ChaiTRex

Differential Rev(s): Phab:D5077

comment:6 Changed 13 months ago by ChaiTRex

Status: newpatch

comment:7 Changed 11 months ago by bgamari

Component: Build SystemBuild System (make)

The new Hadrian build system has been merged. Relabeling the tickets concerning the legacy make build system to prevent confusion.

Note: See TracTickets for help on using tickets.