summaryrefslogtreecommitdiff
path: root/lib/libalpm/trans.c
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-02-28 10:46:00 -0600
committerDan McGee <dan@archlinux.org>2011-02-28 10:46:00 -0600
commitf45369800abdeb54847d9ea6a326eb613f30cd3b (patch)
tree41ed4f7ae8c9fa18ed60a5b5ca1ccf6d4540bc62 /lib/libalpm/trans.c
parent5ea4706f57e15de23a5fd36eff3bc4619aeac224 (diff)
downloadpacman-f45369800abdeb54847d9ea6a326eb613f30cd3b.tar.xz
Check local DB version before continuing transaction
Ensure we have a local DB version that is up to par with what we expect before we go down any road that might modify it. This should prevent stupid mistakes with the 3.5.X upgrade and people not running pacman-db-upgrade after the transaction as they will need to. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib/libalpm/trans.c')
-rw-r--r--lib/libalpm/trans.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/libalpm/trans.c b/lib/libalpm/trans.c
index 8e47f377..4b29f9a8 100644
--- a/lib/libalpm/trans.c
+++ b/lib/libalpm/trans.c
@@ -105,10 +105,12 @@ static int remove_lock(pmhandle_t *handle)
* @return 0 on success, -1 on error (pm_errno is set accordingly)
*/
int SYMEXPORT alpm_trans_init(pmtransflag_t flags,
- alpm_trans_cb_event event, alpm_trans_cb_conv conv,
- alpm_trans_cb_progress progress)
+ alpm_trans_cb_event event, alpm_trans_cb_conv conv,
+ alpm_trans_cb_progress progress)
{
pmtrans_t *trans;
+ const int required_db_version = 2;
+ int db_version;
ALPM_LOG_FUNC;
@@ -124,6 +126,15 @@ int SYMEXPORT alpm_trans_init(pmtransflag_t flags,
}
}
+ /* check database version */
+ db_version = _alpm_db_version(handle->db_local);
+ if(db_version < required_db_version) {
+ _alpm_log(PM_LOG_ERROR,
+ _("%s database version is too old\n"), handle->db_local->treename);
+ remove_lock(handle);
+ RET_ERR(PM_ERR_DB_VERSION, -1);
+ }
+
trans = _alpm_trans_new();
if(trans == NULL) {
RET_ERR(PM_ERR_MEMORY, -1);