Skip to contentSkip to conversation

RUNTIME_PREFIX relocatable Git

PATCH Superseded Dan Jacques 3 participants 12 messages Nov 27, 2017 – Nov 29, 2017 Kbuild

v3 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

v3 cover RUNTIME_PREFIX relocatable Git

Previous threads:
v1: https://public-inbox.org/git/[email protected]/
v2: https://public-inbox.org/git/[email protected]/

After working with avarab@, I isolated the Perl changes into a separate set of patches and adapted the code to be more correct and readable. I opted to prescribe a relative Perl library path instead of letting MakeMaker or the Config module choose one, since the latter both incorporate build system parameters and a major purpose of this is to be portable between ABI-compatible systems.

I've tested this via Travis and run full test suite with and without RUNTIME_PREFIX/RUNTIME_PREFIX_PERL, and tested locally on Mac, Linux, and FreeBSD systems. Please take a look!

Built using this "config.mak":

=== BEGIN config.mak ===

RUNTIME_PREFIX = YesPlease
RUNTIME_PREFIX_PERL = YesPlease
gitexecdir = libexec/git-core
template_dir = share/git-core/templates
sysconfdir = etc

=== END config.mak ===

Changes in v3 from v2:

- Broken into multiple patches now that Perl is isolated in its own RUNTIME_PREFIX_PERL flag.

- Working with avarab@, several changes to Perl script runtime prefix support:

- Moved Perl header body content from Makefile into external template

    file(s).

- Added generic "perllibdir" variable to override Perl installation path.

- RUNTIME_PREFIX_PERL generated script header is more descriptive and consistent with how the C version operates.

- Fixed Generated Perl header Makefile dependency, should rebuild when dependent files and flags change.

- Changed some of the new RUNTIME_PREFIX trace strings to use consistent formatting and terminology.

Changes in v2 from v1:

- Added comments and formatting to improve readability of platform-sepecific executable path resolution sleds in git_get_exec_path.

- Consolidated "cached_exec_path" and "argv_exec_path" globals into "exec_path_value".

- Use strbuf_realpath instead of realpath for procfs resolution.

- Removed new environment variable exports. Git with RUNTIME_PREFIX no longer exports or consumes any additional environment information.

- Updated Perl script resolution strategy: rather than having Git export the relative executable path to the Perl scripts, they now resolve it independently when RUNTIME_PREFIX_PERL is enabled.

- Updated resolution strategy for "gettext()": use system_path() instead of special environment variable.

- Added sysctl executable resolution support for BSDs that don't mount "procfs" by default (most of them).

Dan Jacques (4):
Makefile: generate Perl header from template file
Makefile: add support for "perllibdir"
Makefile: add Perl runtime prefix support
exec_cmd: RUNTIME_PREFIX on some POSIX systems

 .gitignore                             |   1 +
 Makefile                               | 110 +++++++++++++--
 cache.h                                |   1 +
 common-main.c                          |   4 +-
 config.mak.uname                       |   7 +
 exec_cmd.c                             | 239 ++++++++++++++++++++++++++++-----
 exec_cmd.h                             |   4 +-
 gettext.c                              |   8 +-
 git.c                                  |   2 +-
 perl/Makefile                          |  52 ++++++-
 perl/header_fixed_prefix.pl.template   |   1 +
 perl/header_runtime_prefix.pl.template |  24 ++++
 12 files changed, 395 insertions(+), 58 deletions(-)
 create mode 100644 perl/header_fixed_prefix.pl.template
 create mode 100644 perl/header_runtime_prefix.pl.template
Signature · 1 line
2.15.0.chromium12
#1 lore raw

PATCH v3 1/4 Makefile: generate Perl header from template file

Currently, the generated Perl script headers are emitted by commands in the Makefile. This mechanism restricts options to introduce alternative header content, needed by Perl runtime prefix support, and obscures the origin of the Perl script header.

Change the Makefile to generate a header by processing a template file and move the header content into the "perl/" subdirectory. The processed generated will now be stored in the "GIT-PERL-HEADER" file. This allows the content of the Perl header to be controlled by changing the path of the template in the Makefile.

---
 .gitignore                           |  1 +
 Makefile                             | 23 ++++++++++++++---------
 perl/header_fixed_prefix.pl.template |  1 +
 3 files changed, 16 insertions(+), 9 deletions(-)
 create mode 100644 perl/header_fixed_prefix.pl.template
.gitignore +1 -0
index 833ef3b0b..89bd7bd8a 100644
@@ -3,6 +3,7 @@
 /GIT-LDFLAGS
 /GIT-PREFIX
 /GIT-PERL-DEFINES
+/GIT-PERL-HEADER
 /GIT-PYTHON-VARS
 /GIT-SCRIPT-DEFINES
 /GIT-USER-AGENT
Makefile +14 -9
index e53750ca0..5ad60a54c 100644
@@ -1964,18 +1964,15 @@ perl/PM.stamp: FORCE
 perl/perl.mak: GIT-CFLAGS GIT-PREFIX perl/Makefile perl/Makefile.PL
 	$(QUIET_SUBDIR0)perl $(QUIET_SUBDIR1) PERL_PATH='$(PERL_PATH_SQ)' prefix='$(prefix_SQ)' $(@F)
 
