diff options
Diffstat (limited to 'lib/libalpm/trans.c')
-rw-r--r-- | lib/libalpm/trans.c | 68 |
1 files changed, 32 insertions, 36 deletions
diff --git a/lib/libalpm/trans.c b/lib/libalpm/trans.c index 7affbfbd..af1bccee 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 @@ -66,22 +62,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 */ @@ -92,9 +88,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. */ @@ -143,7 +139,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) @@ -153,7 +149,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; @@ -168,7 +164,7 @@ static alpm_list_t *check_arch(alpm_list_t *pkgs) invalid = alpm_list_add(invalid, string); } } - return(invalid); + return invalid; } /** Prepare a transaction. */ @@ -189,7 +185,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); @@ -203,18 +199,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. */ @@ -236,7 +232,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; @@ -244,18 +240,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. */ @@ -275,7 +271,7 @@ int SYMEXPORT alpm_trans_interrupt(void) trans->state = STATE_INTERRUPTED; - return(0); + return 0; } /** Release a transaction. */ @@ -307,7 +303,7 @@ int SYMEXPORT alpm_trans_release(void) } } - return(0); + return 0; } /** @} */ @@ -321,7 +317,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) @@ -350,7 +346,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]; @@ -361,16 +357,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]; @@ -385,7 +381,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 */ @@ -396,7 +392,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; } @@ -442,7 +438,7 @@ cleanup: _alpm_log(PM_LOG_WARNING, _("could not remove tmpdir %s\n"), tmpdir); } - return(retval); + return retval; } int SYMEXPORT alpm_trans_get_flags() @@ -457,8 +453,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; } @@ -466,8 +462,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; } |