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:
Diffstat (limited to 'lib/libalpm/trans.c')
-rw-r--r--lib/libalpm/trans.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/lib/libalpm/trans.c b/lib/libalpm/trans.c
index 02612ec1..804ab7a1 100644
--- a/lib/libalpm/trans.c
+++ b/lib/libalpm/trans.c
@@ -1,7 +1,7 @@
/*
* trans.c
*
- * Copyright (c) 2006-2010 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2011 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* Copyright (c) 2005 by Christian Hamar <krics@linuxforum.hu>
@@ -31,6 +31,7 @@
#include <sys/stat.h>
#include <sys/statvfs.h>
#include <errno.h>
+#include <limits.h>
/* libalpm */
#include "trans.h"
@@ -44,7 +45,6 @@
#include "sync.h"
#include "alpm.h"
#include "deps.h"
-#include "cache.h"
/** \addtogroup alpm_trans Transaction Functions
* @brief Functions to manipulate libalpm transactions
@@ -323,11 +323,11 @@ static int grep(const char *fn, const char *needle)
}
while(!feof(fp)) {
char line[1024];
- int sline = sizeof(line)-1;
- fgets(line, sline, fp);
- if(feof(fp)) {
+ if(fgets(line, sizeof(line), fp) == NULL) {
continue;
}
+ /* TODO: this will not work if the search string
+ * ends up being split across line reads */
if(strstr(line, needle)) {
fclose(fp);
return(1);
@@ -344,6 +344,7 @@ int _alpm_runscriptlet(const char *root, const char *installfn,
char scriptfn[PATH_MAX];
char cmdline[PATH_MAX];
char tmpdir[PATH_MAX];
+ char *argv[] = { "sh", "-c", cmdline, NULL };
char *scriptpath;
int clean_tmpdir = 0;
int retval = 0;
@@ -371,7 +372,7 @@ 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")) {
+ if(strcmp(script, "pre_upgrade") == 0 || strcmp(script, "pre_install") == 0) {
if(_alpm_unpack_single(installfn, tmpdir, ".INSTALL")) {
retval = 1;
}
@@ -401,7 +402,9 @@ int _alpm_runscriptlet(const char *root, const char *installfn,
scriptpath, script, ver);
}
- retval = _alpm_run_chroot(root, cmdline);
+ _alpm_log(PM_LOG_DEBUG, "executing \"%s\"\n", cmdline);
+
+ retval = _alpm_run_chroot(root, "/bin/sh", argv);
cleanup:
if(clean_tmpdir && _alpm_rmrf(tmpdir)) {