{"thread":{"id":"47329","subject":"[PATCH v3 0/4] RUNTIME_PREFIX relocatable Git","startedAt":"2017-11-27T16:41:11Z","lastAt":"2017-11-29T02:19:10Z","messageCount":12,"participants":["Dan Jacques","Johannes Schindelin","Junio C Hamano"],"isPatch":true,"patchVersion":3,"patchTotal":4},"messages":[{"id":"333610","messageId":"20171127164055.93283-1-dnj@google.com","threadId":"47329","inReplyTo":null,"subject":"[PATCH v3 0/4] RUNTIME_PREFIX relocatable Git","fromName":"Dan Jacques","fromEmail":"dnj@google.com","sentAt":"2017-11-27T16:40:51Z","receivedAt":"2017-11-27T16:41:11Z","isPatch":true,"sender":{"key":"dnj@google.com","avatar":"https://avatars.githubusercontent.com/u/9965104?v=4"},"body":"Previous threads:\nv1: https://public-inbox.org/git/20171116170523.28696-1-dnj@google.com/\nv2: https://public-inbox.org/git/20171119173141.4896-1-dnj@google.com/\n\nAfter working with avarab@, I isolated the Perl changes into a separate\nset of patches and adapted the code to be more correct and readable. I\nopted to prescribe a relative Perl library path instead of letting\nMakeMaker or the Config module choose one, since the latter both\nincorporate build system parameters and a major purpose of this is to be\nportable between ABI-compatible systems.\n\nI've tested this via Travis and run full test suite with and without\nRUNTIME_PREFIX/RUNTIME_PREFIX_PERL, and tested locally on Mac, Linux,\nand FreeBSD systems. Please take a look!\n\nBuilt using this \"config.mak\":\n\n=== BEGIN config.mak ===\n\nRUNTIME_PREFIX = YesPlease\nRUNTIME_PREFIX_PERL = YesPlease\ngitexecdir = libexec/git-core\ntemplate_dir = share/git-core/templates\nsysconfdir = etc\n\n=== END config.mak ===\n\nChanges in v3 from v2:\n\n- Broken into multiple patches now that Perl is isolated in its own\n  RUNTIME_PREFIX_PERL flag.\n\n- Working with avarab@, several changes to Perl script runtime prefix\n  support:\n\n  - Moved Perl header body content from Makefile into external template\n    file(s).\n\n  - Added generic \"perllibdir\" variable to override Perl installation\n    path.\n\n  - RUNTIME_PREFIX_PERL generated script header is more descriptive and\n    consistent with how the C version operates.\n\n  - Fixed Generated Perl header Makefile dependency, should rebuild\n    when dependent files and flags change.\n\n- Changed some of the new RUNTIME_PREFIX trace strings to use consistent\n  formatting and terminology.\n\nChanges in v2 from v1:\n\n- Added comments and formatting to improve readability of\n  platform-sepecific executable path resolution sleds in\n  `git_get_exec_path`.\n\n- Consolidated \"cached_exec_path\" and \"argv_exec_path\" globals\n  into \"exec_path_value\".\n\n- Use `strbuf_realpath` instead of `realpath` for procfs resolution.\n\n- Removed new environment variable exports. Git with RUNTIME_PREFIX no\n  longer exports or consumes any additional environment information.\n\n- Updated Perl script resolution strategy: rather than having Git export\n  the relative executable path to the Perl scripts, they now resolve\n  it independently when RUNTIME_PREFIX_PERL is enabled.\n\n- Updated resolution strategy for \"gettext()\": use system_path() instead\n  of special environment variable.\n\n- Added `sysctl` executable resolution support for BSDs that don't\n  mount \"procfs\" by default (most of them).\n\nDan Jacques (4):\n  Makefile: generate Perl header from template file\n  Makefile: add support for \"perllibdir\"\n  Makefile: add Perl runtime prefix support\n  exec_cmd: RUNTIME_PREFIX on some POSIX systems\n\n .gitignore                             |   1 +\n Makefile                               | 110 +++++++++++++--\n cache.h                                |   1 +\n common-main.c                          |   4 +-\n config.mak.uname                       |   7 +\n exec_cmd.c                             | 239 ++++++++++++++++++++++++++++-----\n exec_cmd.h                             |   4 +-\n gettext.c                              |   8 +-\n git.c                                  |   2 +-\n perl/Makefile                          |  52 ++++++-\n perl/header_fixed_prefix.pl.template   |   1 +\n perl/header_runtime_prefix.pl.template |  24 ++++\n 12 files changed, 395 insertions(+), 58 deletions(-)\n create mode 100644 perl/header_fixed_prefix.pl.template\n create mode 100644 perl/header_runtime_prefix.pl.template\n\n-- \n2.15.0.chromium12\n\n"},{"id":"333611","messageId":"20171127164055.93283-4-dnj@google.com","threadId":"47329","inReplyTo":"20171127164055.93283-1-dnj@google.com","subject":"[PATCH v3 3/4] Makefile: add Perl runtime prefix support","fromName":"Dan Jacques","fromEmail":"dnj@google.com","sentAt":"2017-11-27T16:40:54Z","receivedAt":"2017-11-27T16:41:16Z","isPatch":true,"sender":{"key":"dnj@google.com","avatar":"https://avatars.githubusercontent.com/u/9965104?v=4"},"body":"Add a new Makefile flag, RUNTIME_PREFIX_PERL, which, when enabled,\nconfigures Perl scripts to locate the Git installation's Perl support\nlibraries by resolving against the script's path, rather than\nhard-coding that path at build-time.\n\nEnabling RUNTIME_PREFIX_PERL overrides the system-specific Perl script\ninstallation path generated by MakeMaker to force installation into a\nplatform-neutral location, \"<prefix>/share/perl5\".\n\nThis change enables Git's Perl scripts to work when their Git installation\nis relocated or moved to another system.\n\nSigned-off-by: Dan Jacques <dnj@google.com>\n---\n Makefile                               | 40 +++++++++++++++++++++++++++++++++-\n perl/header_runtime_prefix.pl.template | 24 ++++++++++++++++++++\n 2 files changed, 63 insertions(+), 1 deletion(-)\n create mode 100644 perl/header_runtime_prefix.pl.template\n\ndiff --git a/Makefile b/Makefile\nindex 7a2ed8857..a36815b49 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -425,6 +425,10 @@ all::\n #\n # to say \"export LESS=FRX (and LV=-c) if the environment variable\n # LESS (and LV) is not set, respectively\".\n+#\n+# Define RUNTIME_PREFIX_PERL to configure Git's PERL commands to locate Git\n+# support libraries relative to their filesystem path instead of hard-coding\n+# it.\n \n GIT-VERSION-FILE: FORCE\n \t@$(SHELL_PATH) ./GIT-VERSION-GEN\n@@ -485,6 +489,7 @@ pathsep = :\n \n mandir_relative = $(patsubst $(prefix)/%,%,$(mandir))\n infodir_relative = $(patsubst $(prefix)/%,%,$(infodir))\n+sharedir_relative = $(patsubst $(prefix)/%,%,$(sharedir))\n htmldir_relative = $(patsubst $(prefix)/%,%,$(htmldir))\n \n export prefix bindir sharedir sysconfdir gitwebdir localedir\n@@ -1967,7 +1972,38 @@ perl/PM.stamp: GIT-PERL-DEFINES FORCE\n PERL_HEADER_TEMPLATE = perl/header_fixed_prefix.pl.template\n \n PERL_DEFINES := $(PERL_PATH_SQ) $(PERLLIB_EXTRA_SQ)\n-PERL_DEFINES += $(NO_PERL_MAKEMAKER)\n+PERL_DEFINES += $(NO_PERL_MAKEMAKER) $(RUNTIME_PREFIX_PERL)\n+\n+# Support Perl runtime prefix. In this mode, a different header is installed\n+# into Perl scripts. This header expects both the scripts and their support\n+# library to be installed relative to $(prefix), and resolves the path to\n+# the Perl libraries (perllibdir) from the executable's current path\n+# (gitexecdir).\n+#\n+# This configuration requires both $(perllibdir) and $(gitexecdir) to be\n+# relative paths, and will error if this is not the case.\n+ifdef RUNTIME_PREFIX_PERL\n+\n+PERL_HEADER_TEMPLATE = perl/header_runtime_prefix.pl.template\n+PERL_DEFINES += $(gitexecdir)\n+\n+# RUNTIME_PREFIX_PERL requires a $(perllibdir) value.\n+ifeq ($(perllibdir),)\n+perllibdir = $(sharedir_relative)/perl5\n+endif\n+\n+ifneq ($(filter /%,$(firstword $(gitexecdir))),)\n+$(error RUNTIME_PREFIX_PERL requires a relative $(gitexecdir))\n+endif\n+gitexecdir_relative_SQ = $(gitexecdir_SQ)\n+\n+ifneq ($(filter /%,$(firstword $(perllibdir))),)\n+$(error RUNTIME_PREFIX_PERL requires a relative perllibdir)\n+endif\n+perllibdir_relative_SQ = $(perllibdir_SQ)\n+\n+endif\n+\n PERL_DEFINES += $(perllibdir)\n \n perl/perl.mak: GIT-CFLAGS GIT-PREFIX perl/Makefile perl/Makefile.PL\n@@ -2001,6 +2037,8 @@ GIT-PERL-HEADER: $(PERL_HEADER_TEMPLATE) GIT-PERL-DEFINES perl/perl.mak\n \tINSTLIBDIR=\"$$INSTLIBDIR$${INSTLIBDIR_EXTRA:+:$$INSTLIBDIR_EXTRA}\" && \\\n \tsed -e 's=@@PATHSEP@@='$(pathsep)'=g' \\\n \t    -e 's=@@INSTLIBDIR@@='$$INSTLIBDIR'=g' \\\n+\t    -e 's=@@GITEXECDIR@@='$(gitexecdir_relative_SQ)'=g' \\\n+\t    -e 's=@@PERLLIBDIR@@='$(perllibdir_relative_SQ)'=g' \\\n \t    $< >$@\n \n .PHONY: gitweb\ndiff --git a/perl/header_runtime_prefix.pl.template b/perl/header_runtime_prefix.pl.template\nnew file mode 100644\nindex 000000000..fb9a9924d\n--- /dev/null\n+++ b/perl/header_runtime_prefix.pl.template\n@@ -0,0 +1,24 @@\n+# BEGIN RUNTIME_PREFIX_PERL generated code.\n+#\n+# This finds our Git::* libraries relative to the script's runtime path.\n+BEGIN {\n+\tuse lib split /@@PATHSEP@@/,\n+\t(\n+\t\t$ENV{GITPERLLIB}\n+\t\t||\n+\t\tdo {\n+\t\t\trequire FindBin;\n+\t\t\trequire File::Spec;\n+\t\t\tmy $gitexecdir_relative = '@@GITEXECDIR@@';\n+\t\t\tmy $perllibdir_relative = '@@PERLLIBDIR@@';\n+\n+\t\t\t($FindBin::Bin =~ m=${gitexecdir_relative}$=) ||\n+\t\t\t    die('Unrecognized runtime path.');\n+\t\t\tmy $prefix = substr($FindBin::Bin, 0, -length($gitexecdir_relative));\n+\t\t\tmy $perllibdir = File::Spec->catdir($prefix, $perllibdir_relative);\n+\t\t\t(-e $perllibdir) || die(\"Invalid library path: $perllibdir\");\n+\t\t\t$perllibdir;\n+\t\t}\n+\t);\n+}\n+# END RUNTIME_PREFIX_PERL generated code.\n-- \n2.15.0.chromium12\n\n"},{"id":"333612","messageId":"20171127164055.93283-2-dnj@google.com","threadId":"47329","inReplyTo":"20171127164055.93283-1-dnj@google.com","subject":"[PATCH v3 1/4] Makefile: generate Perl header from template file","fromName":"Dan Jacques","fromEmail":"dnj@google.com","sentAt":"2017-11-27T16:40:52Z","receivedAt":"2017-11-27T16:41:17Z","isPatch":true,"sender":{"key":"dnj@google.com","avatar":"https://avatars.githubusercontent.com/u/9965104?v=4"},"body":"Currently, the generated Perl script headers are emitted by commands in\nthe Makefile. This mechanism restricts options to introduce alternative\nheader content, needed by Perl runtime prefix support, and obscures the\norigin of the Perl script header.\n\nChange the Makefile to generate a header by processing a template file and\nmove the header content into the \"perl/\" subdirectory. The processed\ngenerated will now be stored in the \"GIT-PERL-HEADER\" file. This allows\nthe content of the Perl header to be controlled by changing the path of\nthe template in the Makefile.\n\nSigned-off-by: Dan Jacques <dnj@google.com>\n---\n .gitignore                           |  1 +\n Makefile                             | 23 ++++++++++++++---------\n perl/header_fixed_prefix.pl.template |  1 +\n 3 files changed, 16 insertions(+), 9 deletions(-)\n create mode 100644 perl/header_fixed_prefix.pl.template\n\ndiff --git a/.gitignore b/.gitignore\nindex 833ef3b0b..89bd7bd8a 100644\n--- a/.gitignore\n+++ b/.gitignore\n@@ -3,6 +3,7 @@\n /GIT-LDFLAGS\n /GIT-PREFIX\n /GIT-PERL-DEFINES\n+/GIT-PERL-HEADER\n /GIT-PYTHON-VARS\n /GIT-SCRIPT-DEFINES\n /GIT-USER-AGENT\ndiff --git a/Makefile b/Makefile\nindex e53750ca0..5ad60a54c 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -1964,18 +1964,15 @@ perl/PM.stamp: FORCE\n perl/perl.mak: GIT-CFLAGS GIT-PREFIX perl/Makefile perl/Makefile.PL\n \t$(QUIET_SUBDIR0)perl $(QUIET_SUBDIR1) PERL_PATH='$(PERL_PATH_SQ)' prefix='$(prefix_SQ)' $(@F)\n \n+PERL_HEADER_TEMPLATE = perl/header_fixed_prefix.pl.template\n PERL_DEFINES = $(PERL_PATH_SQ):$(PERLLIB_EXTRA_SQ)\n-$(SCRIPT_PERL_GEN): % : %.perl perl/perl.mak GIT-PERL-DEFINES GIT-VERSION-FILE\n+\n+$(SCRIPT_PERL_GEN): % : %.perl perl/perl.mak GIT-PERL-DEFINES GIT-PERL-HEADER GIT-VERSION-FILE\n \t$(QUIET_GEN)$(RM) $@ $@+ && \\\n-\tINSTLIBDIR=`MAKEFLAGS= $(MAKE) -C perl -s --no-print-directory instlibdir` && \\\n-\tINSTLIBDIR_EXTRA='$(PERLLIB_EXTRA_SQ)' && \\\n-\tINSTLIBDIR=\"$$INSTLIBDIR$${INSTLIBDIR_EXTRA:+:$$INSTLIBDIR_EXTRA}\" && \\\n \tsed -e '1{' \\\n \t    -e '\ts|#!.*perl|#!$(PERL_PATH_SQ)|' \\\n-\t    -e '\th' \\\n-\t    -e '\ts=.*=use lib (split(/$(pathsep)/, $$ENV{GITPERLLIB} || \"'\"$$INSTLIBDIR\"'\"));=' \\\n-\t    -e '\tH' \\\n-\t    -e '\tx' \\\n+\t    -e '\trGIT-PERL-HEADER' \\\n+\t    -e '\tG' \\\n \t    -e '}' \\\n \t    -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \\\n \t    $< >$@+ && \\\n@@ -1989,6 +1986,14 @@ GIT-PERL-DEFINES: FORCE\n \t\techo \"$$FLAGS\" >$@; \\\n \t    fi\n \n+GIT-PERL-HEADER: $(PERL_HEADER_TEMPLATE) GIT-PERL-DEFINES perl/perl.mak\n+\t$(QUIET_GEN)$(RM) $@ && \\\n+\tINSTLIBDIR=`MAKEFLAGS= $(MAKE) -C perl -s --no-print-directory instlibdir` && \\\n+\tINSTLIBDIR_EXTRA='$(PERLLIB_EXTRA_SQ)' && \\\n+\tINSTLIBDIR=\"$$INSTLIBDIR$${INSTLIBDIR_EXTRA:+:$$INSTLIBDIR_EXTRA}\" && \\\n+\tsed -e 's=@@PATHSEP@@='$(pathsep)'=g' \\\n+\t    -e 's=@@INSTLIBDIR@@='$$INSTLIBDIR'=g' \\\n+\t    $< >$@\n \n .PHONY: gitweb\n gitweb:\n@@ -2707,7 +2712,7 @@ ifndef NO_TCLTK\n endif\n \t$(RM) GIT-VERSION-FILE GIT-CFLAGS GIT-LDFLAGS GIT-BUILD-OPTIONS\n \t$(RM) GIT-USER-AGENT GIT-PREFIX\n-\t$(RM) GIT-SCRIPT-DEFINES GIT-PERL-DEFINES GIT-PYTHON-VARS\n+\t$(RM) GIT-SCRIPT-DEFINES GIT-PERL-DEFINES GIT-PERL-HEADER GIT-PYTHON-VARS\n \n .PHONY: all install profile-clean clean strip\n .PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell\ndiff --git a/perl/header_fixed_prefix.pl.template b/perl/header_fixed_prefix.pl.template\nnew file mode 100644\nindex 000000000..9a4bc4d30\n--- /dev/null\n+++ b/perl/header_fixed_prefix.pl.template\n@@ -0,0 +1 @@\n+use lib (split(/@@PATHSEP@@/, $ENV{GITPERLLIB} || \"@@INSTLIBDIR@@\"));\n-- \n2.15.0.chromium12\n\n"},{"id":"333613","messageId":"20171127164055.93283-5-dnj@google.com","threadId":"47329","inReplyTo":"20171127164055.93283-1-dnj@google.com","subject":"[PATCH v3 4/4] exec_cmd: RUNTIME_PREFIX on some POSIX systems","fromName":"Dan Jacques","fromEmail":"dnj@google.com","sentAt":"2017-11-27T16:40:55Z","receivedAt":"2017-11-27T16:41:20Z","isPatch":true,"sender":{"key":"dnj@google.com","avatar":"https://avatars.githubusercontent.com/u/9965104?v=4"},"body":"Enable Git to resolve its own binary location using a variety of\nOS-specific and generic methods, including:\n\n- procfs via \"/proc/self/exe\" (Linux)\n- _NSGetExecutablePath (Darwin)\n- KERN_PROC_PATHNAME sysctl on BSDs.\n- argv0, if absolute (all, including Windows).\n\nThis is used to enable RUNTIME_PREFIX support for non-Windows systems,\nnotably Linux and Darwin. When configured with RUNTIME_PREFIX, Git will\ndo a best-effort resolution of its executable path and automatically use\nthis as its \"exec_path\" for relative helper and data lookups, unless\nexplicitly overridden.\n\nSmall incidental formatting cleanup of \"exec_cmd.c\".\n\nSigned-off-by: Dan Jacques <dnj@google.com>\n---\n Makefile         |  35 +++++++-\n cache.h          |   1 +\n common-main.c    |   4 +-\n config.mak.uname |   7 ++\n exec_cmd.c       | 239 +++++++++++++++++++++++++++++++++++++++++++++++--------\n exec_cmd.h       |   4 +-\n gettext.c        |   8 +-\n git.c            |   2 +-\n 8 files changed, 260 insertions(+), 40 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex a36815b49..014988318 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -416,6 +416,16 @@ all::\n #\n # Define HAVE_BSD_SYSCTL if your platform has a BSD-compatible sysctl function.\n #\n+# Define HAVE_BSD_KERN_PROC_SYSCTL if your platform supports the KERN_PROC BSD\n+# sysctl function.\n+#\n+# Define PROCFS_EXECUTABLE_PATH if your platform mounts a \"procfs\" filesystem\n+# capable of resolving the path of the current executable. If defined, this\n+# must be the canonical path for the \"procfs\" current executable path.\n+#\n+# Define HAVE_NS_GET_EXECUTABLE_PATH if your platform supports calling\n+# _NSGetExecutablePath to retrieve the path of the running executable.\n+#\n # Define HAVE_GETDELIM if your system has the getdelim() function.\n #\n # Define PAGER_ENV to a SP separated VAR=VAL pairs to define\n@@ -426,6 +436,12 @@ all::\n # to say \"export LESS=FRX (and LV=-c) if the environment variable\n # LESS (and LV) is not set, respectively\".\n #\n+# Define RUNTIME_PREFIX to configure Git to resolve its ancillary tooling and\n+# support files relative to the location of the runtime binary, rather than\n+# hard-coding them into the binary. Git installations built with RUNTIME_PREFIX\n+# can be moved to arbitrary filesystem locations. Users may want to enable\n+# RUNTIME_PREFIX_PERL as well (see below).\n+#\n # Define RUNTIME_PREFIX_PERL to configure Git's PERL commands to locate Git\n # support libraries relative to their filesystem path instead of hard-coding\n # it.\n@@ -466,6 +482,7 @@ ARFLAGS = rcs\n #   mandir\n #   infodir\n #   htmldir\n+#   localedir\n #   perllibdir\n # This can help installing the suite in a relocatable way.\n \n@@ -491,6 +508,7 @@ mandir_relative = $(patsubst $(prefix)/%,%,$(mandir))\n infodir_relative = $(patsubst $(prefix)/%,%,$(infodir))\n sharedir_relative = $(patsubst $(prefix)/%,%,$(sharedir))\n htmldir_relative = $(patsubst $(prefix)/%,%,$(htmldir))\n+localedir_relative = $(patsubst $(prefix)/%,%,$(localedir))\n \n export prefix bindir sharedir sysconfdir gitwebdir localedir\n \n@@ -1637,10 +1655,23 @@ ifdef HAVE_BSD_SYSCTL\n \tBASIC_CFLAGS += -DHAVE_BSD_SYSCTL\n endif\n \n+ifdef HAVE_BSD_KERN_PROC_SYSCTL\n+\tBASIC_CFLAGS += -DHAVE_BSD_KERN_PROC_SYSCTL\n+endif\n+\n ifdef HAVE_GETDELIM\n \tBASIC_CFLAGS += -DHAVE_GETDELIM\n endif\n \n+ifneq ($(PROCFS_EXECUTABLE_PATH),)\n+\tprocfs_executable_path_SQ = $(subst ','\\'',$(PROCFS_EXECUTABLE_PATH))\n+\tBASIC_CFLAGS += '-DPROCFS_EXECUTABLE_PATH=\"$(procfs_executable_path_SQ)\"'\n+endif\n+\n+ifdef HAVE_NS_GET_EXECUTABLE_PATH\n+\tBASIC_CFLAGS += -DHAVE_NS_GET_EXECUTABLE_PATH\n+endif\n+\n ifeq ($(TCLTK_PATH),)\n NO_TCLTK = NoThanks\n endif\n@@ -1723,6 +1754,7 @@ bindir_relative_SQ = $(subst ','\\'',$(bindir_relative))\n mandir_relative_SQ = $(subst ','\\'',$(mandir_relative))\n infodir_relative_SQ = $(subst ','\\'',$(infodir_relative))\n localedir_SQ = $(subst ','\\'',$(localedir))\n+localedir_relative_SQ = $(subst ','\\'',$(localedir_relative))\n gitexecdir_SQ = $(subst ','\\'',$(gitexecdir))\n template_dir_SQ = $(subst ','\\'',$(template_dir))\n htmldir_relative_SQ = $(subst ','\\'',$(htmldir_relative))\n@@ -2184,6 +2216,7 @@ endif\n exec_cmd.sp exec_cmd.s exec_cmd.o: GIT-PREFIX\n exec_cmd.sp exec_cmd.s exec_cmd.o: EXTRA_CPPFLAGS = \\\n \t'-DGIT_EXEC_PATH=\"$(gitexecdir_SQ)\"' \\\n+\t'-DGIT_LOCALE_PATH=\"$(localedir_relative_SQ)\"' \\\n \t'-DBINDIR=\"$(bindir_relative_SQ)\"' \\\n \t'-DPREFIX=\"$(prefix_SQ)\"'\n \n@@ -2201,7 +2234,7 @@ attr.sp attr.s attr.o: EXTRA_CPPFLAGS = \\\n \n gettext.sp gettext.s gettext.o: GIT-PREFIX\n gettext.sp gettext.s gettext.o: EXTRA_CPPFLAGS = \\\n-\t-DGIT_LOCALE_PATH='\"$(localedir_SQ)\"'\n+\t-DGIT_LOCALE_PATH='\"$(localedir_relative_SQ)\"'\n \n http-push.sp http.sp http-walker.sp remote-curl.sp imap-send.sp: SPARSE_FLAGS += \\\n \t-DCURL_DISABLE_TYPECHECK\ndiff --git a/cache.h b/cache.h\nindex 2e1434505..3d84aa0bf 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -449,6 +449,7 @@ static inline enum object_type object_type(unsigned int mode)\n #define GIT_ICASE_PATHSPECS_ENVIRONMENT \"GIT_ICASE_PATHSPECS\"\n #define GIT_QUARANTINE_ENVIRONMENT \"GIT_QUARANTINE_PATH\"\n #define GIT_OPTIONAL_LOCKS_ENVIRONMENT \"GIT_OPTIONAL_LOCKS\"\n+#define GIT_TEXT_DOMAIN_DIR_ENVIRONMENT \"GIT_TEXTDOMAINDIR\"\n \n /*\n  * This environment variable is expected to contain a boolean indicating\ndiff --git a/common-main.c b/common-main.c\nindex 6a689007e..6516a1f89 100644\n--- a/common-main.c\n+++ b/common-main.c\n@@ -32,12 +32,12 @@ int main(int argc, const char **argv)\n \t */\n \tsanitize_stdfds();\n \n+\tgit_resolve_executable_dir(argv[0]);\n+\n \tgit_setup_gettext();\n \n \tattr_start();\n \n-\tgit_extract_argv0_path(argv[0]);\n-\n \trestore_sigpipe_to_default();\n \n \treturn cmd_main(argc, argv);\ndiff --git a/config.mak.uname b/config.mak.uname\nindex 685a80d13..58fd62b4d 100644\n--- a/config.mak.uname\n+++ b/config.mak.uname\n@@ -37,6 +37,7 @@ ifeq ($(uname_S),Linux)\n \tHAVE_GETDELIM = YesPlease\n \tSANE_TEXT_GREP=-a\n \tFREAD_READS_DIRECTORIES = UnfortunatelyYes\n+\tPROCFS_EXECUTABLE_PATH = /proc/self/exe\n endif\n ifeq ($(uname_S),GNU/kFreeBSD)\n \tHAVE_ALLOCA_H = YesPlease\n@@ -111,6 +112,7 @@ ifeq ($(uname_S),Darwin)\n \tBASIC_CFLAGS += -DPROTECT_HFS_DEFAULT=1\n \tHAVE_BSD_SYSCTL = YesPlease\n \tFREAD_READS_DIRECTORIES = UnfortunatelyYes\n+\tHAVE_NS_GET_EXECUTABLE_PATH = YesPlease\n endif\n ifeq ($(uname_S),SunOS)\n \tNEEDS_SOCKET = YesPlease\n@@ -206,6 +208,7 @@ ifeq ($(uname_S),FreeBSD)\n \tHAVE_PATHS_H = YesPlease\n \tGMTIME_UNRELIABLE_ERRORS = UnfortunatelyYes\n \tHAVE_BSD_SYSCTL = YesPlease\n+\tHAVE_BSD_KERN_PROC_SYSCTL = YesPlease\n \tPAGER_ENV = LESS=FRX LV=-c MORE=FRX\n \tFREAD_READS_DIRECTORIES = UnfortunatelyYes\n endif\n@@ -218,6 +221,8 @@ ifeq ($(uname_S),OpenBSD)\n \tBASIC_LDFLAGS += -L/usr/local/lib\n \tHAVE_PATHS_H = YesPlease\n \tHAVE_BSD_SYSCTL = YesPlease\n+\tHAVE_BSD_KERN_PROC_SYSCTL = YesPlease\n+\tPROCFS_EXECUTABLE_PATH = /proc/curproc/file\n endif\n ifeq ($(uname_S),MirBSD)\n \tNO_STRCASESTR = YesPlease\n@@ -236,6 +241,8 @@ ifeq ($(uname_S),NetBSD)\n \tUSE_ST_TIMESPEC = YesPlease\n \tHAVE_PATHS_H = YesPlease\n \tHAVE_BSD_SYSCTL = YesPlease\n+\tHAVE_BSD_KERN_PROC_SYSCTL = YesPlease\n+\tPROCFS_EXECUTABLE_PATH = /proc/curproc/exe\n endif\n ifeq ($(uname_S),AIX)\n \tDEFAULT_PAGER = more\ndiff --git a/exec_cmd.c b/exec_cmd.c\nindex ce192a2d6..c9006c4c9 100644\n--- a/exec_cmd.c\n+++ b/exec_cmd.c\n@@ -2,53 +2,232 @@\n #include \"exec_cmd.h\"\n #include \"quote.h\"\n #include \"argv-array.h\"\n-#define MAX_ARGS\t32\n \n-static const char *argv_exec_path;\n+#if defined(RUNTIME_PREFIX)\n+\n+#if defined(HAVE_NS_GET_EXECUTABLE_PATH)\n+#include <mach-o/dyld.h>\n+#endif\n+\n+#if defined(HAVE_BSD_KERN_PROC_SYSCTL)\n+#include <sys/param.h>\n+#include <sys/types.h>\n+#include <sys/sysctl.h>\n+#endif\n+\n+#endif /* RUNTIME_PREFIX */\n+\n+#define MAX_ARGS 32\n+\n+static const char *system_prefix(void);\n \n #ifdef RUNTIME_PREFIX\n-static const char *argv0_path;\n+\n+/**\n+ * When using a runtime prefix, Git dynamically resolves paths relative to its\n+ * executable.\n+ *\n+ * The method for determining the path of the executable is highly\n+ * platform-specific.\n+ */\n+\n+/**\n+ * Path to the current Git executable. Resolved on startup by\n+ * 'git_resolve_executable_dir'.\n+ */\n+static const char *executable_dirname;\n \n static const char *system_prefix(void)\n {\n \tstatic const char *prefix;\n \n-\tassert(argv0_path);\n-\tassert(is_absolute_path(argv0_path));\n+\tassert(executable_dirname);\n+\tassert(is_absolute_path(executable_dirname));\n \n \tif (!prefix &&\n-\t    !(prefix = strip_path_suffix(argv0_path, GIT_EXEC_PATH)) &&\n-\t    !(prefix = strip_path_suffix(argv0_path, BINDIR)) &&\n-\t    !(prefix = strip_path_suffix(argv0_path, \"git\"))) {\n+\t    !(prefix = strip_path_suffix(executable_dirname, GIT_EXEC_PATH)) &&\n+\t    !(prefix = strip_path_suffix(executable_dirname, BINDIR)) &&\n+\t    !(prefix = strip_path_suffix(executable_dirname, \"git\"))) {\n \t\tprefix = PREFIX;\n \t\ttrace_printf(\"RUNTIME_PREFIX requested, \"\n-\t\t\t\t\"but prefix computation failed.  \"\n-\t\t\t\t\"Using static fallback '%s'.\\n\", prefix);\n+\t\t\t     \"but prefix computation failed.  \"\n+\t\t\t     \"Using static fallback '%s'.\\n\",\n+\t\t\t     prefix);\n \t}\n \treturn prefix;\n }\n \n-void git_extract_argv0_path(const char *argv0)\n+/*\n+ * Resolves the executable path from argv[0], only if it is absolute.\n+ *\n+ * Returns 0 on success, -1 on failure.\n+ */\n+static int git_get_exec_path_from_argv0(struct strbuf *buf, const char *argv0)\n {\n \tconst char *slash;\n \n \tif (!argv0 || !*argv0)\n-\t\treturn;\n+\t\treturn -1;\n \n \tslash = find_last_dir_sep(argv0);\n+\tif (slash) {\n+\t\ttrace_printf(\"trace: resolved executable path from argv0: %s\\n\",\n+\t\t\t     argv0);\n+\t\tstrbuf_add_absolute_path(buf, argv0);\n+\t\treturn 0;\n+\t}\n+\treturn -1;\n+}\n+\n+#ifdef PROCFS_EXECUTABLE_PATH\n+/*\n+ * Resolves the executable path by examining a procfs symlink.\n+ *\n+ * Returns 0 on success, -1 on failure.\n+ */\n+static int git_get_exec_path_procfs(struct strbuf *buf)\n+{\n+\tif (strbuf_realpath(buf, PROCFS_EXECUTABLE_PATH, 0)) {\n+\t\ttrace_printf(\n+\t\t\t\"trace: resolved executable path from procfs: %s\\n\",\n+\t\t\tbuf->buf);\n+\t\treturn 0;\n+\t}\n+\treturn -1;\n+}\n+#endif /* PROCFS_EXECUTABLE_PATH */\n+\n+#ifdef HAVE_BSD_KERN_PROC_SYSCTL\n+/*\n+ * Resolves the executable path using KERN_PROC_PATHNAME BSD sysctl.\n+ *\n+ * Returns 0 on success, -1 on failure.\n+ */\n+static int git_get_exec_path_bsd_sysctl(struct strbuf *buf)\n+{\n+\tint mib[4];\n+\tchar path[MAXPATHLEN];\n+\tsize_t cb = sizeof(path);\n+\n+\tmib[0] = CTL_KERN;\n+\tmib[1] = KERN_PROC;\n+\tmib[2] = KERN_PROC_PATHNAME;\n+\tmib[3] = -1;\n+\tif (!sysctl(mib, 4, path, &cb, NULL, 0)) {\n+\t\ttrace_printf(\n+\t\t\t\"trace: resolved executable path from sysctl: %s\\n\",\n+\t\t\tpath);\n+\t\tstrbuf_addstr(buf, path);\n+\t\treturn 0;\n+\t}\n+\treturn -1;\n+}\n+#endif /* HAVE_BSD_KERN_PROC_SYSCTL */\n+\n+#ifdef HAVE_NS_GET_EXECUTABLE_PATH\n+/*\n+ * Resolves the executable path by querying Darwin applicaton stack.\n+ *\n+ * Returns 0 on success, -1 on failure.\n+ */\n+static int git_get_exec_path_darwin(struct strbuf *buf)\n+{\n+\tchar path[PATH_MAX];\n+\tuint32_t size = sizeof(path);\n+\tif (!_NSGetExecutablePath(path, &size)) {\n+\t\ttrace_printf(\n+\t\t\t\"trace: resolved executable path from Darwin stack: %s\\n\",\n+\t\t\tpath);\n+\t\tstrbuf_addstr(buf, path);\n+\t\treturn 0;\n+\t}\n+\treturn -1;\n+}\n+#endif /* HAVE_NS_GET_EXECUTABLE_PATH */\n+\n+/*\n+ * Resolves the absolute path of the current executable.\n+ *\n+ * Returns 0 on success, -1 on failure.\n+ */\n+static int git_get_exec_path(struct strbuf *buf, const char *argv0)\n+{\n+\t/*\n+\t * Identifying the executable path is operating system specific.\n+\t * Selectively employ all available methods in order of preference,\n+\t * preferring highly-available authoratative methods over\n+\t * selectively-available or non- authoratative methods.\n+\t *\n+\t * All cases fall back on resolving against argv[0] if there isn't a\n+\t * better functional method. However, note that argv[0] can be\n+\t * used-supplied on many operating sysetems, and is not authoratative\n+\t * in those cases.\n+\t *\n+\t * Each of these functions returns 0 on success, so evaluation will stop\n+\t * after the first successful method.\n+\t */\n+\tif (\n+#ifdef HAVE_BSD_KERN_PROC_SYSCTL\n+\t\tgit_get_exec_path_bsd_sysctl(buf) &&\n+#endif /* HAVE_BSD_KERN_PROC_SYSCTL */\n+\n+#ifdef HAVE_NS_GET_EXECUTABLE_PATH\n+\t\tgit_get_exec_path_darwin(buf) &&\n+#endif /* HAVE_NS_GET_EXECUTABLE_PATH */\n+\n+#ifdef PROCFS_EXECUTABLE_PATH\n+\t\tgit_get_exec_path_procfs(buf) &&\n+#endif /* PROCFS_EXECUTABLE_PATH */\n+\n+\t\tgit_get_exec_path_from_argv0(buf, argv0)) {\n+\t\treturn -1;\n+\t}\n \n+\tif (strbuf_normalize_path(buf)) {\n+\t\ttrace_printf(\"trace: could not normalize path: %s\\n\", buf->buf);\n+\t\treturn -1;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+void git_resolve_executable_dir(const char *argv0)\n+{\n+\tstruct strbuf buf = STRBUF_INIT;\n+\tchar *resolved;\n+\tconst char *slash;\n+\n+\tif (git_get_exec_path(&buf, argv0)) {\n+\t\ttrace_printf(\n+\t\t\t\"trace: could not determine executable path from: %s\\n\",\n+\t\t\targv0);\n+\t\tstrbuf_release(&buf);\n+\t\treturn;\n+\t}\n+\n+\tresolved = strbuf_detach(&buf, NULL);\n+\tslash = find_last_dir_sep(resolved);\n \tif (slash)\n-\t\targv0_path = xstrndup(argv0, slash - argv0);\n+\t\tresolved[slash - resolved] = '\\0';\n+\n+\texecutable_dirname = resolved;\n+\ttrace_printf(\"trace: resolved executable dir: %s\\n\",\n+\t\t     executable_dirname);\n }\n \n #else\n \n+/**\n+ * When not using a runtime prefix, Git uses a hard-coded path, and there is\n+ * nothing to resolve.\n+ */\n+\n static const char *system_prefix(void)\n {\n \treturn PREFIX;\n }\n \n-void git_extract_argv0_path(const char *argv0)\n+void git_resolve_executable_dir(const char *argv0)\n {\n }\n \n@@ -65,32 +244,28 @@ char *system_path(const char *path)\n \treturn strbuf_detach(&d, NULL);\n }\n \n-void git_set_argv_exec_path(const char *exec_path)\n+static const char *exec_path_value;\n+\n+void git_set_exec_path(const char *exec_path)\n {\n-\targv_exec_path = exec_path;\n+\texec_path_value = exec_path;\n \t/*\n \t * Propagate this setting to external programs.\n \t */\n \tsetenv(EXEC_PATH_ENVIRONMENT, exec_path, 1);\n }\n \n-\n-/* Returns the highest-priority, location to look for git programs. */\n+/* Returns the highest-priority location to look for git programs. */\n const char *git_exec_path(void)\n {\n-\tstatic char *cached_exec_path;\n-\n-\tif (argv_exec_path)\n-\t\treturn argv_exec_path;\n-\n-\tif (!cached_exec_path) {\n+\tif (!exec_path_value) {\n \t\tconst char *env = getenv(EXEC_PATH_ENVIRONMENT);\n \t\tif (env && *env)\n-\t\t\tcached_exec_path = xstrdup(env);\n+\t\t\texec_path_value = xstrdup(env);\n \t\telse\n-\t\t\tcached_exec_path = system_path(GIT_EXEC_PATH);\n+\t\t\texec_path_value = system_path(GIT_EXEC_PATH);\n \t}\n-\treturn cached_exec_path;\n+\treturn exec_path_value;\n }\n \n static void add_path(struct strbuf *out, const char *path)\n@@ -103,10 +278,12 @@ static void add_path(struct strbuf *out, const char *path)\n \n void setup_path(void)\n {\n+\tconst char *exec_path = git_exec_path();\n \tconst char *old_path = getenv(\"PATH\");\n \tstruct strbuf new_path = STRBUF_INIT;\n \n-\tadd_path(&new_path, git_exec_path());\n+\tgit_set_exec_path(exec_path);\n+\tadd_path(&new_path, exec_path);\n \n \tif (old_path)\n \t\tstrbuf_addstr(&new_path, old_path);\n@@ -125,7 +302,8 @@ const char **prepare_git_cmd(struct argv_array *out, const char **argv)\n \treturn out->argv;\n }\n \n-int execv_git_cmd(const char **argv) {\n+int execv_git_cmd(const char **argv)\n+{\n \tstruct argv_array nargv = ARGV_ARRAY_INIT;\n \n \tprepare_git_cmd(&nargv, argv);\n@@ -140,8 +318,7 @@ int execv_git_cmd(const char **argv) {\n \treturn -1;\n }\n \n-\n-int execl_git_cmd(const char *cmd,...)\n+int execl_git_cmd(const char *cmd, ...)\n {\n \tint argc;\n \tconst char *argv[MAX_ARGS + 1];\ndiff --git a/exec_cmd.h b/exec_cmd.h\nindex ff0b48048..2522453cd 100644\n--- a/exec_cmd.h\n+++ b/exec_cmd.h\n@@ -3,8 +3,8 @@\n \n struct argv_array;\n \n-extern void git_set_argv_exec_path(const char *exec_path);\n-extern void git_extract_argv0_path(const char *path);\n+extern void git_set_exec_path(const char *exec_path);\n+extern void git_resolve_executable_dir(const char *path);\n extern const char *git_exec_path(void);\n extern void setup_path(void);\n extern const char **prepare_git_cmd(struct argv_array *out, const char **argv);\ndiff --git a/gettext.c b/gettext.c\nindex db727ea02..6b64d5c2e 100644\n--- a/gettext.c\n+++ b/gettext.c\n@@ -2,7 +2,8 @@\n  * Copyright (c) 2010 Ævar Arnfjörð Bjarmason\n  */\n \n-#include \"git-compat-util.h\"\n+#include \"cache.h\"\n+#include \"exec_cmd.h\"\n #include \"gettext.h\"\n #include \"strbuf.h\"\n #include \"utf8.h\"\n@@ -157,10 +158,11 @@ static void init_gettext_charset(const char *domain)\n \n void git_setup_gettext(void)\n {\n-\tconst char *podir = getenv(\"GIT_TEXTDOMAINDIR\");\n+\tconst char *podir = getenv(GIT_TEXT_DOMAIN_DIR_ENVIRONMENT);\n \n \tif (!podir)\n-\t\tpodir = GIT_LOCALE_PATH;\n+\t\tpodir = system_path(GIT_LOCALE_PATH);\n+\n \tbindtextdomain(\"git\", podir);\n \tsetlocale(LC_MESSAGES, \"\");\n \tsetlocale(LC_TIME, \"\");\ndiff --git a/git.c b/git.c\nindex 9e96dd409..dc4cc1419 100644\n--- a/git.c\n+++ b/git.c\n@@ -65,7 +65,7 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)\n \t\t */\n \t\tif (skip_prefix(cmd, \"--exec-path\", &cmd)) {\n \t\t\tif (*cmd == '=')\n-\t\t\t\tgit_set_argv_exec_path(cmd + 1);\n+\t\t\t\tgit_set_exec_path(cmd + 1);\n \t\t\telse {\n \t\t\t\tputs(git_exec_path());\n \t\t\t\texit(0);\n-- \n2.15.0.chromium12\n\n"},{"id":"333614","messageId":"20171127164055.93283-3-dnj@google.com","threadId":"47329","inReplyTo":"20171127164055.93283-1-dnj@google.com","subject":"[PATCH v3 2/4] Makefile: add support for \"perllibdir\"","fromName":"Dan Jacques","fromEmail":"dnj@google.com","sentAt":"2017-11-27T16:40:53Z","receivedAt":"2017-11-27T16:41:30Z","isPatch":true,"sender":{"key":"dnj@google.com","avatar":"https://avatars.githubusercontent.com/u/9965104?v=4"},"body":"Add the \"perllibdir\" Makefile variable, which allows the customization\nof the Perl library installation path.\n\nThe Perl library installation path is currently left entirely to the\nPerl Makefile implementation, either MakeMaker (default) or a fixed path\nwhen NO_PERL_MAKEMAKER is enabled. This patch introduces \"perllibdir\", a\nMakefile variable that can override that Perl module installation path.\n\nAs with some other Makefile variables, \"perllibdir\" may be either\nabsolute or relative. In the latter case, it is treated as relative to\n\"$(prefix)\".\n\nAdd some incidental documentation to perl/Makefile.\n\nExplicitly specifying an installation path is necessary for Perl runtime\nprefix support, as runtime prefix resolution code must know in advance\nwhere the Perl support modules are installed.\n\nSigned-off-by: Dan Jacques <dnj@google.com>\n---\n Makefile      | 18 +++++++++++++-----\n perl/Makefile | 52 ++++++++++++++++++++++++++++++++++++++++++++++------\n 2 files changed, 59 insertions(+), 11 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex 5ad60a54c..7a2ed8857 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -462,6 +462,7 @@ ARFLAGS = rcs\n #   mandir\n #   infodir\n #   htmldir\n+#   perllibdir\n # This can help installing the suite in a relocatable way.\n \n prefix = $(HOME)\n@@ -1721,6 +1722,7 @@ gitexecdir_SQ = $(subst ','\\'',$(gitexecdir))\n template_dir_SQ = $(subst ','\\'',$(template_dir))\n htmldir_relative_SQ = $(subst ','\\'',$(htmldir_relative))\n prefix_SQ = $(subst ','\\'',$(prefix))\n+perllibdir_SQ = $(subst ','\\'',$(perllibdir))\n gitwebdir_SQ = $(subst ','\\'',$(gitwebdir))\n \n SHELL_PATH_SQ = $(subst ','\\'',$(SHELL_PATH))\n@@ -1955,17 +1957,22 @@ $(SCRIPT_PERL_GEN): perl/perl.mak\n \n perl/perl.mak: perl/PM.stamp\n \n-perl/PM.stamp: FORCE\n+perl/PM.stamp: GIT-PERL-DEFINES FORCE\n \t@$(FIND) perl -type f -name '*.pm' | sort >$@+ && \\\n+\tcat GIT-PERL-DEFINES >>$@+ && \\\n \t$(PERL_PATH) -V >>$@+ && \\\n \t{ cmp $@+ $@ >/dev/null 2>/dev/null || mv $@+ $@; } && \\\n \t$(RM) $@+\n \n-perl/perl.mak: GIT-CFLAGS GIT-PREFIX perl/Makefile perl/Makefile.PL\n-\t$(QUIET_SUBDIR0)perl $(QUIET_SUBDIR1) PERL_PATH='$(PERL_PATH_SQ)' prefix='$(prefix_SQ)' $(@F)\n-\n PERL_HEADER_TEMPLATE = perl/header_fixed_prefix.pl.template\n-PERL_DEFINES = $(PERL_PATH_SQ):$(PERLLIB_EXTRA_SQ)\n+\n+PERL_DEFINES := $(PERL_PATH_SQ) $(PERLLIB_EXTRA_SQ)\n+PERL_DEFINES += $(NO_PERL_MAKEMAKER)\n+PERL_DEFINES += $(perllibdir)\n+\n+perl/perl.mak: GIT-CFLAGS GIT-PREFIX perl/Makefile perl/Makefile.PL\n+\t$(QUIET_SUBDIR0)perl $(QUIET_SUBDIR1) PERL_PATH='$(PERL_PATH_SQ)' \\\n+\t  prefix='$(prefix_SQ)' perllibdir='$(perllibdir_SQ)' $(@F)\n \n $(SCRIPT_PERL_GEN): % : %.perl perl/perl.mak GIT-PERL-DEFINES GIT-PERL-HEADER GIT-VERSION-FILE\n \t$(QUIET_GEN)$(RM) $@ $@+ && \\\n@@ -1979,6 +1986,7 @@ $(SCRIPT_PERL_GEN): % : %.perl perl/perl.mak GIT-PERL-DEFINES GIT-PERL-HEADER GI\n \tchmod +x $@+ && \\\n \tmv $@+ $@\n \n+PERL_DEFINES := $(subst $(space),:,$(PERL_DEFINES))\n GIT-PERL-DEFINES: FORCE\n \t@FLAGS='$(PERL_DEFINES)'; \\\n \t    if test x\"$$FLAGS\" != x\"`cat $@ 2>/dev/null`\" ; then \\\ndiff --git a/perl/Makefile b/perl/Makefile\nindex f657de20e..b2aeeb0d8 100644\n--- a/perl/Makefile\n+++ b/perl/Makefile\n@@ -1,6 +1,22 @@\n #\n # Makefile for perl support modules and routine\n #\n+# This Makefile generates \"perl.mak\", which contains the actual build and\n+# installation directions.\n+#\n+# PERL_PATH must be defined to be the path of the Perl interpreter to use.\n+#\n+# prefix must be defined as the Git installation prefix.\n+#\n+# localedir must be defined as the path to the locale data.\n+#\n+# perllibdir may be optionally defined to override the default Perl module\n+# installation directory, which is relative to prefix. If perllibdir is not\n+# absolute, it will be treated as relative to prefix.\n+#\n+# NO_PERL_MAKEMAKER may be defined to use a built-in Makefile generation method\n+# instead of Perl MakeMaker.\n+\n makfile:=perl.mak\n modules =\n \n@@ -12,6 +28,16 @@ ifndef V\n \tQUIET = @\n endif\n \n+# If a library directory is provided, and it is not an absolute path, resolve\n+# it relative to prefix.\n+ifneq ($(perllibdir),)\n+ifneq ($(filter /%,$(firstword $(perllibdir))),)\n+perllib_instdir = $(perllibdir)\n+else\n+perllib_instdir = $(prefix)/$(perllibdir)\n+endif\n+endif\n+\n all install instlibdir: $(makfile)\n \t$(QUIET)$(MAKE) -f $(makfile) $@\n \n@@ -25,7 +51,12 @@ clean:\n $(makfile): PM.stamp\n \n ifdef NO_PERL_MAKEMAKER\n-instdir_SQ = $(subst ','\\'',$(prefix)/lib)\n+\n+ifeq ($(perllib_instdir),)\n+perllib_instdir = $(prefix)/lib\n+endif\n+\n+instdir_SQ = $(subst ','\\'',$(perllib_instdir))\n \n modules += Git\n modules += Git/I18N\n@@ -42,7 +73,7 @@ modules += Git/SVN/Prompt\n modules += Git/SVN/Ra\n modules += Git/SVN/Utils\n \n-$(makfile): ../GIT-CFLAGS Makefile\n+$(makfile): ../GIT-CFLAGS ../GIT-PERL-DEFINES Makefile\n \techo all: private-Error.pm Git.pm Git/I18N.pm > $@\n \tset -e; \\\n \tfor i in $(modules); \\\n@@ -79,12 +110,21 @@ $(makfile): ../GIT-CFLAGS Makefile\n \techo '\tcp private-Error.pm \"$$(DESTDIR)$(instdir_SQ)/Error.pm\"' >> $@\n \techo instlibdir: >> $@\n \techo '\techo $(instdir_SQ)' >> $@\n+\n else\n-$(makfile): Makefile.PL ../GIT-CFLAGS\n-\t$(PERL_PATH) $< PREFIX='$(prefix_SQ)' INSTALL_BASE='' --localedir='$(localedir_SQ)'\n+\n+# This may be empty if perllibdir was empty.\n+instdir_SQ = $(subst ','\\'',$(perllib_instdir))\n+\n+$(makfile): Makefile.PL ../GIT-CFLAGS ../GIT-PERL-DEFINES\n+\t$(PERL_PATH) $< \\\n+\t  PREFIX='$(prefix_SQ)' INSTALL_BASE='' \\\n+\t  LIB='$(instdir_SQ)' \\\n+\t  --localedir='$(localedir_SQ)'\n+\n endif\n \n # this is just added comfort for calling make directly in perl dir\n # (even though GIT-CFLAGS aren't used yet. If ever)\n-../GIT-CFLAGS:\n-\t$(MAKE) -C .. GIT-CFLAGS\n+../GIT-CFLAGS ../GIT-PERL-DEFINES:\n+\t$(MAKE) -C .. $(@F)\n-- \n2.15.0.chromium12\n\n"},{"id":"333655","messageId":"alpine.DEB.2.21.1.1711280039010.6482@virtualbox","threadId":"47329","inReplyTo":"20171127164055.93283-5-dnj@google.com","subject":"Re: [PATCH v3 4/4] exec_cmd: RUNTIME_PREFIX on some POSIX systems","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2017-11-27T23:42:25Z","receivedAt":"2017-11-27T23:43:05Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Dan,\n\nOn Mon, 27 Nov 2017, Dan Jacques wrote:\n\n> diff --git a/gettext.c b/gettext.c\n> index db727ea02..6b64d5c2e 100644\n> --- a/gettext.c\n> +++ b/gettext.c\n> @@ -2,7 +2,8 @@\n>   * Copyright (c) 2010 Ævar Arnfjörð Bjarmason\n>   */\n>  \n> -#include \"git-compat-util.h\"\n> +#include \"cache.h\"\n> +#include \"exec_cmd.h\"\n>  #include \"gettext.h\"\n>  #include \"strbuf.h\"\n>  #include \"utf8.h\"\n> @@ -157,10 +158,11 @@ static void init_gettext_charset(const char *domain)\n>  \n>  void git_setup_gettext(void)\n>  {\n> -\tconst char *podir = getenv(\"GIT_TEXTDOMAINDIR\");\n> +\tconst char *podir = getenv(GIT_TEXT_DOMAIN_DIR_ENVIRONMENT);\n>  \n>  \tif (!podir)\n> -\t\tpodir = GIT_LOCALE_PATH;\n> +\t\tpodir = system_path(GIT_LOCALE_PATH);\n\nIn Git for Windows, we have an almost identical patch:\n\n\thttps://github.com/git-for-windows/git/commit/bdd739bb2b0b\n\nWe just guard the call to system_path() behind a test whether podir is\nalready absolute, but these days, system_path() does that itself.\n\nI am too little of a Perl expert to be helpful with the other patches, but\nI would gladly runa build & test on Windows if you direct me to an\neasily-pullable branch.\n\nCiao,\nJohannes"},{"id":"333674","messageId":"20171128032538.98071-1-dnj@google.com","threadId":"47329","inReplyTo":"alpine.DEB.2.21.1.1711280039010.6482@virtualbox","subject":"Re: [PATCH v3 4/4] exec_cmd: RUNTIME_PREFIX on some POSIX systems","fromName":"Dan Jacques","fromEmail":"dnj@google.com","sentAt":"2017-11-28T03:25:38Z","receivedAt":"2017-11-28T03:25:47Z","isPatch":true,"sender":{"key":"dnj@google.com","avatar":"https://avatars.githubusercontent.com/u/9965104?v=4"},"body":"> In Git for Windows, we have an almost identical patch:\n>\n> https://github.com/git-for-windows/git/commit/bdd739bb2b0b\n>\n> We just guard the call to system_path() behind a test whether podir is\n> already absolute, but these days, system_path() does that itself.\n>\n> I am too little of a Perl expert to be helpful with the other patches, but\n> I would gladly runa build & test on Windows if you direct me to an\n> easily-pullable branch.\n\nOh interesting - I've only peripherally looked at Git-for-Windows code,\nsince Chromium uses its packages verbatim (thanks, BTW!). I think you're\ncorrect though - this patch set seems to be doing the same thing.\n\nI've been force-pushing my changes to the \"runtime-prefix\" branch of my Git\nfork for travis.ci testing. The latest commit on that branch adds a\n\"config.mak\" for testing, so one commit from the branch head will contain\nthe sum set of this patch series applied at (or near) Git's master branch:\n\nhttps://github.com/danjacques/git/tree/runtime-prefix~1\n\nLet me know if this is what you are looking for, and if I can offer any\nhelp with Windows testing. Thanks!\n"},{"id":"333675","messageId":"xmqq374z83p8.fsf@gitster.mtv.corp.google.com","threadId":"47329","inReplyTo":"20171128032538.98071-1-dnj@google.com","subject":"Re: [PATCH v3 4/4] exec_cmd: RUNTIME_PREFIX on some POSIX systems","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-11-28T03:47:15Z","receivedAt":"2017-11-28T03:47:22Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Dan Jacques <dnj@google.com> writes:\n\n>> In Git for Windows, we have an almost identical patch:\n>>\n>> https://github.com/git-for-windows/git/commit/bdd739bb2b0b\n>>\n>> We just guard the call to system_path() behind a test whether podir is\n>> already absolute, but these days, system_path() does that itself.\n>>\n>> I am too little of a Perl expert to be helpful with the other patches, but\n>> I would gladly runa build & test on Windows if you direct me to an\n>> easily-pullable branch.\n>\n> Oh interesting - I've only peripherally looked at Git-for-Windows code,\n> since Chromium uses its packages verbatim (thanks, BTW!). I think you're\n> correct though - this patch set seems to be doing the same thing.\n>\n> I've been force-pushing my changes to the \"runtime-prefix\" branch of my Git\n> fork for travis.ci testing. The latest commit on that branch adds a\n> \"config.mak\" for testing, so one commit from the branch head will contain\n> the sum set of this patch series applied at (or near) Git's master branch:\n>\n> https://github.com/danjacques/git/tree/runtime-prefix~1\n>\n> Let me know if this is what you are looking for, and if I can offer any\n> help with Windows testing. Thanks!\n\nFWIW, I plan to include this somewhere on 'pu' for today's\nintegration cycle, so dj/runtime-prefix topic branch would also be\nwhat can easily be grabbed.\n"},{"id":"333685","messageId":"alpine.DEB.2.21.1.1711281231510.6482@virtualbox","threadId":"47329","inReplyTo":"xmqq374z83p8.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH v3 4/4] exec_cmd: RUNTIME_PREFIX on some POSIX systems","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2017-11-28T11:36:57Z","receivedAt":"2017-11-28T11:37:11Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Junio,\n\nOn Tue, 28 Nov 2017, Junio C Hamano wrote:\n\n> Dan Jacques <dnj@google.com> writes:\n> \n> >> In Git for Windows, we have an almost identical patch:\n> >>\n> >> https://github.com/git-for-windows/git/commit/bdd739bb2b0b\n> >>\n> >> We just guard the call to system_path() behind a test whether podir is\n> >> already absolute, but these days, system_path() does that itself.\n> >>\n> >> I am too little of a Perl expert to be helpful with the other patches, but\n> >> I would gladly runa build & test on Windows if you direct me to an\n> >> easily-pullable branch.\n> >\n> > Oh interesting - I've only peripherally looked at Git-for-Windows code,\n> > since Chromium uses its packages verbatim (thanks, BTW!). I think you're\n> > correct though - this patch set seems to be doing the same thing.\n> >\n> > I've been force-pushing my changes to the \"runtime-prefix\" branch of my Git\n> > fork for travis.ci testing. The latest commit on that branch adds a\n> > \"config.mak\" for testing, so one commit from the branch head will contain\n> > the sum set of this patch series applied at (or near) Git's master branch:\n> >\n> > https://github.com/danjacques/git/tree/runtime-prefix~1\n> >\n> > Let me know if this is what you are looking for, and if I can offer any\n> > help with Windows testing. Thanks!\n> \n> FWIW, I plan to include this somewhere on 'pu' for today's\n> integration cycle, so dj/runtime-prefix topic branch would also be\n> what can easily be grabbed.\n\nThanks for the offer.\n\nHaving said that, I prefer to work with Dan's branch directly, as that\nwould be the branch that would need changes in case I need to patch\nanything. It's better to save the time on the roundtrip through your\nbranch (that may display other side effects, too, as you almost certainly\nchose a different base commit than Dan did).\n\nAlso, I could easily offer the changes in a PR which is *a lot* more\nconvenient on my side.\n\nCiao,\nDscho\n"},{"id":"333689","messageId":"alpine.DEB.2.21.1.1711281330150.6482@virtualbox","threadId":"47329","inReplyTo":"20171128032538.98071-1-dnj@google.com","subject":"Re: [PATCH v3 4/4] exec_cmd: RUNTIME_PREFIX on some POSIX systems","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2017-11-28T14:08:53Z","receivedAt":"2017-11-28T14:09:29Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Dan, and (based on the timezone recorded in your mail:) good morning!\n\nOn Mon, 27 Nov 2017, Dan Jacques wrote:\n\n> > In Git for Windows, we have an almost identical patch:\n> >\n> > https://github.com/git-for-windows/git/commit/bdd739bb2b0b\n> >\n> > We just guard the call to system_path() behind a test whether podir is\n> > already absolute, but these days, system_path() does that itself.\n> >\n> > I am too little of a Perl expert to be helpful with the other patches, but\n> > I would gladly runa build & test on Windows if you direct me to an\n> > easily-pullable branch.\n> \n> Oh interesting - I've only peripherally looked at Git-for-Windows code,\n> since Chromium uses its packages verbatim (thanks, BTW!). I think you're\n> correct though - this patch set seems to be doing the same thing.\n\nExcellent, thanks for confirming.\n\n> I've been force-pushing my changes to the \"runtime-prefix\" branch of my\n> Git fork for travis.ci testing. The latest commit on that branch adds a\n> \"config.mak\" for testing, so one commit from the branch head will\n> contain the sum set of this patch series applied at (or near) Git's\n> master branch:\n> \n> https://github.com/danjacques/git/tree/runtime-prefix~1\n> \n> Let me know if this is what you are looking for, and if I can offer any\n> help with Windows testing. Thanks!\n\nThank you, that was exactly what I was looking for.\n\nBTW I think that your config.mak settings are partially unnecessary: the\ngitexecdir and template_dir should be identical, and sysconfdir, too (at\nleast unless you override prefix).\n\nI triggered a build (with the config.mak commit, because it does not\nreally matter), and it failed immediately due to a quoting issue: the path\nseparator is a semicolon on Windows and therefore must be quoted (so that\nit is not misinterpreted as ending the command). There were a couple of\nother issues, too, and I opened a PR here:\n\n\thttps://github.com/danjacques/git/pull/1\n\nCiao,\nDscho\n"},{"id":"333720","messageId":"20171129013848.37208-1-dnj@google.com","threadId":"47329","inReplyTo":"xmqq374z83p8.fsf@gitster.mtv.corp.google.com","subject":"Question regarding \"next\" merge","fromName":"Dan Jacques","fromEmail":"dnj@google.com","sentAt":"2017-11-29T01:38:48Z","receivedAt":"2017-11-29T01:38:55Z","isPatch":false,"sender":{"key":"dnj@google.com","avatar":"https://avatars.githubusercontent.com/u/9965104?v=4"},"body":"Junio,\n\nI read the \"what's cooking in Git\" notes and saw that you were intending to\nintroduce this patch set into \"next\". Johannes pointed out some quoting errors\nthat break Windows builds, and I have incorporated fixes in my working copy.\n\nI was going to hold off on publishing v4 in case some of the other reviewers\nhad additional comments, but if you would prefer, I can publish them now\nbefore you merge, so \"next\" doesn't break on Windows.\n\nPlease advise! Thanks,\n-Dan\n"},{"id":"333764","messageId":"xmqqwp294yjw.fsf@gitster.mtv.corp.google.com","threadId":"47329","inReplyTo":"20171129013848.37208-1-dnj@google.com","subject":"Re: Question regarding \"next\" merge","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-11-29T02:18:59Z","receivedAt":"2017-11-29T02:19:10Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Dan Jacques <dnj@google.com> writes:\n\n> I read the \"what's cooking in Git\" notes and saw that you were intending to\n> introduce this patch set into \"next\". Johannes pointed out some quoting errors\n> that break Windows builds, and I have incorporated fixes in my working copy.\n>\n> I was going to hold off on publishing v4 in case some of the other reviewers\n> had additional comments, but if you would prefer, I can publish them now\n> before you merge, so \"next\" doesn't break on Windows.\n\nPlease do so.  Even though I try to, I cannot follow and remember\nall discussions on each and every topic, and noticing your own topic\ngetting mislabeled in \"What's cooking\" summary and yelling loudly at\nme is the best way to help the project overall by preventing me from\nmistakenly merging a topic that needs still an update.\n\nAnd if you are *not* ready and need a bit more time to send in an\nupdate, I'd prefer that you do *not* rush.  I can easily make a note\nto wait for an update without merging the latest round of the topic\nI have in my tree.  Also, I'll go offline towards the end of this\nweek, so even if you rushed, the updated one may not hit my tree\nanyway.\n\nThanks for stopping me.\n\n"}]}