diff options
-rw-r--r-- | NEWS | 5 | ||||
-rw-r--r-- | URPM.pm | 2 | ||||
-rw-r--r-- | URPM.xs | 26 |
3 files changed, 32 insertions, 1 deletions
@@ -1,3 +1,8 @@ +Version 4.5 - 9 Jan 2011, by Per Øyvind Karlsen + +- ensure that a db environment with config & required directories exists for + chroots before opening the rpmdb + Version 4.4 - 6 Jan 2011, by Per Øyvind Karlsen - check URPM::Transactin::add() for errors and return them if any (#61746) @@ -11,7 +11,7 @@ use URPM::Resolve; use URPM::Signature; our @ISA = qw(DynaLoader); -our $VERSION = '4.4'; +our $VERSION = '4.5'; URPM->bootstrap($VERSION); @@ -2805,6 +2805,9 @@ Db_open(prefix=NULL, write_perm=0) int write_perm PREINIT: URPM__DB db; + const char *dbpath = NULL; + const char *tmp = NULL; + struct stat st; CODE: read_config_files(0); db = malloc(sizeof(struct s_Transaction)); @@ -2822,6 +2825,29 @@ Db_open(prefix=NULL, write_perm=0) } else { rpmtsSetRootDir(db->ts, prefix && prefix[0] ? prefix : NULL); } + /* XXX: be sure that we have db environment in place before using it */ + if(rpmtsRootDir(db->ts)) { + dbpath = rpmGenPath(rpmtsRootDir(db->ts), "%{_dbpath}", "log"); + rpmioMkpath(dbpath, 0755, -1, -1); + stpcpy((char*)dbpath+strlen(dbpath)-3, "tmp"); + rpmioMkpath(dbpath, 0755, -1, -1); + dbpath = _free(dbpath); + dbpath = rpmGenPath(rpmtsRootDir(db->ts), "%{_dbpath}", "DB_CONFIG"); + if(Stat(dbpath, &st) < 0) { + tmp = dbpath + strlen(rpmtsRootDir(db->ts))-1; + if(Stat(tmp, &st) >= 0) { + FD_t chrootDbConf = Fopen(dbpath, "w"); + FD_t sysDbConf = Fopen(tmp, "r"); + char buf[BUFSIZ]; + size_t r; + + while((r = Fread(buf, 1, sizeof(buf), sysDbConf)) > 0) + Fwrite(buf, 1, r, chrootDbConf); + Fclose(chrootDbConf); + Fclose(sysDbConf); + } + } + } if (rpmtsOpenDB(db->ts, write_perm ? O_RDWR | O_CREAT : O_RDONLY) == 0) { RETVAL = db; } else { |