aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPer Øyvind Karlsen <peroyvind@mandriva.org>2011-06-23 13:33:24 +0000
committerPer Øyvind Karlsen <peroyvind@mandriva.org>2011-06-23 13:33:24 +0000
commitd90d346dea440491682e78c0ca14dded8e0efb5c (patch)
tree17c176e885d0d265b905d58bfeebbcb4e7c44bd9
parentf0675d61ccb49295001eb4850690ded79ab353c1 (diff)
downloadperl-URPM-d90d346dea440491682e78c0ca14dded8e0efb5c.tar
perl-URPM-d90d346dea440491682e78c0ca14dded8e0efb5c.tar.gz
perl-URPM-d90d346dea440491682e78c0ca14dded8e0efb5c.tar.bz2
perl-URPM-d90d346dea440491682e78c0ca14dded8e0efb5c.tar.xz
perl-URPM-d90d346dea440491682e78c0ca14dded8e0efb5c.zip
add a workaround for handling upgrade from older berkeley db versions which
might not support new configuration in DB_CONFIG, causing it to break during upgrade
-rw-r--r--NEWS3
-rw-r--r--URPM.xs30
2 files changed, 32 insertions, 1 deletions
diff --git a/NEWS b/NEWS
index 36bcddb..297c364 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,8 @@
Version 4.34 - 23 June 2011, by Per Øyvid Karlsen
+- add a workaround for handling upgrade from older berkeley db versions which
+ might not support new configuration in DB_CONFIG, causing it to break during
+ upgrade
- add support for specifying tag name to match with URPM::Transaction->remove()
- add some regression tests for parsing disttag & distepoch from synthesis
- extract disttag & distepoch from new fields in @info@ of synthesis
diff --git a/URPM.xs b/URPM.xs
index e89ec65..a27fd17 100644
--- a/URPM.xs
+++ b/URPM.xs
@@ -1645,9 +1645,12 @@ rpmdb_convert(const char *prefix, int dbtype, int swap, int rebuild) {
const char *_dbi_tags = NULL;
const char *_dbi_config = NULL;
const char *_dbi_config_Packages = NULL;
- const char *fn = NULL;
+ const char *fn = NULL, *fn2 = NULL;
const char *tmppath = NULL;
glob_t gl = { .gl_pathc = 0, .gl_pathv = NULL, .gl_offs = 0 };
+ struct stat st;
+ FD_t fd = NULL;
+
unsetenv("TMPDIR");
rpmReadConfigFiles(NULL, NULL);
@@ -1668,6 +1671,31 @@ rpmdb_convert(const char *prefix, int dbtype, int swap, int rebuild) {
tsCur = rpmtsCreate();
rpmtsSetRootDir(tsCur, prefix && prefix[0] ? prefix : NULL);
+
+ /* To try make upgrades smooth, we've tried to prevent the new configuration
+ * with possibly incompatible configuration from being dropped in during the
+ * upgrade. Now that the rpm upgrade has finished we'll make sure to switch
+ * to this new configuration before performing the conversion.
+ */
+ fn2 = rpmGetPath(prefix && prefix[0] ? prefix : "", "%{_dbpath}", "/DB_CONFIG.rpmnew", NULL);
+ if (!Stat(fn2, &st) && st.st_size) {
+ fn = rpmGetPath(prefix && prefix[0] ? prefix : "", "%{_dbpath}", "/DB_CONFIG", NULL);
+ if (!Stat(fn, &st)) {
+ /* if empty configuration, we'll just remove it */
+ if (!st.st_size)
+ Unlink(fn);
+ else {
+ /* if non-empty configuration exists, we'll rename it */
+ fn2 = rpmGetPath(prefix && prefix[0] ? prefix : "", "%{_dbpath}", "/DB_CONFIG.rpmsave", NULL);
+ Rename(fn, fn2);
+ fn2 = _free(fn2);
+ }
+ }
+ Rename(fn2, fn);
+ fn = _free(fn);
+ }
+ fn2 = _free(fn2);
+
if(!rpmtsOpenDB(tsCur, O_RDONLY)) {
if(dbtype == 1) {
addMacro(NULL, "_dbi_tags", NULL, "Packages:Name:Basenames:Group:Requirename:Providename:Conflictname:Triggername:Dirnames:Requireversion:Provideversion:Installtid:Sigmd5:Sha1header:Filedigests:Depends:Pubkeys", -1);