summaryrefslogtreecommitdiff
path: root/lib/libalpm/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libalpm/util.c')
-rw-r--r--lib/libalpm/util.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c
index 4836812e..6b2b60a6 100644
--- a/lib/libalpm/util.c
+++ b/lib/libalpm/util.c
@@ -40,6 +40,8 @@
#include "util.h"
#include "alpm.h"
+static char *chrootbin = NULL;
+
/* borrowed and modified from Per Liden's pkgutils (http://crux.nu) */
long _alpm_gzopen_frontend(char *pathname, int oflags, int mode)
{
@@ -366,6 +368,23 @@ int _alpm_runscriptlet(char *root, char *installfn, char *script, char *ver, cha
return(0);
}
+ if(chrootbin == NULL) {
+ char *dirs[] = {"/usr/sbin","/usr/bin","/sbin","/bin"};
+ int i;
+ for(i = 0; i < 4 && !chrootbin; i++) {
+ char cpath[PATH_MAX];
+ snprintf(cpath, PATH_MAX, "%s/chroot", dirs[i]);
+ if(!stat(cpath, &buf)) {
+ chrootbin = strdup(cpath);
+ _alpm_log(PM_LOG_DEBUG, "found chroot binary: %s", chrootbin);
+ }
+ }
+ if(chrootbin == NULL) {
+ _alpm_log(PM_LOG_ERROR, "cannot find chroot binary - unable to run scriptlet");
+ return(1);
+ }
+ }
+
if(!strcmp(script, "pre_upgrade") || !strcmp(script, "pre_install")) {
snprintf(tmpdir, PATH_MAX, "%stmp/", root);
if(stat(tmpdir, &buf)) {