Git: patch to make git relocatable with buildcache. (#11596)

* Apply patch to git to make it search for config files from its current location instead of the locations hard coded at install.

* Add provenance info for patch

* Pass needed flags to make

* Environment variables need because of relocation
This commit is contained in:
Patrick Gartung 2019-05-31 15:38:40 -05:00 committed by GitHub
parent 88473a8da3
commit 30ec13f375
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 58 additions and 0 deletions

View File

@ -185,6 +185,16 @@ class Git(AutotoolsPackage):
depends_on('m4', type='build')
depends_on('tk', type=('build', 'link'), when='+tcltk')
patch('patch/relocatable.patch', 0)
build_targets = ['NO_INSTALL_HARDLINKS=1',
'ETC_GITATTRIBUTES=config',
'ETC_GITCONFIG=config']
install_targets = ['NO_INSTALL_HARDLINKS=1',
'ETC_GITATTRIBUTES=config',
'ETC_GITCONFIG=config',
'install']
# See the comment in setup_environment re EXTLIBS.
def patch(self):
filter_file(r'^EXTLIBS =$',
@ -209,6 +219,12 @@ def setup_environment(self, spack_env, run_env):
spack_env.append_flags('CFLAGS', '-I{0}'.format(
self.spec['gettext'].prefix.include))
run_env.set('GIT_EXEC_PATH', '%s/git-core' % self.spec.prefix.libexec)
run_env.set('GIT_TEMPLATE_DIR', '%s/git-core/templates' %
self.spec.prefix.share)
run_env.set('GIT_HOME', '%s' % self.spec.prefix)
run_env.set('GITPERLLIB', '%s/perl5' % self.spec.prefix.share)
def configure_args(self):
spec = self.spec

View File

@ -0,0 +1,42 @@
# Copied from https://cdcvs.fnal.gov/redmine/projects/build-framework/repository/git-ssi-build/revisions/master/entry/patch/git.patch
# curl -o relocatable.patch https://cdcvs.fnal.gov/redmine/projects/build-framework/repository/git-ssi-build/revisions/master/raw/patch/git.patch
diff -Naur config.c config.c
--- config.c 2015-07-15 14:31:07.000000000 -0500
+++ config.c 2015-07-17 10:33:34.966072446 -0500
@@ -1153,7 +1153,15 @@
{
static const char *system_wide;
if (!system_wide)
- system_wide = system_path(ETC_GITCONFIG);
+ /* system_wide = system_path(ETC_GITCONFIG); */
+ system_wide = ETC_GITCONFIG;
+ if (!is_absolute_path(system_wide)) {
+ /* interpret path relative to exec-dir */
+ const char *exec_path = git_exec_path();
+ system_wide = prefix_path(exec_path, strlen(exec_path),
+ system_wide);
+ }
+
return system_wide;
}
diff -Naur attr.c attr.c
--- attr.c 2015-07-15 14:31:07.000000000 -0500
+++ attr.c 2015-07-17 10:33:34.966072446 -0500
@@ -479,7 +479,15 @@
{
static const char *system_wide;
if (!system_wide)
- system_wide = system_path(ETC_GITATTRIBUTES);
+ /* system_wide = system_path(ETC_GITATTRIBUTES); */
+ system_wide = ETC_GITATTRIBUTES;
+ if (!is_absolute_path(system_wide)) {
+ /* interpret path relative to exec-dir */
+ const char *exec_path = git_exec_path();
+ system_wide = prefix_path(exec_path, strlen(exec_path),
+ system_wide);
+ }
+
return system_wide;
}