summaryrefslogtreecommitdiffstats
path: root/lib/libalpm/trans.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libalpm/trans.c')
-rw-r--r--lib/libalpm/trans.c33
1 files changed, 6 insertions, 27 deletions
diff --git a/lib/libalpm/trans.c b/lib/libalpm/trans.c
index ecc40a0f..06084ae9 100644
--- a/lib/libalpm/trans.c
+++ b/lib/libalpm/trans.c
@@ -25,6 +25,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#include <unistd.h>
#include <sys/wait.h>
#include <sys/types.h>
#include <sys/stat.h>
@@ -35,7 +36,6 @@
/* libalpm */
#include "trans.h"
#include "alpm_list.h"
-#include "error.h"
#include "package.h"
#include "util.h"
#include "log.h"
@@ -228,7 +228,6 @@ pmtrans_t *_alpm_trans_new()
CALLOC(trans, 1, sizeof(pmtrans_t), RET_ERR(PM_ERR_MEMORY, NULL));
- trans->targets = NULL;
trans->packages = NULL;
trans->skip_add = NULL;
trans->skip_remove = NULL;
@@ -250,10 +249,10 @@ void _alpm_trans_free(pmtrans_t *trans)
return;
}
- FREELIST(trans->targets);
if(trans->type == PM_TRANS_TYPE_SYNC) {
alpm_list_free_inner(trans->packages, (alpm_list_fn_free)_alpm_sync_free);
- } else {
+ } else if (trans->type == PM_TRANS_TYPE_REMOVE ||
+ trans->type == PM_TRANS_TYPE_REMOVEUPGRADE) {
alpm_list_free_inner(trans->packages, (alpm_list_fn_free)_alpm_pkg_free);
}
alpm_list_free(trans->packages);
@@ -307,13 +306,7 @@ int _alpm_trans_addtarget(pmtrans_t *trans, char *target)
ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1));
ASSERT(target != NULL, RET_ERR(PM_ERR_WRONG_ARGS, -1));
- if(alpm_list_find_str(trans->targets, target)) {
- return(0);
- //RET_ERR(PM_ERR_TRANS_DUP_TARGET, -1);
- }
-
switch(trans->type) {
- case PM_TRANS_TYPE_ADD:
case PM_TRANS_TYPE_UPGRADE:
if(_alpm_add_loadtarget(trans, handle->db_local, target) == -1) {
/* pm_errno is set by _alpm_add_loadtarget() */
@@ -335,8 +328,6 @@ int _alpm_trans_addtarget(pmtrans_t *trans, char *target)
break;
}
- trans->targets = alpm_list_add(trans->targets, strdup(target));
-
return(0);
}
@@ -357,7 +348,6 @@ int _alpm_trans_prepare(pmtrans_t *trans, alpm_list_t **data)
}
switch(trans->type) {
- case PM_TRANS_TYPE_ADD:
case PM_TRANS_TYPE_UPGRADE:
if(_alpm_add_prepare(trans, handle->db_local, data) == -1) {
/* pm_errno is set by _alpm_add_prepare() */
@@ -402,7 +392,6 @@ int _alpm_trans_commit(pmtrans_t *trans, alpm_list_t **data)
trans->state = STATE_COMMITING;
switch(trans->type) {
- case PM_TRANS_TYPE_ADD:
case PM_TRANS_TYPE_UPGRADE:
if(_alpm_add_commit(trans, handle->db_local) == -1) {
/* pm_errno is set by _alpm_add_commit() */
@@ -463,7 +452,6 @@ int _alpm_runscriptlet(const char *root, const char *installfn,
char tmpdir[PATH_MAX];
char cwd[PATH_MAX];
char *scriptpath;
- struct stat buf;
pid_t pid;
int clean_tmpdir = 0;
int restore_cwd = 0;
@@ -471,14 +459,14 @@ int _alpm_runscriptlet(const char *root, const char *installfn,
ALPM_LOG_FUNC;
- if(stat(installfn, &buf)) {
+ if(access(installfn, R_OK)) {
/* not found */
_alpm_log(PM_LOG_DEBUG, "scriptlet '%s' not found\n", installfn);
return(0);
}
/* NOTE: popen will use the PARENT's /bin/sh, not the chroot's */
- if(stat("/bin/sh", &buf)) {
+ if(access("/bin/sh", X_OK)) {
/* not found */
_alpm_log(PM_LOG_ERROR, _("No /bin/sh in parent environment, aborting scriptlet\n"));
return(0);
@@ -486,7 +474,7 @@ int _alpm_runscriptlet(const char *root, const char *installfn,
/* creates a directory in $root/tmp/ for copying/extracting the scriptlet */
snprintf(tmpdir, PATH_MAX, "%stmp/", root);
- if(stat(tmpdir, &buf)) {
+ if(access(tmpdir, F_OK) != 0) {
_alpm_makepath_mode(tmpdir, 01777);
}
snprintf(tmpdir, PATH_MAX, "%stmp/alpm_XXXXXX", root);
@@ -636,15 +624,6 @@ unsigned int SYMEXPORT alpm_trans_get_flags()
return handle->trans->flags;
}
-alpm_list_t SYMEXPORT * alpm_trans_get_targets()
-{
- /* Sanity checks */
- ASSERT(handle != NULL, return(NULL));
- ASSERT(handle->trans != NULL, return(NULL));
-
- return handle->trans->targets;
-}
-
alpm_list_t SYMEXPORT * alpm_trans_get_pkgs()
{
/* Sanity checks */