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.c68
1 files changed, 32 insertions, 36 deletions
diff --git a/lib/libalpm/trans.c b/lib/libalpm/trans.c
index bf9ef722..5ffb5df2 100644
--- a/lib/libalpm/trans.c
+++ b/lib/libalpm/trans.c
@@ -28,8 +28,6 @@
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/statvfs.h>
#include <errno.h>
#include <limits.h>
#include <fcntl.h>
@@ -41,11 +39,9 @@
#include "util.h"
#include "log.h"
#include "handle.h"
-#include "add.h"
#include "remove.h"
#include "sync.h"
#include "alpm.h"
-#include "deps.h"
/** \addtogroup alpm_trans Transaction Functions
* @brief Functions to manipulate libalpm transactions
@@ -68,22 +64,22 @@ static int make_lock(pmhandle_t *handle)
}
if(_alpm_makepath(dir)) {
FREE(dir);
- return(-1);
+ return -1;
}
FREE(dir);
do {
fd = open(handle->lockfile, O_WRONLY | O_CREAT | O_EXCL, 0000);
- } while (fd == -1 && errno == EINTR);
+ } while(fd == -1 && errno == EINTR);
if(fd > 0) {
FILE *f = fdopen(fd, "w");
fprintf(f, "%ld\n", (long)getpid());
fflush(f);
fsync(fd);
handle->lckstream = f;
- return(0);
+ return 0;
}
- return(-1);
+ return -1;
}
/* Remove a lock file */
@@ -94,9 +90,9 @@ static int remove_lock(pmhandle_t *handle)
handle->lckstream = NULL;
}
if(unlink(handle->lockfile) == -1 && errno != ENOENT) {
- return(-1);
+ return -1;
}
- return(0);
+ return 0;
}
/** Initialize the transaction. */
@@ -144,7 +140,7 @@ int SYMEXPORT alpm_trans_init(pmtransflag_t flags,
RET_ERR(PM_ERR_DB_VERSION, -1);
}
- return(0);
+ return 0;
}
static alpm_list_t *check_arch(alpm_list_t *pkgs)
@@ -154,7 +150,7 @@ static alpm_list_t *check_arch(alpm_list_t *pkgs)
const char *arch = alpm_option_get_arch();
if(!arch) {
- return(NULL);
+ return NULL;
}
for(i = pkgs; i; i = i->next) {
pmpkg_t *pkg = i->data;
@@ -169,7 +165,7 @@ static alpm_list_t *check_arch(alpm_list_t *pkgs)
invalid = alpm_list_add(invalid, string);
}
}
- return(invalid);
+ return invalid;
}
/** Prepare a transaction. */
@@ -190,7 +186,7 @@ int SYMEXPORT alpm_trans_prepare(alpm_list_t **data)
/* If there's nothing to do, return without complaining */
if(trans->add == NULL && trans->remove == NULL) {
- return(0);
+ return 0;
}
alpm_list_t *invalid = check_arch(trans->add);
@@ -204,18 +200,18 @@ int SYMEXPORT alpm_trans_prepare(alpm_list_t **data)
if(trans->add == NULL) {
if(_alpm_remove_prepare(trans, handle->db_local, data) == -1) {
/* pm_errno is set by _alpm_remove_prepare() */
- return(-1);
+ return -1;
}
} else {
if(_alpm_sync_prepare(trans, handle->db_local, handle->dbs_sync, data) == -1) {
/* pm_errno is set by _alpm_sync_prepare() */
- return(-1);
+ return -1;
}
}
trans->state = STATE_PREPARED;
- return(0);
+ return 0;
}
/** Commit a transaction. */
@@ -237,7 +233,7 @@ int SYMEXPORT alpm_trans_commit(alpm_list_t **data)
/* If there's nothing to do, return without complaining */
if(trans->add == NULL && trans->remove == NULL) {
- return(0);
+ return 0;
}
trans->state = STATE_COMMITING;
@@ -245,18 +241,18 @@ int SYMEXPORT alpm_trans_commit(alpm_list_t **data)
if(trans->add == NULL) {
if(_alpm_remove_packages(trans, handle->db_local) == -1) {
/* pm_errno is set by _alpm_remove_commit() */
- return(-1);
+ return -1;
}
} else {
if(_alpm_sync_commit(trans, handle->db_local, data) == -1) {
/* pm_errno is set by _alpm_sync_commit() */
- return(-1);
+ return -1;
}
}
trans->state = STATE_COMMITED;
- return(0);
+ return 0;
}
/** Interrupt a transaction. */
@@ -276,7 +272,7 @@ int SYMEXPORT alpm_trans_interrupt(void)
trans->state = STATE_INTERRUPTED;
- return(0);
+ return 0;
}
/** Release a transaction. */
@@ -308,7 +304,7 @@ int SYMEXPORT alpm_trans_release(void)
}
}
- return(0);
+ return 0;
}
/** @} */
@@ -322,7 +318,7 @@ pmtrans_t *_alpm_trans_new(void)
CALLOC(trans, 1, sizeof(pmtrans_t), RET_ERR(PM_ERR_MEMORY, NULL));
trans->state = STATE_IDLE;
- return(trans);
+ return trans;
}
void _alpm_trans_free(pmtrans_t *trans)
@@ -351,7 +347,7 @@ static int grep(const char *fn, const char *needle)
FILE *fp;
if((fp = fopen(fn, "r")) == NULL) {
- return(0);
+ return 0;
}
while(!feof(fp)) {
char line[1024];
@@ -362,16 +358,16 @@ static int grep(const char *fn, const char *needle)
* ends up being split across line reads */
if(strstr(line, needle)) {
fclose(fp);
- return(1);
+ return 1;
}
}
fclose(fp);
- return(0);
+ return 0;
}
int _alpm_runscriptlet(const char *root, const char *installfn,
- const char *script, const char *ver,
- const char *oldver, pmtrans_t *trans)
+ const char *script, const char *ver,
+ const char *oldver, pmtrans_t UNUSED *trans)
{
char scriptfn[PATH_MAX];
char cmdline[PATH_MAX];
@@ -386,7 +382,7 @@ int _alpm_runscriptlet(const char *root, const char *installfn,
if(access(installfn, R_OK)) {
/* not found */
_alpm_log(PM_LOG_DEBUG, "scriptlet '%s' not found\n", installfn);
- return(0);
+ return 0;
}
/* creates a directory in $root/tmp/ for copying/extracting the scriptlet */
@@ -397,7 +393,7 @@ int _alpm_runscriptlet(const char *root, const char *installfn,
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);
+ return 1;
} else {
clean_tmpdir = 1;
}
@@ -443,7 +439,7 @@ cleanup:
_alpm_log(PM_LOG_WARNING, _("could not remove tmpdir %s\n"), tmpdir);
}
- return(retval);
+ return retval;
}
int SYMEXPORT alpm_trans_get_flags()
@@ -458,8 +454,8 @@ int SYMEXPORT alpm_trans_get_flags()
alpm_list_t SYMEXPORT * alpm_trans_get_add()
{
/* Sanity checks */
- ASSERT(handle != NULL, return(NULL));
- ASSERT(handle->trans != NULL, return(NULL));
+ ASSERT(handle != NULL, return NULL);
+ ASSERT(handle->trans != NULL, return NULL);
return handle->trans->add;
}
@@ -467,8 +463,8 @@ alpm_list_t SYMEXPORT * alpm_trans_get_add()
alpm_list_t SYMEXPORT * alpm_trans_get_remove()
{
/* Sanity checks */
- ASSERT(handle != NULL, return(NULL));
- ASSERT(handle->trans != NULL, return(NULL));
+ ASSERT(handle != NULL, return NULL);
+ ASSERT(handle->trans != NULL, return NULL);
return handle->trans->remove;
}