+PERL_HEADER_TEMPLATE = perl/header_fixed_prefix.pl.template
 PERL_DEFINES = $(PERL_PATH_SQ):$(PERLLIB_EXTRA_SQ)
-$(SCRIPT_PERL_GEN): % : %.perl perl/perl.mak GIT-PERL-DEFINES GIT-VERSION-FILE
+
+$(SCRIPT_PERL_GEN): % : %.perl perl/perl.mak GIT-PERL-DEFINES GIT-PERL-HEADER GIT-VERSION-FILE
 	$(QUIET_GEN)$(RM) $@ $@+ && \
-	INSTLIBDIR=`MAKEFLAGS= $(MAKE) -C perl -s --no-print-directory instlibdir` && \
-	INSTLIBDIR_EXTRA='$(PERLLIB_EXTRA_SQ)' && \
-	INSTLIBDIR="$$INSTLIBDIR$${INSTLIBDIR_EXTRA:+:$$INSTLIBDIR_EXTRA}" && \
 	sed -e '1{' \
 	    -e '	s|#!.*perl|#!$(PERL_PATH_SQ)|' \
-	    -e '	h' \
-	    -e '	s=.*=use lib (split(/$(pathsep)/, $$ENV{GITPERLLIB} || "'"$$INSTLIBDIR"'"));=' \
-	    -e '	H' \
-	    -e '	x' \
+	    -e '	rGIT-PERL-HEADER' \
+	    -e '	G' \
 	    -e '}' \
 	    -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
 	    $< >$@+ && \
@@ -1989,6 +1986,14 @@ GIT-PERL-DEFINES: FORCE
 		echo "$$FLAGS" >$@; \
 	    fi
 
+GIT-PERL-HEADER: $(PERL_HEADER_TEMPLATE) GIT-PERL-DEFINES perl/perl.mak
+	$(QUIET_GEN)$(RM) $@ && \
+	INSTLIBDIR=`MAKEFLAGS= $(MAKE) -C perl -s --no-print-directory instlibdir` && \
+	INSTLIBDIR_EXTRA='$(PERLLIB_EXTRA_SQ)' && \
+	INSTLIBDIR="$$INSTLIBDIR$${INSTLIBDIR_EXTRA:+:$$INSTLIBDIR_EXTRA}" && \
+	sed -e 's=@@PATHSEP@@='$(pathsep)'=g' \
+	    -e 's=@@INSTLIBDIR@@='$$INSTLIBDIR'=g' \
+	    $< >$@
 
 .PHONY: gitweb
 gitweb:
@@ -2707,7 +2712,7 @@ ifndef NO_TCLTK
 endif
 	$(RM) GIT-VERSION-FILE GIT-CFLAGS GIT-LDFLAGS GIT-BUILD-OPTIONS
 	$(RM) GIT-USER-AGENT GIT-PREFIX
-	$(RM) GIT-SCRIPT-DEFINES GIT-PERL-DEFINES GIT-PYTHON-VARS
+	$(RM) GIT-SCRIPT-DEFINES GIT-PERL-DEFINES GIT-PERL-HEADER GIT-PYTHON-VARS
 
 .PHONY: all install profile-clean clean strip
 .PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell
perl/header_fixed_prefix.pl.template new file +1 -0
new file mode 100644
index 000000000..9a4bc4d30
@@ -0,0 +1 @@
+use lib (split(/@@PATHSEP@@/, $ENV{GITPERLLIB} || "@@INSTLIBDIR@@"));
Signature · 1 line
2.15.0.chromium12
#2 lore raw

PATCH v3 2/4 Makefile: add support for "perllibdir"

In reply to Dan Jacques

Add the "perllibdir" Makefile variable, which allows the customization of the Perl library installation path.

The Perl library installation path is currently left entirely to the Perl Makefile implementation, either MakeMaker (default) or a fixed path when NO_PERL_MAKEMAKER is enabled. This patch introduces "perllibdir", a Makefile variable that can override that Perl module installation path.

As with some other Makefile variables, "perllibdir" may be either absolute or relative. In the latter case, it is treated as relative to "$(prefix)".

Add some incidental documentation to perl/Makefile.

Explicitly specifying an installation path is necessary for Perl runtime prefix support, as runtime prefix resolution code must know in advance where the Perl support modules are installed.

---
 Makefile      | 18 +++++++++++++-----
 perl/Makefile | 52 ++++++++++++++++++++++++++++++++++++++++++++++------
 2 files changed, 59 insertions(+), 11 deletions(-)
Makefile +13 -5
index 5ad60a54c..7a2ed8857 100644
@@ -462,6 +462,7 @@ ARFLAGS = rcs
 #   mandir
 #   infodir
 #   htmldir
+#   perllibdir
 # This can help installing the suite in a relocatable way.
 
 prefix = $(HOME)
