index : pacman | |
Archlinux32 fork of pacman | gitolite user |
summaryrefslogtreecommitdiff |
author | Aurelien Foret <aurelien@archlinux.org> | 2006-01-09 20:16:00 +0000 |
---|---|---|
committer | Aurelien Foret <aurelien@archlinux.org> | 2006-01-09 20:16:00 +0000 |
commit | fd6ce1f4cb8011756f7c07d28c5e06ce0be1acb7 (patch) | |
tree | 1e735f251fdfb3413085862bf77f851ec0ce3eb0 /lib | |
parent | 45a7e57f6c4c375d6b8716e2dfc15da592ec147b (diff) |
-rw-r--r-- | lib/libalpm/add.c | 6 | ||||
-rw-r--r-- | lib/libalpm/alpm.c | 7 | ||||
-rw-r--r-- | lib/libalpm/db.c | 2 | ||||
-rw-r--r-- | lib/libalpm/deps.c | 4 | ||||
-rw-r--r-- | lib/libalpm/package.c | 37 | ||||
-rw-r--r-- | lib/libalpm/package.h | 3 | ||||
-rw-r--r-- | lib/libalpm/sync.c | 10 | ||||
-rw-r--r-- | lib/libalpm/trans.c | 4 | ||||
-rw-r--r-- | lib/libalpm/util.c | 2 | ||||
-rw-r--r-- | lib/libalpm/util.h | 2 |
diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c index d683877d..e2276695 100644 --- a/lib/libalpm/add.c +++ b/lib/libalpm/add.c @@ -71,7 +71,7 @@ int add_loadtarget(pmtrans_t *trans, pmdb_t *db, char *name) */ if(strchr(name, '|')) { char *str, *ptr, *p; - dummy = pkg_new(); + dummy = pkg_new(NULL, NULL); if(dummy == NULL) { pm_errno = PM_ERR_MEMORY; goto error; @@ -339,10 +339,8 @@ int add_commit(pmtrans_t *trans, pmdb_t *db) _alpm_log(PM_LOG_FLOW1, "upgrading package %s-%s", info->name, info->version); /* we'll need to save some record for backup checks later */ - oldpkg = pkg_new(); + oldpkg = pkg_new(local->name, local->version); if(oldpkg) { - strncpy(oldpkg->name, local->name, PKG_NAME_LEN); - strncpy(oldpkg->version, local->version, PKG_VERSION_LEN); if(!(local->infolevel & INFRQ_FILES)) { char name[PKG_FULLNAME_LEN]; snprintf(name, PKG_FULLNAME_LEN, "%s-%s", local->name, local->version); diff --git a/lib/libalpm/alpm.c b/lib/libalpm/alpm.c index 610c3f64..fed105e2 100644 --- a/lib/libalpm/alpm.c +++ b/lib/libalpm/alpm.c @@ -565,9 +565,12 @@ int alpm_trans_init(unsigned char type, unsigned char flags, alpm_trans_cb_event { /* Sanity checks */ ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1)); - ASSERT(handle->trans == NULL, RET_ERR(PM_ERR_TRANS_NOT_NULL, -1)); + /* ORE + * perform sanity checks on type and flags: + * for instance, we can't set UPGRADE and FRESHEN at the same time */ + handle->trans = trans_new(); if(handle->trans == NULL) { RET_ERR(PM_ERR_MEMORY, -1); @@ -708,7 +711,7 @@ int alpm_logaction(char *fmt, ...) It allows to share the log file between several frontends and to actually know who does what */ - return(_alpm_log_action(handle->usesyslog, handle->logfd, str)); + return(_alpm_logaction(handle->usesyslog, handle->logfd, str)); } /** @} */ diff --git a/lib/libalpm/db.c b/lib/libalpm/db.c index ef7dfe0b..a2c26883 100644 --- a/lib/libalpm/db.c +++ b/lib/libalpm/db.c @@ -238,7 +238,7 @@ pmpkg_t *db_scan(pmdb_t *db, char *target, unsigned int inforeq) } } - pkg = pkg_new(); + pkg = pkg_new(NULL, NULL); if(pkg == NULL) { return(NULL); } diff --git a/lib/libalpm/deps.c b/lib/libalpm/deps.c index 6b9ab6c3..8c1e3558 100644 --- a/lib/libalpm/deps.c +++ b/lib/libalpm/deps.c @@ -562,7 +562,7 @@ PMList* removedeps(pmdb_t *db, PMList *targs) } if(!needed) { char *name; - pmpkg_t *pkg = pkg_dummy(dep->name, dep->version); + pmpkg_t *pkg = pkg_new(dep->name, dep->version); if(pkg == NULL) { _alpm_log(PM_LOG_ERROR, "could not allocate memory for a package structure"); continue; @@ -696,7 +696,7 @@ int resolvedeps(pmdb_t *local, PMList *dbs_sync, pmpkg_t *syncpkg, PMList *list, } } if(found) { - pmpkg_t *dummypkg = pkg_dummy(miss->target, NULL); + pmpkg_t *dummypkg = pkg_new(miss->target, NULL); QUESTION(trans, PM_TRANS_CONV_INSTALL_IGNOREPKG, dummypkg, sync, NULL, &usedep); FREEPKG(dummypkg); } diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c index aa331bb4..784b9b07 100644 --- a/lib/libalpm/package.c +++ b/lib/libalpm/package.c @@ -35,14 +35,22 @@ #include "package.h" #include "alpm.h" -pmpkg_t *pkg_new() +pmpkg_t *pkg_new(const char *name, const char *version) { pmpkg_t* pkg = NULL; MALLOC(pkg, sizeof(pmpkg_t)); - pkg->name[0] = '\0'; - pkg->version[0] = '\0'; + if(name && name[0] != 0) { + STRNCPY(pkg->name, name, PKG_NAME_LEN); + } else { + pkg->name[0] = '\0'; + } + if(version && version[0] != 0) { + STRNCPY(pkg->version, version, PKG_VERSION_LEN); + } else { + pkg->version[0] = '\0'; + } pkg->desc[0] = '\0'; pkg->url[0] = '\0'; pkg->license = NULL; @@ -133,27 +141,6 @@ void pkg_free(pmpkg_t *pkg) return; } -/* Create a dummy package struct that only contains the package - * name and version. This is useful when we're only passing - * name/version data, but it needs to be wrapped in a pmpkg_t - */ -pmpkg_t* pkg_dummy(const char *name, const char *version) -{ - pmpkg_t *pkg = pkg_new(); - if(pkg == NULL) { - return(NULL); - } - - if(name) { - STRNCPY(pkg->name, name, PKG_NAME_LEN); - } - if(version) { - STRNCPY(pkg->version, version, PKG_VERSION_LEN); - } - - return(pkg); -} - /* Parses the package description file for the current package * * Returns: 0 on success, 1 on error @@ -262,7 +249,7 @@ pmpkg_t *pkg_load(char *pkgfile) RET_ERR(PM_ERR_NOT_A_FILE, NULL); } - info = pkg_new(); + info = pkg_new(NULL, NULL); if(info == NULL) { tar_close(tar); RET_ERR(PM_ERR_MEMORY, NULL); diff --git a/lib/libalpm/package.h b/lib/libalpm/package.h index c96e667a..7bc5418a 100644 --- a/lib/libalpm/package.h +++ b/lib/libalpm/package.h @@ -86,10 +86,9 @@ do { \ } \ } while(0) -pmpkg_t* pkg_new(void); +pmpkg_t* pkg_new(const char *name, const char *version); pmpkg_t *pkg_dup(pmpkg_t *pkg); void pkg_free(pmpkg_t *pkg); -pmpkg_t* pkg_dummy(const char *name, const char *version); pmpkg_t *pkg_load(char *pkgfile); int pkg_isin(pmpkg_t *needle, PMList *haystack); int pkg_splitname(char *target, char *name, char *version); diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c index ab1a0fdd..7908a484 100644 --- a/lib/libalpm/sync.c +++ b/lib/libalpm/sync.c @@ -161,7 +161,7 @@ int sync_sysupgrade(pmtrans_t *trans, pmdb_t *db_local, PMList *dbs_sync) * the package to replace. */ pmsyncpkg_t *sync; - pmpkg_t *dummy = pkg_dummy(lpkg->name, NULL); + pmpkg_t *dummy = pkg_new(lpkg->name, NULL); if(dummy == NULL) { pm_errno = PM_ERR_MEMORY; goto error; @@ -227,7 +227,7 @@ int sync_sysupgrade(pmtrans_t *trans, pmdb_t *db_local, PMList *dbs_sync) _alpm_log(PM_LOG_FLOW1, "%s-%s: ignoring package upgrade (%s)", local->name, local->version, spkg->version); } else { - pmpkg_t *dummy = pkg_dummy(local->name, local->version); + pmpkg_t *dummy = pkg_new(local->name, local->version); sync = sync_new(PM_SYNC_TYPE_UPGRADE, spkg, dummy); if(sync == NULL) { FREEPKG(dummy); @@ -311,12 +311,10 @@ int sync_addtarget(pmtrans_t *trans, pmdb_t *db_local, PMList *dbs_sync, char *n if(!find_pkginsync(spkg->name, trans->packages)) { pmpkg_t *dummy = NULL; if(local) { - dummy = pkg_new(); + dummy = pkg_new(local->name, local->version); if(dummy == NULL) { RET_ERR(PM_ERR_MEMORY, -1); } - STRNCPY(dummy->name, local->name, PKG_NAME_LEN); - STRNCPY(dummy->version, local->version, PKG_VERSION_LEN); } sync = sync_new(PM_SYNC_TYPE_UPGRADE, spkg, dummy); if(sync == NULL) { @@ -512,7 +510,7 @@ int sync_prepare(pmtrans_t *trans, pmdb_t *db_local, PMList *dbs_sync, PMList ** for(l = trans->packages; l; l = l->next) { pmsyncpkg_t *s = l->data; if(!strcmp(s->pkg->name, miss->target)) { - pmpkg_t *q = pkg_new(); + pmpkg_t *q = pkg_new(NULL, NULL); STRNCPY(q->name, miss->depend.name, PKG_NAME_LEN); if(s->type == PM_SYNC_TYPE_REPLACE) { /* append to the replaces list */ diff --git a/lib/libalpm/trans.c b/lib/libalpm/trans.c index 12441f01..fd0814e6 100644 --- a/lib/libalpm/trans.c +++ b/lib/libalpm/trans.c @@ -82,10 +82,6 @@ int trans_init(pmtrans_t *trans, unsigned char type, unsigned char flags, alpm_t /* Sanity checks */ ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1)); - /* ORE - perform sanity checks on type and flags: - for instance, we can't set UPGRADE and FRESHEN at the same time */ - trans->type = type; trans->flags = flags; trans->cb_event = event; diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c index 79287d34..3458e156 100644 --- a/lib/libalpm/util.c +++ b/lib/libalpm/util.c @@ -308,7 +308,7 @@ int _alpm_rmrf(char *path) return(0); } -int _alpm_log_action(unsigned char usesyslog, FILE *f, char *fmt, ...) +int _alpm_logaction(unsigned char usesyslog, FILE *f, char *fmt, ...) { char msg[1024]; va_list args; diff --git a/lib/libalpm/util.h b/lib/libalpm/util.h index 1f662bbb..50c70145 100644 --- a/lib/libalpm/util.h +++ b/lib/libalpm/util.h @@ -53,7 +53,7 @@ int _alpm_lckmk(char *file); int _alpm_lckrm(char *file); int _alpm_unpack(char *archive, const char *prefix, const char *fn); int _alpm_rmrf(char *path); -int _alpm_log_action(unsigned char usesyslog, FILE *f, char *fmt, ...); +int _alpm_logaction(unsigned char usesyslog, FILE *f, char *fmt, ...); int _alpm_ldconfig(char *root); int _alpm_runscriptlet(char *util, char *installfn, char *script, char *ver, char *oldver); |