libalpm/trans.c : remove the DBPath <-> RootDir dependence in runscriptlet.
This code assumed that DBPath was under RootDir, while this is not necessarily the case : pacman doesn't enforce anymore than DBPath is under RootDir. So now, all scriptlets will be put somewhere in RootDir/tmp/, so that when it chroots in RootDir, the scriptlets are still available inside the chroot. This also removes the need of normalizing both dbpath and rootdir, in order to do computation on the paths. Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
This commit is contained in:
parent
5d30c5c0b7
commit
4e6a03c4f6
1 changed files with 24 additions and 18 deletions
|
@ -559,7 +559,7 @@ int _alpm_runscriptlet(const char *root, const char *installfn,
|
|||
return(0);
|
||||
}
|
||||
|
||||
if(!strcmp(script, "pre_upgrade") || !strcmp(script, "pre_install")) {
|
||||
/* creates a directory in $root/tmp/ for copying/extracting the scriptlet */
|
||||
snprintf(tmpdir, PATH_MAX, "%stmp/", root);
|
||||
if(stat(tmpdir, &buf)) {
|
||||
_alpm_makepath(tmpdir);
|
||||
|
@ -569,15 +569,21 @@ int _alpm_runscriptlet(const char *root, const char *installfn,
|
|||
_alpm_log(PM_LOG_ERROR, _("could not create temp directory\n"));
|
||||
return(1);
|
||||
}
|
||||
_alpm_unpack(installfn, tmpdir, ".INSTALL");
|
||||
|
||||
/* either extract or copy the scriptlet */
|
||||
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;
|
||||
if(!strcmp(script, "pre_upgrade") || !strcmp(script, "pre_install")) {
|
||||
_alpm_unpack(installfn, tmpdir, ".INSTALL");
|
||||
} else {
|
||||
strncpy(scriptfn, installfn, PATH_MAX);
|
||||
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 */
|
||||
|
|
Loading…
Add table
Reference in a new issue