[pacman-dev] CVS update of pacman-lib/lib/libalpm (9 files)
Aaron Griffin
aaron at archlinux.org
Wed Feb 21 01:44:15 EST 2007
Date: Wednesday, February 21, 2007 @ 01:44:15
Author: aaron
Path: /home/cvs-pacman/pacman-lib/lib/libalpm
Modified: alpm.h (1.76 -> 1.77) be_files.c (1.27 -> 1.28)
cache.c (1.30 -> 1.31) conflict.c (1.39 -> 1.40)
db.c (1.59 -> 1.60) handle.c (1.32 -> 1.33) handle.h (1.15 -> 1.16)
remove.c (1.68 -> 1.69) sync.c (1.101 -> 1.102)
* Re-added a compare function for syncpkg's - it was removed without thinking
properly
* Error when re-reading the DB for replacements, wrong info level
* Removed an duplicate debug message "checking for package replacements"
* Check ignorepkg for REAL upgrades...
* Properly check the NOSAVE flag
* some unlink_file (remove.c) cleanup
* fix indent level on handle.c
* Force libalpm paths to end with a '/' char
* Fixed 'target' looping in conflict.c (pmsyncpkg_t, not pmpkg_t)
* Added some debug output to cache and db scanning
** All pactest tests succeed again, yay **
------------+
alpm.h | 4 +-
be_files.c | 6 ++--
cache.c | 4 ++
conflict.c | 10 ++++++-
db.c | 2 -
handle.c | 79 +++++++++++++++++++++++++++++++++++++++++------------------
handle.h | 2 -
remove.c | 26 +++++++++++--------
sync.c | 43 +++++++++++++++++---------------
9 files changed, 114 insertions(+), 62 deletions(-)
Index: pacman-lib/lib/libalpm/alpm.h
diff -u pacman-lib/lib/libalpm/alpm.h:1.76 pacman-lib/lib/libalpm/alpm.h:1.77
--- pacman-lib/lib/libalpm/alpm.h:1.76 Sun Feb 11 23:45:22 2007
+++ pacman-lib/lib/libalpm/alpm.h Wed Feb 21 01:44:14 2007
@@ -35,8 +35,8 @@
*/
#define PM_ROOT "/"
-#define PM_DBPATH "var/lib/pacman"
-#define PM_CACHEDIR "var/cache/pacman/pkg"
+#define PM_DBPATH "var/lib/pacman/"
+#define PM_CACHEDIR "var/cache/pacman/pkg/"
#define PM_LOCK "tmp/pacman.lck"
Index: pacman-lib/lib/libalpm/be_files.c
diff -u pacman-lib/lib/libalpm/be_files.c:1.27 pacman-lib/lib/libalpm/be_files.c:1.28
--- pacman-lib/lib/libalpm/be_files.c:1.27 Mon Feb 12 20:46:33 2007
+++ pacman-lib/lib/libalpm/be_files.c Wed Feb 21 01:44:14 2007
@@ -72,6 +72,7 @@
RET_ERR(PM_ERR_DB_NULL, -1);
}
+ _alpm_log(PM_LOG_DEBUG, _("opening database from path '%s'"), db->path);
db->handle = opendir(db->path);
if(db->handle == NULL) {
RET_ERR(PM_ERR_DB_OPEN, -1);
@@ -154,8 +155,7 @@
if(!found) {
return(NULL);
}
- } else {
- /* normal iteration */
+ } else { /* target == NULL, full scan */
int isdir = 0;
while(!isdir) {
ent = readdir(db->handle);
@@ -176,6 +176,7 @@
pkg = _alpm_pkg_new(NULL, NULL);
if(pkg == NULL) {
+ _alpm_log(PM_LOG_DEBUG, _("db scan could not find package: %s"), target);
return(NULL);
}
if(_alpm_pkg_splitname(ent->d_name, pkg->name, pkg->version, 0) == -1) {
@@ -188,6 +189,7 @@
}
}
+ _alpm_log(PM_LOG_DEBUG, _("db scan found package: %s"), pkg->name);
return(pkg);
}
Index: pacman-lib/lib/libalpm/cache.c
diff -u pacman-lib/lib/libalpm/cache.c:1.30 pacman-lib/lib/libalpm/cache.c:1.31
--- pacman-lib/lib/libalpm/cache.c:1.30 Wed Jan 31 01:48:06 2007
+++ pacman-lib/lib/libalpm/cache.c Wed Feb 21 01:44:14 2007
@@ -61,6 +61,7 @@
_alpm_db_rewind(db);
while((info = _alpm_db_scan(db, NULL, infolevel)) != NULL) {
+ _alpm_log(PM_LOG_DEBUG, _("adding '%s' to package cache for db '%s'"), info->name, db->treename);
info->origin = PKG_FROM_CACHE;
info->data = db;
/* add to the collection */
@@ -104,6 +105,9 @@
_alpm_db_ensure_pkgcache(db, infolevel);
+ if(!db->pkgcache) {
+ _alpm_log(PM_LOG_DEBUG, _("error: pkgcache is NULL for db %s"), db->treename);
+ }
return(db->pkgcache);
}
Index: pacman-lib/lib/libalpm/conflict.c
diff -u pacman-lib/lib/libalpm/conflict.c:1.39 pacman-lib/lib/libalpm/conflict.c:1.40
--- pacman-lib/lib/libalpm/conflict.c:1.39 Mon Feb 19 21:14:27 2007
+++ pacman-lib/lib/libalpm/conflict.c Wed Feb 21 01:44:14 2007
@@ -379,9 +379,16 @@
/* stat the file - if it exists and is not a dir, do some checks */
if(lstat(path, &buf) == 0 && !S_ISDIR(buf.st_mode)) {
+
/* Look at all the targets to see if file has changed hands */
for(k = targets; k; k = k->next) {
- p2 = (pmpkg_t *)k->data;
+ pmsyncpkg_t *sync = k->data;
+ if(!sync) {
+ continue;
+ }
+
+ p2 = sync->pkg;
+
/* Ensure we aren't looking at current package */
if(p2 == p1) {
continue;
@@ -404,6 +411,7 @@
_alpm_log(PM_LOG_DEBUG, "file changed packages, adding to remove skiplist: %s", filestr);
}
} else {
+ _alpm_log(PM_LOG_DEBUG, "file found in conflict: %s", filestr);
conflicts = add_fileconflict(conflicts, PM_CONFLICT_TYPE_FILE,
filestr, p1->name, NULL);
break;
Index: pacman-lib/lib/libalpm/db.c
diff -u pacman-lib/lib/libalpm/db.c:1.59 pacman-lib/lib/libalpm/db.c:1.60
--- pacman-lib/lib/libalpm/db.c:1.59 Wed Jan 31 01:10:21 2007
+++ pacman-lib/lib/libalpm/db.c Wed Feb 21 01:44:14 2007
@@ -71,7 +71,7 @@
FREE(db);
RET_ERR(PM_ERR_MEMORY, NULL);
}
- sprintf(db->path, "%s%s/%s", root, dbpath, treename);
+ sprintf(db->path, "%s%s%s", root, dbpath, treename);
STRNCPY(db->treename, treename, PATH_MAX);
Index: pacman-lib/lib/libalpm/handle.c
diff -u pacman-lib/lib/libalpm/handle.c:1.32 pacman-lib/lib/libalpm/handle.c:1.33
--- pacman-lib/lib/libalpm/handle.c:1.32 Sun Feb 11 23:45:22 2007
+++ pacman-lib/lib/libalpm/handle.c Wed Feb 21 01:44:15 2007
@@ -66,28 +66,29 @@
/* see if we're root or not (fakeroot does not count) */
#ifndef FAKEROOT
if(handle->uid == 0 && !getenv("FAKEROOTKEY")) {
+ /* } make vim indent work - stupid ifdef's */
#else
- if(handle->uid == 0) {
+ if(handle->uid == 0) {
#endif
- handle->access = PM_ACCESS_RW;
- } else {
- handle->access = PM_ACCESS_RO;
- }
+ handle->access = PM_ACCESS_RW;
+ } else {
+ handle->access = PM_ACCESS_RO;
+ }
#else
handle->access = PM_ACCESS_RW;
#endif
- handle->root = strdup(PM_ROOT);
+ handle->root = strdup(PM_ROOT);
handle->dbpath = strdup(PM_DBPATH);
handle->cachedir = strdup(PM_CACHEDIR);
- handle->logmask = PM_LOG_ERROR | PM_LOG_WARNING;
+ handle->logmask = PM_LOG_ERROR | PM_LOG_WARNING;
return(handle);
}
int _alpm_handle_free(pmhandle_t *handle)
{
- ALPM_LOG_FUNC;
+ ALPM_LOG_FUNC;
ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1));
@@ -139,7 +140,7 @@
pmdb_t *alpm_option_get_localdb() { return handle->db_local; }
alpm_list_t SYMEXPORT *alpm_option_get_syncdbs()
{
- return handle->dbs_sync;
+ return handle->dbs_sync;
}
void SYMEXPORT alpm_option_set_logcb(alpm_cb_log cb) { handle->logcb = cb; }
@@ -151,24 +152,54 @@
void alpm_option_set_root(const char *root)
{
if(handle->root) FREE(handle->root);
- if(root) handle->root = strdup(root);
+ if(root) {
+ /* verify root ends in a '/' */
+ int rootlen = strlen(root);
+ if(root[rootlen-1] != '/') {
+ rootlen += 1;
+ }
+ handle->root = calloc(rootlen+1, sizeof(char));
+ strncpy(handle->root, root, rootlen);
+ handle->root[rootlen-1] = '/';
+ _alpm_log(PM_LOG_DEBUG, _("option 'root' = %s"), handle->root);
+ }
}
void SYMEXPORT alpm_option_set_dbpath(const char *dbpath)
{
- if(handle->dbpath) FREE(handle->dbpath);
- if(dbpath) handle->dbpath = strdup(dbpath);
+ if(handle->dbpath) FREE(handle->dbpath);
+ if(dbpath) {
+ /* verify dbpath ends in a '/' */
+ int dbpathlen = strlen(dbpath);
+ if(dbpath[dbpathlen-1] != '/') {
+ dbpathlen += 1;
+ }
+ handle->dbpath = calloc(dbpathlen+1, sizeof(char));
+ strncpy(handle->dbpath, dbpath, dbpathlen);
+ handle->dbpath[dbpathlen-1] = '/';
+ _alpm_log(PM_LOG_DEBUG, _("option 'dbpath' = %s"), handle->dbpath);
+ }
}
void alpm_option_set_cachedir(const char *cachedir)
{
- if(handle->cachedir) FREE(handle->cachedir);
- if(cachedir) handle->cachedir = strdup(cachedir);
+ if(handle->cachedir) FREE(handle->cachedir);
+ if(cachedir) {
+ /* verify cachedir ends in a '/' */
+ int cachedirlen = strlen(cachedir);
+ if(cachedir[cachedirlen-1] != '/') {
+ cachedirlen += 1;
+ }
+ handle->cachedir = calloc(cachedirlen+1, sizeof(char));
+ strncpy(handle->cachedir, cachedir, cachedirlen);
+ handle->cachedir[cachedirlen-1] = '/';
+ _alpm_log(PM_LOG_DEBUG, _("option 'cachedir' = %s"), handle->cachedir);
+ }
}
void alpm_option_set_logfile(const char *logfile)
{
- ALPM_LOG_FUNC;
+ ALPM_LOG_FUNC;
if(handle->logfile) {
FREE(handle->logfile);
@@ -185,12 +216,12 @@
void alpm_option_set_usesyslog(unsigned short usesyslog)
{
- handle->usesyslog = usesyslog;
+ handle->usesyslog = usesyslog;
}
void alpm_option_add_noupgrade(char *pkg)
{
- handle->noupgrade = alpm_list_add(handle->noupgrade, strdup(pkg));
+ handle->noupgrade = alpm_list_add(handle->noupgrade, strdup(pkg));
}
void alpm_option_set_noupgrades(alpm_list_t *noupgrade)
@@ -201,7 +232,7 @@
void alpm_option_add_noextract(char *pkg)
{
- handle->noextract = alpm_list_add(handle->noextract, strdup(pkg));
+ handle->noextract = alpm_list_add(handle->noextract, strdup(pkg));
}
void alpm_option_set_noextracts(alpm_list_t *noextract)
{
@@ -211,7 +242,7 @@
void SYMEXPORT alpm_option_add_ignorepkg(char *pkg)
{
- handle->ignorepkg = alpm_list_add(handle->ignorepkg, strdup(pkg));
+ handle->ignorepkg = alpm_list_add(handle->ignorepkg, strdup(pkg));
}
void alpm_option_set_ignorepkgs(alpm_list_t *ignorepkgs)
{
@@ -221,7 +252,7 @@
void alpm_option_add_holdpkg(char *pkg)
{
- handle->holdpkg = alpm_list_add(handle->holdpkg, strdup(pkg));
+ handle->holdpkg = alpm_list_add(handle->holdpkg, strdup(pkg));
}
void alpm_option_set_holdpkgs(alpm_list_t *holdpkgs)
{
@@ -231,7 +262,7 @@
void alpm_option_set_upgradedelay(time_t delay)
{
- handle->upgradedelay = delay;
+ handle->upgradedelay = delay;
}
void alpm_option_set_xfercommand(const char *cmd)
@@ -242,14 +273,14 @@
void alpm_option_set_nopassiveftp(unsigned short nopasv)
{
- handle->nopassiveftp = nopasv;
+ handle->nopassiveftp = nopasv;
}
void alpm_option_set_chomp(unsigned short chomp) { handle->chomp = chomp; }
void alpm_option_set_usecolor(unsigned short usecolor)
{
- handle->use_color = usecolor;
+ handle->use_color = usecolor;
}
-/* vim: set ts=2 sw=2 et: */
+/* vim: set ts=2 sw=2 noet: */
Index: pacman-lib/lib/libalpm/handle.h
diff -u pacman-lib/lib/libalpm/handle.h:1.15 pacman-lib/lib/libalpm/handle.h:1.16
--- pacman-lib/lib/libalpm/handle.h:1.15 Sun Feb 11 23:45:22 2007
+++ pacman-lib/lib/libalpm/handle.h Wed Feb 21 01:44:15 2007
@@ -69,7 +69,7 @@
#define FREEHANDLE(p) do { if (p) { _alpm_handle_free(p); p = NULL; } } while (0)
-pmhandle_t *_alpm_handle_new(void);
+pmhandle_t *_alpm_handle_new();
int _alpm_handle_free(pmhandle_t *handle);
#endif /* _ALPM_HANDLE_H */
Index: pacman-lib/lib/libalpm/remove.c
diff -u pacman-lib/lib/libalpm/remove.c:1.68 pacman-lib/lib/libalpm/remove.c:1.69
--- pacman-lib/lib/libalpm/remove.c:1.68 Mon Feb 19 21:14:27 2007
+++ pacman-lib/lib/libalpm/remove.c Wed Feb 21 01:44:15 2007
@@ -206,10 +206,11 @@
FREE(hash);
}
- if(!needbackup && trans->type == PM_TRANS_TYPE_UPGRADE) {
+ if(trans->type == PM_TRANS_TYPE_UPGRADE) {
/* check noupgrade */
if(alpm_list_find_str(handle->noupgrade, lp->data)) {
- needbackup = 1;
+ _alpm_log(PM_LOG_DEBUG, _("Skipping removal of '%s' due to NoUpgrade"), file);
+ return;
}
}
@@ -232,28 +233,31 @@
* explanation. */
if(alpm_list_find_str(trans->skip_remove, file)) {
_alpm_log(PM_LOG_DEBUG, _("%s is in trans->skip_remove, skipping removal"), file);
+ return;
} else if(needbackup) {
/* if the file is flagged, back it up to .pacsave */
if(!(trans->type == PM_TRANS_TYPE_UPGRADE)) {
/* if it was an upgrade, the file would be left alone because
* pacman_add() would handle it */
- if(!(trans->type & PM_TRANS_FLAG_NOSAVE)) {
+ if(!(trans->flags & PM_TRANS_FLAG_NOSAVE)) {
char newpath[PATH_MAX];
snprintf(newpath, PATH_MAX, "%s.pacsave", file);
rename(file, newpath);
_alpm_log(PM_LOG_WARNING, _("%s saved as %s"), file, newpath);
+ return;
+ } else {
+ _alpm_log(PM_LOG_DEBUG, _("transaction is set to NOSAVE, not backing up '%s'"), file);
}
}
- } else {
- _alpm_log(PM_LOG_DEBUG, _("unlinking %s"), file);
- int list_count = alpm_list_count(trans->packages); /* this way we don't have to call alpm_list_count twice during PROGRESS */
+ }
+ _alpm_log(PM_LOG_DEBUG, _("unlinking %s"), file);
+ int list_count = alpm_list_count(trans->packages); /* this way we don't have to call alpm_list_count twice during PROGRESS */
- PROGRESS(trans, PM_TRANS_PROGRESS_REMOVE_START, info->name, (double)(percent * 100), list_count, (list_count - alpm_list_count(targ) + 1));
- ++(*position);
+ PROGRESS(trans, PM_TRANS_PROGRESS_REMOVE_START, info->name, (double)(percent * 100), list_count, (list_count - alpm_list_count(targ) + 1));
+ ++(*position);
- if(unlink(file) == -1) {
- _alpm_log(PM_LOG_ERROR, _("cannot remove file %s: %s"), lp->data, strerror(errno));
- }
+ if(unlink(file) == -1) {
+ _alpm_log(PM_LOG_ERROR, _("cannot remove file %s: %s"), lp->data, strerror(errno));
}
}
}
Index: pacman-lib/lib/libalpm/sync.c
diff -u pacman-lib/lib/libalpm/sync.c:1.101 pacman-lib/lib/libalpm/sync.c:1.102
--- pacman-lib/lib/libalpm/sync.c:1.101 Tue Feb 13 03:15:38 2007
+++ pacman-lib/lib/libalpm/sync.c Wed Feb 21 01:44:15 2007
@@ -128,7 +128,7 @@
/* check for "recommended" package replacements */
_alpm_log(PM_LOG_DEBUG, _("checking for package replacements"));
for(i = dbs_sync; i; i = i->next) {
- for(j = _alpm_db_get_pkgcache(i->data, INFRQ_DESC); j; j = j->next) {
+ for(j = _alpm_db_get_pkgcache(i->data, INFRQ_DEPENDS); j; j = j->next) {
pmpkg_t *spkg = j->data;
for(k = spkg->replaces; k; k = k->next) {
alpm_list_t *m;
@@ -194,7 +194,6 @@
ALPM_LOG_FUNC;
/* check for "recommended" package replacements */
- _alpm_log(PM_LOG_DEBUG, _("checking for package replacements"));
if( find_replacements(trans, db_local, dbs_sync) == 0 ) {
/* match installed packages with the sync dbs and compare versions */
_alpm_log(PM_LOG_DEBUG, _("checking for package upgrades"));
@@ -229,19 +228,24 @@
/* compare versions and see if we need to upgrade */
if(alpm_pkg_compare_versions(local, spkg)) {
- _alpm_log(PM_LOG_DEBUG, _("%s-%s elected for upgrade (%s => %s)"),
- local->name, local->version, local->version, spkg->version);
- if(!find_pkginsync(spkg->name, trans->packages)) {
- pmpkg_t *dummy = _alpm_pkg_new(local->name, local->version);
- if(dummy == NULL) {
- goto error;
- }
- sync = _alpm_sync_new(PM_SYNC_TYPE_UPGRADE, spkg, dummy);
- if(sync == NULL) {
- FREEPKG(dummy);
- goto error;
+ if(alpm_list_find_str(handle->ignorepkg, local->name)) {
+ _alpm_log(PM_LOG_WARNING, _("%s-%s: ignoring package upgrade (%s => %s)"),
+ local->name, local->version, local->version, spkg->version);
+ } else {
+ _alpm_log(PM_LOG_DEBUG, _("%s-%s elected for upgrade (%s => %s)"),
+ local->name, local->version, local->version, spkg->version);
+ if(!find_pkginsync(spkg->name, trans->packages)) {
+ pmpkg_t *dummy = _alpm_pkg_new(local->name, local->version);
+ if(dummy == NULL) {
+ goto error;
+ }
+ sync = _alpm_sync_new(PM_SYNC_TYPE_UPGRADE, spkg, dummy);
+ if(sync == NULL) {
+ FREEPKG(dummy);
+ goto error;
+ }
+ trans->packages = alpm_list_add(trans->packages, sync);
}
- trans->packages = alpm_list_add(trans->packages, sync);
}
}
}
@@ -358,11 +362,10 @@
/* Helper functions for alpm_list_remove
*/
-/* removed - use pkg_cmp all of the time
-static int ptr_cmp(const void *s1, const void *s2)
+static int syncpkg_cmp(const void *s1, const void *s2)
{
return(strcmp(((pmsyncpkg_t *)s1)->pkg->name, ((pmsyncpkg_t *)s2)->pkg->name));
-}*/
+}
static int pkg_cmp(const void *p1, const void *p2)
{
@@ -554,8 +557,8 @@
if(rmpkg) {
pmsyncpkg_t *rsync = find_pkginsync(rmpkg, trans->packages);
void *vpkg;
- _alpm_log(PM_LOG_DEBUG, _("removing '%s' from target list"), rmpkg);
- trans->packages = alpm_list_remove(trans->packages, rsync, pkg_cmp, &vpkg);
+ _alpm_log(PM_LOG_DEBUG, _("removing '%s' from target list"), rsync->pkg->name);
+ trans->packages = alpm_list_remove(trans->packages, rsync, syncpkg_cmp, &vpkg);
FREESYNC(vpkg);
continue;
}
@@ -592,7 +595,7 @@
/* remove it from the target list */
void *vpkg;
_alpm_log(PM_LOG_DEBUG, _("removing '%s' from target list"), miss->depend.name);
- trans->packages = alpm_list_remove(trans->packages, rsync, pkg_cmp, &vpkg);
+ trans->packages = alpm_list_remove(trans->packages, rsync, syncpkg_cmp, &vpkg);
FREESYNC(vpkg);
}
} else {
More information about the pacman-dev
mailing list