[pacman-dev] [PATCH] Allow specifying shell for running scriptlets
Some distributions insist on using bash specific commands in their install scripts under the assumption that "sh" is a symlink to bash. This can causes issues if (e.g.) their users what to change sh to point at another shell, such as dash, that does not support these features. Add a configure option to explicitly set the shell being used to run install scripts. Signed-off-by: Allan McRae <allan@archlinux.org> --- configure.ac | 8 ++++++++ lib/libalpm/Makefile.am | 4 +++- lib/libalpm/trans.c | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 45e0111..ac65a5c 100644 --- a/configure.ac +++ b/configure.ac @@ -89,6 +89,12 @@ AC_ARG_WITH(buildscript, AS_HELP_STRING([--with-buildscript=name], [set the build script name used by makepkg]), [BUILDSCRIPT=$withval], [BUILDSCRIPT=PKGBUILD]) +# Help line for changing shell used to run install scriptlets +AC_ARG_WITH(scriptlet-shell, + AS_HELP_STRING([--with-scriptlet-shell=shell], + [set the shell used to run install scriptlets]), + [SCRIPTLETSHELL=$withval], [SCRIPTLETSHELL=sh]) + # Help line for using OpenSSL AC_ARG_WITH(openssl, AS_HELP_STRING([--with-openssl], [use OpenSSL crypto implementations instead of internal routines]), @@ -338,6 +344,8 @@ AC_DEFINE_UNQUOTED([SRCEXT], "$SRCEXT", [The file extension used by pacman sourc # Set makepkg build script name AC_SUBST(BUILDSCRIPT) AC_DEFINE_UNQUOTED([BUILDSCRIPT], "$BUILDSCRIPT", [The build script name used by makepkg]) +# Set shell used by install scriptlets +AC_SUBST(SCRIPTLETSHELL) # Configuration files AC_CONFIG_FILES([ diff --git a/lib/libalpm/Makefile.am b/lib/libalpm/Makefile.am index 61dcb87..5691019 100644 --- a/lib/libalpm/Makefile.am +++ b/lib/libalpm/Makefile.am @@ -5,7 +5,9 @@ SUBDIRS = po lib_LTLIBRARIES = libalpm.la include_HEADERS = alpm_list.h alpm.h -DEFS = -DLOCALEDIR=\"@localedir@\" @DEFS@ +DEFS = -DLOCALEDIR=\"@localedir@\" \ + -DSCRIPTLETSHELL=\"$(SCRIPTLETSHELL)\" \ + @DEFS@ AM_CPPFLAGS = \ -imacros $(top_builddir)/config.h diff --git a/lib/libalpm/trans.c b/lib/libalpm/trans.c index 5ceaaa7..e5937c1 100644 --- a/lib/libalpm/trans.c +++ b/lib/libalpm/trans.c @@ -277,7 +277,7 @@ int _alpm_runscriptlet(alpm_handle_t *handle, const char *filepath, const char *script, const char *ver, const char *oldver, int is_archive) { char cmdline[PATH_MAX]; - char *argv[] = { "sh", "-c", cmdline, NULL }; + char *argv[] = { SCRIPTLETSHELL, "-c", cmdline, NULL }; char *tmpdir, *scriptfn = NULL, *scriptpath; int retval = 0; size_t len; -- 1.7.9
Some distributions insist on using bash specific commands in their install scripts under the assumption that "sh" is a symlink to bash. This can causes issues if (e.g.) their users what to change sh to point at another shell, such as dash, that does not support these features. Add a configure option to explicitly set the shell being used to run install scripts.
Signed-off-by: Allan McRae <allan@archlinux.org> --- configure.ac | 8 ++++++++ lib/libalpm/Makefile.am | 4 +++- lib/libalpm/trans.c | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/configure.ac b/configure.ac index 45e0111..ac65a5c 100644 --- a/configure.ac +++ b/configure.ac @@ -89,6 +89,12 @@ AC_ARG_WITH(buildscript, AS_HELP_STRING([--with-buildscript=name], [set the build script name used by makepkg]), [BUILDSCRIPT=$withval], [BUILDSCRIPT=PKGBUILD])
+# Help line for changing shell used to run install scriptlets +AC_ARG_WITH(scriptlet-shell, + AS_HELP_STRING([--with-scriptlet-shell=shell], + [set the shell used to run install scriptlets]), + [SCRIPTLETSHELL=$withval], [SCRIPTLETSHELL=sh]) Minor nag, but if the option is scriptlet-shell, I'd expect the variable to be SCRIPTLET_SHELL. + # Help line for using OpenSSL AC_ARG_WITH(openssl, AS_HELP_STRING([--with-openssl], [use OpenSSL crypto implementations instead of internal routines]), @@ -338,6 +344,8 @@ AC_DEFINE_UNQUOTED([SRCEXT], "$SRCEXT", [The file extension used by pacman sourc # Set makepkg build script name AC_SUBST(BUILDSCRIPT) AC_DEFINE_UNQUOTED([BUILDSCRIPT], "$BUILDSCRIPT", [The build script name used by makepkg]) +# Set shell used by install scriptlets +AC_SUBST(SCRIPTLETSHELL)
# Configuration files AC_CONFIG_FILES([ diff --git a/lib/libalpm/Makefile.am b/lib/libalpm/Makefile.am index 61dcb87..5691019 100644 --- a/lib/libalpm/Makefile.am +++ b/lib/libalpm/Makefile.am @@ -5,7 +5,9 @@ SUBDIRS = po lib_LTLIBRARIES = libalpm.la include_HEADERS = alpm_list.h alpm.h
-DEFS = -DLOCALEDIR=\"@localedir@\" @DEFS@ +DEFS = -DLOCALEDIR=\"@localedir@\" \ + -DSCRIPTLETSHELL=\"$(SCRIPTLETSHELL)\" \ + @DEFS@ I think I'd rather see this in config.h than have to change the defs
On Fri, Feb 10, 2012 at 1:31 AM, Allan McRae <allan@archlinux.org> wrote: line- is that possible? If you just add an AC_DEFINE_UNQUOTED call similar to the PKGEXT stuff already in configure.ac, it should work.
AM_CPPFLAGS = \ -imacros $(top_builddir)/config.h diff --git a/lib/libalpm/trans.c b/lib/libalpm/trans.c index 5ceaaa7..e5937c1 100644 --- a/lib/libalpm/trans.c +++ b/lib/libalpm/trans.c @@ -277,7 +277,7 @@ int _alpm_runscriptlet(alpm_handle_t *handle, const char *filepath, const char *script, const char *ver, const char *oldver, int is_archive) { char cmdline[PATH_MAX]; - char *argv[] = { "sh", "-c", cmdline, NULL }; + char *argv[] = { SCRIPTLETSHELL, "-c", cmdline, NULL }; char *tmpdir, *scriptfn = NULL, *scriptpath; int retval = 0; size_t len; -- 1.7.9
On 11/02/12 01:42, Dan McGee wrote:
Some distributions insist on using bash specific commands in their install scripts under the assumption that "sh" is a symlink to bash. This can causes issues if (e.g.) their users what to change sh to point at another shell, such as dash, that does not support these features. Add a configure option to explicitly set the shell being used to run install scripts.
Signed-off-by: Allan McRae <allan@archlinux.org> --- configure.ac | 8 ++++++++ lib/libalpm/Makefile.am | 4 +++- lib/libalpm/trans.c | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/configure.ac b/configure.ac index 45e0111..ac65a5c 100644 --- a/configure.ac +++ b/configure.ac @@ -89,6 +89,12 @@ AC_ARG_WITH(buildscript, AS_HELP_STRING([--with-buildscript=name], [set the build script name used by makepkg]), [BUILDSCRIPT=$withval], [BUILDSCRIPT=PKGBUILD])
+# Help line for changing shell used to run install scriptlets +AC_ARG_WITH(scriptlet-shell, + AS_HELP_STRING([--with-scriptlet-shell=shell], + [set the shell used to run install scriptlets]), + [SCRIPTLETSHELL=$withval], [SCRIPTLETSHELL=sh]) Minor nag, but if the option is scriptlet-shell, I'd expect the variable to be SCRIPTLET_SHELL. + # Help line for using OpenSSL AC_ARG_WITH(openssl, AS_HELP_STRING([--with-openssl], [use OpenSSL crypto implementations instead of internal routines]), @@ -338,6 +344,8 @@ AC_DEFINE_UNQUOTED([SRCEXT], "$SRCEXT", [The file extension used by pacman sourc # Set makepkg build script name AC_SUBST(BUILDSCRIPT) AC_DEFINE_UNQUOTED([BUILDSCRIPT], "$BUILDSCRIPT", [The build script name used by makepkg]) +# Set shell used by install scriptlets +AC_SUBST(SCRIPTLETSHELL)
# Configuration files AC_CONFIG_FILES([ diff --git a/lib/libalpm/Makefile.am b/lib/libalpm/Makefile.am index 61dcb87..5691019 100644 --- a/lib/libalpm/Makefile.am +++ b/lib/libalpm/Makefile.am @@ -5,7 +5,9 @@ SUBDIRS = po lib_LTLIBRARIES = libalpm.la include_HEADERS = alpm_list.h alpm.h
-DEFS = -DLOCALEDIR=\"@localedir@\" @DEFS@ +DEFS = -DLOCALEDIR=\"@localedir@\" \ + -DSCRIPTLETSHELL=\"$(SCRIPTLETSHELL)\" \ + @DEFS@ I think I'd rather see this in config.h than have to change the defs
On Fri, Feb 10, 2012 at 1:31 AM, Allan McRae <allan@archlinux.org> wrote: line- is that possible? If you just add an AC_DEFINE_UNQUOTED call similar to the PKGEXT stuff already in configure.ac, it should work.
I followed ROOTDIR as the example. Would you also like that moved to config.h? It seems to be the only variable not defined there... Allan
participants (2)
-
Allan McRae
-
Dan McGee