index : pacman | |
Archlinux32 fork of pacman | gitolite user |
summaryrefslogtreecommitdiff |
author | Chantry Xavier <shiningxc@gmail.com> | 2007-10-05 18:09:49 +0200 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2007-10-14 18:46:43 -0500 |
commit | 4e6a03c4f6d413aa9f1c98d255c370c442ce55eb (patch) | |
tree | a445b61cc223f4a6019b31dfc6b2c83e11f30036 | |
parent | 5d30c5c0b76e76b336abd2486ac6d24dd972fcc3 (diff) |
-rw-r--r-- | lib/libalpm/trans.c | 36 |
diff --git a/lib/libalpm/trans.c b/lib/libalpm/trans.c index 22780899..68203fca 100644 --- a/lib/libalpm/trans.c +++ b/lib/libalpm/trans.c @@ -559,26 +559,32 @@ int _alpm_runscriptlet(const char *root, const char *installfn, return(0); } + /* creates a directory in $root/tmp/ for copying/extracting the scriptlet */ + snprintf(tmpdir, PATH_MAX, "%stmp/", root); + if(stat(tmpdir, &buf)) { + _alpm_makepath(tmpdir); + } + snprintf(tmpdir, PATH_MAX, "%stmp/alpm_XXXXXX", root); + if(mkdtemp(tmpdir) == NULL) { + _alpm_log(PM_LOG_ERROR, _("could not create temp directory\n")); + return(1); + } + + /* either extract or copy the scriptlet */ + snprintf(scriptfn, PATH_MAX, "%s/.INSTALL", tmpdir); if(!strcmp(script, "pre_upgrade") || !strcmp(script, "pre_install")) { - snprintf(tmpdir, PATH_MAX, "%stmp/", root); - if(stat(tmpdir, &buf)) { - _alpm_makepath(tmpdir); - } - snprintf(tmpdir, PATH_MAX, "%stmp/alpm_XXXXXX", root); - if(mkdtemp(tmpdir) == NULL) { - _alpm_log(PM_LOG_ERROR, _("could not create temp directory\n")); - return(1); - } _alpm_unpack(installfn, tmpdir, ".INSTALL"); - snprintf(scriptfn, PATH_MAX, "%s/.INSTALL", tmpdir); - /* chop off the root so we can find the tmpdir in the chroot */ - scriptpath = scriptfn + strlen(root) - 1; } else { - strncpy(scriptfn, installfn, PATH_MAX); - /* chop off the root so we can find the tmpdir in the chroot */ - scriptpath = scriptfn + strlen(root) - 1; + if(_alpm_copyfile(installfn, scriptfn)) { + _alpm_log(PM_LOG_ERROR, _("could not copy tempfile to %s (%s)\n"), scriptfn, strerror(errno)); + retval = 1; + goto cleanup; + } } + /* chop off the root so we can find the tmpdir in the chroot */ + scriptpath = scriptfn + strlen(root) - 1; + if(!grep(scriptfn, script)) { /* script not found in scriptlet file */ goto cleanup; |