[pacman-dev] [PATCH] libalpm: Explicitly run install scriptlets in bash.

Loui Chang louipc.ist at gmail.com
Tue Jul 28 12:34:38 EDT 2009


I was experimenting using dash as /bin/sh and noticed that a lot of
packages were having errors in their install scriptlets.

popen passes commands to /bin/sh so we need to explicitly invoke bash,
which the scriptlets are written for. WOO!

Signed-off-by: Loui Chang <louipc.ist at gmail.com>
---
 lib/libalpm/trans.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/lib/libalpm/trans.c b/lib/libalpm/trans.c
index d1c0e93..5e63326 100644
--- a/lib/libalpm/trans.c
+++ b/lib/libalpm/trans.c
@@ -435,6 +435,7 @@ int _alpm_runscriptlet(const char *root, const char *installfn,
 {
 	char scriptfn[PATH_MAX];
 	char cmdline[PATH_MAX];
+	char cmdargs[PATH_MAX];
 	char tmpdir[PATH_MAX];
 	char *scriptpath;
 	int clean_tmpdir = 0;
@@ -486,13 +487,16 @@ int _alpm_runscriptlet(const char *root, const char *installfn,
 	}
 
 	if(oldver) {
-		snprintf(cmdline, PATH_MAX, ". %s; %s %s %s",
+		snprintf(cmdargs, PATH_MAX, "%s; %s %s %s",
 				scriptpath, script, ver, oldver);
 	} else {
-		snprintf(cmdline, PATH_MAX, ". %s; %s %s",
+		snprintf(cmdargs, PATH_MAX, "%s; %s %s",
 				scriptpath, script, ver);
 	}
 
+	/* Explicitly run scriptlets in bash */
+	snprintf(cmdline, PATH_MAX, "/bin/bash -c 'source %s'", cmdargs);
+
 	retval = _alpm_run_chroot(root, cmdline);
 
 cleanup:
-- 
1.6.3.3



More information about the pacman-dev mailing list