@@ -1721,6 +1722,7 @@ gitexecdir_SQ = $(subst ','\'',$(gitexecdir))
 template_dir_SQ = $(subst ','\'',$(template_dir))
 htmldir_relative_SQ = $(subst ','\'',$(htmldir_relative))
 prefix_SQ = $(subst ','\'',$(prefix))
+perllibdir_SQ = $(subst ','\'',$(perllibdir))
 gitwebdir_SQ = $(subst ','\'',$(gitwebdir))
 
 SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
@@ -1955,17 +1957,22 @@ $(SCRIPT_PERL_GEN): perl/perl.mak
 
 perl/perl.mak: perl/PM.stamp
 
-perl/PM.stamp: FORCE
+perl/PM.stamp: GIT-PERL-DEFINES FORCE
 	@$(FIND) perl -type f -name '*.pm' | sort >$@+ && \
+	cat GIT-PERL-DEFINES >>$@+ && \
 	$(PERL_PATH) -V >>$@+ && \
 	{ cmp $@+ $@ >/dev/null 2>/dev/null || mv $@+ $@; } && \
 	$(RM) $@+
 
-perl/perl.mak: GIT-CFLAGS GIT-PREFIX perl/Makefile perl/Makefile.PL
-	$(QUIET_SUBDIR0)perl $(QUIET_SUBDIR1) PERL_PATH='$(PERL_PATH_SQ)' prefix='$(prefix_SQ)' $(@F)
-
 PERL_HEADER_TEMPLATE = perl/header_fixed_prefix.pl.template
-PERL_DEFINES = $(PERL_PATH_SQ):$(PERLLIB_EXTRA_SQ)
+
+PERL_DEFINES := $(PERL_PATH_SQ) $(PERLLIB_EXTRA_SQ)
+PERL_DEFINES += $(NO_PERL_MAKEMAKER)
+PERL_DEFINES += $(perllibdir)
+
+perl/perl.mak: GIT-CFLAGS GIT-PREFIX perl/Makefile perl/Makefile.PL
+	$(QUIET_SUBDIR0)perl $(QUIET_SUBDIR1) PERL_PATH='$(PERL_PATH_SQ)' \
+	  prefix='$(prefix_SQ)' perllibdir='$(perllibdir_SQ)' $(@F)
 
 $(SCRIPT_PERL_GEN): % : %.perl perl/perl.mak GIT-PERL-DEFINES GIT-PERL-HEADER GIT-VERSION-FILE
 	$(QUIET_GEN)$(RM) $@ $@+ && \
@@ -1979,6 +1986,7 @@ $(SCRIPT_PERL_GEN): % : %.perl perl/perl.mak GIT-PERL-DEFINES GIT-PERL-HEADER GI
 	chmod +x $@+ && \
 	mv $@+ $@
 
+PERL_DEFINES := $(subst $(space),:,$(PERL_DEFINES))
 GIT-PERL-DEFINES: FORCE
 	@FLAGS='$(PERL_DEFINES)'; \
 	    if test x"$$FLAGS" != x"`cat $@ 2>/dev/null`" ; then \
perl/Makefile +46 -6

84 lines not on this page · raw message

Signature · 1 line
2.15.0.chromium12
#3 lore raw

PATCH v3 3/4 Makefile: add Perl runtime prefix support

In reply to Dan Jacques

Add a new Makefile flag, RUNTIME_PREFIX_PERL, which, when enabled, configures Perl scripts to locate the Git installation's Perl support libraries by resolving against the script's path, rather than hard-coding that path at build-time.

Enabling RUNTIME_PREFIX_PERL overrides the system-specific Perl script installation path generated by MakeMaker to force installation into a platform-neutral location, "<prefix>/share/perl5".

This change enables Git's Perl scripts to work when their Git installation is relocated or moved to another system.

---
 Makefile                               | 40 +++++++++++++++++++++++++++++++++-
 perl/header_runtime_prefix.pl.template | 24 ++++++++++++++++++++
 2 files changed, 63 insertions(+), 1 deletion(-)
 create mode 100644 perl/header_runtime_prefix.pl.template
Makefile +39 -1
index 7a2ed8857..a36815b49 100644
@@ -425,6 +425,10 @@ all::
 #
 # to say "export LESS=FRX (and LV=-c) if the environment variable
 # LESS (and LV) is not set, respectively".
+#
+# Define RUNTIME_PREFIX_PERL to configure Git's PERL commands to locate Git
+# support libraries relative to their filesystem path instead of hard-coding
+# it.
 
 GIT-VERSION-FILE: FORCE
 	@$(SHELL_PATH) ./GIT-VERSION-GEN
@@ -485,6 +489,7 @@ pathsep = :
 
 mandir_relative = $(patsubst $(prefix)/%,%,$(mandir))
 infodir_relative = $(patsubst $(prefix)/%,%,$(infodir))
+sharedir_relative = $(patsubst $(prefix)/%,%,$(sharedir))
 htmldir_relative = $(patsubst $(prefix)/%,%,$(htmldir))
 
 export prefix bindir sharedir sysconfdir gitwebdir localedir
