From 20c4928ee155db7b43b9f5b440a2cb199f178bb4 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Fri, 1 Apr 2011 12:30:57 -0500 Subject: Ignore upcoming new values in sync backend PGPSIG and SHA256SUM are new and we can safely ignore them for now if we come across them. Signed-off-by: Dan McGee --- lib/libalpm/be_sync.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib/libalpm/be_sync.c') diff --git a/lib/libalpm/be_sync.c b/lib/libalpm/be_sync.c index 98516fd8..5a13adda 100644 --- a/lib/libalpm/be_sync.c +++ b/lib/libalpm/be_sync.c @@ -418,6 +418,12 @@ static int sync_db_read(pmdb_t *db, struct archive *archive, pkg->isize = atol(line); } else if(strcmp(line, "%MD5SUM%") == 0) { READ_AND_STORE(pkg->md5sum); + } else if(strcmp(line, "%SHA256SUM%") == 0) { + /* we don't do anything with this value right now */ + READ_NEXT(line); + } else if(strcmp(line, "%PGPSIG%") == 0) { + /* we don't do anything with this value right now */ + READ_NEXT(line); } else if(strcmp(line, "%REPLACES%") == 0) { READ_AND_STORE_ALL(pkg->replaces); } else if(strcmp(line, "%DEPENDS%") == 0) { -- cgit v1.2.3-54-g00ecf From 39fd8bc318d4a90aab704f892cd80c22f5c7345f Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Fri, 1 Apr 2011 14:31:50 -0500 Subject: Ensure dbpath is not null when populating sync database We didn't do this sanity check before trying to open an archive. If the alpm dbpath wasn't set, the sync database dbpath would be NULL, causing us to hang indefinitely in archive_read_open_filename() rather than erroring out. We already have a corresponding check in local_db_populate(). The following program will test this case, and hangs before this patch without the call to set_dbpath: int main(int argc, char *argv[]) { alpm_initialize(); // alpm_option_set_dbpath("/var/lib/pacman/"); pmdb_t *core = alpm_db_register_sync("core"); pmpkg_t *pkg = alpm_db_get_pkg(core, "pacman"); return 0; } Signed-off-by: Dan McGee --- lib/libalpm/be_sync.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'lib/libalpm/be_sync.c') diff --git a/lib/libalpm/be_sync.c b/lib/libalpm/be_sync.c index 5a13adda..ef8517e3 100644 --- a/lib/libalpm/be_sync.c +++ b/lib/libalpm/be_sync.c @@ -209,6 +209,7 @@ static size_t estimate_package_count(struct stat *st, struct archive *archive) static int sync_db_populate(pmdb_t *db) { + const char *dbpath; size_t est_count; int count = 0; struct stat buf; @@ -226,14 +227,22 @@ static int sync_db_populate(pmdb_t *db) archive_read_support_compression_all(archive); archive_read_support_format_all(archive); - if(archive_read_open_filename(archive, _alpm_db_path(db), + dbpath = _alpm_db_path(db); + if(!dbpath) { + /* pm_errno set in _alpm_db_path() */ + return 1; + } + + _alpm_log(PM_LOG_DEBUG, "opening database archive %s\n", dbpath); + + if(archive_read_open_filename(archive, dbpath, ARCHIVE_DEFAULT_BYTES_PER_BLOCK) != ARCHIVE_OK) { - _alpm_log(PM_LOG_ERROR, _("could not open file %s: %s\n"), _alpm_db_path(db), + _alpm_log(PM_LOG_ERROR, _("could not open file %s: %s\n"), dbpath, archive_error_string(archive)); archive_read_finish(archive); RET_ERR(PM_ERR_DB_OPEN, 1); } - if(stat(_alpm_db_path(db), &buf) != 0) { + if(stat(dbpath, &buf) != 0) { RET_ERR(PM_ERR_DB_OPEN, 1); } est_count = estimate_package_count(&buf, archive); -- cgit v1.2.3-54-g00ecf From c37710734694c5a64da924bbfbbcfc07496e241e Mon Sep 17 00:00:00 2001 From: Rémy Oudompheng Date: Sat, 2 Apr 2011 00:35:37 +0200 Subject: Fix compatibility with older versions of libarchive. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There is no reason to not support versions of libarchive that lack ARCHIVE_COMPRESSION_UU. Distributions should work properly without this. Signed-off-by: Rémy Oudompheng Signed-off-by: Dan McGee --- lib/libalpm/be_sync.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib/libalpm/be_sync.c') diff --git a/lib/libalpm/be_sync.c b/lib/libalpm/be_sync.c index ef8517e3..c2c62aa2 100644 --- a/lib/libalpm/be_sync.c +++ b/lib/libalpm/be_sync.c @@ -197,9 +197,11 @@ static size_t estimate_package_count(struct stat *st, struct archive *archive) case ARCHIVE_COMPRESSION_XZ: per_package = 143; break; +#ifdef ARCHIVE_COMPRESSION_UU case ARCHIVE_COMPRESSION_UU: per_package = 3543; break; +#endif default: /* assume it is at least somewhat compressed */ per_package = 200; -- cgit v1.2.3-54-g00ecf