From 5ef51b3e266cf43411947248886372001fdb207a Mon Sep 17 00:00:00 2001 From: Judd Vinet Date: Fri, 7 Oct 2005 23:29:49 +0000 Subject: Merging in recent fixes/additions from 2.9.7 --- lib/libalpm/util.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'lib/libalpm/util.c') 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)) { -- cgit v1.2.3-54-g00ecf