@@ -1967,7 +1972,38 @@ perl/PM.stamp: GIT-PERL-DEFINES FORCE
 PERL_HEADER_TEMPLATE = perl/header_fixed_prefix.pl.template
 
 PERL_DEFINES := $(PERL_PATH_SQ) $(PERLLIB_EXTRA_SQ)
-PERL_DEFINES += $(NO_PERL_MAKEMAKER)
+PERL_DEFINES += $(NO_PERL_MAKEMAKER) $(RUNTIME_PREFIX_PERL)
+
+# Support Perl runtime prefix. In this mode, a different header is installed
+# into Perl scripts. This header expects both the scripts and their support
+# library to be installed relative to $(prefix), and resolves the path to
+# the Perl libraries (perllibdir) from the executable's current path
+# (gitexecdir).
+#
+# This configuration requires both $(perllibdir) and $(gitexecdir) to be
+# relative paths, and will error if this is not the case.
+ifdef RUNTIME_PREFIX_PERL
+
+PERL_HEADER_TEMPLATE = perl/header_runtime_prefix.pl.template
+PERL_DEFINES += $(gitexecdir)
+
+# RUNTIME_PREFIX_PERL requires a $(perllibdir) value.
+ifeq ($(perllibdir),)
+perllibdir = $(sharedir_relative)/perl5
+endif
+
+ifneq ($(filter /%,$(firstword $(gitexecdir))),)
+$(error RUNTIME_PREFIX_PERL requires a relative $(gitexecdir))
+endif
+gitexecdir_relative_SQ = $(gitexecdir_SQ)
+
+ifneq ($(filter /%,$(firstword $(perllibdir))),)
+$(error RUNTIME_PREFIX_PERL requires a relative perllibdir)
+endif
+perllibdir_relative_SQ = $(perllibdir_SQ)
+
+endif
+
 PERL_DEFINES += $(perllibdir)
 
 perl/perl.mak: GIT-CFLAGS GIT-PREFIX perl/Makefile perl/Makefile.PL
@@ -2001,6 +2037,8 @@ GIT-PERL-HEADER: $(PERL_HEADER_TEMPLATE) GIT-PERL-DEFINES perl/perl.mak
 	INSTLIBDIR="$$INSTLIBDIR$${INSTLIBDIR_EXTRA:+:$$INSTLIBDIR_EXTRA}" && \
 	sed -e 's=@@PATHSEP@@='$(pathsep)'=g' \
 	    -e 's=@@INSTLIBDIR@@='$$INSTLIBDIR'=g' \
+	    -e 's=@@GITEXECDIR@@='$(gitexecdir_relative_SQ)'=g' \
+	    -e 's=@@PERLLIBDIR@@='$(perllibdir_relative_SQ)'=g' \
 	    $< >$@
 
 .PHONY: gitweb
perl/header_runtime_prefix.pl.template new file +24 -0
new file mode 100644
index 000000000..fb9a9924d
@@ -0,0 +1,24 @@
+# BEGIN RUNTIME_PREFIX_PERL generated code.
+#
+# This finds our Git::* libraries relative to the script's runtime path.
+BEGIN {
+	use lib split /@@PATHSEP@@/,
+	(
+		$ENV{GITPERLLIB}
+		||
+		do {
+			require FindBin;
+			require File::Spec;
+			my $gitexecdir_relative = '@@GITEXECDIR@@';
+			my $perllibdir_relative = '@@PERLLIBDIR@@';
+
+			($FindBin::Bin =~ m=${gitexecdir_relative}$=) ||
+			    die('Unrecognized runtime path.');
+			my $prefix = substr($FindBin::Bin, 0, -length($gitexecdir_relative));
+			my $perllibdir = File::Spec->catdir($prefix, $perllibdir_relative);
+			(-e $perllibdir) || die("Invalid library path: $perllibdir");
+			$perllibdir;
+		}
+	);
+}
+# END RUNTIME_PREFIX_PERL generated code.
Signature · 1 line
2.15.0.chromium12
#4 lore raw

PATCH v3 4/4 exec_cmd: RUNTIME_PREFIX on some POSIX systems

In reply to Dan Jacques

Enable Git to resolve its own binary location using a variety of OS-specific and generic methods, including:

- procfs via "/proc/self/exe" (Linux)
- _NSGetExecutablePath (Darwin)
- KERN_PROC_PATHNAME sysctl on BSDs.
- argv0, if absolute (all, including Windows).

This is used to enable RUNTIME_PREFIX support for non-Windows systems, notably Linux and Darwin. When configured with RUNTIME_PREFIX, Git will do a best-effort resolution of its executable path and automatically use this as its "exec_path" for relative helper and data lookups, unless explicitly overridden.

Small incidental formatting cleanup of "exec_cmd.c".

---
 Makefile         |  35 +++++++-
 cache.h          |   1 +
 common-main.c    |   4 +-
 config.mak.uname |   7 ++
 exec_cmd.c       | 239 +++++++++++++++++++++++++++++++++++++++++++++++--------
 exec_cmd.h       |   4 +-
 gettext.c        |   8 +-
 git.c            |   2 +-
 8 files changed, 260 insertions(+), 40 deletions(-)
