This is an automated email from the git hooks/post-receive script. guillem pushed a commit to branch main in repository dpkg.
View the commit online: https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=2aec1a7af58b361990821f468c71050b1cc6000d commit 2aec1a7af58b361990821f468c71050b1cc6000d Author: Guillem Jover <[email protected]> AuthorDate: Mon Sep 25 00:48:47 2023 +0200 build: Make default shell and pager selectable at configure time We parametrize these so that their values in both the code and the manual pages match what got selected. --- configure.ac | 4 ++++ lib/dpkg/command.c | 2 +- lib/dpkg/pager.c | 2 +- lib/dpkg/t/t-pager.c | 2 +- m4/dpkg-progs.m4 | 29 +++++++++++++++++++++++++++-- man/Makefile.am | 2 ++ man/dpkg-query.pod | 2 +- man/dpkg.pod | 6 +++--- src/main/help.c | 2 +- 9 files changed, 41 insertions(+), 10 deletions(-) diff --git a/configure.ac b/configure.ac index 65cb131f3..98e6ab38a 100644 --- a/configure.ac +++ b/configure.ac @@ -75,6 +75,8 @@ DPKG_WITH_DIR([zshcompletionsdir], [${datadir}/zsh/vendor-completions], DPKG_DEB_COMPRESSOR([xz]) # Checks for programs. +DPKG_PROG_SHELL +DPKG_PROG_PAGER AC_PROG_SED AC_PROG_GREP AC_PROG_EGREP @@ -286,6 +288,8 @@ Configuration: mmap loaders . . . . . . . . : $enable_mmap disk pre-allocation . . . . . : $enable_disk_preallocate default dpkg-deb compressor . : $with_deb_compressor + default shell interpreter . . : $DPKG_SHELL + default pager program . . . . : $DPKG_PAGER Paths: devlibdir . . . . . . . . . . : $devlibdir diff --git a/lib/dpkg/command.c b/lib/dpkg/command.c index 8f6934425..36a155337 100644 --- a/lib/dpkg/command.c +++ b/lib/dpkg/command.c @@ -206,7 +206,7 @@ command_shell(const char *cmd, const char *name) } if (str_is_unset(shell)) - shell = DEFAULTSHELL; + shell = DPKG_DEFAULT_SHELL; execlp(shell, shell, mode, "--", cmd, NULL); ohshite(_("unable to execute %s (%s)"), name, cmd); diff --git a/lib/dpkg/pager.c b/lib/dpkg/pager.c index 4eab2f09e..08eb8d028 100644 --- a/lib/dpkg/pager.c +++ b/lib/dpkg/pager.c @@ -61,7 +61,7 @@ pager_get_exec(void) if (str_is_unset(pager)) pager = getenv("PAGER"); if (str_is_unset(pager)) - pager = DEFAULTPAGER; + pager = DPKG_DEFAULT_PAGER; return pager; } diff --git a/lib/dpkg/t/t-pager.c b/lib/dpkg/t/t-pager.c index 2481e8065..9ce7a2450 100644 --- a/lib/dpkg/t/t-pager.c +++ b/lib/dpkg/t/t-pager.c @@ -57,7 +57,7 @@ test_pager_get_exec(void) default_pager = pager_get_exec(); dup2(origfd, STDOUT_FILENO); test_str(pager, ==, "test-pager"); - test_str(default_pager, ==, DEFAULTPAGER); + test_str(default_pager, ==, DPKG_DEFAULT_PAGER); } /* Test stdout not being a tty. */ diff --git a/m4/dpkg-progs.m4 b/m4/dpkg-progs.m4 index 5fd1f5e8a..fd7f52074 100644 --- a/m4/dpkg-progs.m4 +++ b/m4/dpkg-progs.m4 @@ -1,7 +1,32 @@ -# serial 2 +# serial 3 # Copyright © 2005 Scott James Remnant <[email protected]> # Copyright © 2007 Frank Lichtenheld <[email protected]> -# Copyright © 2007, 2009, 2011 Guillem Jover <[email protected]> +# Copyright © 2007-2023 Guillem Jover <[email protected]> + +# DPKG_PROG_SHELL +# --------------- +# Locate a POSIX shell interpreter to use in dpkg. +AC_DEFUN([DPKG_PROG_SHELL], [ + AC_ARG_VAR([DPKG_SHELL], [default POSIX shell interpreter used by dpkg]) + AS_IF([test -z "$DPKG_SHELL"], [ + DPKG_SHELL=sh + ]) + + AC_SUBST([DPKG_DEFAULT_SHELL], [$DPKG_SHELL]) + AC_DEFINE_UNQUOTED([DPKG_DEFAULT_SHELL], ["$DPKG_SHELL"], + [POSIX shell interpreter used by dpkg]) +])# DPKG_PROG_SHELL + +# DPKG_PROG_PAGER +# --------------- +# Locate a pager program to use in dpkg. +AC_DEFUN([DPKG_PROG_PAGER], [ + AC_ARG_VAR([DPKG_PAGER], [default pager program used by dpkg]) + + AC_SUBST([DPKG_DEFAULT_PAGER], [$DPKG_PAGER]) + AC_DEFINE_UNQUOTED([DPKG_DEFAULT_PAGER], ["$DPKG_PAGER"], + [pager program used by dpkg]) +])# DPKG_PROG_PAGER # DPKG_PROG_PERL # -------------- diff --git a/man/Makefile.am b/man/Makefile.am index 7b8c0f6ef..075bef801 100644 --- a/man/Makefile.am +++ b/man/Makefile.am @@ -248,6 +248,8 @@ PODSUBST = $(SED) \ -e 's:%INSTDIR_ENVVAR%:DPKG_ROOT:g' \ -e 's:%ADMINDIR_ENVVAR%:DPKG_ADMINDIR:g' \ -e 's:%DEB_DEFAULT_COMPRESSOR%:$(DEB_DEFAULT_COMPRESSOR):g' \ + -e 's:%DPKG_DEFAULT_PAGER%:$(DPKG_DEFAULT_PAGER):g' \ + -e 's:%DPKG_DEFAULT_SHELL%:$(DPKG_DEFAULT_SHELL):g' \ # EOL MANFIXUP = $(SED) \ diff --git a/man/dpkg-query.pod b/man/dpkg-query.pod index 707f91081..930dc992c 100644 --- a/man/dpkg-query.pod +++ b/man/dpkg-query.pod @@ -505,7 +505,7 @@ Sets the program to execute when spawning a command via a shell Sets the pager command to use (since dpkg 1.19.1), which will be executed with «B<$SHELL -c>». -If B<SHELL> is not set, «B<sh>» will be used instead. +If B<SHELL> is not set, «B<%DPKG_DEFAULT_SHELL%>» will be used instead. The B<DPKG_PAGER> overrides the B<PAGER> environment variable (since dpkg 1.19.2). diff --git a/man/dpkg.pod b/man/dpkg.pod index 9e189e6b6..6d8f23cd6 100644 --- a/man/dpkg.pod +++ b/man/dpkg.pod @@ -968,7 +968,7 @@ co-installable instances with the same version, but different architecture. =item B<--post-invoke=>I<command> -Set an invoke hook I<command> to be run via “sh -c” before or +Set an invoke hook I<command> to be run via “%DPKG_DEFAULT_SHELL% -c” before or after the B<dpkg> run for the I<unpack>, I<configure>, I<install>, I<triggers-only>, I<remove> and @@ -1150,7 +1150,7 @@ B<configure>, B<trigproc>, B<disappear>, B<remove>, B<purge>. =item B<--status-logger>=I<command> Send machine-readable package status and progress information to the -shell I<command>'s standard input, to be run via “sh -c” +shell I<command>'s standard input, to be run via “%DPKG_DEFAULT_SHELL% -c” (since dpkg 1.16.0). This option can be specified multiple times. The output format used is the same as in B<--status-fd>. @@ -1275,7 +1275,7 @@ or when spawning a command via a shell. The program B<dpkg> will execute when running a pager, which will be executed with «B<$SHELL -c>», for example when displaying the conffile differences. -If B<SHELL> is not set, «B<sh>» will be used instead. +If B<SHELL> is not set, «B<%DPKG_DEFAULT_SHELL%>» will be used instead. The B<DPKG_PAGER> overrides the B<PAGER> environment variable (since dpkg 1.19.2). diff --git a/src/main/help.c b/src/main/help.c index 1cecfc065..615da0eac 100644 --- a/src/main/help.c +++ b/src/main/help.c @@ -81,7 +81,7 @@ namenodetouse(struct fsys_namenode *namenode, struct pkginfo *pkg, */ void checkpath(void) { static const char *const prog_list[] = { - DEFAULTSHELL, + DPKG_DEFAULT_SHELL, RM, TAR, DIFF, -- Dpkg.Org's dpkg

