Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAurelien Foret <aurelien@archlinux.org>2005-03-29 21:15:15 +0000
committerAurelien Foret <aurelien@archlinux.org>2005-03-29 21:15:15 +0000
commit3bbfdf4ce8d47f05006e5c62bbb71432b1ae67e3 (patch)
treefc8ec8f9fea68d48c653dc79d626f23d6a80fe5a
parent425a6c64489d3be253dbf58a0e7c1344f04f5a4d (diff)
backport from pacman 2.9.5 - chdir
-rw-r--r--lib/libalpm/util.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c
index 29e39d30..73bab264 100644
--- a/lib/libalpm/util.c
+++ b/lib/libalpm/util.c
@@ -354,8 +354,7 @@ int _alpm_runscriptlet(char *root, char *installfn, char *script, char *ver, cha
char tmpdir[PATH_MAX] = "";
char *scriptpath;
struct stat buf;
-
- return(0);
+ char cwd[PATH_MAX];
if(stat(installfn, &buf)) {
/* not found */
@@ -367,7 +366,7 @@ int _alpm_runscriptlet(char *root, char *installfn, char *script, char *ver, cha
if(stat(tmpdir, &buf)) {
_alpm_makepath(tmpdir);
}
- snprintf(tmpdir, PATH_MAX, "%stmp/pacman-XXXXXX", root);
+ snprintf(tmpdir, PATH_MAX, "%stmp/alpm_XXXXXX", root);
if(mkdtemp(tmpdir) == NULL) {
_alpm_log(PM_LOG_ERROR, "could not create temp directory");
return(1);
@@ -391,6 +390,11 @@ int _alpm_runscriptlet(char *root, char *installfn, char *script, char *ver, cha
return(0);
}
+ /* save the cwd so we can restore it later */
+ getcwd(cwd, PATH_MAX);
+ /* just in case our cwd was removed in the upgrade operation */
+ chdir("/");
+
_alpm_log(PM_LOG_FLOW2, "executing %s script...", script);
if(oldver) {
snprintf(cmdline, PATH_MAX, "echo \"umask 0022; source %s %s %s %s\" | chroot %s /bin/sh",
@@ -405,6 +409,8 @@ int _alpm_runscriptlet(char *root, char *installfn, char *script, char *ver, cha
if(strlen(tmpdir) && _alpm_rmrf(tmpdir)) {
_alpm_log(PM_LOG_WARNING, "could not remove tmpdir %s", tmpdir);
}
+
+ chdir(cwd);
return(0);
}