Makefile +34 -1
index a36815b49..014988318 100644
@@ -416,6 +416,16 @@ all::
 #
 # Define HAVE_BSD_SYSCTL if your platform has a BSD-compatible sysctl function.
 #
+# Define HAVE_BSD_KERN_PROC_SYSCTL if your platform supports the KERN_PROC BSD
+# sysctl function.
+#
+# Define PROCFS_EXECUTABLE_PATH if your platform mounts a "procfs" filesystem
+# capable of resolving the path of the current executable. If defined, this
+# must be the canonical path for the "procfs" current executable path.
+#
+# Define HAVE_NS_GET_EXECUTABLE_PATH if your platform supports calling
+# _NSGetExecutablePath to retrieve the path of the running executable.
+#
 # Define HAVE_GETDELIM if your system has the getdelim() function.
 #
 # Define PAGER_ENV to a SP separated VAR=VAL pairs to define
@@ -426,6 +436,12 @@ all::
 # to say "export LESS=FRX (and LV=-c) if the environment variable
 # LESS (and LV) is not set, respectively".
 #
+# Define RUNTIME_PREFIX to configure Git to resolve its ancillary tooling and
+# support files relative to the location of the runtime binary, rather than
+# hard-coding them into the binary. Git installations built with RUNTIME_PREFIX
+# can be moved to arbitrary filesystem locations. Users may want to enable
+# RUNTIME_PREFIX_PERL as well (see below).
+#
 # Define RUNTIME_PREFIX_PERL to configure Git's PERL commands to locate Git
 # support libraries relative to their filesystem path instead of hard-coding
 # it.
@@ -466,6 +482,7 @@ ARFLAGS = rcs
 #   mandir
 #   infodir
 #   htmldir
+#   localedir
 #   perllibdir
 # This can help installing the suite in a relocatable way.
 
@@ -491,6 +508,7 @@ mandir_relative = $(patsubst $(prefix)/%,%,$(mandir))
 infodir_relative = $(patsubst $(prefix)/%,%,$(infodir))
 sharedir_relative = $(patsubst $(prefix)/%,%,$(sharedir))
 htmldir_relative = $(patsubst $(prefix)/%,%,$(htmldir))
+localedir_relative = $(patsubst $(prefix)/%,%,$(localedir))
 
 export prefix bindir sharedir sysconfdir gitwebdir localedir
 
@@ -1637,10 +1655,23 @@ ifdef HAVE_BSD_SYSCTL
 	BASIC_CFLAGS += -DHAVE_BSD_SYSCTL
 endif
 
+ifdef HAVE_BSD_KERN_PROC_SYSCTL
+	BASIC_CFLAGS += -DHAVE_BSD_KERN_PROC_SYSCTL
+endif
+
 ifdef HAVE_GETDELIM
 	BASIC_CFLAGS += -DHAVE_GETDELIM
 endif
 
+ifneq ($(PROCFS_EXECUTABLE_PATH),)
+	procfs_executable_path_SQ = $(subst ','\'',$(PROCFS_EXECUTABLE_PATH))
+	BASIC_CFLAGS += '-DPROCFS_EXECUTABLE_PATH="$(procfs_executable_path_SQ)"'
+endif
+
+ifdef HAVE_NS_GET_EXECUTABLE_PATH
+	BASIC_CFLAGS += -DHAVE_NS_GET_EXECUTABLE_PATH
+endif
+
 ifeq ($(TCLTK_PATH),)
 NO_TCLTK = NoThanks
 endif
@@ -1723,6 +1754,7 @@ bindir_relative_SQ = $(subst ','\'',$(bindir_relative))
 mandir_relative_SQ = $(subst ','\'',$(mandir_relative))
 infodir_relative_SQ = $(subst ','\'',$(infodir_relative))
 localedir_SQ = $(subst ','\'',$(localedir))
+localedir_relative_SQ = $(subst ','\'',$(localedir_relative))
 gitexecdir_SQ = $(subst ','\'',$(gitexecdir))
 template_dir_SQ = $(subst ','\'',$(template_dir))
 htmldir_relative_SQ = $(subst ','\'',$(htmldir_relative))
@@ -2184,6 +2216,7 @@ endif
 exec_cmd.sp exec_cmd.s exec_cmd.o: GIT-PREFIX
 exec_cmd.sp exec_cmd.s exec_cmd.o: EXTRA_CPPFLAGS = \
 	'-DGIT_EXEC_PATH="$(gitexecdir_SQ)"' \
+	'-DGIT_LOCALE_PATH="$(localedir_relative_SQ)"' \
 	'-DBINDIR="$(bindir_relative_SQ)"' \
 	'-DPREFIX="$(prefix_SQ)"'
 
@@ -2201,7 +2234,7 @@ attr.sp attr.s attr.o: EXTRA_CPPFLAGS = \
 
 gettext.sp gettext.s gettext.o: GIT-PREFIX
 gettext.sp gettext.s gettext.o: EXTRA_CPPFLAGS = \
