diff options
author | Christian Couder <chriscool@tuxfamily.org> | 2020-04-29 11:03:49 +0300 |
---|---|---|
committer | Zeger-Jan van de Weg <git@zjvandeweg.nl> | 2020-04-29 11:03:49 +0300 |
commit | e44103767d8928dca16da5327b4c85bfe2c6eda5 (patch) | |
tree | bef81cd1767dec21d5753c2c51b6f4c2d2c5adcf /_support | |
parent | 3bc638cb3a46b42e9f0b60eed5284dced0e3725a (diff) |
Add download-git target to Makefile
The new 'download-git' target can be used like this:
$ make GIT_REV=test-next download-git
to download a tarball from:
https://gitlab.com/gitlab-org/gitlab-git/-/jobs/artifacts/test-next/raw/git_full_bins.tgz?job=build
Diffstat (limited to '_support')
-rw-r--r-- | _support/Makefile.template | 18 | ||||
-rw-r--r-- | _support/makegen.go | 62 |
2 files changed, 80 insertions, 0 deletions
diff --git a/_support/Makefile.template b/_support/Makefile.template index feae6dcce..672331bc7 100644 --- a/_support/Makefile.template +++ b/_support/Makefile.template @@ -285,3 +285,21 @@ no-changes: smoke-test: all rspec @cd {{ .SourceDir }} && go test ./internal/rubyserver + +.PHONY: download-git +download-git: + @echo "Getting Git from {{ .GitArtifactUrl }}" + wget -P {{ .BuildDir }} -O {{ .GitBuildTarball }} {{ .GitArtifactUrl }} + rm -rf {{ .GitInstallDir }} + mkdir -p {{ .GitInstallDir }} + tar -C {{ .GitInstallDir }} -xvzf {{ .BuildDir }}/{{ .GitBuildTarball }} + +.PHONY: build-git +build-git: + @echo "Getting Git from {{ .GitDefaultRepoUrl }}" + rm -rf {{ .GitSourceDir }} {{ .GitInstallDir }} + git clone {{ .GitDefaultRepoUrl }} {{ .GitSourceDir }} + git -C {{ .GitSourceDir }} checkout {{ .GitDefaultRev }} + rm -rf {{ .GitInstallDir }} + mkdir -p {{ .GitInstallDir }} + $(MAKE) -C {{ .GitSourceDir }} prefix={{ .GitDefaultPrefix }} {{ .GitBuildOptions }} install diff --git a/_support/makegen.go b/_support/makegen.go index 57b6e39dc..a821d0da7 100644 --- a/_support/makegen.go +++ b/_support/makegen.go @@ -326,6 +326,68 @@ func (gm *gitalyMake) IsGDK() bool { return err == nil } +// Variables used with Git + +func (gm *gitalyMake) GitDefaultRev() string { + rev := os.Getenv("GIT_REV") + if rev != "" { + return rev + } + return "master" +} + +func (gm *gitalyMake) GitDefaultBuildJob() string { + job := os.Getenv("GIT_BUILD_JOB") + if job != "" { + return job + } + return "build" +} + +func (gm *gitalyMake) GitInstallDir() string { return filepath.Join(gm.BuildDir(), "git") } +func (gm *gitalyMake) GitBuildTarball() string { return "git_full_bins.tgz"} + +func (gm *gitalyMake) GitArtifactUrl() string { + return "https://gitlab.com/gitlab-org/gitlab-git/-/jobs/artifacts/" + + gm.GitDefaultRev() + "/raw/" + + gm.GitBuildTarball() + "?job=" + + gm.GitDefaultBuildJob() +} + +func (gm *gitalyMake) GitDefaultRepoUrl() string { + url := os.Getenv("GIT_REPO_URL") + if url != "" { + return url + } + return "https://gitlab.com/gitlab-org/gitlab-git.git" +} + +func (gm *gitalyMake) GitSourceDir() string { return filepath.Join(gm.BuildDir(), "src", "git") } + +func (gm *gitalyMake) GitBuildOptions() string { + buildOptions := []string{ + "-j 8", // use multiple parallele jobs + "DEVELOPER=1", // activate developer checks + "CFLAGS='-O0 -g3'", // make it easy to debug in case of crashes + "NO_PERL=YesPlease", + "NO_EXPAT=YesPlease", + "NO_TCLTK=YesPlease", + "NO_GETTEXT=YesPlease", + "NO_PYTHON=YesPlease", + "NO_INSTALL_HARDLINKS=YesPlease", + "NO_R_TO_GCC_LINKER=YesPlease", + } + return strings.Join(buildOptions, " ") +} + +func (gm *gitalyMake) GitDefaultPrefix() string { + prefix := os.Getenv("GIT_PREFIX") + if prefix != "" { + return prefix + } + return gm.GitInstallDir() +} + var templateText = func() string { contents, err := ioutil.ReadFile("../_support/Makefile.template") if err != nil { |