summaryrefslogtreecommitdiffstats
path: root/lib/libalpm/util.c
diff options
context:
space:
mode:
authorJudd Vinet <judd@archlinux.org>2005-10-08 01:29:49 +0200
committerJudd Vinet <judd@archlinux.org>2005-10-08 01:29:49 +0200
commit5ef51b3e266cf43411947248886372001fdb207a (patch)
tree8d255349530045686053faacd1804502a96b269c /lib/libalpm/util.c
parent79031ccd1a544475162facb8ca3d671f3464d1f8 (diff)
downloadpacman-5ef51b3e266cf43411947248886372001fdb207a.tar.gz
pacman-5ef51b3e266cf43411947248886372001fdb207a.tar.xz
Merging in recent fixes/additions from 2.9.7
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)) {