-	-DGIT_LOCALE_PATH='"$(localedir_SQ)"'
+	-DGIT_LOCALE_PATH='"$(localedir_relative_SQ)"'
 
 http-push.sp http.sp http-walker.sp remote-curl.sp imap-send.sp: SPARSE_FLAGS += \
 	-DCURL_DISABLE_TYPECHECK
cache.h +1 -0
index 2e1434505..3d84aa0bf 100644
@@ -449,6 +449,7 @@ static inline enum object_type object_type(unsigned int mode)
 #define GIT_ICASE_PATHSPECS_ENVIRONMENT "GIT_ICASE_PATHSPECS"
 #define GIT_QUARANTINE_ENVIRONMENT "GIT_QUARANTINE_PATH"
 #define GIT_OPTIONAL_LOCKS_ENVIRONMENT "GIT_OPTIONAL_LOCKS"
+#define GIT_TEXT_DOMAIN_DIR_ENVIRONMENT "GIT_TEXTDOMAINDIR"
 
 /*
  * This environment variable is expected to contain a boolean indicating
common-main.c +2 -2
index 6a689007e..6516a1f89 100644
@@ -32,12 +32,12 @@ int main(int argc, const char **argv)
 	 */
 	sanitize_stdfds();
 
+	git_resolve_executable_dir(argv[0]);
+
 	git_setup_gettext();
 
 	attr_start();
 
-	git_extract_argv0_path(argv[0]);
-
 	restore_sigpipe_to_default();
 
 	return cmd_main(argc, argv);
config.mak.uname +7 -0
index 685a80d13..58fd62b4d 100644
@@ -37,6 +37,7 @@ ifeq ($(uname_S),Linux)
 	HAVE_GETDELIM = YesPlease
 	SANE_TEXT_GREP=-a
 	FREAD_READS_DIRECTORIES = UnfortunatelyYes
+	PROCFS_EXECUTABLE_PATH = /proc/self/exe
 endif
 ifeq ($(uname_S),GNU/kFreeBSD)
 	HAVE_ALLOCA_H = YesPlease
@@ -111,6 +112,7 @@ ifeq ($(uname_S),Darwin)
 	BASIC_CFLAGS += -DPROTECT_HFS_DEFAULT=1
 	HAVE_BSD_SYSCTL = YesPlease
 	FREAD_READS_DIRECTORIES = UnfortunatelyYes
+	HAVE_NS_GET_EXECUTABLE_PATH = YesPlease
 endif
 ifeq ($(uname_S),SunOS)
 	NEEDS_SOCKET = YesPlease
@@ -206,6 +208,7 @@ ifeq ($(uname_S),FreeBSD)
 	HAVE_PATHS_H = YesPlease
 	GMTIME_UNRELIABLE_ERRORS = UnfortunatelyYes
 	HAVE_BSD_SYSCTL = YesPlease
+	HAVE_BSD_KERN_PROC_SYSCTL = YesPlease
 	PAGER_ENV = LESS=FRX LV=-c MORE=FRX
 	FREAD_READS_DIRECTORIES = UnfortunatelyYes
 endif
@@ -218,6 +221,8 @@ ifeq ($(uname_S),OpenBSD)
 	BASIC_LDFLAGS += -L/usr/local/lib
 	HAVE_PATHS_H = YesPlease
 	HAVE_BSD_SYSCTL = YesPlease
+	HAVE_BSD_KERN_PROC_SYSCTL = YesPlease
+	PROCFS_EXECUTABLE_PATH = /proc/curproc/file
 endif
 ifeq ($(uname_S),MirBSD)
 	NO_STRCASESTR = YesPlease
@@ -236,6 +241,8 @@ ifeq ($(uname_S),NetBSD)
 	USE_ST_TIMESPEC = YesPlease
 	HAVE_PATHS_H = YesPlease
 	HAVE_BSD_SYSCTL = YesPlease
+	HAVE_BSD_KERN_PROC_SYSCTL = YesPlease
+	PROCFS_EXECUTABLE_PATH = /proc/curproc/exe
 endif
 ifeq ($(uname_S),AIX)
 	DEFAULT_PAGER = more
exec_cmd.c +208 -31

318 lines not on this page · raw message

exec_cmd.h +2 -2
index ff0b48048..2522453cd 100644
@@ -3,8 +3,8 @@
 
 struct argv_array;
 
-extern void git_set_argv_exec_path(const char *exec_path);
-extern void git_extract_argv0_path(const char *path);
+extern void git_set_exec_path(const char *exec_path);
+extern void git_resolve_executable_dir(const char *path);
 extern const char *git_exec_path(void);
 extern void setup_path(void);
 extern const char **prepare_git_cmd(struct argv_array *out, const char **argv);
gettext.c +5 -3
index db727ea02..6b64d5c2e 100644
@@ -2,7 +2,8 @@
  * Copyright (c) 2010 Ævar Arnfjörð Bjarmason
  */
 
-#include "git-compat-util.h"
+#include "cache.h"
+#include "exec_cmd.h"
 #include "gettext.h"
 #include "strbuf.h"
 #include "utf8.h"
