Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/lib/libalpm/trans.c
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2007-11-18 16:49:02 -0600
committerDan McGee <dan@archlinux.org>2007-11-18 16:49:02 -0600
commit23b4e0270b1a1881b2daf362a398a3bdc20fab43 (patch)
tree35a543992891c1e4ed1e19a25f1debb0dfb96797 /lib/libalpm/trans.c
parent2aa7e69da91c1d7a18473cf05df98c92bd1dc747 (diff)
Fix sh and scriptlet interaction
dash doesn't pass positional parameters to sourced scripts, causing install scripts to fail. Instead of sourcing the script, make it executable and call it directly which allows positional parameters to be passed correctly. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib/libalpm/trans.c')
-rw-r--r--lib/libalpm/trans.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/libalpm/trans.c b/lib/libalpm/trans.c
index 50e346d9..b7085ba1 100644
--- a/lib/libalpm/trans.c
+++ b/lib/libalpm/trans.c
@@ -505,14 +505,21 @@ int _alpm_runscriptlet(const char *root, const char *installfn,
/* either extract or copy the scriptlet */
snprintf(scriptfn, PATH_MAX, "%s/.INSTALL", tmpdir);
if(!strcmp(script, "pre_upgrade") || !strcmp(script, "pre_install")) {
- _alpm_unpack(installfn, tmpdir, ".INSTALL");
+ if(_alpm_unpack(installfn, tmpdir, ".INSTALL")) {
+ retval = 1;
+ }
} else {
if(_alpm_copyfile(installfn, scriptfn)) {
_alpm_log(PM_LOG_ERROR, _("could not copy tempfile to %s (%s)\n"), scriptfn, strerror(errno));
retval = 1;
- goto cleanup;
}
}
+ if(retval == 1) {
+ goto cleanup;
+ }
+
+ /* mark the scriptlet as executable */
+ chmod(scriptfn, 0755);
/* chop off the root so we can find the tmpdir in the chroot */
scriptpath = scriptfn + strlen(root) - 1;
@@ -538,10 +545,10 @@ int _alpm_runscriptlet(const char *root, const char *installfn,
_alpm_log(PM_LOG_DEBUG, "executing %s script...\n", script);
if(oldver) {
- snprintf(cmdline, PATH_MAX, ". %s %s %s %s",
+ snprintf(cmdline, PATH_MAX, "%s %s %s %s",
scriptpath, script, ver, oldver);
} else {
- snprintf(cmdline, PATH_MAX, ". %s %s %s",
+ snprintf(cmdline, PATH_MAX, "%s %s %s",
scriptpath, script, ver);
}
_alpm_log(PM_LOG_DEBUG, "%s\n", cmdline);