From f6c7de77edee89650e8dabf728f296d48cd4b3e0 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Mon, 15 Mar 2010 23:03:29 -0500 Subject: Unbreak the database partial extraction code Basically I'm the idiot that thought I could make it better and completely forgot how freeing the contents of the original lists would screw up our nice little diff extraction lists. This caused segfaults among other problems. Last time I try to do that... Program received signal SIGSEGV, Segmentation fault. 0x00007ffff627ce26 in strcmp () from /lib/libc.so.6 (gdb) bt Signed-off-by: Dan McGee --- lib/libalpm/be_files.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'lib/libalpm') diff --git a/lib/libalpm/be_files.c b/lib/libalpm/be_files.c index 4ddb1369..955351ce 100644 --- a/lib/libalpm/be_files.c +++ b/lib/libalpm/be_files.c @@ -210,7 +210,8 @@ int SYMEXPORT alpm_db_update(int force, pmdb_t *db) { char *dbfile, *dbfilepath; const char *dbpath, *syncdbpath; - alpm_list_t *filelist = NULL; + alpm_list_t *newdirlist = NULL, *olddirlist = NULL; + alpm_list_t *onlynew = NULL, *onlyold = NULL; size_t len; int ret; @@ -266,28 +267,18 @@ int SYMEXPORT alpm_db_update(int force, pmdb_t *db) } } else { /* if not forcing, only remove and extract what is necessary */ - alpm_list_t *newdirlist = NULL; - alpm_list_t *olddirlist = NULL; - alpm_list_t *onlyold = NULL; - ret = dirlist_from_tar(dbfilepath, &newdirlist); if(ret) { - FREELIST(newdirlist); goto cleanup; } ret = dirlist_from_fs(syncdbpath, &olddirlist); if(ret) { - FREELIST(olddirlist); - FREELIST(newdirlist); goto cleanup; } - alpm_list_diff_sorted(olddirlist, newdirlist, _alpm_str_cmp, &onlyold, &filelist); - FREELIST(olddirlist); - FREELIST(newdirlist); + alpm_list_diff_sorted(olddirlist, newdirlist, _alpm_str_cmp, &onlyold, &onlynew); ret = remove_olddir(syncdbpath, onlyold); - alpm_list_free(onlyold); if(ret) { goto cleanup; } @@ -297,9 +288,14 @@ int SYMEXPORT alpm_db_update(int force, pmdb_t *db) _alpm_db_free_pkgcache(db); checkdbdir(db); - ret = _alpm_unpack(dbfilepath, syncdbpath, filelist, 0); + ret = _alpm_unpack(dbfilepath, syncdbpath, onlynew, 0); cleanup: + FREELIST(newdirlist); + FREELIST(olddirlist); + alpm_list_free(onlynew); + alpm_list_free(onlyold); + free(dbfilepath); if(ret) { -- cgit v1.2.3-70-g09d2