@@ -157,10 +158,11 @@ static void init_gettext_charset(const char *domain)
 
 void git_setup_gettext(void)
 {
-	const char *podir = getenv("GIT_TEXTDOMAINDIR");
+	const char *podir = getenv(GIT_TEXT_DOMAIN_DIR_ENVIRONMENT);
 
 	if (!podir)
-		podir = GIT_LOCALE_PATH;
+		podir = system_path(GIT_LOCALE_PATH);
+
 	bindtextdomain("git", podir);
 	setlocale(LC_MESSAGES, "");
 	setlocale(LC_TIME, "");
git.c +1 -1
index 9e96dd409..dc4cc1419 100644
@@ -65,7 +65,7 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
 		 */
 		if (skip_prefix(cmd, "--exec-path", &cmd)) {
 			if (*cmd == '=')
-				git_set_argv_exec_path(cmd + 1);
+				git_set_exec_path(cmd + 1);
 			else {
 				puts(git_exec_path());
 				exit(0);
Signature · 1 line
2.15.0.chromium12
#5 lore raw

Re: [PATCH v3 4/4] exec_cmd: RUNTIME_PREFIX on some POSIX systems

Hi Dan,

Quoted 15 lines · Dan Jacques
gettext.c +2 -1
index db727ea02..6b64d5c2e 100644
@@ -2,7 +2,8 @@
  * Copyright (c) 2010 Ævar Arnfjörð Bjarmason
  */
 
-#include "git-compat-util.h"
+#include "cache.h"
+#include "exec_cmd.h"
 #include "gettext.h"
 #include "strbuf.h"
 #include "utf8.h"

gettext.c static void init_gettext_charset(const char *domain) · line 164

Quoted 9 lines
gettext.c +2 -2
@@ -157,10 +158,11 @@ static void init_gettext_charset(const char *domain)
 
 void git_setup_gettext(void)
 {
-	const char *podir = getenv("GIT_TEXTDOMAINDIR");
+	const char *podir = getenv(GIT_TEXT_DOMAIN_DIR_ENVIRONMENT);
 
 	if (!podir)
-		podir = GIT_LOCALE_PATH;
+		podir = system_path(GIT_LOCALE_PATH);

In Git for Windows, we have an almost identical patch:

	https://github.com/git-for-windows/git/commit/bdd739bb2b0b

We just guard the call to system_path() behind a test whether podir is already absolute, but these days, system_path() does that itself.

I am too little of a Perl expert to be helpful with the other patches, but I would gladly runa build & test on Windows if you direct me to an easily-pullable branch.

Ciao,
Johannes

#6 lore raw

Re: [PATCH v3 4/4] exec_cmd: RUNTIME_PREFIX on some POSIX systems

Quoted 10 lines

In Git for Windows, we have an almost identical patch:

https://github.com/git-for-windows/git/commit/bdd739bb2b0b

We just guard the call to system_path() behind a test whether podir is already absolute, but these days, system_path() does that itself.

I am too little of a Perl expert to be helpful with the other patches, but I would gladly runa build & test on Windows if you direct me to an easily-pullable branch.

Oh interesting - I've only peripherally looked at Git-for-Windows code, since Chromium uses its packages verbatim (thanks, BTW!). I think you're correct though - this patch set seems to be doing the same thing.

I've been force-pushing my changes to the "runtime-prefix" branch of my Git fork for travis.ci testing. The latest commit on that branch adds a "config.mak" for testing, so one commit from the branch head will contain the sum set of this patch series applied at (or near) Git's master branch:

https://github.com/danjacques/git/tree/runtime-prefix~1

Let me know if this is what you are looking for, and if I can offer any help with Windows testing. Thanks!

#7 lore raw

Re: [PATCH v3 4/4] exec_cmd: RUNTIME_PREFIX on some POSIX systems

Quoted 20 lines · Dan Jacques
Quoted 10 lines

In Git for Windows, we have an almost identical patch:

https://github.com/git-for-windows/git/commit/bdd739bb2b0b

We just guard the call to system_path() behind a test whether podir is already absolute, but these days, system_path() does that itself.

I am too little of a Perl expert to be helpful with the other patches, but I would gladly runa build & test on Windows if you direct me to an easily-pullable branch.

Oh interesting - I've only peripherally looked at Git-for-Windows code, since Chromium uses its packages verbatim (thanks, BTW!). I think you're correct though - this patch set seems to be doing the same thing.

I've been force-pushing my changes to the "runtime-prefix" branch of my Git fork for travis.ci testing. The latest commit on that branch adds a "config.mak" for testing, so one commit from the branch head will contain the sum set of this patch series applied at (or near) Git's master branch:

Quoted 4 lines

https://github.com/danjacques/git/tree/runtime-prefix~1

Let me know if this is what you are looking for, and if I can offer any help with Windows testing. Thanks!

FWIW, I plan to include this somewhere on 'pu' for today's integration cycle, so dj/runtime-prefix topic branch would also be what can easily be grabbed.

#8 lore raw

Re: [PATCH v3 4/4] exec_cmd: RUNTIME_PREFIX on some POSIX systems

Hi Junio,

Quoted 22 lines · Junio C Hamano
Quoted 20 lines · Dan Jacques
Quoted 10 lines

In Git for Windows, we have an almost identical patch:

https://github.com/git-for-windows/git/commit/bdd739bb2b0b

We just guard the call to system_path() behind a test whether podir is already absolute, but these days, system_path() does that itself.

I am too little of a Perl expert to be helpful with the other patches, but I would gladly runa build & test on Windows if you direct me to an easily-pullable branch.

Oh interesting - I've only peripherally looked at Git-for-Windows code, since Chromium uses its packages verbatim (thanks, BTW!). I think you're correct though - this patch set seems to be doing the same thing.

I've been force-pushing my changes to the "runtime-prefix" branch of my Git fork for travis.ci testing. The latest commit on that branch adds a "config.mak" for testing, so one commit from the branch head will contain the sum set of this patch series applied at (or near) Git's master branch:

Quoted 8 lines
Quoted 4 lines

https://github.com/danjacques/git/tree/runtime-prefix~1

Let me know if this is what you are looking for, and if I can offer any help with Windows testing. Thanks!

FWIW, I plan to include this somewhere on 'pu' for today's integration cycle, so dj/runtime-prefix topic branch would also be what can easily be grabbed.

Thanks for the offer.

Having said that, I prefer to work with Dan's branch directly, as that would be the branch that would need changes in case I need to patch anything. It's better to save the time on the roundtrip through your branch (that may display other side effects, too, as you almost certainly chose a different base commit than Dan did).

Also, I could easily offer the changes in a PR which is *a lot* more convenient on my side.

Ciao,
Dscho

#9 lore raw

Question regarding "next" merge

In reply to Junio C Hamano

Junio,

I read the "what's cooking in Git" notes and saw that you were intending to introduce this patch set into "next". Johannes pointed out some quoting errors that break Windows builds, and I have incorporated fixes in my working copy.

I was going to hold off on publishing v4 in case some of the other reviewers had additional comments, but if you would prefer, I can publish them now before you merge, so "next" doesn't break on Windows.

Please advise! Thanks,
-Dan

#10 lore raw

Re: Question regarding "next" merge

Quoted 7 lines · Dan Jacques

I read the "what's cooking in Git" notes and saw that you were intending to introduce this patch set into "next". Johannes pointed out some quoting errors that break Windows builds, and I have incorporated fixes in my working copy.

I was going to hold off on publishing v4 in case some of the other reviewers had additional comments, but if you would prefer, I can publish them now before you merge, so "next" doesn't break on Windows.

Please do so. Even though I try to, I cannot follow and remember all discussions on each and every topic, and noticing your own topic getting mislabeled in "What's cooking" summary and yelling loudly at me is the best way to help the project overall by preventing me from mistakenly merging a topic that needs still an update.

And if you are *not* ready and need a bit more time to send in an update, I'd prefer that you do *not* rush. I can easily make a note to wait for an update without merging the latest round of the topic I have in my tree. Also, I'll go offline towards the end of this week, so even if you rushed, the updated one may not hit my tree anyway.

Thanks for stopping me.

#11 lore raw

Re: [PATCH v3 4/4] exec_cmd: RUNTIME_PREFIX on some POSIX systems

In reply to Dan Jacques

Hi Dan, and (based on the timezone recorded in your mail:) good morning!

Quoted 7 lines · Dan Jacques
Quoted 7 lines

In Git for Windows, we have an almost identical patch:

https://github.com/git-for-windows/git/commit/bdd739bb2b0b

We just guard the call to system_path() behind a test whether podir is already absolute, but these days, system_path() does that itself.

Quoted 7 lines
Quoted 3 lines

I am too little of a Perl expert to be helpful with the other patches, but I would gladly runa build & test on Windows if you direct me to an easily-pullable branch.

Oh interesting - I've only peripherally looked at Git-for-Windows code, since Chromium uses its packages verbatim (thanks, BTW!). I think you're correct though - this patch set seems to be doing the same thing.

Excellent, thanks for confirming.

Quoted 10 lines

I've been force-pushing my changes to the "runtime-prefix" branch of my Git fork for travis.ci testing. The latest commit on that branch adds a "config.mak" for testing, so one commit from the branch head will contain the sum set of this patch series applied at (or near) Git's master branch:

https://github.com/danjacques/git/tree/runtime-prefix~1

Let me know if this is what you are looking for, and if I can offer any help with Windows testing. Thanks!

Thank you, that was exactly what I was looking for.

BTW I think that your config.mak settings are partially unnecessary: the gitexecdir and template_dir should be identical, and sysconfdir, too (at least unless you override prefix).

I triggered a build (with the config.mak commit, because it does not really matter), and it failed immediately due to a quoting issue: the path separator is a semicolon on Windows and therefore must be quoted (so that it is not misinterpreted as ending the command). There were a couple of other issues, too, and I opened a PR here:

https://github.com/danjacques/git/pull/1

Ciao,
Dscho