Git-Url: 
http://git.frugalware.org/gitweb/gitweb.cgi?p=pacman-g2.git;a=commitdiff;h=b08494c0f58509e5881b96488894cf30d2b26d94

commit b08494c0f58509e5881b96488894cf30d2b26d94
Author: Michel Hermier <[email protected]>
Date:   Sun Nov 3 10:48:28 2013 +0100

libpacman: Remove unecessary path manipulation in the host, before invoking 
_pacman_chroot_system.

diff --git a/lib/libpacman/util.c b/lib/libpacman/util.c
index 6bbad50..b031040 100644
--- a/lib/libpacman/util.c
+++ b/lib/libpacman/util.c
@@ -515,7 +515,6 @@ int _pacman_runscriptlet(char *root, char *installfn, const 
char *script, char *
char tmpdir[PATH_MAX] = "";
char *scriptpath;
struct stat buf;
-       char cwd[PATH_MAX] = "";
int retval = 0;

if(stat(installfn, &buf)) {
@@ -548,18 +547,6 @@ int _pacman_runscriptlet(char *root, char *installfn, 
const char *script, char *
goto cleanup;
}

-       /* save the cwd so we can restore it later */
-       if(getcwd(cwd, PATH_MAX) == NULL) {
-               _pacman_log(PM_LOG_ERROR, _("could not get current working 
directory"));
-               /* in case of error, cwd content is undefined: so we set it to 
something */
-               cwd[0] = 0;
-       }
-
-       /* just in case our cwd was removed in the upgrade operation */
-       if(chdir(root) != 0) {
-               _pacman_log(PM_LOG_ERROR, _("could not change directory to %s 
(%s)"), root, strerror(errno));
-       }
-
_pacman_log(PM_LOG_FLOW2, _("executing %s script..."), script);

if(oldver) {
@@ -575,9 +562,6 @@ cleanup:
if(!_pacman_strempty(tmpdir) && _pacman_rmrf(tmpdir)) {
_pacman_log(PM_LOG_WARNING, _("could not remove tmpdir %s"), tmpdir);
}
-       if(!_pacman_strempty(cwd)) {
-               chdir(cwd);
-       }

return(retval);
}
@@ -588,7 +572,6 @@ int _pacman_runhook(const char *hookname, pmtrans_t *trans)
char scriptfn[PATH_MAX];
char hookpath[PATH_MAX];
char cmdline[PATH_MAX];
-       char cwd[PATH_MAX] = "";
int retval = 0;
DIR *dir;
struct dirent *ent;
@@ -598,18 +581,6 @@ int _pacman_runhook(const char *hookname, pmtrans_t *trans)

_pacman_log(PM_LOG_FLOW2, _("executing %s hooks..."), hookname);

-       /* save the cwd so we can restore it later */
-       if(getcwd(cwd, PATH_MAX) == NULL) {
-               _pacman_log(PM_LOG_ERROR, _("could not get current working 
directory"));
-               /* in case of error, cwd content is undefined: so we set it to 
something */
-               cwd[0] = 0;
-       }
-
-       /* just in case our cwd was removed in the upgrade operation */
-       if(chdir(root) != 0) {
-               _pacman_log(PM_LOG_ERROR, _("could not change directory to %s 
(%s)"), root, strerror(errno));
-       }
-
snprintf(hookpath, PATH_MAX, "%s/%s", root, hookdir);

dir = opendir(hookpath);
@@ -638,10 +609,6 @@ cleanup:
closedir(dir);
}

-       if(!_pacman_strempty(cwd)) {
-               chdir(cwd);
-       }
-
return(retval);
}
_______________________________________________
Frugalware-git mailing list
[email protected]
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to