From 13b3f80177b1fc3d66470c319fdbfc43e76a2550db4ae21d5032fc3ee8600925 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Schr=C3=B6der?= Date: Mon, 19 Oct 2020 09:57:57 +0000 Subject: [PATCH] - Backport FA_TOUCH fixes from upsteam [bnc#1175025] [bnc#1177428] OBS-URL: https://build.opensuse.org/package/show/Base:System/rpm?expand=0&rev=558 --- bdb_ro.diff | 884 +++++++++++++++++++++++++++++ brp-compress-no-img.patch | 8 +- brp.diff | 22 +- brpcompress.diff | 29 +- checkfilesnoinfodir.diff | 8 +- db_conversion.diff | 116 ++-- db_ops_name.diff | 248 ++++++++ dbrointerruptable.diff | 12 +- disable_bdb.diff | 15 + finddebuginfo-check-res-file.patch | 9 +- findsupplements.diff | 24 +- gcryptdsa2.diff | 19 + ignore-auxv.diff | 17 +- initgcrypt.diff | 11 + lazystatfs.diff | 50 ++ macrosin.diff | 43 +- ndb_backport.diff | 733 ++++++++++++++++++++++++ ndb_backport2.diff | 305 ++++++++++ nextiteratorheaderblob.diff | 66 --- nobuildcolor.diff | 12 +- nomagiccheck.diff | 12 +- platformin.diff | 2 +- python-rpm.changes | 5 - python-rpm.spec | 2 +- rpm-4.12.0.1-fix-bashisms.patch | 12 + rpm-4.15.1.tar.bz2 | 3 + rpm-4.16.0.tar.bz2 | 3 - rpm-shorten-changelog.diff | 28 +- rpm.changes | 52 +- rpm.spec | 29 +- rpmqpack.diff | 20 +- suspendlock.diff | 36 +- touch_backport.diff | 64 +++ 33 files changed, 2589 insertions(+), 310 deletions(-) create mode 100644 bdb_ro.diff create mode 100644 db_ops_name.diff create mode 100644 disable_bdb.diff create mode 100644 gcryptdsa2.diff create mode 100644 initgcrypt.diff create mode 100644 lazystatfs.diff create mode 100644 ndb_backport.diff create mode 100644 ndb_backport2.diff delete mode 100644 nextiteratorheaderblob.diff create mode 100644 rpm-4.12.0.1-fix-bashisms.patch create mode 100644 rpm-4.15.1.tar.bz2 delete mode 100644 rpm-4.16.0.tar.bz2 create mode 100644 touch_backport.diff diff --git a/bdb_ro.diff b/bdb_ro.diff new file mode 100644 index 0000000..e53e7d3 --- /dev/null +++ b/bdb_ro.diff @@ -0,0 +1,884 @@ +--- ./configure.ac.orig 2020-01-17 12:07:10.366060891 +0000 ++++ ./configure.ac 2020-01-17 12:07:57.129945219 +0000 +@@ -588,6 +588,20 @@ AS_IF([test "$enable_ndb" = yes],[ + AM_CONDITIONAL([NDB], [test "$enable_ndb" = yes]) + + #================= ++# Process --enable-bdb-ro ++AC_ARG_ENABLE([bdb-ro], [AS_HELP_STRING([--enable-bdb-ro (EXPERIMENTAL)],[enable the read-only Berkeley DB code])], ++[case "$enable_bdb_ro" in ++yes|no) ;; ++*) AC_MSG_ERROR([invalid argument to --enable-bdb-ro]) ++ ;; ++esac], ++[enable_bdb_ro=no]) ++AS_IF([test "$enable_bdb_ro" = yes],[ ++ AC_DEFINE(WITH_BDB_RO, 1, [Build with read-only Berkeley DB]) ++]) ++AM_CONDITIONAL([BDB_RO], [test "$enable_bdb_ro" = yes]) ++ ++#================= + # Check for LMDB support + AC_ARG_ENABLE([lmdb], + [AS_HELP_STRING([--enable-lmdb=@<:@yes/no/auto@:>@ (EXPERIMENTAL)], +--- ./lib/Makefile.am.orig 2019-06-26 14:17:31.404985707 +0000 ++++ ./lib/Makefile.am 2020-01-17 12:07:57.129945219 +0000 +@@ -68,6 +68,10 @@ librpm_la_LIBADD += @WITH_DB_LIB@ + endif + endif + ++if BDB_RO ++librpm_la_SOURCES += backend/bdb_ro.c ++endif ++ + if NDB + librpm_la_SOURCES += \ + backend/ndb/glue.c \ +--- ./lib/backend/bdb_ro.c.orig 2020-01-17 12:07:57.129945219 +0000 ++++ ./lib/backend/bdb_ro.c 2020-01-17 12:11:21.125440629 +0000 +@@ -0,0 +1,819 @@ ++#include "system.h" ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#include "lib/rpmdb_internal.h" ++#include ++#include ++ ++#define BDB_HASH 0 ++#define BDB_BTREE 1 ++ ++struct dbiCursor_s; ++ ++struct bdb_kv { ++ unsigned char *kv; ++ unsigned int len; ++}; ++ ++struct bdb_db { ++ int fd; /* file descriptor of database */ ++ int type; /* BDB_HASH / BDB_BTREE */ ++ unsigned int pagesize; ++ unsigned int lastpage; ++ int swapped; /* different endianess? */ ++ /* btree */ ++ unsigned int root; /* root page of the b-tree */ ++ /* hash */ ++ unsigned int maxbucket; ++ unsigned int highmask; ++ unsigned int lowmask; ++ unsigned int spares[32]; /* spare pages for each splitpoint */ ++}; ++ ++struct bdb_cur { ++ struct bdb_db *db; ++ ++ struct bdb_kv key; /* key and value from the db entry */ ++ struct bdb_kv val; ++ ++ unsigned char *page; /* the page we're looking at */ ++ ++ unsigned char *ovpage; ++ struct bdb_kv keyov; /* space to store oversized keys/values */ ++ struct bdb_kv valov; ++ ++ int state; /* 1: onpage, -1: error */ ++ int idx; /* entry index */ ++ int numidx; /* number of entries on the page */ ++ int islookup; /* we're doing a lookup operation */ ++ ++ /* hash */ ++ unsigned int bucket; /* current bucket */ ++}; ++ ++ ++static void swap16(unsigned char *p) ++{ ++ int a = p[0]; ++ p[0] = p[1]; ++ p[1] = a; ++} ++ ++static void swap32(unsigned char *p) ++{ ++ int a = p[0]; ++ p[0] = p[3]; ++ p[3] = a; ++ a = p[1]; ++ p[1] = p[2]; ++ p[2] = a; ++} ++ ++static void swap32_2(unsigned char *p) ++{ ++ swap32(p); ++ swap32(p + 4); ++} ++ ++static void bdb_swapmetapage(struct bdb_db *db, unsigned char *page) ++{ ++ int i, maxi = db->type == BDB_HASH ? 224 : 92; ++ for (i = 8; i < maxi; i += 4) ++ swap32((unsigned char *)(page + i)); ++ swap32((unsigned char *)(page + 24)); ++} ++ ++static void bdb_swappage(struct bdb_db *db, unsigned char *page) ++{ ++ unsigned int pagesize = db->pagesize; ++ int type, i, nent, off; ++ swap32(page + 8); /* page number */ ++ swap32_2(page + 12); /* prev/next page */ ++ swap16(page + 20); /* nitems */ ++ swap16(page + 22); /* highfree */ ++ ++ type = page[25]; ++ if (type != 2 && type != 13 && type != 3 && type != 5) ++ return; ++ nent = *(uint16_t *)(page + 20); ++ if (nent > (pagesize - 26) / 2) ++ nent = (pagesize - 26) / 2; ++ for (i = 0; i < nent; i++) { ++ int minoff = 26 + nent * 2; ++ swap16(page + 26 + i * 2); /* offset */ ++ off = *(uint16_t *)(page + 26 + i * 2); ++ if (off < minoff || off >= pagesize) ++ continue; ++ if (type == 2 || type == 13) { /* hash */ ++ if (page[off] == 3 && off + 12 <= pagesize) ++ swap32_2(page + off + 4); /* page no/length */ ++ } else if (type == 3) { /* btree internal */ ++ if (off + 12 > pagesize) ++ continue; ++ swap16(page + off); /* length */ ++ swap32_2(page + off + 4); /* page no/num recs */ ++ if (page[off + 2] == 3 && off + 24 <= pagesize) ++ swap32_2(page + off + 16); /* with overflow page/length */ ++ } else if (type == 5) { /* btree leaf */ ++ if (off + 3 <= pagesize && page[off + 2] == 1) ++ swap16(page + off); /* length */ ++ else if (off + 12 <= pagesize && page[off + 2] == 3) ++ swap32_2(page + off + 4); /* overflow page/length */ ++ } ++ } ++} ++ ++static int bdb_getpage(struct bdb_db *db, unsigned char *page, unsigned int pageno) ++{ ++ if (!pageno || pageno > db->lastpage) ++ return -1; ++ if (pread(db->fd, page, db->pagesize, (off_t)pageno * db->pagesize) != db->pagesize) { ++ rpmlog(RPMLOG_ERR, "pread: %s\n", strerror(errno)); ++ return -1; ++ } ++ if (db->swapped) ++ bdb_swappage(db, page); ++ if (pageno != *(uint32_t *)(page + 8)) ++ return -1; ++ return 0; ++} ++ ++static void bdb_close(struct bdb_db *db) ++{ ++ if (db->fd >= 0) ++ close(db->fd); ++ free(db); ++} ++ ++static struct bdb_db *bdb_open(const char *name) ++{ ++ uint32_t meta[512 / 4]; ++ int i, fd; ++ struct bdb_db *db; ++ ++ fd = open(name, O_RDONLY); ++ if (!fd) { ++ rpmlog(RPMLOG_ERR, "%s: %s\n", name, strerror(errno)); ++ return NULL; ++ } ++ db = xcalloc(1, sizeof(*db)); ++ db->fd = fd; ++ if (pread(fd, meta, 512, 0) != 512) { ++ rpmlog(RPMLOG_ERR, "%s: pread: %s\n", name, strerror(errno)); ++ bdb_close(db); ++ return NULL; ++ } ++ if (meta[3] == 0x00061561 || meta[3] == 0x61150600) { ++ db->type = BDB_HASH; ++ db->swapped = meta[3] == 0x61150600; ++ } else if (meta[3] == 0x00053162 || meta[3] == 0x62310500) { ++ db->type = BDB_BTREE; ++ db->swapped = meta[3] == 0x62310500; ++ } else { ++ rpmlog(RPMLOG_ERR, "%s: not a berkeley db hash/btree database\n", name); ++ bdb_close(db); ++ return NULL; ++ } ++ if (db->swapped) ++ bdb_swapmetapage(db, (unsigned char *)meta); ++ db->pagesize = meta[5]; ++ db->lastpage = meta[8]; ++ if (db->type == BDB_HASH) { ++ if (meta[4] < 8 || meta[4] > 10) { ++ rpmlog(RPMLOG_ERR, "%s: unsupported hash version %d\n", name, meta[4]); ++ bdb_close(db); ++ return NULL; ++ } ++ db->maxbucket = meta[18]; ++ db->highmask = meta[19]; ++ db->lowmask = meta[20]; ++ for (i = 0; i < 32; i++) ++ db->spares[i] = meta[24 + i]; ++ } ++ if (db->type == BDB_BTREE) { ++ if (meta[4] < 9 || meta[4] > 10) { ++ rpmlog(RPMLOG_ERR, "%s: unsupported btree version %d\n", name, meta[4]); ++ bdb_close(db); ++ return NULL; ++ } ++ db->root = meta[22]; ++ } ++ return db; ++} ++ ++ ++/****** overflow handling ******/ ++ ++static int ovfl_get(struct bdb_cur *cur, struct bdb_kv *kv, struct bdb_kv *ov, uint32_t *pagenolen) ++{ ++ unsigned int pageno = pagenolen[0]; ++ unsigned int len = pagenolen[1]; ++ unsigned int plen; ++ unsigned char *p; ++ ++ if (len == 0) ++ return -1; ++ if (len > ov->len) { ++ if (ov->kv) ++ ov->kv = xrealloc(ov->kv, len); ++ else ++ ov->kv = xmalloc(len); ++ ov->len = len; ++ } ++ if (!cur->ovpage) ++ cur->ovpage = xmalloc(cur->db->pagesize); ++ p = ov->kv; ++ while (len > 0) { ++ if (bdb_getpage(cur->db, cur->ovpage, pageno)) ++ return -1; ++ if (cur->ovpage[25] != 7) ++ return -1; ++ plen = *(uint16_t *)(cur->ovpage + 22); ++ if (plen + 26 > cur->db->pagesize || plen > len) ++ return -1; ++ memcpy(p, cur->ovpage + 26, plen); ++ p += plen; ++ len -= plen; ++ pageno = *(uint32_t *)(cur->ovpage + 16); ++ } ++ if (kv) { ++ kv->kv = ov->kv; ++ kv->len = pagenolen[1]; ++ } ++ return 0; ++} ++ ++ ++/****** hash implementation ******/ ++ ++static int hash_bucket_to_page(struct bdb_db *db, unsigned int bucket) ++{ ++ unsigned int b; ++ int i = 0; ++ for (b = bucket; b; b >>= 1) ++ i++; ++ return bucket + db->spares[i]; ++} ++ ++static int hash_lookup(struct bdb_cur *cur, const unsigned char *key, unsigned int keyl) ++{ ++ uint32_t bucket; ++ unsigned int pg, i; ++ cur->state = -1; ++ for (bucket = 0, i = 0; i < keyl; i++) ++ bucket = (bucket * 16777619) ^ key[i]; ++ bucket &= cur->db->highmask; ++ if (bucket > cur->db->maxbucket) ++ bucket &= cur->db->lowmask; ++ cur->bucket = bucket; ++ pg = hash_bucket_to_page(cur->db, bucket); ++ if (bdb_getpage(cur->db, cur->page, pg)) ++ return -1; ++ if (cur->page[25] != 8 && cur->page[25] != 13) ++ return -1; ++ cur->idx = (unsigned int)-2; ++ cur->numidx = *(uint16_t *)(cur->page + 20); ++ cur->state = 1; ++ return 0; ++} ++ ++static int hash_getkv(struct bdb_cur *cur, struct bdb_kv *kv, struct bdb_kv *ov, int off, int len) ++{ ++ if (len <= 0 || off + len > cur->db->pagesize) ++ return -1; ++ if (cur->page[off] == 1) { ++ kv->kv = cur->page + off + 1; ++ kv->len = len - 1; ++ } else if (cur->page[off] == 3) { ++ uint32_t ovlpage[2]; ++ if (len != 12) ++ return -1; ++ memcpy(ovlpage, cur->page + off + 4, 8); /* off is unaligned */ ++ if (ovfl_get(cur, kv, ov, ovlpage)) ++ return -1; ++ } else { ++ return -1; ++ } ++ return 0; ++} ++ ++static int hash_next(struct bdb_cur *cur) ++{ ++ int pagesize = cur->db->pagesize; ++ int koff, klen, voff, vlen; ++ if (!cur->state && hash_lookup(cur, 0, 0)) ++ return -1; ++ cur->idx += 2; ++ for (;;) { ++ if (cur->idx + 1 >= cur->numidx) { ++ unsigned int pg; ++ cur->idx = cur->numidx = 0; ++ pg = *(uint32_t *)(cur->page + 16); ++ if (!pg) { ++ if (cur->islookup || cur->bucket >= cur->db->maxbucket) ++ return 1; ++ pg = hash_bucket_to_page(cur->db, ++cur->bucket); ++ } ++ if (bdb_getpage(cur->db, cur->page, pg)) ++ return -1; ++ if (cur->page[25] != 8 && cur->page[25] != 13) ++ return -1; ++ cur->numidx = *(uint16_t *)(cur->page + 20); ++ continue; ++ } ++ koff = *(uint16_t *)(cur->page + 26 + 2 * cur->idx); ++ voff = *(uint16_t *)(cur->page + 28 + 2 * cur->idx); ++ if (koff >= pagesize || voff >= pagesize) ++ return -1; ++ if (cur->idx == 0) ++ klen = pagesize - koff; ++ else ++ klen = *(uint16_t *)(cur->page + 24 + 2 * cur->idx) - koff; ++ vlen = koff - voff; ++ if (hash_getkv(cur, &cur->key, &cur->keyov, koff, klen)) ++ return -1; ++ if (!cur->islookup && hash_getkv(cur, &cur->val, &cur->valov, voff, vlen)) ++ return -1; ++ return 0; ++ } ++} ++ ++static int hash_getval(struct bdb_cur *cur) ++{ ++ int koff, voff; ++ if (cur->state != 1 || cur->idx + 1 >= cur->numidx) ++ return -1; ++ koff = *(uint16_t *)(cur->page + 26 + 2 * cur->idx); ++ voff = *(uint16_t *)(cur->page + 28 + 2 * cur->idx); ++ return hash_getkv(cur, &cur->val, &cur->valov, voff, koff - voff); ++} ++ ++ ++/****** btree implementation ******/ ++ ++static int btree_lookup(struct bdb_cur *cur, const unsigned char *key, unsigned int keylen) ++{ ++ int pagesize = cur->db->pagesize; ++ int off, lastoff, idx, numidx; ++ unsigned int pg; ++ unsigned char *ekey; ++ unsigned int ekeylen; ++ int cmp; ++ ++ cur->state = -1; ++ pg = cur->db->root; ++ for (;;) { ++ if (bdb_getpage(cur->db, cur->page, pg)) ++ return -1; ++ if (cur->page[25] == 5) ++ break; /* found leaf page */ ++ if (cur->page[25] != 3) ++ return -1; ++ numidx = *(uint16_t *)(cur->page + 20); ++ if (!numidx) ++ return -1; ++ for (lastoff = 0, idx = 0; idx < numidx; idx++, lastoff = off) { ++ off = *(uint16_t *)(cur->page + 26 + 2 * idx); ++ if ((off & 3) != 0 || off + 3 > pagesize) ++ return -1; ++ ekeylen = *(uint16_t *)(cur->page + off); ++ if (off + 12 + ekeylen > pagesize) ++ return -1; ++ if (!keylen) { ++ lastoff = off; ++ break; ++ } ++ if (idx == 0) ++ continue; ++ ekey = cur->page + off + 12; ++ if ((cur->page[off + 2] & 0x7f) == 3) { ++ if (ekeylen != 12) ++ return -1; ++ if (ovfl_get(cur, 0, &cur->keyov, (uint32_t *)(ekey + 4))) ++ return -1; ++ ekeylen = *(uint32_t *)(ekey + 8); ++ ekey = cur->keyov.kv; ++ } else if ((cur->page[off + 2] & 0x7f) != 1) { ++ return -1; ++ } ++ cmp = memcmp(ekey, key, keylen < ekeylen ? keylen : ekeylen); ++ if (cmp > 0 || (cmp == 0 && ekeylen > keylen)) ++ break; ++ } ++ pg = *(uint32_t *)(cur->page + lastoff + 4); ++ } ++ cur->idx = (unsigned int)-2; ++ cur->numidx = *(uint16_t *)(cur->page + 20); ++ cur->state = 1; ++ return 0; ++} ++ ++static int btree_getkv(struct bdb_cur *cur, struct bdb_kv *kv, struct bdb_kv *ov, int off) ++{ ++ if ((off & 3) != 0) ++ return -1; ++ if (cur->page[off + 2] == 1) { ++ int len = *(uint16_t *)(cur->page + off); ++ if (off + 3 + len > cur->db->pagesize) ++ return -1; ++ kv->kv = cur->page + off + 3; ++ kv->len = len; ++ } else if (cur->page[off + 2] == 3) { ++ if (off + 12 > cur->db->pagesize) ++ return -1; ++ if (ovfl_get(cur, kv, ov, (uint32_t *)(cur->page + off + 4))) ++ return -1; ++ } else { ++ return -1; ++ } ++ return 0; ++} ++ ++static int btree_next(struct bdb_cur *cur) ++{ ++ int pagesize = cur->db->pagesize; ++ int koff, voff; ++ if (!cur->state && btree_lookup(cur, 0, 0)) ++ return -1; ++ cur->idx += 2; ++ for (;;) { ++ if (cur->idx + 1 >= cur->numidx) { ++ unsigned int pg; ++ cur->idx = cur->numidx = 0; ++ pg = *(uint32_t *)(cur->page + 16); ++ if (cur->islookup || !pg) ++ return 1; ++ if (bdb_getpage(cur->db, cur->page, pg)) ++ return -1; ++ if (cur->page[25] != 5) ++ return -1; ++ cur->numidx = *(uint16_t *)(cur->page + 20); ++ continue; ++ } ++ koff = *(uint16_t *)(cur->page + 26 + 2 * cur->idx); ++ voff = *(uint16_t *)(cur->page + 28 + 2 * cur->idx); ++ if (koff + 3 > pagesize || voff + 3 > pagesize) ++ return -1; ++ if ((cur->page[koff + 2] & 0x80) != 0 || (cur->page[voff + 2] & 0x80) != 0) ++ continue; /* ignore deleted */ ++ if (btree_getkv(cur, &cur->key, &cur->keyov, koff)) ++ return -1; ++ if (!cur->islookup && btree_getkv(cur, &cur->val, &cur->valov, voff)) ++ return -1; ++ return 0; ++ } ++} ++ ++static int btree_getval(struct bdb_cur *cur) ++{ ++ int voff; ++ if (cur->state != 1 || cur->idx + 1 >= cur->numidx) ++ return -1; ++ voff = *(uint16_t *)(cur->page + 28 + 2 * cur->idx); ++ return btree_getkv(cur, &cur->val, &cur->valov, voff); ++} ++ ++ ++/****** cursor functions ******/ ++ ++static struct bdb_cur *cur_open(struct bdb_db *db) ++{ ++ struct bdb_cur *cur = xcalloc(1, sizeof(*cur)); ++ cur->db = db; ++ cur->page = xmalloc(db->pagesize); ++ return cur; ++} ++ ++static void cur_close(struct bdb_cur *cur) ++{ ++ if (cur->page) ++ free(cur->page); ++ if (cur->ovpage) ++ free(cur->ovpage); ++ if (cur->keyov.kv) ++ free(cur->keyov.kv); ++ if (cur->valov.kv) ++ free(cur->valov.kv); ++ free(cur); ++} ++ ++static int cur_next(struct bdb_cur *cur) ++{ ++ if (cur->state < 0) ++ return -1; ++ if (cur->db->type == BDB_HASH) ++ return hash_next(cur); ++ if (cur->db->type == BDB_BTREE) ++ return btree_next(cur); ++ return -1; ++} ++ ++static int cur_getval(struct bdb_cur *cur) ++{ ++ if (cur->state < 0) ++ return -1; ++ if (cur->db->type == BDB_HASH) ++ return hash_getval(cur); ++ if (cur->db->type == BDB_BTREE) ++ return btree_getval(cur); ++ return -1; ++} ++ ++static int cur_lookup(struct bdb_cur *cur, const unsigned char *key, unsigned int keyl) ++{ ++ int r = -1; ++ if (cur->db->type == BDB_HASH) ++ r = hash_lookup(cur, key, keyl); ++ if (cur->db->type == BDB_BTREE) ++ r = btree_lookup(cur, key, keyl); ++ if (r != 0) ++ return r; ++ cur->islookup = 1; ++ while ((r = cur_next(cur)) == 0) ++ if (keyl == cur->key.len && !memcmp(key, cur->key.kv, keyl)) ++ break; ++ cur->islookup = 0; ++ if (r == 0) ++ r = cur_getval(cur); ++ return r; ++} ++ ++static int cur_lookup_ge(struct bdb_cur *cur, const unsigned char *key, unsigned int keyl) ++{ ++ int r = -1; ++ if (cur->db->type == BDB_BTREE) ++ r = btree_lookup(cur, key, keyl); ++ if (r != 0) ++ return r; ++ cur->islookup = 1; ++ while ((r = cur_next(cur)) == 0) { ++ unsigned int ekeyl = cur->key.len; ++ int cmp = memcmp(cur->key.kv, key, keyl < ekeyl ? keyl : ekeyl); ++ if (cmp > 0 || (cmp == 0 && ekeyl >= keyl)) ++ break; ++ } ++ cur->islookup = 0; ++ if (r == 0) ++ r = cur_getval(cur); ++ else if (r == 1) ++ r = cur_next(cur); ++ return r; ++} ++ ++/****** glue code ******/ ++ ++static unsigned int getui32(unsigned char *x, int swapped) ++{ ++ union _dbswap bs; ++ memcpy(bs.uc, x, 4); ++ if (swapped) ++ _DBSWAP(bs); ++ return bs.ui; ++} ++ ++static void setui32(unsigned char *x, uint32_t v, int swapped) ++{ ++ union _dbswap bs; ++ bs.ui = v; ++ if (swapped) ++ _DBSWAP(bs); ++ memcpy(x, bs.uc, 4); ++} ++ ++static void log_error(dbiIndex dbi) ++{ ++ rpmlog(RPMLOG_ERR, "bdb_ro error reading %s database\n", dbi->dbi_file); ++} ++ ++static int bdbro_Open(rpmdb rdb, rpmDbiTagVal rpmtag, dbiIndex * dbip, int flags) ++{ ++ const char *dbhome = rpmdbHome(rdb); ++ dbiIndex dbi = NULL; ++ char *path; ++ ++ if (dbip) ++ *dbip = NULL; ++ if ((rdb->db_mode & O_ACCMODE) != O_RDONLY) ++ return EPERM; ++ if ((dbi = dbiNew(rdb, rpmtag)) == NULL) ++ return 1; ++ path = rstrscat(NULL, dbhome, "/", dbi->dbi_file, NULL); ++ rpmlog(RPMLOG_DEBUG, "opening db index %s\n", path); ++ dbi->dbi_db = bdb_open(path); ++ if (!dbi->dbi_db) { ++ rpmlog(RPMLOG_ERR, "could not open %s: %s\n", path, strerror(errno)); ++ free(path); ++ dbiFree(dbi); ++ return 1; ++ } ++ free(path); ++ dbi->dbi_flags |= DBI_RDONLY; ++ if (dbip) ++ *dbip = dbi; ++ else ++ (void) dbiClose(dbi, 0); ++ return 0; ++} ++ ++static int bdbro_Close(dbiIndex dbi, unsigned int flags) ++{ ++ if (dbi->dbi_db) ++ bdb_close(dbi->dbi_db); ++ dbiFree(dbi); ++ return 0; ++} ++ ++static int bdbro_Verify(dbiIndex dbi, unsigned int flags) ++{ ++ return 0; ++} ++ ++static void bdbro_SetFSync(rpmdb rdb, int enable) ++{ ++} ++ ++static int bdbro_Ctrl(rpmdb rdb, dbCtrlOp ctrl) ++{ ++ return 0; ++} ++ ++static dbiCursor bdbro_CursorInit(dbiIndex dbi, unsigned int flags) ++{ ++ return dbi ? (void *)cur_open(dbi->dbi_db) : NULL; ++} ++ ++static dbiCursor bdbro_CursorFree(dbiIndex dbi, dbiCursor dbc) ++{ ++ if (dbc) ++ cur_close((void *)dbc); ++ return NULL; ++} ++ ++static void appenddbt(dbiCursor dbc, unsigned char *val, unsigned int vallen, dbiIndexSet *setp) ++{ ++ struct bdb_cur *cur = (void *)dbc; ++ dbiIndexSet set; ++ unsigned int i; ++ ++ set = dbiIndexSetNew(vallen / (2 * sizeof(uint32_t))); ++ set->count = vallen / (2 * sizeof(uint32_t)); ++ ++ for (i = 0; i < set->count; i++, val += 8) { ++ set->recs[i].hdrNum = getui32(val, cur->db->swapped); ++ set->recs[i].tagNum = getui32(val + 4, cur->db->swapped); ++ } ++ if (*setp == NULL) { ++ *setp = set; ++ } else { ++ dbiIndexSetAppendSet(*setp, set, 0); ++ dbiIndexSetFree(set); ++ } ++} ++ ++static rpmRC bdbro_idxdbPut(dbiIndex dbi, dbiCursor dbc, const char *keyp, size_t keylen, dbiIndexItem rec) ++{ ++ return RPMRC_FAIL; ++} ++ ++static rpmRC bdbro_idxdbDel(dbiIndex dbi, dbiCursor dbc, const char *keyp, size_t keylen, dbiIndexItem rec) ++{ ++ return RPMRC_FAIL; ++} ++ ++static rpmRC bdbro_idxdbGet(dbiIndex dbi, dbiCursor dbc, const char *keyp, size_t keylen, ++ dbiIndexSet *set, int searchType) ++{ ++ struct bdb_cur *cur = (void *)dbc; ++ int r; ++ ++ if (!cur) ++ return RPMRC_FAIL; ++ if (searchType == DBC_PREFIX_SEARCH) { ++ rpmRC rc = RPMRC_NOTFOUND; ++ if (!keyp) ++ return RPMRC_FAIL; ++ r = cur_lookup_ge(cur, (const unsigned char *)keyp, keylen); ++ for (; r == 0; r = cur_next(cur)) { ++ if (cur->key.len < keylen || memcmp(cur->key.kv, keyp, keylen) != 0) ++ break; ++ if (set) ++ appenddbt(dbc, cur->val.kv, cur->val.len, set); ++ rc = RPMRC_OK; ++ } ++ if (r == -1) ++ log_error(dbi); ++ cur->key.kv = 0; ++ return r == -1 ? RPMRC_FAIL : rc; ++ } ++ if (keyp) { ++ if (keylen == 0) { ++ keyp = ""; ++ keylen = 1; ++ } ++ r = cur_lookup(cur, (const unsigned char *)keyp, keylen); ++ } else { ++ r = cur_next(cur); ++ } ++ if (r == 0) { ++ if (set) ++ appenddbt(dbc, cur->val.kv, cur->val.len, set); ++ return RPMRC_OK; ++ } ++ if (r == -1) ++ log_error(dbi); ++ cur->key.kv = 0; ++ return r == 1 ? RPMRC_NOTFOUND : RPMRC_FAIL; ++} ++ ++static const void *bdbro_idxdbKey(dbiIndex dbi, dbiCursor dbc, unsigned int *keylen) ++{ ++ struct bdb_cur *cur = (void *)dbc; ++ if (!cur || !cur->key.kv) ++ return 0; ++ if (keylen) ++ *keylen = cur->key.len; ++ return cur->key.kv; ++} ++ ++static rpmRC bdbro_pkgdbPut(dbiIndex dbi, dbiCursor dbc, unsigned int hdrNum, ++ unsigned char *hdrBlob, unsigned int hdrLen) ++{ ++ return RPMRC_FAIL; ++} ++ ++static rpmRC bdbro_pkgdbDel(dbiIndex dbi, dbiCursor dbc, unsigned int hdrNum) ++{ ++ return RPMRC_FAIL; ++} ++ ++static rpmRC bdbro_pkgdbNew(dbiIndex dbi, dbiCursor dbc, unsigned int *hdrNum) ++{ ++ return RPMRC_FAIL; ++} ++ ++static rpmRC bdbro_pkgdbGet(dbiIndex dbi, dbiCursor dbc, unsigned int hdrNum, ++ unsigned char **hdrBlob, unsigned int *hdrLen) ++{ ++ struct bdb_cur *cur = (void *)dbc; ++ int r; ++ if (hdrNum) { ++ unsigned char hdrkey[4]; ++ setui32(hdrkey, hdrNum, cur->db->swapped); ++ r = cur_lookup(cur, hdrkey, 4); ++ } else { ++ r = cur_next(cur); ++ } ++ if (r == 0) { ++ if (hdrBlob) ++ *hdrBlob = cur->val.kv; ++ if (hdrLen) ++ *hdrLen = cur->val.len; ++ return RPMRC_OK; ++ } ++ if (r == -1) ++ log_error(dbi); ++ cur->key.kv = 0; ++ return r == 1 ? RPMRC_NOTFOUND : RPMRC_FAIL; ++} ++ ++static unsigned int bdbro_pkgdbKey(dbiIndex dbi, dbiCursor dbc) ++{ ++ struct bdb_cur *cur = (void *)dbc; ++ if (!cur || !cur->key.kv || cur->key.len != 4) ++ return 0; ++ return getui32(cur->key.kv, cur->db->swapped); ++} ++ ++struct rpmdbOps_s bdbro_dbops = { ++ .name = "bdb_ro", ++ .path = "Packages", ++ ++ .open = bdbro_Open, ++ .close = bdbro_Close, ++ .verify = bdbro_Verify, ++ .setFSync = bdbro_SetFSync, ++ .ctrl = bdbro_Ctrl, ++ ++ .cursorInit = bdbro_CursorInit, ++ .cursorFree = bdbro_CursorFree, ++ ++ .pkgdbPut = bdbro_pkgdbPut, ++ .pkgdbDel = bdbro_pkgdbDel, ++ .pkgdbGet = bdbro_pkgdbGet, ++ .pkgdbNew = bdbro_pkgdbNew, ++ .pkgdbKey = bdbro_pkgdbKey, ++ ++ .idxdbGet = bdbro_idxdbGet, ++ .idxdbPut = bdbro_idxdbPut, ++ .idxdbDel = bdbro_idxdbDel, ++ .idxdbKey = bdbro_idxdbKey ++}; ++ +--- ./lib/backend/dbi.c.orig 2020-01-17 12:07:10.382060851 +0000 ++++ ./lib/backend/dbi.c 2020-01-17 12:07:57.129945219 +0000 +@@ -22,6 +22,9 @@ const struct rpmdbOps_s *backends[] = { + #if defined(WITH_BDB) + &db3_dbops, + #endif ++#if defined(WITH_BDB_RO) ++ &bdbro_dbops, ++#endif + &dummydb_dbops, + NULL + }; +--- ./lib/backend/dbi.h.orig 2020-01-17 12:07:10.382060851 +0000 ++++ ./lib/backend/dbi.h 2020-01-17 12:07:57.129945219 +0000 +@@ -273,6 +273,11 @@ RPM_GNUC_INTERNAL + extern struct rpmdbOps_s db3_dbops; + #endif + ++#if defined(WITH_BDB_RO) ++RPM_GNUC_INTERNAL ++extern struct rpmdbOps_s bdbro_dbops; ++#endif ++ + #ifdef ENABLE_NDB + RPM_GNUC_INTERNAL + extern struct rpmdbOps_s ndb_dbops; diff --git a/brp-compress-no-img.patch b/brp-compress-no-img.patch index 14f462e..f378622 100644 --- a/brp-compress-no-img.patch +++ b/brp-compress-no-img.patch @@ -1,10 +1,10 @@ ---- ./scripts/brp-compress.orig 2020-09-30 13:09:28.846434576 +0000 -+++ ./scripts/brp-compress 2020-09-30 13:09:34.514422459 +0000 -@@ -51,6 +51,7 @@ do +--- ./scripts/brp-compress.orig 2019-10-02 12:09:46.263708258 +0000 ++++ ./scripts/brp-compress 2019-10-02 12:09:52.055696056 +0000 +@@ -50,6 +50,7 @@ do find $d -type f ! -name dir | while read f do [ -f "$f" ] || continue + case $(file "$f") in *"image data"*) continue;; esac case "$f" in - *.gz|*.Z) gunzip -f $f || check_for_hard_link $d "$f"; b=`echo $f | sed -e 's/\.\(gz\|Z\)$//'`;; + *.gz|*.Z) gunzip -f "$f" || check_for_hard_link $d "$f"; b=`echo $f | sed -e 's/\.\(gz\|Z\)$//'`;; diff --git a/brp.diff b/brp.diff index 7f2186c..beef7e9 100644 --- a/brp.diff +++ b/brp.diff @@ -1,5 +1,5 @@ ---- ./scripts/brp-strip-comment-note.orig 2020-05-28 10:04:25.076136900 +0000 -+++ ./scripts/brp-strip-comment-note 2020-09-30 12:27:44.484016581 +0000 +--- ./scripts/brp-strip-comment-note.orig 2017-08-10 08:08:07.150108692 +0000 ++++ ./scripts/brp-strip-comment-note 2017-12-01 14:29:56.761975721 +0000 @@ -16,6 +16,8 @@ esac # for already stripped elf files in the build root for f in `find "$RPM_BUILD_ROOT" -type f \( -perm -0100 -or -perm -0010 -or -perm -0001 \) -exec file {} \; | \ @@ -9,11 +9,13 @@ sed -n -e 's/^\(.*\):[ ]*ELF.*, stripped.*/\1/p'`; do note="-R .note" if $OBJDUMP -h $f | grep '^[ ]*[0-9]*[ ]*.note[ ]' -A 1 | \ ---- ./scripts/brp-strip.orig 2020-09-30 12:27:44.484016581 +0000 -+++ ./scripts/brp-strip 2020-09-30 12:28:43.959881586 +0000 -@@ -14,4 +14,4 @@ esac - - # Strip ELF binaries - find "$RPM_BUILD_ROOT" -type f \( -perm -0100 -or -perm -0010 -or -perm -0001 \) \! -regex "${RPM_BUILD_ROOT}/*usr/lib/debug.*" -print0 | \ -- xargs -0 -r -P$NCPUS -n32 sh -c "file \"\$@\" | grep -v ' shared object,' | sed -n -e 's/^\(.*\):[ ]*ELF.*, not stripped.*/\1/p' | xargs -I\{\} $STRIP -g \{\}" ARG0 -+ xargs -0 -r -P$NCPUS -n32 sh -c "file \"\$@\" | grep -v ' shared object,' | grep -v '/lib/modules/' | sed -n -e 's/^\(.*\):[ ]*ELF.*, not stripped.*/\1/p' | xargs -I\{\} $STRIP -g \{\}" ARG0 +--- ./scripts/brp-strip.orig 2017-08-10 08:08:07.150108692 +0000 ++++ ./scripts/brp-strip 2017-12-01 14:29:56.761975721 +0000 +@@ -15,6 +15,7 @@ esac + for f in `find "$RPM_BUILD_ROOT" -type f \( -perm -0100 -or -perm -0010 -or -perm -0001 \) -exec file {} \; | \ + grep -v "^${RPM_BUILD_ROOT}/\?usr/lib/debug" | \ + grep -v ' shared object,' | \ ++ grep -v '/lib/modules/' | \ + sed -n -e 's/^\(.*\):[ ]*ELF.*, not stripped.*/\1/p'`; do + $STRIP -g "$f" || : + done diff --git a/brpcompress.diff b/brpcompress.diff index 4b64ccf..3e42a01 100644 --- a/brpcompress.diff +++ b/brpcompress.diff @@ -1,5 +1,5 @@ ---- ./scripts/brp-compress.orig 2020-05-28 10:04:25.075136894 +0000 -+++ ./scripts/brp-compress 2020-09-30 12:35:24.462971247 +0000 +--- ./scripts/brp-compress.orig 2019-10-02 09:59:40.403995534 +0000 ++++ ./scripts/brp-compress 2019-10-02 10:03:27.075537047 +0000 @@ -5,6 +5,9 @@ if [ -z "$RPM_BUILD_ROOT" ] || [ "$RPM_B exit 0 fi @@ -10,7 +10,7 @@ PREFIX=${1:-/usr} cd "$RPM_BUILD_ROOT" -@@ -13,6 +16,30 @@ cd "$RPM_BUILD_ROOT" +@@ -13,6 +16,29 @@ cd "$RPM_BUILD_ROOT" COMPRESS=${COMPRESS:-gzip -9 -n} COMPRESS_EXT=${COMPRESS_EXT:-.gz} @@ -29,7 +29,6 @@ + *.Z|*.gz) gunzip $b ;; + *.bz2) bunzip2 $b ;; + *.xz|*.lzma) unxz $b ;; -+ *.zst|*.zstd) unzstd --rm $b ;; + esac + + type=${b##*.} @@ -41,7 +40,7 @@ for d in .${PREFIX}/man/man* .${PREFIX}/man/*/man* .${PREFIX}/info \ .${PREFIX}/share/man/man* .${PREFIX}/share/man/*/man* \ .${PREFIX}/share/info .${PREFIX}/kerberos/man \ -@@ -21,36 +48,36 @@ for d in .${PREFIX}/man/man* .${PREFIX}/ +@@ -21,39 +47,39 @@ for d in .${PREFIX}/man/man* .${PREFIX}/ .${PREFIX}/share/fish/man/man* do [ -d $d ] || continue @@ -54,11 +53,9 @@ - *.gz|*.Z) gunzip -f $f; b=`echo $f | sed -e 's/\.\(gz\|Z\)$//'`;; - *.bz2) bunzip2 -f $f; b=`echo $f | sed -e 's/\.bz2$//'`;; - *.xz|*.lzma) unxz -f $f; b=`echo $f | sed -e 's/\.\(xz\|lzma\)$//'`;; -- *.zst|*.zstd) unzstd -f --rm $f; b=`echo $f | sed -e 's/\.\(zst\|zstd\)$//'`;; -+ *.gz|*.Z) gunzip -f $f || check_for_hard_link $d "$f"; b=`echo $f | sed -e 's/\.\(gz\|Z\)$//'`;; -+ *.bz2) bunzip2 -f $f || check_for_hard_link $d "$f"; b=`echo $f | sed -e 's/\.bz2$//'`;; -+ *.xz|*.lzma) unxz -f $f || check_for_hard_link $d "$f"; b=`echo $f | sed -e 's/\.\(xz\|lzma\)$//'`;; -+ *.zst|*.zstd) unzstd -f --rm $f || check_for_hard_link $d "$f"; b=`echo $f | sed -e 's/\.\(zst\|zstd\)$//'`;; ++ *.gz|*.Z) gunzip -f "$f" || check_for_hard_link $d "$f"; b=`echo $f | sed -e 's/\.\(gz\|Z\)$//'`;; ++ *.bz2) bunzip2 -f "$f" || check_for_hard_link $d "$f"; b=`echo $f | sed -e 's/\.bz2$//'`;; ++ *.xz|*.lzma) unxz -f "$f" || check_for_hard_link $d "$f"; b=`echo $f | sed -e 's/\.\(xz\|lzma\)$//'`;; *) b=$f;; esac @@ -87,5 +84,13 @@ - for f in `find $d -type l` + find $d -type l | while read f do - l=`ls -l $f | sed -e 's/.* -> //' -e 's/\.\(gz\|Z\|bz2\|xz\|lzma\|zst\|zstd\)$//'` - rm -f $f +- l=`ls -l $f | sed -e 's/.* -> //' -e 's/\.\(gz\|Z\|bz2\|xz\|lzma\)$//'` +- rm -f $f +- b=`echo $f | sed -e 's/\.\(gz\|Z\|bz2\|xz\|lzma\)$//'` +- ln -sf $l$COMPRESS_EXT $b$COMPRESS_EXT ++ l="`ls -l "$f" | sed -e 's/.* -> //' -e 's/\.\(gz\|Z\|bz2\|xz\|lzma\)$//'`" ++ rm -f "$f" ++ b="`echo "$f" | sed -e 's/\.\(gz\|Z\|bz2\|xz\|lzma\)$//'`" ++ ln -sf "$l$COMPRESS_EXT" "$b$COMPRESS_EXT" + done + done diff --git a/checkfilesnoinfodir.diff b/checkfilesnoinfodir.diff index 424f0a2..67e227e 100644 --- a/checkfilesnoinfodir.diff +++ b/checkfilesnoinfodir.diff @@ -1,12 +1,12 @@ Exclude /usr/share/info/dir from check-files. Probably only interesting for SUSE. ---- ./scripts/check-files.orig 2020-09-30 12:36:56.398762048 +0000 -+++ ./scripts/check-files 2020-09-30 12:41:15.294176572 +0000 +--- scripts/check-files.orig 2013-06-10 15:55:10.000000000 +0000 ++++ scripts/check-files 2013-07-12 11:45:37.000000000 +0000 @@ -28,5 +28,5 @@ trap "rm -f \"${FILES_DISK}\"" 0 2 3 5 1 # Find non-directory files in the build root and compare to the manifest. # TODO: regex chars in last sed(1) expression should be escaped find "${RPM_BUILD_ROOT}" -type f -o -type l | LC_ALL=C sort > "${FILES_DISK}" --LC_ALL=C sort | diff -d "${FILES_DISK}" - | sed -n 's!^\(-\|< \)'"${RPM_BUILD_ROOT}"'\(.*\)$! \2!gp' -+LC_ALL=C sort | diff -d "${FILES_DISK}" - | sed -n -e 's!^\(-\|< \)'"${RPM_BUILD_ROOT}"'/usr/share/info/dir$!!' -e 's!^\(-\|< \)'"${RPM_BUILD_ROOT}"'\(.*\)$! \2!gp' +-LC_ALL=C sort | diff -d "${FILES_DISK}" - | sed -n 's|^< '"${RPM_BUILD_ROOT}"'\(.*\)$| \1|gp' ++LC_ALL=C sort | diff -d "${FILES_DISK}" - | sed -n -e 's|^< '"${RPM_BUILD_ROOT}"'/usr/share/info/dir$||' -e 's|^< '"${RPM_BUILD_ROOT}"'\(.*\)$| \1|gp' diff --git a/db_conversion.diff b/db_conversion.diff index e53d40c..f0f02af 100644 --- a/db_conversion.diff +++ b/db_conversion.diff @@ -1,6 +1,6 @@ ---- ./lib/backend/bdb_ro.c.orig 2020-05-28 10:04:25.027136631 +0000 -+++ ./lib/backend/bdb_ro.c 2020-10-07 13:57:21.021813205 +0000 -@@ -790,6 +790,7 @@ static unsigned int bdbro_pkgdbKey(dbiIn +--- ./lib/backend/bdb_ro.c.orig 2020-03-24 20:45:19.121907476 +0000 ++++ ./lib/backend/bdb_ro.c 2020-03-24 20:46:17.141727988 +0000 +@@ -795,6 +795,7 @@ static unsigned int bdbro_pkgdbKey(dbiIn struct rpmdbOps_s bdbro_dbops = { .name = "bdb_ro", .path = "Packages", @@ -8,13 +8,13 @@ .open = bdbro_Open, .close = bdbro_Close, ---- ./lib/backend/dbi.c.orig 2020-08-31 09:14:07.991087349 +0000 -+++ ./lib/backend/dbi.c 2020-10-07 13:57:21.021813205 +0000 -@@ -119,11 +119,20 @@ exit: +--- ./lib/backend/dbi.c.orig 2020-03-24 20:45:19.121907476 +0000 ++++ ./lib/backend/dbi.c 2020-03-24 20:46:17.141727988 +0000 +@@ -105,11 +105,20 @@ dbDetectBackend(rpmdb rdb) } rdb->db_descr = rdb->db_ops->name; -+ rdb->db_ops_config = cfg; ++ rdb->db_ops_config = ops_config; if (db_backend) free(db_backend); @@ -31,17 +31,17 @@ const char * dbiName(dbiIndex dbi) { return dbi->dbi_file; ---- ./lib/backend/dbi.h.orig 2020-10-07 13:57:12.145839232 +0000 -+++ ./lib/backend/dbi.h 2020-10-07 13:57:21.021813205 +0000 -@@ -11,6 +11,7 @@ enum rpmdbFlags { +--- ./lib/backend/dbi.h.orig 2020-03-24 20:45:19.121907476 +0000 ++++ ./lib/backend/dbi.h 2020-03-24 20:46:17.141727988 +0000 +@@ -10,6 +10,7 @@ enum rpmdbFlags { + RPMDB_FLAG_JUSTCHECK = (1 << 0), RPMDB_FLAG_REBUILD = (1 << 1), RPMDB_FLAG_VERIFYONLY = (1 << 2), - RPMDB_FLAG_SALVAGE = (1 << 3), -+ RPMDB_FLAG_CONVERT = (1 << 4), ++ RPMDB_FLAG_CONVERT = (1 << 3), }; typedef enum dbCtrlOp_e { -@@ -63,6 +64,7 @@ struct rpmdb_s { +@@ -62,6 +63,7 @@ struct rpmdb_s { int db_buildindex; /*!< Index rebuild indicator */ const struct rpmdbOps_s * db_ops; /*!< backend ops */ @@ -49,7 +49,7 @@ /* dbenv and related parameters */ void * db_dbenv; /*!< Backend private handle */ -@@ -209,6 +211,14 @@ RPM_GNUC_INTERNAL +@@ -201,6 +203,14 @@ RPM_GNUC_INTERNAL const char * dbiName(dbiIndex dbi); /** \ingroup dbi @@ -64,7 +64,7 @@ * Open a database cursor. * @param dbi index database handle * @param flags DBC_WRITE if writing, or 0 (DBC_READ) for reading -@@ -252,6 +262,7 @@ const void * idxdbKey(dbiIndex dbi, dbiC +@@ -246,6 +256,7 @@ const void * idxdbKey(dbiIndex dbi, dbiC struct rpmdbOps_s { const char *name; /* backend name */ const char *path; /* main database name */ @@ -72,24 +72,27 @@ int (*open)(rpmdb rdb, rpmDbiTagVal rpmtag, dbiIndex * dbip, int flags); int (*close)(dbiIndex dbi, unsigned int flags); ---- ./lib/rpmdb.c.orig 2020-10-07 13:57:12.145839232 +0000 -+++ ./lib/rpmdb.c 2020-10-07 13:57:37.609764566 +0000 -@@ -516,7 +516,13 @@ static int openDatabase(const char * pre +--- ./lib/rpmdb.c.orig 2020-03-24 20:45:19.117907488 +0000 ++++ ./lib/rpmdb.c 2020-03-24 21:01:54.870821518 +0000 +@@ -513,8 +513,16 @@ static int openDatabase(const char * pre rpmsqActivate(1); } -- rc = doOpen(db, justPkgs); ++ /* Convert the database if needed */ + if (!db->db_pkgs && !justCheck && (mode & O_ACCMODE) == O_RDWR && dbiNeedConversion(db)) { -+ rc = rpmdbRebuild(prefix, NULL, NULL, RPMDB_REBUILD_FLAG_CONVERT); ++ rpmlog(RPMLOG_WARNING, _("Converting database from %s to %s format\n"), db->db_ops->name, db->db_ops_config->name); ++ rc = rpmdbRebuild(prefix, NULL, NULL, RPMDB_FLAG_CONVERT); + db->db_ops = NULL; /* force re-detection of backend */ + } + + /* Just the primary Packages database opened here */ +- rc = pkgdbOpen(db, db->db_flags, NULL); + if (!rc) -+ rc = doOpen(db, justPkgs); - ++ rc = pkgdbOpen(db, db->db_flags, NULL); if (!db->db_descr) db->db_descr = "unknown db"; -@@ -2311,6 +2317,15 @@ int rpmdbAdd(rpmdb db, Header h) + } +@@ -2316,6 +2324,15 @@ int rpmdbAdd(rpmdb db, Header h) if (db == NULL) return 0; @@ -105,12 +108,32 @@ hdrBlob = headerExport(h, &hdrLen); if (hdrBlob == NULL || hdrLen == 0) { ret = -1; -@@ -2506,7 +2521,22 @@ int rpmdbRebuild(const char * prefix, rp +@@ -2331,7 +2348,8 @@ int rpmdbAdd(rpmdb db, Header h) + + /* Add header to primary index */ + dbc = dbiCursorInit(dbi, DBC_WRITE); +- ret = pkgdbNew(dbi, dbc, &hdrNum); ++ if ((db->db_flags & RPMDB_FLAG_CONVERT) == 0) ++ ret = pkgdbNew(dbi, dbc, &hdrNum); + if (ret == 0) + ret = pkgdbPut(dbi, dbc, hdrNum, hdrBlob, hdrLen); + dbiCursorFree(dbi, dbc); +@@ -2491,7 +2509,8 @@ static int rpmdbSetPermissions(char * sr + } + + int rpmdbRebuild(const char * prefix, rpmts ts, +- rpmRC (*hdrchk) (rpmts ts, const void *uh, size_t uc, char ** msg)) ++ rpmRC (*hdrchk) (rpmts ts, const void *uh, size_t uc, char ** msg), ++ int newdbflags) + { + rpmdb olddb; + char * dbpath = NULL; +@@ -2512,7 +2531,22 @@ int rpmdbRebuild(const char * prefix, rp } rootdbpath = rpmGetPath(prefix, dbpath, NULL); - newdbpath = rpmGetPath("%{?_dbpath_rebuild}", NULL); -+ if ((rebuildflags & RPMDB_REBUILD_FLAG_CONVERT) != 0) { ++ if ((newdbflags & RPMDB_FLAG_CONVERT) != 0) { + char lbuf[PATH_MAX]; + ssize_t s = readlink(rootdbpath, lbuf, PATH_MAX); + if (s > 0 && s < PATH_MAX) { @@ -129,24 +152,43 @@ if (rstreq(newdbpath, "") || rstreq(newdbpath, dbpath)) { newdbpath = _free(newdbpath); rasprintf(&newdbpath, "%srebuilddb.%d", dbpath, (int) getpid()); -@@ -2532,7 +2562,9 @@ int rpmdbRebuild(const char * prefix, rp +@@ -2536,7 +2570,7 @@ int rpmdbRebuild(const char * prefix, rp goto exit; } if (openDatabase(prefix, newdbpath, &newdb, - (O_RDWR | O_CREAT), 0644, RPMDB_FLAG_REBUILD)) { -+ (O_RDWR | O_CREAT), 0644, RPMDB_FLAG_REBUILD | -+ (rebuildflags & RPMDB_REBUILD_FLAG_CONVERT ? -+ RPMDB_FLAG_CONVERT : 0))) { ++ (O_RDWR | O_CREAT), 0644, RPMDB_FLAG_REBUILD | newdbflags)) { rc = 1; goto exit; } ---- ./lib/rpmdb_internal.h.orig 2020-05-28 10:04:25.037136686 +0000 -+++ ./lib/rpmdb_internal.h 2020-10-07 13:57:21.021813205 +0000 -@@ -25,6 +25,7 @@ extern "C" { - - enum rpmdbRebuildFlags_e { - RPMDB_REBUILD_FLAG_SALVAGE = (1 << 0), -+ RPMDB_REBUILD_FLAG_CONVERT = (1 << 1), - }; +--- ./lib/rpmdb_internal.h.orig 2019-06-26 14:17:31.412985694 +0000 ++++ ./lib/rpmdb_internal.h 2020-03-24 20:46:17.141727988 +0000 +@@ -63,11 +63,13 @@ int rpmdbClose (rpmdb db); + * @param prefix path to top of install tree + * @param ts transaction set (or NULL) + * @param (*hdrchk) headerCheck() vector (or NULL) ++ * @param newdbflags extra flags for the new database + * @return 0 on success + */ + RPM_GNUC_INTERNAL + int rpmdbRebuild(const char * prefix, rpmts ts, +- rpmRC (*hdrchk) (rpmts ts, const void *uh, size_t uc, char ** msg)); ++ rpmRC (*hdrchk) (rpmts ts, const void *uh, size_t uc, char ** msg), ++ int newdbflags); /** \ingroup rpmdb + * Verify database components. +--- ./lib/rpmts.c.orig 2020-03-24 20:45:19.105907526 +0000 ++++ ./lib/rpmts.c 2020-03-24 20:46:17.145727976 +0000 +@@ -143,9 +143,9 @@ int rpmtsRebuildDB(rpmts ts) + txn = rpmtxnBegin(ts, RPMTXN_WRITE); + if (txn) { + if (!(ts->vsflags & RPMVSF_NOHDRCHK)) +- rc = rpmdbRebuild(ts->rootDir, ts, headerCheck); ++ rc = rpmdbRebuild(ts->rootDir, ts, headerCheck, 0); + else +- rc = rpmdbRebuild(ts->rootDir, NULL, NULL); ++ rc = rpmdbRebuild(ts->rootDir, NULL, NULL, 0); + rpmtxnEnd(txn); + } + return rc; diff --git a/db_ops_name.diff b/db_ops_name.diff new file mode 100644 index 0000000..bb3423d --- /dev/null +++ b/db_ops_name.diff @@ -0,0 +1,248 @@ +--- ./lib/backend/db3.c.orig 2020-01-17 11:50:39.048477444 +0000 ++++ ./lib/backend/db3.c 2020-01-17 11:58:15.351365745 +0000 +@@ -421,10 +421,6 @@ static int db_init(rpmdb rdb, const char + if (rdb->db_dbenv != NULL) { + rdb->db_opens++; + return 0; +- } else { +- /* On first call, set backend description to something... */ +- free(rdb->db_descr); +- rasprintf(&rdb->db_descr, "db%u", DB_VERSION_MAJOR); + } + + /* +@@ -1426,6 +1422,9 @@ static rpmRC db3_pkgdbNew(dbiIndex dbi, + } + + struct rpmdbOps_s db3_dbops = { ++ .name = "bdb", ++ .path = "Packages", ++ + .open = db3_dbiOpen, + .close = db3_dbiClose, + .verify = db3_dbiVerify, +--- ./lib/backend/dbi.c.orig 2020-01-17 11:54:38.207894769 +0000 ++++ ./lib/backend/dbi.c 2020-01-17 11:56:45.555584517 +0000 +@@ -12,6 +12,19 @@ + #include "lib/rpmdb_internal.h" + #include "debug.h" + ++const struct rpmdbOps_s *backends[] = { ++#if defined(WITH_LMDB) ++ &lmdb_dbops, ++#endif ++#ifdef ENABLE_NDB ++ &ndb_dbops, ++#endif ++#if defined(WITH_BDB) ++ &db3_dbops, ++#endif ++ &dummydb_dbops, ++ NULL ++}; + + dbiIndex dbiFree(dbiIndex dbi) + { +@@ -38,59 +51,58 @@ dbDetectBackend(rpmdb rdb) + const char *dbhome = rpmdbHome(rdb); + char *db_backend = rpmExpand("%{?_db_backend}", NULL); + char *path = NULL; ++ const struct rpmdbOps_s **ops, *ops_config; + +-#if defined(WITH_LMDB) +- if (!strcmp(db_backend, "lmdb")) { +- rdb->db_ops = &lmdb_dbops; +- } else +-#endif +-#ifdef ENABLE_NDB +- if (!strcmp(db_backend, "ndb")) { +- rdb->db_ops = &ndb_dbops; +- } else +-#endif +-#if defined(WITH_BDB) +- { +- rdb->db_ops = &db3_dbops; +- if (*db_backend == '\0') { +- free(db_backend); +- db_backend = xstrdup("bdb"); ++ rdb->db_ops = NULL; ++ ++ ops_config = NULL; ++ for (ops = backends; *ops; ops++) { ++ if (rstreq(db_backend, (*ops)->name)) { ++ ops_config = *ops; ++ break; + } + } +-#endif + +-#if defined(WITH_LMDB) +- path = rstrscat(NULL, dbhome, "/data.mdb", NULL); +- if (access(path, F_OK) == 0 && rdb->db_ops != &lmdb_dbops) { +- rdb->db_ops = &lmdb_dbops; +- rpmlog(RPMLOG_WARNING, _("Found LMDB data.mdb database while attempting %s backend: using lmdb backend.\n"), db_backend); ++ /* if we have a configured backend, check it first */ ++ if (ops_config && ops_config->path) { ++ path = rstrscat(NULL, dbhome, "/", ops_config->path, NULL); ++ if (access(path, F_OK) == 0) ++ rdb->db_ops = ops_config; ++ free(path); + } +- free(path); +-#endif + +-#ifdef ENABLE_NDB +- path = rstrscat(NULL, dbhome, "/Packages.db", NULL); +- if (access(path, F_OK) == 0 && rdb->db_ops != &ndb_dbops) { +- rdb->db_ops = &ndb_dbops; +- rpmlog(RPMLOG_WARNING, _("Found NDB Packages.db database while attempting %s backend: using ndb backend.\n"), db_backend); +- } +- free(path); +-#endif ++ /* if it did not match, check all available backends */ ++ if (rdb->db_ops == NULL) { ++ for (ops = backends; *ops; ops++) { ++ if ((*ops)->path == NULL || *ops == ops_config) ++ continue; + +-#if defined(WITH_BDB) +- path = rstrscat(NULL, dbhome, "/Packages", NULL); +- if (access(path, F_OK) == 0 && rdb->db_ops != &db3_dbops) { +- rdb->db_ops = &db3_dbops; +- rpmlog(RPMLOG_WARNING, _("Found BDB Packages database while attempting %s backend: using bdb backend.\n"), db_backend); ++ path = rstrscat(NULL, dbhome, "/", (*ops)->path, NULL); ++ if (access(path, F_OK) == 0) { ++ rpmlog(RPMLOG_DEBUG, ++ _("Found %s %s database while attempting %s backend: " ++ "using %s backend.\n"), ++ (*ops)->name, (*ops)->path, db_backend, (*ops)->name); ++ rdb->db_ops = *ops; ++ } ++ free(path); ++ if (rdb->db_ops != NULL) ++ break; ++ } + } +- free(path); +-#endif + ++ /* if we did not find a match, use the configured backend */ ++ if (rdb->db_ops == NULL && ops_config) ++ rdb->db_ops = ops_config; ++ ++ /* if everything failed fall back to dummydb */ + if (rdb->db_ops == NULL) { + rdb->db_ops = &dummydb_dbops; +- rpmlog(RPMLOG_DEBUG, "using dummy database, installs not possible\n"); ++ rpmlog(RPMLOG_WARNING, "using dummy database, installs not possible\n"); + } + ++ rdb->db_descr = rdb->db_ops->name; ++ + if (db_backend) + free(db_backend); + } +--- ./lib/backend/dbi.h.orig 2020-01-17 11:52:17.960236465 +0000 ++++ ./lib/backend/dbi.h 2020-01-17 11:57:36.907459407 +0000 +@@ -51,7 +51,7 @@ struct rpmdb_s { + int db_flags; + int db_mode; /*!< open mode */ + int db_perms; /*!< open permissions */ +- char * db_descr; /*!< db backend description (for error msgs) */ ++ const char * db_descr; /*!< db backend description (for error msgs) */ + struct dbChk_s * db_checked;/*!< headerCheck()'ed package instances */ + rpmdb db_next; + int db_opens; +@@ -61,7 +61,7 @@ struct rpmdb_s { + dbiIndex * db_indexes; /*!< Tag indices. */ + int db_buildindex; /*!< Index rebuild indicator */ + +- struct rpmdbOps_s * db_ops; /*!< backend ops */ ++ const struct rpmdbOps_s * db_ops; /*!< backend ops */ + + /* dbenv and related parameters */ + void * db_dbenv; /*!< Backend private handle */ +@@ -244,6 +244,9 @@ RPM_GNUC_INTERNAL + const void * idxdbKey(dbiIndex dbi, dbiCursor dbc, unsigned int *keylen); + + struct rpmdbOps_s { ++ const char *name; /* backend name */ ++ const char *path; /* main database name */ ++ + int (*open)(rpmdb rdb, rpmDbiTagVal rpmtag, dbiIndex * dbip, int flags); + int (*close)(dbiIndex dbi, unsigned int flags); + int (*verify)(dbiIndex dbi, unsigned int flags); +--- ./lib/backend/dummydb.c.orig 2020-01-17 11:50:49.472452046 +0000 ++++ ./lib/backend/dummydb.c 2020-01-17 11:52:08.048260613 +0000 +@@ -93,6 +93,9 @@ static const void * dummydb_idxdbKey(dbi + + + struct rpmdbOps_s dummydb_dbops = { ++ .name = "dummy", ++ .path = NULL, ++ + .open = dummydb_Open, + .close = dummydb_Close, + .verify = dummydb_Verify, +--- ./lib/backend/lmdb.c.orig 2020-01-17 11:50:45.808460969 +0000 ++++ ./lib/backend/lmdb.c 2020-01-17 11:58:30.247329459 +0000 +@@ -137,10 +137,6 @@ static int db_init(rpmdb rdb, const char + if (rdb->db_dbenv != NULL) { + rdb->db_opens++; + return 0; +- } else { +- /* On first call, set backend description to something... */ +- free(rdb->db_descr); +- rdb->db_descr = xstrdup("lmdb"); + } + + MDB_dbi maxdbs = 32; +@@ -916,6 +912,9 @@ exit: + } + + struct rpmdbOps_s lmdb_dbops = { ++ .name = "lmdb", ++ .path = "data.mdb", ++ + .open = lmdb_dbiOpen, + .close = lmdb_dbiClose, + .verify = lmdb_dbiVerify, +--- ./lib/backend/ndb/glue.c.orig 2020-01-17 11:51:09.708402746 +0000 ++++ ./lib/backend/ndb/glue.c 2020-01-17 11:51:56.272289298 +0000 +@@ -482,6 +482,9 @@ static const void * ndb_idxdbKey(dbiInde + + + struct rpmdbOps_s ndb_dbops = { ++ .name = "ndb", ++ .path = "Packages.db", ++ + .open = ndb_Open, + .close = ndb_Close, + .verify = ndb_Verify, +--- ./lib/rpmdb.c.orig 2020-01-17 11:59:15.279219743 +0000 ++++ ./lib/rpmdb.c 2020-01-17 12:00:36.495021876 +0000 +@@ -417,7 +417,6 @@ int rpmdbClose(rpmdb db) + db->db_fullpath = _free(db->db_fullpath); + db->db_checked = dbChkFree(db->db_checked); + db->db_indexes = _free(db->db_indexes); +- db->db_descr = _free(db->db_descr); + + if (next) { + *prev = next->db_next; +@@ -482,7 +481,6 @@ static rpmdb newRpmdb(const char * root, + db->db_tags = dbiTags; + db->db_ndbi = sizeof(dbiTags) / sizeof(rpmDbiTag); + db->db_indexes = xcalloc(db->db_ndbi, sizeof(*db->db_indexes)); +- db->db_descr = xstrdup("unknown db"); + db->nrefs = 0; + return rpmdbLink(db); + } +@@ -517,6 +515,8 @@ static int openDatabase(const char * pre + + /* Just the primary Packages database opened here */ + rc = pkgdbOpen(db, db->db_flags, NULL); ++ if (!db->db_descr) ++ db->db_descr = "unknown db"; + } + + if (rc || justCheck || dbp == NULL) diff --git a/dbrointerruptable.diff b/dbrointerruptable.diff index a36bb0f..6e44578 100644 --- a/dbrointerruptable.diff +++ b/dbrointerruptable.diff @@ -1,5 +1,5 @@ ---- ./lib/rpmdb.c.orig 2020-05-28 10:04:25.037136686 +0000 -+++ ./lib/rpmdb.c 2020-09-30 12:23:50.708547165 +0000 +--- ./lib/rpmdb.c.orig 2018-08-08 13:40:18.153941351 +0000 ++++ ./lib/rpmdb.c 2018-10-16 09:20:11.196708098 +0000 @@ -387,9 +387,11 @@ int rpmdbClose(rpmdb db) { rpmdb * prev, next; @@ -12,7 +12,7 @@ prev = &rpmdbRock; while ((next = *prev) != NULL && next != db) -@@ -423,7 +425,7 @@ int rpmdbClose(rpmdb db) +@@ -424,7 +426,7 @@ int rpmdbClose(rpmdb db) db = _free(db); @@ -21,9 +21,9 @@ rpmsqActivate(0); } exit: -@@ -510,7 +512,7 @@ static int openDatabase(const char * pre - int justPkgs = (db->db_flags & RPMDB_FLAG_REBUILD) && - ((db->db_mode & O_ACCMODE) == O_RDONLY); +@@ -509,7 +511,7 @@ static int openDatabase(const char * pre + rc = rpmioMkpath(rpmdbHome(db), 0755, getuid(), getgid()); + if (rc == 0) { /* Enable signal queue on the first db open */ - if (db->db_next == NULL) { + if (db->db_next == NULL && (db->db_mode & (O_RDWR|O_WRONLY)) != 0) { diff --git a/disable_bdb.diff b/disable_bdb.diff new file mode 100644 index 0000000..ec419d9 --- /dev/null +++ b/disable_bdb.diff @@ -0,0 +1,15 @@ +--- configure.ac.orig 2020-01-17 12:25:06.451387587 +0000 ++++ configure.ac 2020-01-17 12:25:17.707357939 +0000 +@@ -537,11 +537,11 @@ AC_ARG_ENABLE([bdb], + [enable_bdb="$enableval"], + [enable_bdb=yes]) + ++have_bdb="no" + AS_IF([test "x$enable_bdb" != "xno"], [ + if [ test -x db/dist/configure ]; then + have_bdb="internal" + else +- have_bdb="no" + AC_CHECK_HEADERS([db.h],[ + AC_PREPROC_IFELSE([ + AC_LANG_SOURCE([ diff --git a/finddebuginfo-check-res-file.patch b/finddebuginfo-check-res-file.patch index 2450058..0f8185f 100644 --- a/finddebuginfo-check-res-file.patch +++ b/finddebuginfo-check-res-file.patch @@ -12,14 +12,9 @@ as no single res.$number has been written. But if you have more than X jobs, the build will succeed, which makes the whole process random. This commit remove this randomness. ---- - scripts/find-debuginfo.sh | 1 + - 1 file changed, 1 insertion(+) -diff --git a/scripts/find-debuginfo.sh b/scripts/find-debuginfo.sh -index 081e24148..e0c36ebb6 100755 ---- a/scripts/find-debuginfo.sh -+++ b/scripts/find-debuginfo.sh +--- scripts/find-debuginfo.sh.orig ++++ scripts/find-debuginfo.sh @@ -498,6 +498,7 @@ else wait ) diff --git a/findsupplements.diff b/findsupplements.diff index b206023..d357bcb 100644 --- a/findsupplements.diff +++ b/findsupplements.diff @@ -1,25 +1,25 @@ ---- ./scripts/Makefile.am.orig 2020-05-28 10:04:25.075136894 +0000 -+++ ./scripts/Makefile.am 2020-09-30 13:11:48.626135765 +0000 +--- ./scripts/Makefile.am.orig 2019-06-26 14:17:31.452985634 +0000 ++++ ./scripts/Makefile.am 2019-10-02 12:27:55.885450155 +0000 @@ -16,7 +16,7 @@ EXTRA_DIST = \ - rpmdb_dump rpmdb_load \ - rpm.daily rpm.log rpm.supp rpm2cpio.sh \ + perl.prov perl.req pythondeps.sh pythondistdeps.py \ + rpmdb_loadcvt rpm.daily rpm.log rpm.supp rpm2cpio.sh \ tgpg vpkg-provides.sh \ - find-requires find-provides \ + find-requires find-provides find-supplements \ find-requires.php find-provides.php \ - ocamldeps.sh \ - pkgconfigdeps.sh libtooldeps.sh \ -@@ -28,7 +28,7 @@ rpmconfig_SCRIPTS = \ - brp-strip-shared brp-strip-static-archive \ + ocaml-find-requires.sh ocaml-find-provides.sh \ + pkgconfigdeps.sh libtooldeps.sh metainfo.prov \ +@@ -29,7 +29,7 @@ rpmconfig_SCRIPTS = \ check-files check-prereqs \ check-buildroot check-rpaths check-rpaths-worker \ + debuginfo.prov \ - find-lang.sh find-requires find-provides \ + find-lang.sh find-requires find-provides find-supplements \ - perl.prov perl.req pythondistdeps.py \ + perl.prov perl.req pythondeps.sh pythondistdeps.py \ + metainfo.prov \ pkgconfigdeps.sh libtooldeps.sh \ - ocamldeps.sh \ ---- ./scripts/find-supplements.orig 2020-09-30 13:10:46.546268477 +0000 -+++ ./scripts/find-supplements 2020-09-30 13:10:46.546268477 +0000 +--- ./scripts/find-supplements.orig 2019-10-02 12:27:55.885450155 +0000 ++++ ./scripts/find-supplements 2019-10-02 12:27:55.885450155 +0000 @@ -0,0 +1,3 @@ +#!/bin/sh + diff --git a/gcryptdsa2.diff b/gcryptdsa2.diff new file mode 100644 index 0000000..7bfedc0 --- /dev/null +++ b/gcryptdsa2.diff @@ -0,0 +1,19 @@ +--- ./rpmio/digest_libgcrypt.c.orig ++++ ./rpmio/digest_libgcrypt.c +@@ -302,10 +302,16 @@ static int pgpVerifySigDSA(pgpDigAlg pgpkey, pgpDigAlg pgpsig, uint8_t *hash, si + struct pgpDigSigDSA_s *sig = pgpsig->data; + gcry_sexp_t sexp_sig = NULL, sexp_data = NULL, sexp_pkey = NULL; + int rc = 1; ++ size_t qlen; + + if (!sig || !key) + return rc; + ++ qlen = (mpi_get_nbits(key->q) + 7) / 8; ++ if (qlen < 20) ++ qlen = 20; /* sanity */ ++ if (hashlen > qlen) ++ hashlen = qlen; /* dsa2: truncate hash to qlen */ + gcry_sexp_build(&sexp_sig, NULL, "(sig-val (dsa (r %M) (s %M)))", sig->r, sig->s); + gcry_sexp_build(&sexp_data, NULL, "(data (flags raw) (value %b))", (int)hashlen, (const char *)hash); + gcry_sexp_build(&sexp_pkey, NULL, "(public-key (dsa (p %M) (q %M) (g %M) (y %M)))", key->p, key->q, key->g, key->y); diff --git a/ignore-auxv.diff b/ignore-auxv.diff index ac76d48..4dec457 100644 --- a/ignore-auxv.diff +++ b/ignore-auxv.diff @@ -1,6 +1,6 @@ ---- ./lib/rpmrc.c.orig 2020-09-30 07:48:01.215567727 +0000 -+++ ./lib/rpmrc.c 2020-09-30 12:22:46.612692258 +0000 -@@ -78,10 +78,12 @@ struct rpmOption { +--- ./lib/rpmrc.c.orig 2019-06-26 14:17:31.416985688 +0000 ++++ ./lib/rpmrc.c 2019-10-02 09:52:05.076903733 +0000 +@@ -79,11 +79,13 @@ struct rpmOption { int localize; }; @@ -8,21 +8,22 @@ static struct rpmat_s { const char *platform; uint64_t hwcap; + uint64_t hwcap2; } rpmat; +#endif typedef struct defaultEntry_s { char * name; -@@ -948,7 +950,7 @@ static int is_geode(void) +@@ -950,7 +952,7 @@ static int is_geode(void) #endif -#if defined(__linux__) +#if defined(__linux__) && (defined(__powerpc__) || defined(__sparc__) || (defined(__arm__) && defined(__ARM_PCS_VFP))) - /** - * Populate rpmat structure with auxv values - */ -@@ -1004,7 +1006,7 @@ static void defaultMachine(rpmrcCtx ctx, + #ifndef AT_HWCAP2 /* glibc < 2.18 */ + #define AT_HWCAP2 26 + #endif +@@ -1013,7 +1015,7 @@ static void defaultMachine(rpmrcCtx ctx, canonEntry canon; int rc; diff --git a/initgcrypt.diff b/initgcrypt.diff new file mode 100644 index 0000000..306cebd --- /dev/null +++ b/initgcrypt.diff @@ -0,0 +1,11 @@ +--- ./rpmio/digest_libgcrypt.c.orig 2020-04-06 10:10:26.096842925 +0000 ++++ ./rpmio/digest_libgcrypt.c 2020-04-06 10:10:39.832806646 +0000 +@@ -20,6 +20,8 @@ struct DIGEST_CTX_s { + /**************************** init ************************************/ + + int rpmInitCrypto(void) { ++ gcry_check_version (NULL); ++ gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); + return 0; + } + diff --git a/lazystatfs.diff b/lazystatfs.diff new file mode 100644 index 0000000..5869a23 --- /dev/null +++ b/lazystatfs.diff @@ -0,0 +1,50 @@ +Prefer sys/vfs.h, as statvfs stats all filesystems again +--- ./configure.ac.orig 2011-05-12 12:36:32.000000000 +0000 ++++ ./configure.ac 2011-05-12 12:36:42.000000000 +0000 +@@ -402,25 +402,25 @@ dnl + found_struct_statfs=no + + if test X$found_struct_statfs = Xno ; then +-dnl Solaris 2.6+ wants to use statvfs ++dnl first try including sys/vfs.h + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + #ifdef HAVE_SYS_TYPES_H + #include + #endif +-#include ]], [[struct statvfs sfs;]])],[AC_MSG_RESULT(in sys/statvfs.h) +- AC_DEFINE(STATFS_IN_SYS_STATVFS, 1, +- [statfs in (for solaris 2.6+ systems)]) ++#include ]], [[struct statfs sfs;]])],[AC_MSG_RESULT(in sys/vfs.h) ++ AC_DEFINE(STATFS_IN_SYS_VFS, 1, [statfs in (for linux systems)]) + found_struct_statfs=yes],[]) + fi + + if test X$found_struct_statfs = Xno ; then +-dnl first try including sys/vfs.h ++dnl Solaris 2.6+ wants to use statvfs + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + #ifdef HAVE_SYS_TYPES_H + #include + #endif +-#include ]], [[struct statfs sfs;]])],[AC_MSG_RESULT(in sys/vfs.h) +- AC_DEFINE(STATFS_IN_SYS_VFS, 1, [statfs in (for linux systems)]) ++#include ]], [[struct statvfs sfs;]])],[AC_MSG_RESULT(in sys/statvfs.h) ++ AC_DEFINE(STATFS_IN_SYS_STATVFS, 1, ++ [statfs in (for solaris 2.6+ systems)]) + found_struct_statfs=yes],[]) + fi + +--- ./lib/transaction.c.orig 2011-05-12 12:36:55.000000000 +0000 ++++ ./lib/transaction.c 2011-05-12 12:38:03.000000000 +0000 +@@ -114,7 +114,11 @@ static rpmDiskSpaceInfo rpmtsCreateDSI(c + dsi->bneeded = 0; + dsi->ineeded = 0; + #ifdef STATFS_HAS_F_BAVAIL ++# ifdef ST_RDONLY + dsi->bavail = (sfb.f_flag & ST_RDONLY) ? 0 : sfb.f_bavail; ++# else ++ dsi->bavail = sfb.f_bavail; ++# endif + #else + /* FIXME: the statfs struct doesn't have a member to tell how many blocks are + * available for non-superusers. f_blocks - f_bfree is probably too big, but diff --git a/macrosin.diff b/macrosin.diff index 8c9ddbf..5d04c46 100644 --- a/macrosin.diff +++ b/macrosin.diff @@ -1,5 +1,5 @@ ---- ./macros.in.orig 2020-09-30 12:42:09.146057387 +0000 -+++ ./macros.in 2020-09-30 12:45:30.517611707 +0000 +--- ./macros.in.orig 2019-10-02 11:13:35.966773848 +0000 ++++ ./macros.in 2019-10-02 11:17:37.210282271 +0000 @@ -177,7 +177,7 @@ %{?_unique_build_ids:--build-id-seed "%{VERSION}-%{RELEASE}"} \\\ %{?_unique_debug_names:--unique-debug-suffix "-%{VERSION}-%{RELEASE}.%{_arch}"} \\\ @@ -19,7 +19,7 @@ %_defaultlicensedir %{_datadir}/licenses # Following macros for filtering auto deps must not be used in spec files. -@@ -280,7 +281,8 @@ package or when debugging this package.\ +@@ -276,7 +277,8 @@ package or when debugging this package.\ %_tmppath %{_var}/tmp # Path to top of build area. @@ -29,7 +29,7 @@ # The path to the unzip executable (legacy, use %{__unzip} instead). %_unzipbin %{__unzip} -@@ -392,7 +394,7 @@ package or when debugging this package.\ +@@ -388,7 +390,7 @@ package or when debugging this package.\ # "w.ufdio" uncompressed # #%_source_payload w9.gzdio @@ -38,7 +38,7 @@ # Algorithm to use for generating file checksum digests on build. # If not specified or 0, MD5 is used. -@@ -499,6 +501,19 @@ package or when debugging this package.\ +@@ -495,6 +497,19 @@ package or when debugging this package.\ # #%_include_minidebuginfo 1 @@ -58,7 +58,7 @@ # # Include a .gdb_index section in the .debug files. # Requires _enable_debug_packages and gdb-add-index installed. -@@ -531,7 +546,7 @@ package or when debugging this package.\ +@@ -527,7 +542,7 @@ package or when debugging this package.\ # Same as for "separate" but if the __debug_package global is set then # the -debuginfo package will have a compatibility link for the main # ELF /usr/lib/debug/.build-id/xx/yyy -> /usr/lib/.build-id/xx/yyy @@ -67,7 +67,7 @@ # Whether build-ids should be made unique between package version/releases # when generating debuginfo packages. If set to 1 this will pass -@@ -560,10 +575,10 @@ package or when debugging this package.\ +@@ -556,10 +571,10 @@ package or when debugging this package.\ %_unique_debug_srcs 1 # Whether rpm should put debug source files into its own subpackage @@ -80,9 +80,9 @@ # # Use internal dependency generator rather than external helpers? -@@ -576,6 +591,10 @@ package or when debugging this package.\ +@@ -572,6 +587,10 @@ package or when debugging this package.\ # Directories whose contents should be considered as documentation. - %__docdir_path %{_datadir}/doc:%{_datadir}/man:%{_datadir}/info:%{_datadir}/gtk-doc/html:%{_datadir}/gnome/help:%{?_docdir}:%{?_mandir}:%{?_infodir}:%{?_javadocdir}:/usr/doc:/usr/man:/usr/info:/usr/X11R6/man + %__docdir_path %{_datadir}/doc:%{_datadir}/man:%{_datadir}/info:%{_datadir}/gtk-doc/html:%{?_docdir}:%{?_mandir}:%{?_infodir}:%{?_javadocdir}:/usr/doc:/usr/man:/usr/info:/usr/X11R6/man +# maxnum,cuttime,minnum +# 2014/10/13 (SLES12 GA) @@ -91,7 +91,7 @@ # # Path to scripts to autogenerate package dependencies, # -@@ -586,6 +605,7 @@ package or when debugging this package.\ +@@ -582,6 +601,7 @@ package or when debugging this package.\ %__find_requires %{_rpmconfigdir}/find-requires #%__find_conflicts ??? #%__find_obsoletes ??? @@ -99,7 +99,7 @@ # # Path to file attribute classifications for automatic dependency -@@ -665,10 +685,10 @@ package or when debugging this package.\ +@@ -660,10 +680,10 @@ package or when debugging this package.\ # Misc BDB tuning options %__dbi_other mp_mmapsize=128Mb mp_size=1Mb @@ -112,7 +112,7 @@ #============================================================================== # ---- GPG/PGP/PGP5 signature macros. -@@ -1011,7 +1031,7 @@ package or when debugging this package.\ +@@ -1000,7 +1020,7 @@ package or when debugging this package.\ %_build_vendor %{_host_vendor} %_build_os %{_host_os} %_host @host@ @@ -121,18 +121,15 @@ %_host_cpu @host_cpu@ %_host_vendor @host_vendor@ %_host_os @host_os@ -@@ -1130,11 +1150,13 @@ package or when debugging this package.\ +@@ -1119,7 +1139,10 @@ package or when debugging this package.\ #------------------------------------------------------------------------------ - # arch macro for all supported 32-bit ARM processors --%arm32 armv3l armv4b armv4l armv4tl armv5tl armv5tel armv5tejl armv6l armv6hl armv7l armv7hl armv7hnl armv8l armv8hl armv8hnl armv8hcnl -+%arm32 armv3l armv4b armv4l armv4tl armv5b armv5l armv5teb armv5tel armv5tejl armv6l armv6hl armv7l armv7hl armv7hnl armv8l armv8hl armv8hnl armv8hcnl + # arch macro for all supported ARM processors +-%arm armv3l armv4b armv4l armv4tl armv5tl armv5tel armv5tejl armv6l armv6hl armv7l armv7hl armv7hnl armv8l armv8hl armv8hnl armv8hcnl ++%arm armv3l armv4b armv4l armv4tl armv5b armv5l armv5teb armv5tel armv5tejl armv6l armv6hl armv7l armv7hl armv7hnl armv8l armv8hl armv8hnl armv8hcnl ++%arml armv3l armv4l armv5l armv5tel armv6l armv6hl armv7l armv7hl armv7hnl armv8l armv8hl armv8hnl armv8hcnl ++%armb armv4b armv5b armv5teb ++%arm64 aarch64 #------------------------------------------------------------------------------ - # arch macro for all supported 32-bit ARM processors (legacy, use %%arm32 instead) - %arm %{arm32} -+%arml armv3l armv4l armv5l armv5tel armv6l armv6hl armv7l armv7hl armv7hnl armv8l armv8hl armv8hnl armv8hcnl -+%armb armv4b armv5b armv5teb - - #------------------------------------------------------------------------------ - # arch macro for all supported 64-bit ARM processors + # arch macro for 32-bit MIPS processors diff --git a/ndb_backport.diff b/ndb_backport.diff new file mode 100644 index 0000000..dbea6ee --- /dev/null +++ b/ndb_backport.diff @@ -0,0 +1,733 @@ +--- ./lib/backend/ndb/glue.c.orig 2020-01-23 12:47:46.527816289 +0000 ++++ ./lib/backend/ndb/glue.c 2020-02-03 12:57:34.817304473 +0000 +@@ -52,8 +52,8 @@ static void closeEnv(rpmdb rdb) + if (ndbenv->data) + free(ndbenv->data); + free(ndbenv); ++ rdb->db_dbenv = 0; + } +- rdb->db_dbenv = 0; + } + + static struct ndbEnv_s *openEnv(rpmdb rdb) +@@ -80,6 +80,31 @@ static int ndb_Close(dbiIndex dbi, unsig + return 0; + } + ++static void ndb_CheckIndexSync(rpmpkgdb pkgdb, rpmxdb xdb) ++{ ++ unsigned int generation, xdb_generation; ++ if (!pkgdb || !xdb) ++ return; ++ if (rpmpkgLock(pkgdb, 0)) ++ return; ++ if (rpmpkgGeneration(pkgdb, &generation)) { ++ rpmpkgUnlock(pkgdb, 0); ++ return; ++ } ++ if (!rpmxdbGetUserGeneration(xdb, &xdb_generation) && generation == xdb_generation) { ++ rpmpkgUnlock(pkgdb, 0); ++ return; ++ } ++ rpmpkgUnlock(pkgdb, 0); ++ /* index corrupt or with different generation */ ++ if (rpmxdbIsRdonly(xdb)) { ++ rpmlog(RPMLOG_WARNING, _("Detected outdated index databases\n")); ++ } else { ++ rpmlog(RPMLOG_WARNING, _("Rebuilding outdated index databases\n")); ++ rpmxdbDelAllBlobs(xdb); ++ } ++} ++ + static int ndb_Open(rpmdb rdb, rpmDbiTagVal rpmtag, dbiIndex * dbip, int flags) + { + const char *dbhome = rpmdbHome(rdb); +@@ -130,12 +155,13 @@ static int ndb_Open(rpmdb rdb, rpmDbiTag + } + if (!ndbenv->xdb) { + char *path = rstrscat(NULL, dbhome, "/Index.db", NULL); ++ int created = 0; + rpmlog(RPMLOG_DEBUG, "opening db index %s mode=0x%x\n", path, rdb->db_mode); + + /* Open indexes readwrite if possible */ + ioflags = O_RDWR; + rc = rpmxdbOpen(&ndbenv->xdb, rdb->db_pkgs->dbi_db, path, ioflags, 0666); +- if (rc && errno == EACCES) { ++ if (rc && (errno == EACCES || errno == EROFS)) { + /* If it is not asked for rw explicitly, try to open ro */ + if (!(oflags & O_RDWR)) { + ioflags = O_RDONLY; +@@ -144,6 +170,7 @@ static int ndb_Open(rpmdb rdb, rpmDbiTag + } else if (rc && errno == ENOENT) { + ioflags = O_CREAT|O_RDWR; + rc = rpmxdbOpen(&ndbenv->xdb, rdb->db_pkgs->dbi_db, path, ioflags, 0666); ++ created = 1; + } + if (rc) { + perror("rpmxdbOpen"); +@@ -153,6 +180,8 @@ static int ndb_Open(rpmdb rdb, rpmDbiTag + } + free(path); + rpmxdbSetFsync(ndbenv->xdb, ndbenv->dofsync); ++ if (!created) ++ ndb_CheckIndexSync(ndbenv->pkgdb, ndbenv->xdb); + } + if (rpmxdbLookupBlob(ndbenv->xdb, &id, rpmtag, 0, 0) == RPMRC_NOTFOUND) { + dbi->dbi_flags |= DBI_CREATED; +@@ -179,7 +208,13 @@ static int ndb_Open(rpmdb rdb, rpmDbiTag + + static int ndb_Verify(dbiIndex dbi, unsigned int flags) + { +- return 0; ++ int rc; ++ if (dbi->dbi_type == DBI_PRIMARY) { ++ rc = rpmpkgVerify(dbi->dbi_db); ++ } else { ++ rc = 0; /* cannot verify the index databases */ ++ } ++ return rc; + } + + static void ndb_SetFSync(rpmdb rdb, int enable) +@@ -396,15 +431,15 @@ static rpmRC ndb_idxdbIter(dbiIndex dbi, + } + k = dbc->listdata + dbc->list[dbc->ilist]; + kl = dbc->list[dbc->ilist + 1]; +-#if 0 +- if (searchType == DBC_KEY_SEARCH) { ++ ++ if (set == NULL) { + dbc->ilist += 2; + dbc->key = k; + dbc->keylen = kl; + rc = RPMRC_OK; + break; + } +-#endif ++ + pkglist = 0; + pkglistn = 0; + rc = rpmidxGet(dbc->dbi->dbi_db, k, kl, &pkglist, &pkglistn); +--- ./lib/backend/ndb/rpmpkg.c.orig 2019-11-13 09:19:29.306710577 +0000 ++++ ./lib/backend/ndb/rpmpkg.c 2020-01-23 12:48:59.739630414 +0000 +@@ -7,7 +7,6 @@ + #include + #include + #include +-#include + #include + #include + #include +@@ -19,10 +18,6 @@ + #define RPMRC_NOTFOUND 1 + #define RPMRC_OK 0 + +-#ifdef RPMPKG_LZO +-static int rpmpkgLZOCompress(unsigned char **blobp, unsigned int *bloblp); +-static int rpmpkgLZODecompress(unsigned char **blobp, unsigned int *bloblp); +-#endif + + static int rpmpkgVerifyblob(rpmpkgdb pkgdb, unsigned int pkgidx, unsigned int blkoff, unsigned int blkcnt); + +@@ -49,23 +44,19 @@ typedef struct rpmpkgdb_s { + unsigned int nextpkgidx; + + struct pkgslot_s *slots; +- unsigned int aslots; /* allocated slots */ + unsigned int nslots; /* used slots */ + + unsigned int *slothash; + unsigned int nslothash; + + unsigned int freeslot; /* first free slot */ +- int slotorder; ++ int ordered; /* slots are ordered by the blk offsets */ + + char *filename; + unsigned int fileblks; /* file size in blks */ + int dofsync; + } * rpmpkgdb; + +-#define SLOTORDER_UNORDERED 0 +-#define SLOTORDER_BLKOFF 1 +- + + static inline unsigned int le2h(unsigned char *p) + { +@@ -144,10 +135,6 @@ static int rpmpkgReadHeader(rpmpkgdb pkg + if (pkgdb->slots && (pkgdb->generation != generation || pkgdb->slotnpages != slotnpages)) { + free(pkgdb->slots); + pkgdb->slots = 0; +- if (pkgdb->slothash) { +- free(pkgdb->slothash); +- pkgdb->slothash = 0; +- } + } + pkgdb->generation = generation; + pkgdb->slotnpages = slotnpages; +@@ -200,6 +187,7 @@ static inline unsigned int hashpkgidx(un + return h; + } + ++/* (re-)create a hash mapping pkgidx numbers to slots */ + static int rpmpkgHashSlots(rpmpkgdb pkgdb) + { + unsigned int nslots, num; +@@ -208,14 +196,14 @@ static int rpmpkgHashSlots(rpmpkgdb pkgd + int i; + pkgslot *slot; + +- pkgdb->nslothash = 0; +- num = pkgdb->nslots; ++ num = pkgdb->nslots + 32; + while (num & (num - 1)) + num = num & (num - 1); + num *= 4; + hash = pkgdb->slothash; + if (!hash || pkgdb->nslothash != num) { +- free(pkgdb->slothash); ++ if (hash) ++ free(hash); + hash = pkgdb->slothash = xcalloc(num, sizeof(unsigned int)); + pkgdb->nslothash = num; + } else { +@@ -228,8 +216,6 @@ static int rpmpkgHashSlots(rpmpkgdb pkgd + ; + hash[h] = i + 1; + } +- pkgdb->slothash = hash; +- pkgdb->nslothash = num; + return RPMRC_OK; + } + +@@ -247,10 +233,6 @@ static int rpmpkgReadSlots(rpmpkgdb pkgd + free(pkgdb->slots); + pkgdb->slots = 0; + } +- if (pkgdb->slothash) { +- free(pkgdb->slothash); +- pkgdb->slothash = 0; +- } + pkgdb->nslots = 0; + pkgdb->freeslot = 0; + +@@ -262,8 +244,7 @@ static int rpmpkgReadSlots(rpmpkgdb pkgd + fileblks = stb.st_size / BLK_SIZE; + + /* read (and somewhat verify) all slots */ +- pkgdb->aslots = slotnpages * (PAGE_SIZE / SLOT_SIZE); +- pkgdb->slots = xcalloc(pkgdb->aslots, sizeof(*pkgdb->slots)); ++ pkgdb->slots = xcalloc(slotnpages * (PAGE_SIZE / SLOT_SIZE), sizeof(*pkgdb->slots)); + i = 0; + slot = pkgdb->slots; + minblkoff = slotnpages * (PAGE_SIZE / BLK_SIZE); +@@ -299,7 +280,7 @@ static int rpmpkgReadSlots(rpmpkgdb pkgd + } + } + pkgdb->nslots = i; +- pkgdb->slotorder = SLOTORDER_UNORDERED; /* XXX: always order? */ ++ pkgdb->ordered = 0; + pkgdb->fileblks = fileblks; + pkgdb->freeslot = freeslot; + if (rpmpkgHashSlots(pkgdb)) { +@@ -317,15 +298,13 @@ static int orderslots_blkoff_cmp(const v + return blkoffa > blkoffb ? 1 : blkoffa < blkoffb ? -1 : 0; + } + +-static void rpmpkgOrderSlots(rpmpkgdb pkgdb, int slotorder) ++static void rpmpkgOrderSlots(rpmpkgdb pkgdb) + { +- if (pkgdb->slotorder == slotorder) ++ if (pkgdb->ordered) + return; +- if (slotorder == SLOTORDER_BLKOFF) { +- if (pkgdb->nslots > 1) +- qsort(pkgdb->slots, pkgdb->nslots, sizeof(*pkgdb->slots), orderslots_blkoff_cmp); +- } +- pkgdb->slotorder = slotorder; ++ if (pkgdb->nslots > 1) ++ qsort(pkgdb->slots, pkgdb->nslots, sizeof(*pkgdb->slots), orderslots_blkoff_cmp); ++ pkgdb->ordered = 1; + rpmpkgHashSlots(pkgdb); + } + +@@ -340,6 +319,8 @@ static inline pkgslot *rpmpkgFindSlot(rp + return 0; + } + ++/* Find an empty space for blkcnt blocks. If dontprepend is true, ignore ++ the space between the slot area and the first blob */ + static int rpmpkgFindEmptyOffset(rpmpkgdb pkgdb, unsigned int pkgidx, unsigned int blkcnt, unsigned *blkoffp, pkgslot **oldslotp, int dontprepend) + { + unsigned int i, nslots = pkgdb->nslots; +@@ -348,8 +329,8 @@ static int rpmpkgFindEmptyOffset(rpmpkgd + unsigned int lastblkend = pkgdb->slotnpages * (PAGE_SIZE / BLK_SIZE); + pkgslot *slot, *oldslot = 0; + +- if (pkgdb->slotorder != SLOTORDER_BLKOFF) +- rpmpkgOrderSlots(pkgdb, SLOTORDER_BLKOFF); ++ if (!pkgdb->ordered) ++ rpmpkgOrderSlots(pkgdb); + + if (dontprepend && nslots) { + lastblkend = pkgdb->slots[0].blkoff; +@@ -382,14 +363,15 @@ static int rpmpkgFindEmptyOffset(rpmpkgd + return RPMRC_OK; + } + ++/* verify the blobs to the left and right of a free area */ + static int rpmpkgNeighbourCheck(rpmpkgdb pkgdb, unsigned int blkoff, unsigned int blkcnt, unsigned int *newblkcnt) + { + unsigned int i, nslots = pkgdb->nslots; + unsigned int lastblkend = pkgdb->slotnpages * (PAGE_SIZE / BLK_SIZE); + pkgslot *slot, *left = 0, *right = 0; + +- if (pkgdb->slotorder != SLOTORDER_BLKOFF) +- rpmpkgOrderSlots(pkgdb, SLOTORDER_BLKOFF); ++ if (!pkgdb->ordered) ++ rpmpkgOrderSlots(pkgdb); + if (blkoff < lastblkend) + return RPMRC_FAIL; + for (i = 0, slot = pkgdb->slots; i < nslots; i++, slot++) { +@@ -413,7 +395,7 @@ static int rpmpkgNeighbourCheck(rpmpkgdb + if (right && rpmpkgVerifyblob(pkgdb, right->pkgidx, right->blkoff, right->blkcnt) != RPMRC_OK) + return RPMRC_FAIL; + *newblkcnt = right ? right->blkoff - blkoff : blkcnt; +- /* bounds are intect. free area. */ ++ /* bounds are intact. ok to zero area. */ + return RPMRC_OK; + } + +@@ -433,6 +415,7 @@ static int rpmpkgWriteslot(rpmpkgdb pkgd + return RPMRC_FAIL; + } + pkgdb->generation++; ++ /* rpmpkgFsync() is done by rpmpkgWriteHeader() */ + if (rpmpkgWriteHeader(pkgdb)) { + return RPMRC_FAIL; + } +@@ -527,7 +510,7 @@ static int rpmpkgValidateZero(rpmpkgdb p + + /*** Blob primitives ***/ + +-/* head: magic + pkgidx + timestamp + bloblen */ ++/* head: magic + pkgidx + generation + bloblen */ + /* tail: adler32 + bloblen + magic */ + + #define BLOBHEAD_MAGIC ('B' | 'l' << 8 | 'b' << 16 | 'S' << 24) +@@ -536,10 +519,10 @@ static int rpmpkgValidateZero(rpmpkgdb p + #define BLOBHEAD_SIZE (4 + 4 + 4 + 4) + #define BLOBTAIL_SIZE (4 + 4 + 4) + +-static int rpmpkgReadBlob(rpmpkgdb pkgdb, unsigned int pkgidx, unsigned int blkoff, unsigned int blkcnt, unsigned char *blob, unsigned int *bloblp, unsigned int *tstampp) ++static int rpmpkgReadBlob(rpmpkgdb pkgdb, unsigned int pkgidx, unsigned int blkoff, unsigned int blkcnt, unsigned char *blob, unsigned int *bloblp, unsigned int *generationp) + { + unsigned char buf[BLOBHEAD_SIZE > BLOBTAIL_SIZE ? BLOBHEAD_SIZE : BLOBTAIL_SIZE]; +- unsigned int bloblen, toread, tstamp; ++ unsigned int bloblen, toread, generation; + off_t fileoff; + unsigned int adl; + int verifyadler = bloblp ? 0 : 1; +@@ -555,7 +538,7 @@ static int rpmpkgReadBlob(rpmpkgdb pkgdb + return RPMRC_FAIL; /* bad blob */ + if (le2h(buf + 4) != pkgidx) + return RPMRC_FAIL; /* bad blob */ +- tstamp = le2h(buf + 8); ++ generation = le2h(buf + 8); + bloblen = le2h(buf + 12); + if (blkcnt != (BLOBHEAD_SIZE + bloblen + BLOBTAIL_SIZE + BLK_SIZE - 1) / BLK_SIZE) + return RPMRC_FAIL; /* bad blob */ +@@ -600,8 +583,8 @@ static int rpmpkgReadBlob(rpmpkgdb pkgdb + } + if (bloblp) + *bloblp = bloblen; +- if (tstampp) +- *tstampp = tstamp; ++ if (generationp) ++ *generationp = generation; + return RPMRC_OK; + } + +@@ -684,14 +667,14 @@ static int rpmpkgMoveBlob(rpmpkgdb pkgdb + unsigned int blkoff = slot->blkoff; + unsigned int blkcnt = slot->blkcnt; + unsigned char *blob; +- unsigned int tstamp, blobl; ++ unsigned int generation, blobl; + + blob = xmalloc((size_t)blkcnt * BLK_SIZE); +- if (rpmpkgReadBlob(pkgdb, pkgidx, blkoff, blkcnt, blob, &blobl, &tstamp)) { ++ if (rpmpkgReadBlob(pkgdb, pkgidx, blkoff, blkcnt, blob, &blobl, &generation)) { + free(blob); + return RPMRC_FAIL; + } +- if (rpmpkgWriteBlob(pkgdb, pkgidx, newblkoff, blkcnt, blob, blobl, tstamp)) { ++ if (rpmpkgWriteBlob(pkgdb, pkgidx, newblkoff, blkcnt, blob, blobl, generation)) { + free(blob); + return RPMRC_FAIL; + } +@@ -703,15 +686,15 @@ static int rpmpkgMoveBlob(rpmpkgdb pkgdb + return RPMRC_FAIL; + } + slot->blkoff = newblkoff; +- pkgdb->slotorder = SLOTORDER_UNORDERED; ++ pkgdb->ordered = 0; + return RPMRC_OK; + } + + static int rpmpkgAddSlotPage(rpmpkgdb pkgdb) + { + unsigned int cutoff; +- if (pkgdb->slotorder != SLOTORDER_BLKOFF) +- rpmpkgOrderSlots(pkgdb, SLOTORDER_BLKOFF); ++ if (!pkgdb->ordered) ++ rpmpkgOrderSlots(pkgdb); + cutoff = (pkgdb->slotnpages + 1) * (PAGE_SIZE / BLK_SIZE); + + /* now move every blob before cutoff */ +@@ -729,7 +712,7 @@ static int rpmpkgAddSlotPage(rpmpkgdb pk + if (rpmpkgMoveBlob(pkgdb, slot, newblkoff)) { + return RPMRC_FAIL; + } +- rpmpkgOrderSlots(pkgdb, SLOTORDER_BLKOFF); ++ rpmpkgOrderSlots(pkgdb); + } + + /* make sure our new page is empty */ +@@ -958,6 +941,7 @@ static int rpmpkgPutInternal(rpmpkgdb pk + pkgslot *oldslot; + + /* we always read all slots when writing, just in case */ ++ /* this also will set pkgdb->freeslot */ + if (rpmpkgReadSlots(pkgdb)) { + return RPMRC_FAIL; + } +@@ -981,14 +965,15 @@ static int rpmpkgPutInternal(rpmpkgdb pk + return RPMRC_FAIL; + } + /* write new blob */ +- if (rpmpkgWriteBlob(pkgdb, pkgidx, blkoff, blkcnt, blob, blobl, (unsigned int)time(0))) { ++ if (rpmpkgWriteBlob(pkgdb, pkgidx, blkoff, blkcnt, blob, blobl, pkgdb->generation)) { + return RPMRC_FAIL; + } ++ /* update nextpkgidx if needed */ ++ if (pkgidx >= pkgdb->nextpkgidx) { ++ pkgdb->nextpkgidx = pkgidx + 1; ++ } + /* write slot */ + slotno = oldslot ? oldslot->slotno : pkgdb->freeslot; +- if (!slotno) { +- return RPMRC_FAIL; +- } + if (rpmpkgWriteslot(pkgdb, slotno, pkgidx, blkoff, blkcnt)) { + free(pkgdb->slots); + pkgdb->slots = 0; +@@ -1006,7 +991,7 @@ static int rpmpkgPutInternal(rpmpkgdb pk + /* just update the slot, no need to free the slot data */ + oldslot->blkoff = blkoff; + oldslot->blkcnt = blkcnt; +- pkgdb->slotorder = SLOTORDER_UNORDERED; ++ pkgdb->ordered = 0; + } else { + free(pkgdb->slots); + pkgdb->slots = 0; +@@ -1023,7 +1008,7 @@ static int rpmpkgDelInternal(rpmpkgdb pk + if (rpmpkgReadSlots(pkgdb)) { + return RPMRC_FAIL; + } +- rpmpkgOrderSlots(pkgdb, SLOTORDER_BLKOFF); ++ rpmpkgOrderSlots(pkgdb); + slot = rpmpkgFindSlot(pkgdb, pkgidx); + if (!slot) { + return RPMRC_OK; +@@ -1049,9 +1034,10 @@ static int rpmpkgDelInternal(rpmpkgdb pk + } + slot->blkoff = 0; + slot->blkcnt = 0; ++ /* try to move the last two slots, the bigger one first */ + slot = pkgdb->slots + pkgdb->nslots - 2; + if (slot->blkcnt < slot[1].blkcnt) +- slot++; /* bigger slot first */ ++ slot++; /* bigger slot first */ + for (i = 0; i < 2; i++, slot++) { + if (slot == pkgdb->slots + pkgdb->nslots) + slot -= 2; +@@ -1065,7 +1051,7 @@ static int rpmpkgDelInternal(rpmpkgdb pk + blkoff += slot->blkcnt; + blkcnt -= slot->blkcnt; + } +- rpmpkgOrderSlots(pkgdb, SLOTORDER_BLKOFF); ++ rpmpkgOrderSlots(pkgdb); + } else { + slot->blkoff = 0; + slot->blkcnt = 0; +@@ -1104,7 +1090,7 @@ static int rpmpkgListInternal(rpmpkgdb p + *npkgidxlistp = pkgdb->nslots; + return RPMRC_OK; + } +- rpmpkgOrderSlots(pkgdb, SLOTORDER_BLKOFF); ++ rpmpkgOrderSlots(pkgdb); + nslots = pkgdb->nslots; + pkgidxlist = xcalloc(nslots + 1, sizeof(unsigned int)); + for (i = 0, slot = pkgdb->slots; i < nslots; i++, slot++) { +@@ -1115,6 +1101,22 @@ static int rpmpkgListInternal(rpmpkgdb p + return RPMRC_OK; + } + ++static int rpmpkgVerifyInternal(rpmpkgdb pkgdb) ++{ ++ unsigned int i, nslots; ++ pkgslot *slot; ++ ++ if (rpmpkgReadSlots(pkgdb)) ++ return RPMRC_FAIL; ++ rpmpkgOrderSlots(pkgdb); ++ nslots = pkgdb->nslots; ++ for (i = 0, slot = pkgdb->slots; i < nslots; i++, slot++) { ++ if (rpmpkgVerifyblob(pkgdb, slot->pkgidx, slot->blkoff, slot->blkcnt)) ++ return RPMRC_FAIL; ++ } ++ return RPMRC_OK; ++} ++ + int rpmpkgGet(rpmpkgdb pkgdb, unsigned int pkgidx, unsigned char **blobp, unsigned int *bloblp) + { + int rc; +@@ -1127,10 +1129,6 @@ int rpmpkgGet(rpmpkgdb pkgdb, unsigned i + return RPMRC_FAIL; + rc = rpmpkgGetInternal(pkgdb, pkgidx, blobp, bloblp); + rpmpkgUnlock(pkgdb, 0); +-#ifdef RPMPKG_LZO +- if (!rc) +- rc = rpmpkgLZODecompress(blobp, bloblp); +-#endif + return rc; + } + +@@ -1143,16 +1141,7 @@ int rpmpkgPut(rpmpkgdb pkgdb, unsigned i + } + if (rpmpkgLockReadHeader(pkgdb, 1)) + return RPMRC_FAIL; +-#ifdef RPMPKG_LZO +- if (rpmpkgLZOCompress(&blob, &blobl)) { +- rpmpkgUnlock(pkgdb, 1); +- return RPMRC_FAIL; +- } +-#endif + rc = rpmpkgPutInternal(pkgdb, pkgidx, blob, blobl); +-#ifdef RPMPKG_LZO +- free(blob); +-#endif + rpmpkgUnlock(pkgdb, 1); + return rc; + } +@@ -1184,6 +1173,16 @@ int rpmpkgList(rpmpkgdb pkgdb, unsigned + return rc; + } + ++int rpmpkgVerify(rpmpkgdb pkgdb) ++{ ++ int rc; ++ if (rpmpkgLockReadHeader(pkgdb, 0)) ++ return RPMRC_FAIL; ++ rc = rpmpkgVerifyInternal(pkgdb); ++ rpmpkgUnlock(pkgdb, 0); ++ return rc; ++} ++ + int rpmpkgNextPkgIdx(rpmpkgdb pkgdb, unsigned int *pkgidxp) + { + if (rpmpkgLockReadHeader(pkgdb, 1)) +@@ -1233,64 +1232,3 @@ int rpmpkgStats(rpmpkgdb pkgdb) + return RPMRC_OK; + } + +-#ifdef RPMPKG_LZO +- +-#include "lzo/lzoconf.h" +-#include "lzo/lzo1x.h" +- +-#define BLOBLZO_MAGIC ('L' | 'Z' << 8 | 'O' << 16 | 'B' << 24) +- +-static int rpmpkgLZOCompress(unsigned char **blobp, unsigned int *bloblp) +-{ +- unsigned char *blob = *blobp; +- unsigned int blobl = *bloblp; +- unsigned char *lzoblob, *workmem; +- unsigned int lzoblobl; +- lzo_uint blobl2; +- +- if (lzo_init() != LZO_E_OK) { +- return RPMRC_FAIL; +- } +- workmem = xmalloc(LZO1X_1_MEM_COMPRESS); +- lzoblobl = 4 + 4 + blobl + blobl / 16 + 64 + 3; +- lzoblob = xmalloc(lzoblobl); +- h2le(BLOBLZO_MAGIC, lzoblob); +- h2le(blobl, lzoblob + 4); +- if (lzo1x_1_compress(blob, blobl, lzoblob + 8, &blobl2, workmem) != LZO_E_OK) { +- free(workmem); +- free(lzoblob); +- return RPMRC_FAIL; +- } +- free(workmem); +- *blobp = lzoblob; +- *bloblp = 8 + blobl2; +- return RPMRC_OK; +-} +- +-static int rpmpkgLZODecompress(unsigned char **blobp, unsigned int *bloblp) +-{ +- unsigned char *lzoblob = *blobp; +- unsigned int lzoblobl = *bloblp; +- unsigned char *blob; +- unsigned int blobl; +- lzo_uint blobl2; +- +- if (!lzoblob || lzoblobl < 8) +- return RPMRC_FAIL; +- if (le2h(lzoblob) != BLOBLZO_MAGIC) +- return RPMRC_FAIL; +- if (lzo_init() != LZO_E_OK) +- return RPMRC_FAIL; +- blobl = le2h(lzoblob + 4); +- blob = xmalloc(blobl ? blobl : 1); +- if (lzo1x_decompress(lzoblob + 8, lzoblobl - 8, blob, &blobl2, 0) != LZO_E_OK || blobl2 != blobl) { +- free(blob); +- return RPMRC_FAIL; +- } +- free(lzoblob); +- *blobp = blob; +- *bloblp = blobl; +- return RPMRC_OK; +-} +- +-#endif +--- ./lib/backend/ndb/rpmpkg.h.orig 2019-06-26 14:17:31.406985703 +0000 ++++ ./lib/backend/ndb/rpmpkg.h 2020-01-23 12:48:20.919728972 +0000 +@@ -12,6 +12,7 @@ int rpmpkgGet(rpmpkgdb pkgdb, unsigned i + int rpmpkgPut(rpmpkgdb pkgdb, unsigned int pkgidx, unsigned char *blob, unsigned int blobl); + int rpmpkgDel(rpmpkgdb pkgdb, unsigned int pkgidx); + int rpmpkgList(rpmpkgdb pkgdb, unsigned int **pkgidxlistp, unsigned int *npkgidxlistp); ++int rpmpkgVerify(rpmpkgdb pkgdb); + + int rpmpkgNextPkgIdx(rpmpkgdb pkgdb, unsigned int *pkgidxp); + int rpmpkgGeneration(rpmpkgdb pkgdb, unsigned int *generationp); +--- ./lib/backend/ndb/rpmxdb.c.orig 2019-11-13 09:19:29.307710583 +0000 ++++ ./lib/backend/ndb/rpmxdb.c 2020-01-23 12:48:20.919728972 +0000 +@@ -224,11 +224,33 @@ static int usedslots_cmp(const void *a, + return sa->startpage > sb->startpage ? 1 : -1; + } + ++static int rpmxdbReadHeaderRaw(rpmxdb xdb, unsigned int *generationp, unsigned int *slotnpagesp, unsigned int *pagesizep, unsigned int *usergenerationp) ++{ ++ unsigned int header[XDB_HEADER_SIZE / sizeof(unsigned int)]; ++ unsigned int version; ++ if (pread(xdb->fd, header, sizeof(header), 0) != sizeof(header)) ++ return RPMRC_FAIL; ++ if (le2ha((unsigned char *)header + XDB_OFFSET_MAGIC) != XDB_MAGIC) ++ return RPMRC_FAIL; ++ version = le2ha((unsigned char *)header + XDB_OFFSET_VERSION); ++ if (version != XDB_VERSION) { ++ rpmlog(RPMLOG_ERR, _("rpmxdb: Version mismatch. Expected version: %u. " ++ "Found version: %u\n"), XDB_VERSION, version); ++ return RPMRC_FAIL; ++ } ++ *generationp = le2ha((unsigned char *)header + XDB_OFFSET_GENERATION); ++ *slotnpagesp = le2ha((unsigned char *)header + XDB_OFFSET_SLOTNPAGES); ++ *pagesizep = le2ha((unsigned char *)header + XDB_OFFSET_PAGESIZE); ++ *usergenerationp = le2ha((unsigned char *)header + XDB_OFFSET_USERGENERATION); ++ if (!*slotnpagesp || !*pagesizep) ++ return RPMRC_FAIL; ++ return RPMRC_OK; ++} ++ + static int rpmxdbReadHeader(rpmxdb xdb) + { + struct xdb_slot *slot; +- unsigned int header[XDB_HEADER_SIZE / sizeof(unsigned int)]; +- unsigned int slotnpages, pagesize, generation, usergeneration, version; ++ unsigned int slotnpages, pagesize, generation, usergeneration; + unsigned int page, *lastfreep; + unsigned char *pageptr; + struct xdb_slot *slots, **usedslots, *lastslot; +@@ -246,23 +268,9 @@ static int rpmxdbReadHeader(rpmxdb xdb) + if (fstat(xdb->fd, &stb)) { + return RPMRC_FAIL; + } +- if (pread(xdb->fd, header, sizeof(header), 0) != sizeof(header)) { +- return RPMRC_FAIL; +- } +- if (le2ha((unsigned char *)header + XDB_OFFSET_MAGIC) != XDB_MAGIC) +- return RPMRC_FAIL; +- version = le2ha((unsigned char *)header + XDB_OFFSET_VERSION); +- if (version != XDB_VERSION) { +- rpmlog(RPMLOG_ERR, _("rpmxdb: Version mismatch. Expected version: %u. " +- "Found version: %u\n"), XDB_VERSION, version); ++ if (rpmxdbReadHeaderRaw(xdb, &generation, &slotnpages, &pagesize, &usergeneration)) + return RPMRC_FAIL; +- } +- +- generation = le2ha((unsigned char *)header + XDB_OFFSET_GENERATION); +- slotnpages = le2ha((unsigned char *)header + XDB_OFFSET_SLOTNPAGES); +- pagesize = le2ha((unsigned char *)header + XDB_OFFSET_PAGESIZE); +- usergeneration = le2ha((unsigned char *)header + XDB_OFFSET_USERGENERATION); +- if (!slotnpages || !pagesize || stb.st_size % pagesize != 0) ++ if (stb.st_size % pagesize != 0) + return RPMRC_FAIL; + xdb->pagesize = pagesize; + xdb->mapflags = xdb->rdonly ? PROT_READ : PROT_READ | PROT_WRITE; +@@ -922,6 +930,43 @@ int rpmxdbDelBlob(rpmxdb xdb, unsigned i + rpmxdbUnlock(xdb, 1); + return RPMRC_OK; + } ++ ++int rpmxdbDelAllBlobs(rpmxdb xdb) ++{ ++ unsigned int slotnpages, pagesize, generation, usergeneration; ++ if (rpmxdbLockOnly(xdb, 1)) ++ return RPMRC_FAIL; ++ /* unmap all blobs */ ++ if (xdb->slots) { ++ int i; ++ struct xdb_slot *slot; ++ for (i = 1, slot = xdb->slots + i; i < xdb->nslots; i++, slot++) { ++ if (slot->startpage && slot->mapped) { ++ unmapslot(xdb, slot); ++ slot->mapcallback(xdb, slot->mapcallbackdata, 0, 0); ++ } ++ } ++ free(xdb->slots); ++ xdb->slots = 0; ++ } ++ if (xdb->mapped) ++ unmapheader(xdb); ++ if (rpmxdbReadHeaderRaw(xdb, &generation, &slotnpages, &pagesize, &usergeneration)) { ++ rpmxdbUnlock(xdb, 1); ++ return RPMRC_FAIL; ++ } ++ xdb->generation = generation + 1; ++ xdb->slotnpages = 1; ++ xdb->pagesize = pagesize; ++ xdb->usergeneration = usergeneration; ++ if (rpmxdbWriteEmptySlotpage(xdb, 0)) { ++ rpmxdbUnlock(xdb, 1); ++ return RPMRC_FAIL; ++ } ++ ftruncate(xdb->fd, xdb->pagesize); ++ rpmxdbUnlock(xdb, 1); ++ return RPMRC_OK; ++} + + int rpmxdbResizeBlob(rpmxdb xdb, unsigned int id, size_t newsize) + { +--- ./lib/backend/ndb/rpmxdb.h.orig 2019-11-13 09:19:29.307710583 +0000 ++++ ./lib/backend/ndb/rpmxdb.h 2020-01-23 12:48:20.919728972 +0000 +@@ -14,6 +14,7 @@ int rpmxdbUnlock(rpmxdb xdb, int excl); + + int rpmxdbLookupBlob(rpmxdb xdb, unsigned int *idp, unsigned int blobtag, unsigned int subtag, int flags); + int rpmxdbDelBlob(rpmxdb xdb, unsigned int id) ; ++int rpmxdbDelAllBlobs(rpmxdb xdb); + + int rpmxdbMapBlob(rpmxdb xdb, unsigned int id, int flags, void (*mapcallback)(rpmxdb xdb, void *data, void *newaddr, size_t newsize), void *mapcallbackdata); + int rpmxdbUnmapBlob(rpmxdb xdb, unsigned int id); diff --git a/ndb_backport2.diff b/ndb_backport2.diff new file mode 100644 index 0000000..c6b25b2 --- /dev/null +++ b/ndb_backport2.diff @@ -0,0 +1,305 @@ +--- ./lib/backend/ndb/glue.c.orig 2020-04-03 10:24:27.954135180 +0000 ++++ ./lib/backend/ndb/glue.c 2020-04-14 09:48:23.304231127 +0000 +@@ -143,9 +143,6 @@ static int ndb_Open(rpmdb rdb, rpmDbiTag + free(path); + dbi->dbi_db = ndbenv->pkgdb = pkgdb; + rpmpkgSetFsync(pkgdb, ndbenv->dofsync); +- +- if ((oflags & (O_RDWR | O_RDONLY)) == O_RDONLY) +- dbi->dbi_flags |= DBI_RDONLY; + } else { + unsigned int id; + rpmidxdb idxdb = 0; +@@ -184,20 +181,20 @@ static int ndb_Open(rpmdb rdb, rpmDbiTag + ndb_CheckIndexSync(ndbenv->pkgdb, ndbenv->xdb); + } + if (rpmxdbLookupBlob(ndbenv->xdb, &id, rpmtag, 0, 0) == RPMRC_NOTFOUND) { ++ oflags = O_RDWR|O_CREAT; + dbi->dbi_flags |= DBI_CREATED; + } + rpmlog(RPMLOG_DEBUG, "opening db index %s tag=%d\n", dbiName(dbi), rpmtag); +- if (rpmidxOpenXdb(&idxdb, rdb->db_pkgs->dbi_db, ndbenv->xdb, rpmtag)) { ++ if (rpmidxOpenXdb(&idxdb, rdb->db_pkgs->dbi_db, ndbenv->xdb, rpmtag, oflags)) { + perror("rpmidxOpenXdb"); + ndb_Close(dbi, 0); + return 1; + } + dbi->dbi_db = idxdb; +- +- if (rpmxdbIsRdonly(ndbenv->xdb)) +- dbi->dbi_flags |= DBI_RDONLY; + } + ++ if ((oflags & (O_RDWR | O_RDONLY)) == O_RDONLY) ++ dbi->dbi_flags |= DBI_RDONLY; + + if (dbip != NULL) + *dbip = dbi; +--- ./lib/backend/ndb/rpmidx.c.orig 2019-11-13 09:19:29.305710571 +0000 ++++ ./lib/backend/ndb/rpmidx.c 2020-04-14 09:48:23.304231127 +0000 +@@ -885,13 +885,17 @@ int rpmidxOpen(rpmidxdb *idxdbp, rpmpkgd + return RPMRC_FAIL; + } + +-int rpmidxOpenXdb(rpmidxdb *idxdbp, rpmpkgdb pkgdb, rpmxdb xdb, unsigned int xdbtag) ++int rpmidxOpenXdb(rpmidxdb *idxdbp, rpmpkgdb pkgdb, rpmxdb xdb, unsigned int xdbtag, int flags) + { + rpmidxdb idxdb; + unsigned int id; + *idxdbp = 0; + int rc; + ++ if (rpmxdbIsRdonly(xdb) && (flags & (O_RDONLY|O_RDWR)) != O_RDONLY) { ++ errno = EACCES; ++ return RPMRC_FAIL; ++ } + if (rpmxdbLock(xdb, 0)) + return RPMRC_FAIL; + rc = rpmxdbLookupBlob(xdb, &id, xdbtag, IDXDB_XDB_SUBTAG, 0); +@@ -907,7 +911,7 @@ int rpmidxOpenXdb(rpmidxdb *idxdbp, rpmp + idxdb->xdbid = id; + idxdb->pkgdb = pkgdb; + idxdb->pagesize = rpmxdbPagesize(xdb); +- idxdb->rdonly = rpmxdbIsRdonly(xdb) ? 1 : 0; ++ idxdb->rdonly = (flags & (O_RDONLY|O_RDWR)) == O_RDONLY ? 1 : 0; + if (!id) { + if (rpmidxInit(idxdb)) { + free(idxdb); +--- ./lib/backend/ndb/rpmidx.h.orig 2019-06-26 14:17:31.406985703 +0000 ++++ ./lib/backend/ndb/rpmidx.h 2020-04-14 09:48:23.304231127 +0000 +@@ -5,7 +5,7 @@ struct rpmidxdb_s; + typedef struct rpmidxdb_s *rpmidxdb; + + int rpmidxOpen(rpmidxdb *idxdbp, rpmpkgdb pkgdb, const char *filename, int flags, int mode); +-int rpmidxOpenXdb(rpmidxdb *idxdbp, rpmpkgdb pkgdb, rpmxdb xdb, unsigned int xdbtag); ++int rpmidxOpenXdb(rpmidxdb *idxdbp, rpmpkgdb pkgdb, rpmxdb xdb, unsigned int xdbtag, int flags); + int rpmidxDelXdb(rpmpkgdb pkgdb, rpmxdb xdb, unsigned int xdbtag); + void rpmidxClose(rpmidxdb idxdbp); + +--- ./lib/backend/ndb/rpmxdb.c.orig 2020-04-03 10:24:27.954135180 +0000 ++++ ./lib/backend/ndb/rpmxdb.c 2020-04-14 09:48:23.304231127 +0000 +@@ -36,7 +36,7 @@ typedef struct rpmxdb_s { + unsigned int usergeneration; + + unsigned char *mapped; +- int mapflags; ++ int mappedrw; + unsigned int mappedlen; + + struct xdb_slot { +@@ -57,6 +57,7 @@ typedef struct rpmxdb_s { + unsigned int usedblobpages; + unsigned int systempagesize; + int dofsync; ++ unsigned int locked_excl; + } *rpmxdb; + + +@@ -125,17 +126,19 @@ static void unmapmem(void *addr, size_t + #define ROUNDTOSYSTEMPAGE(xdb, size) (((size) + (xdb->systempagesize - 1)) & ~(xdb->systempagesize - 1)) + + /* xdb header mapping functions */ +-static int mapheader(rpmxdb xdb, unsigned int slotnpages) ++static int mapheader(rpmxdb xdb, unsigned int slotnpages, int rw) + { + unsigned char *mapped; + size_t mappedlen = slotnpages * xdb->pagesize; ++ int mapflags = rw ? PROT_READ | PROT_WRITE : PROT_READ; + + mappedlen = ROUNDTOSYSTEMPAGE(xdb, mappedlen); +- mapped = mapmem(xdb->mapped, xdb->mappedlen, mappedlen, xdb->mapflags, xdb->fd, 0); ++ mapped = mapmem(xdb->mapped, xdb->mappedlen, mappedlen, mapflags, xdb->fd, 0); + if ((void *)mapped == MAP_FAILED) + return RPMRC_FAIL; + xdb->mapped = mapped; + xdb->mappedlen = mappedlen; ++ xdb->mappedrw = rw; + return RPMRC_OK; + } + +@@ -247,7 +250,7 @@ static int rpmxdbReadHeaderRaw(rpmxdb xd + return RPMRC_OK; + } + +-static int rpmxdbReadHeader(rpmxdb xdb) ++static int rpmxdbReadHeader(rpmxdb xdb, int rw) + { + struct xdb_slot *slot; + unsigned int slotnpages, pagesize, generation, usergeneration; +@@ -261,6 +264,11 @@ static int rpmxdbReadHeader(rpmxdb xdb) + + if (xdb->mapped) { + if (le2ha(xdb->mapped + XDB_OFFSET_GENERATION) == xdb->generation) { ++ if (rw && !xdb->mappedrw) { ++ unmapheader(xdb); ++ if (mapheader(xdb, xdb->slotnpages, rw)) ++ return RPMRC_FAIL; ++ } + return RPMRC_OK; + } + unmapheader(xdb); +@@ -273,9 +281,8 @@ static int rpmxdbReadHeader(rpmxdb xdb) + if (stb.st_size % pagesize != 0) + return RPMRC_FAIL; + xdb->pagesize = pagesize; +- xdb->mapflags = xdb->rdonly ? PROT_READ : PROT_READ | PROT_WRITE; + +- if (mapheader(xdb, slotnpages)) ++ if (mapheader(xdb, slotnpages, rw)) + return RPMRC_FAIL; + + /* read in all slots */ +@@ -368,6 +375,8 @@ static int rpmxdbReadHeader(rpmxdb xdb) + nslot->mapcallback(xdb, nslot->mapcallbackdata, 0, 0); + } + } ++ } else { ++ nslot->mapped = slot->mapped; + } + } + } +@@ -382,17 +391,14 @@ static int rpmxdbReadHeader(rpmxdb xdb) + return RPMRC_OK; + } + +-static int rpmxdbWriteHeader(rpmxdb xdb) ++static void rpmxdbWriteHeader(rpmxdb xdb) + { +- if (!xdb->mapped) +- return RPMRC_FAIL; + h2lea(XDB_MAGIC, xdb->mapped + XDB_OFFSET_MAGIC); + h2lea(XDB_VERSION, xdb->mapped + XDB_OFFSET_VERSION); + h2lea(xdb->generation, xdb->mapped + XDB_OFFSET_GENERATION); + h2lea(xdb->slotnpages, xdb->mapped + XDB_OFFSET_SLOTNPAGES); + h2lea(xdb->pagesize, xdb->mapped + XDB_OFFSET_PAGESIZE); + h2lea(xdb->usergeneration, xdb->mapped + XDB_OFFSET_USERGENERATION); +- return RPMRC_OK; + } + + static void rpmxdbUpdateSlot(rpmxdb xdb, struct xdb_slot *slot) +@@ -473,19 +479,25 @@ static int rpmxdbInitInternal(rpmxdb xdb + /* we use the master pdb for locking */ + static int rpmxdbLockOnly(rpmxdb xdb, int excl) + { ++ int rc; + if (excl && xdb->rdonly) + return RPMRC_FAIL; +- return rpmpkgLock(xdb->pkgdb, excl); ++ rc = rpmpkgLock(xdb->pkgdb, excl); ++ if (!rc && excl) ++ xdb->locked_excl++; ++ return rc; + } + +-/* this is the same as rpmxdbLockReadHeader. It does the ++/* This is similar to rpmxdbLockReadHeader. It does the + * ReadHeader to sync the mappings if xdb moved some blobs. ++ * Note that we just ask for rad-only access in the ++ * rpmxdbReadHeader call. + */ + int rpmxdbLock(rpmxdb xdb, int excl) + { + if (rpmxdbLockOnly(xdb, excl)) + return RPMRC_FAIL; +- if (rpmxdbReadHeader(xdb)) { ++ if (rpmxdbReadHeader(xdb, 0)) { + rpmxdbUnlock(xdb, excl); + return RPMRC_FAIL; + } +@@ -494,14 +506,25 @@ int rpmxdbLock(rpmxdb xdb, int excl) + + int rpmxdbUnlock(rpmxdb xdb, int excl) + { ++ if (excl && xdb->locked_excl) { ++ xdb->locked_excl--; ++ if (!xdb->locked_excl && xdb->mapped && xdb->mappedrw) { ++ unmapheader(xdb); ++ mapheader(xdb, xdb->slotnpages, 0); ++ } ++ } + return rpmpkgUnlock(xdb->pkgdb, excl); + } + ++/* Like rpmxdbLock, but map the header rw if excl is set. ++ * This is what the functions in this module use, whereas ++ * rpmidx uses rpmxdbLock. ++ */ + static int rpmxdbLockReadHeader(rpmxdb xdb, int excl) + { + if (rpmxdbLockOnly(xdb, excl)) + return RPMRC_FAIL; +- if (rpmxdbReadHeader(xdb)) { ++ if (rpmxdbReadHeader(xdb, excl)) { + rpmxdbUnlock(xdb, excl); + return RPMRC_FAIL; + } +@@ -594,6 +617,8 @@ void rpmxdbClose(rpmxdb xdb) + } + if (xdb->slots) + free(xdb->slots); ++ if (xdb->mapped) ++ unmapheader(xdb); + if (xdb->fd >= 0) + close(xdb->fd); + if (xdb->filename) +@@ -623,7 +648,8 @@ static int moveblobto(rpmxdb xdb, struct + didmap = 0; + oldpagecnt = oldslot->pagecnt; + if (!oldslot->mapped && oldpagecnt) { +- oldslot->mapflags = PROT_READ; ++ if (!oldslot->mapcallback) ++ oldslot->mapflags = PROT_READ; + if (mapslot(xdb, oldslot)) + return RPMRC_FAIL; + didmap = 1; +@@ -772,7 +798,7 @@ static int addslotpage(rpmxdb xdb) + return RPMRC_FAIL; + + /* remap the header */ +- if (mapheader(xdb, xdb->slotnpages + 1)) ++ if (mapheader(xdb, xdb->slotnpages + 1, xdb->mappedrw)) + return RPMRC_FAIL; + + /* update the header */ +@@ -852,7 +878,8 @@ int rpmxdbLookupBlob(rpmxdb xdb, unsigne + { + struct xdb_slot *slot; + unsigned int i, nslots; +- if (rpmxdbLockReadHeader(xdb, flags ? 1 : 0)) ++ int excl = flags ? 1 : 0; ++ if (rpmxdbLockReadHeader(xdb, excl)) + return RPMRC_FAIL; + nslots = xdb->nslots; + slot = 0; +@@ -865,18 +892,18 @@ int rpmxdbLookupBlob(rpmxdb xdb, unsigne + i = 0; + if (i && (flags & O_TRUNC) != 0) { + if (rpmxdbResizeBlob(xdb, i, 0)) { +- rpmxdbUnlock(xdb, flags ? 1 : 0); ++ rpmxdbUnlock(xdb, excl); + return RPMRC_FAIL; + } + } + if (!i && (flags & O_CREAT) != 0) { + if (createblob(xdb, &i, blobtag, subtag)) { +- rpmxdbUnlock(xdb, flags ? 1 : 0); ++ rpmxdbUnlock(xdb, excl); + return RPMRC_FAIL; + } + } + *idp = i; +- rpmxdbUnlock(xdb, flags ? 1 : 0); ++ rpmxdbUnlock(xdb, excl); + return i ? RPMRC_OK : RPMRC_NOTFOUND; + } + +--- ./lib/rpmdb.c.orig 2020-04-03 10:24:27.954135180 +0000 ++++ ./lib/rpmdb.c 2020-04-14 09:48:23.304231127 +0000 +@@ -2622,6 +2622,7 @@ int rpmdbRebuild(const char * prefix, rp + } + + rpmdbClose(olddb); ++ dbCtrl(newdb, DB_CTRL_INDEXSYNC); + rpmdbClose(newdb); + + if (failed) { diff --git a/nextiteratorheaderblob.diff b/nextiteratorheaderblob.diff deleted file mode 100644 index 1e46c5b..0000000 --- a/nextiteratorheaderblob.diff +++ /dev/null @@ -1,66 +0,0 @@ ---- ./lib/rpmdb.c.orig 2020-09-30 15:25:13.297438656 +0000 -+++ ./lib/rpmdb.c 2020-09-30 15:27:31.981108826 +0000 -@@ -2681,6 +2681,46 @@ int rpmdbCtrl(rpmdb db, rpmdbCtrlOp ctrl - return dbctrl ? dbCtrl(db, dbctrl) : 1; - } - -+const unsigned char *rpmdbNextIteratorHeaderBlob(rpmdbMatchIterator mi, unsigned int *size) -+{ -+ dbiIndex dbi = NULL; -+ unsigned char * uh; -+ unsigned int uhlen; -+ int rc; -+ if (mi == NULL || mi->mi_re != NULL) -+ return NULL; -+ if (pkgdbOpen(mi->mi_db, 0, &dbi)) -+ return NULL; -+ if (mi->mi_dbc == NULL) -+ mi->mi_dbc = dbiCursorInit(dbi, mi->mi_cflags); -+ miFreeHeader(mi, dbi); -+ do { -+ if (mi->mi_set) { -+ if (!(mi->mi_setx < mi->mi_set->count)) -+ return NULL; -+ mi->mi_offset = dbiIndexRecordOffset(mi->mi_set, mi->mi_setx); -+ mi->mi_filenum = dbiIndexRecordFileNumber(mi->mi_set, mi->mi_setx); -+ } else { -+ rc = pkgdbGet(dbi, mi->mi_dbc, 0, &uh, &uhlen); -+ if (rc == 0) -+ mi->mi_offset = pkgdbKey(dbi, mi->mi_dbc); -+ -+ /* Terminate on error or end of keys */ -+ if (rc || (mi->mi_setx && mi->mi_offset == 0)) -+ return NULL; -+ } -+ mi->mi_setx++; -+ } while (mi->mi_offset == 0); -+ if (uh == NULL) { -+ rc = pkgdbGet(dbi, mi->mi_dbc, mi->mi_offset, &uh, &uhlen); -+ if (rc || uh == NULL) -+ return NULL; -+ } -+ if (size) -+ *size = uhlen; -+ return uh; -+} -+ - char *rpmdbCookie(rpmdb db) - { - void *cookie = NULL; ---- ./lib/rpmdb.h.orig 2020-09-30 15:24:56.821477848 +0000 -+++ ./lib/rpmdb.h 2020-09-30 15:25:13.297438656 +0000 -@@ -253,6 +253,14 @@ int rpmdbStat(const char *prefix, struct - */ - int rpmdbFStat(rpmdb db, struct stat *statbuf); - -+/** \ingroup rpmdb -+ * Return next unverified package header blob from iteration. -+ * @param mi rpm database iterator -+ * @retval size header blob size in bytes -+ * @return NULL on end of iteration. -+ */ -+const unsigned char *rpmdbNextIteratorHeaderBlob(rpmdbMatchIterator mi, unsigned int *size); -+ - #ifdef __cplusplus - } - #endif diff --git a/nobuildcolor.diff b/nobuildcolor.diff index f311e75..9371cb7 100644 --- a/nobuildcolor.diff +++ b/nobuildcolor.diff @@ -1,11 +1,11 @@ Disable file coloring for SUSE systems ---- ./build/rpmfc.c.orig 2020-09-30 13:06:07.502865543 +0000 -+++ ./build/rpmfc.c 2020-09-30 13:07:08.530734545 +0000 -@@ -1607,7 +1607,8 @@ rpmRC rpmfcGenerateDepends(const rpmSpec - goto exit; - - /* Add per-file colors(#files) */ +--- build/rpmfc.c.orig 2013-07-12 12:12:45.000000000 +0000 ++++ build/rpmfc.c 2013-07-12 12:15:51.000000000 +0000 +@@ -1305,7 +1305,8 @@ rpmRC rpmfcGenerateDepends(const rpmSpec + /* XXX Make sure only primary (i.e. Elf32/Elf64) colors are added. */ + for (int i = 0; i < fc->nfiles; i++) + fc->fcolor[i] &= 0x0f; - headerPutUint32(pkg->header, RPMTAG_FILECOLORS, fc->fcolor, fc->nfiles); + if (rpmExpandNumeric("%{?_transaction_color}") != 0) + headerPutUint32(pkg->header, RPMTAG_FILECOLORS, fc->fcolor, fc->nfiles); diff --git a/nomagiccheck.diff b/nomagiccheck.diff index 51cf2c2..0db642e 100644 --- a/nomagiccheck.diff +++ b/nomagiccheck.diff @@ -1,13 +1,13 @@ Don't let rpm complain about a missing /etc/magic.mgc file ---- ./build/rpmfc.c.orig 2020-09-30 13:08:18.770584384 +0000 -+++ ./build/rpmfc.c 2020-09-30 13:08:54.306508417 +0000 -@@ -1159,7 +1159,7 @@ static uint32_t getElfColor(const char * +--- ./build/rpmfc.c.orig 2019-10-02 11:41:15.063357579 +0000 ++++ ./build/rpmfc.c 2019-10-02 11:41:42.583298884 +0000 +@@ -1065,7 +1065,7 @@ static int initAttrs(rpmfc fc) rpmRC rpmfcClassify(rpmfc fc, ARGV_t argv, rpm_mode_t * fmode) { -- int msflags = MAGIC_CHECK | MAGIC_COMPRESS | MAGIC_NO_CHECK_TOKENS | MAGIC_ERROR; -+ int msflags = MAGIC_COMPRESS | MAGIC_NO_CHECK_TOKENS | MAGIC_ERROR; - int mimeflags = msflags | MAGIC_MIME_TYPE; +- int msflags = MAGIC_CHECK | MAGIC_COMPRESS | MAGIC_NO_CHECK_TOKENS; ++ int msflags = MAGIC_COMPRESS | MAGIC_NO_CHECK_TOKENS; int nerrors = 0; rpmRC rc = RPMRC_FAIL; + diff --git a/platformin.diff b/platformin.diff index dbba31a..4b8673e 100644 --- a/platformin.diff +++ b/platformin.diff @@ -21,7 +21,7 @@ +@suse@%__chgrp_Rhf %{__chgrp} -Rhf +@suse@%_fixowner [ `%{__id_u}` = '0' ] && %{__chown_Rhf} root +@suse@%_fixgroup [ `%{__id_u}` = '0' ] && %{__chgrp_Rhf} root -+@suse@%_fixperms %{__chmod} -Rf a+rX,u+w,g-w,o-w ++@suse@%_fixperms %{__chmod} -Rf @FIXPERMS@ +@suse@ +@suse@#--------------------------------------------------------------------- +@suse@# Expanded at start of %build diff --git a/python-rpm.changes b/python-rpm.changes index 48999e5..ca6b108 100644 --- a/python-rpm.changes +++ b/python-rpm.changes @@ -1,8 +1,3 @@ -------------------------------------------------------------------- -Wed Sep 30 14:17:40 CEST 2020 - mls@suse.de - -- update to rpm-4.16.0 - ------------------------------------------------------------------- Tue Nov 19 11:09:08 CET 2019 - mls@suse.de diff --git a/python-rpm.spec b/python-rpm.spec index 3c2e5c0..6d845c0 100644 --- a/python-rpm.spec +++ b/python-rpm.spec @@ -21,7 +21,7 @@ %global with_python 1 %{?!python_module:%define python_module() python-%{**} python3-%{**}} Name: python-rpm -Version: 4.16.0 +Version: 4.15.1 Release: 0 Summary: Python Bindings for Manipulating RPM Packages License: GPL-2.0-or-later diff --git a/rpm-4.12.0.1-fix-bashisms.patch b/rpm-4.12.0.1-fix-bashisms.patch new file mode 100644 index 0000000..4c72a52 --- /dev/null +++ b/rpm-4.12.0.1-fix-bashisms.patch @@ -0,0 +1,12 @@ +diff -Ndur rpm-4.12.0.1/scripts/check-rpaths rpm-4.12.0.1-fix-bashisms/scripts/check-rpaths +--- rpm-4.12.0.1/scripts/check-rpaths 2014-06-30 11:47:14.000000000 +0300 ++++ rpm-4.12.0.1-fix-bashisms/scripts/check-rpaths 2014-11-30 04:51:05.189260640 +0200 +@@ -17,7 +17,7 @@ + + + test -z "$QA_SKIP_RPATHS" || { +- echo $"WARNING: '\$QA_SKIP_RPATHS' is obsoleted by 'QA_RPATHS=[0-7]'" >&2 ++ echo "WARNING: '\$QA_SKIP_RPATHS' is obsoleted by 'QA_RPATHS=[0-7]'" >&2 + exit 0 + } + diff --git a/rpm-4.15.1.tar.bz2 b/rpm-4.15.1.tar.bz2 new file mode 100644 index 0000000..a11d4ba --- /dev/null +++ b/rpm-4.15.1.tar.bz2 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ddef45f9601cd12042edfc9b6e37efcca32814e1e0f4bb8682d08144a3e2d230 +size 4243893 diff --git a/rpm-4.16.0.tar.bz2 b/rpm-4.16.0.tar.bz2 deleted file mode 100644 index 5cf37b8..0000000 --- a/rpm-4.16.0.tar.bz2 +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:ca5974e9da2939afb422598818ef187385061889ba766166c4a3829c5ef8d411 -size 4341683 diff --git a/rpm-shorten-changelog.diff b/rpm-shorten-changelog.diff index a2c19f2..fe1c2cb 100644 --- a/rpm-shorten-changelog.diff +++ b/rpm-shorten-changelog.diff @@ -1,6 +1,6 @@ ---- ./build/pack.c.orig 2020-09-30 12:49:33.397074156 +0000 -+++ ./build/pack.c 2020-09-30 12:51:34.628805840 +0000 -@@ -728,6 +728,71 @@ static rpmRC packageBinary(rpmSpec spec, +--- ./build/pack.c.orig 2019-06-26 14:17:31.395985720 +0000 ++++ ./build/pack.c 2019-10-02 11:31:05.908639084 +0000 +@@ -743,11 +743,78 @@ static rpmRC packageBinary(rpmSpec spec, return rc; } @@ -69,21 +69,19 @@ + rpmtdFreeData(×td); +} + - static int compareBinaries(const void *p1, const void *p2) { - Package pkg1 = *(Package *)p1; - Package pkg2 = *(Package *)p2; -@@ -751,6 +816,8 @@ rpmRC packageBinaries(rpmSpec spec, cons - Package *tasks; - int npkgs = 0; + rpmRC packageBinaries(rpmSpec spec, const char *cookie, int cheating) + { + rpmRC rc = RPMRC_OK; + Package pkg; + trimChangelog(spec->packages->header); + - for (pkg = spec->packages; pkg != NULL; pkg = pkg->next) - npkgs++; - tasks = xcalloc(npkgs, sizeof(Package)); ---- ./build/parseChangelog.c.orig 2020-08-31 09:14:07.991087349 +0000 -+++ ./build/parseChangelog.c 2020-09-30 12:49:33.401074147 +0000 -@@ -267,6 +267,11 @@ static rpmRC addChangelog(Header h, ARGV + /* Run binary creation in parallel */ + #pragma omp parallel + #pragma omp single +--- ./build/parseChangelog.c.orig 2019-06-26 14:17:31.395985720 +0000 ++++ ./build/parseChangelog.c 2019-10-02 11:29:26.684840735 +0000 +@@ -253,6 +253,11 @@ static rpmRC addChangelog(Header h, ARGV goto exit; } diff --git a/rpm.changes b/rpm.changes index a67ee65..e6418e3 100644 --- a/rpm.changes +++ b/rpm.changes @@ -1,55 +1,15 @@ +------------------------------------------------------------------- +Mon Oct 19 11:53:00 CEST 2020 - mls@suse.de + +- Backport FA_TOUCH fixes from upsteam [bnc#1175025] [bnc#1177428] + * new patch: touch_backport.diff + ------------------------------------------------------------------- Fri Oct 9 13:28:33 UTC 2020 - Guillaume GARDET - Add patch to fix finddebuginfo when no res.* file are found: * finddebuginfo-check-res-file.patch -------------------------------------------------------------------- -Fri Oct 2 15:20:13 UTC 2020 - Callum Farmer - -- RPM no longer ships config.sub and config.guess, just copy it - from Libtool since it is identical - -------------------------------------------------------------------- -Wed Sep 30 14:17:40 CEST 2020 - mls@suse.de - -- update to rpm-4.16.0 - * powerful macro and %if expressions including ternary operator - and native version comparison - * optional MIME type based file classification - * dependency generation by parametric macros - * a new version parsing and comparison API in C and Python - * parallelise test-suite execution - * clarify RPM license -- add method to iterate over header blobs - * new patch: nextiteratorheaderblob.diff -- modified patches: - * brpcompress.diff - * brp-compress-no-img.patch - * brp.diff - * checkfilesnoinfodir.diff - * db_conversion.diff - * dbrointerruptable.diff - * findsupplements.diff - * ignore-auxv.diff - * macrosin.diff - * nobuildcolor.diff - * nomagiccheck.diff - * platformin.diff - * rpmqpack.diff - * rpm-shorten-changelog.diff - * suspendlock.diff -- dropped patches: - * rpm-4.12.0.1-fix-bashisms.patch - * lazystatfs.diff - * db_ops_name.diff - * bdb_ro.diff - * disable_bdb.diff - * ndb_backport.diff - * initgcrypt.diff - * gcryptdsa2.diff - * ndb_backport2.diff - ------------------------------------------------------------------- Mon Jul 6 16:35:40 CEST 2020 - Martin Liška diff --git a/rpm.spec b/rpm.spec index 53e9064..cb006d9 100644 --- a/rpm.spec +++ b/rpm.spec @@ -59,11 +59,11 @@ Requires: /usr/bin/awk Summary: The RPM Package Manager License: GPL-2.0-or-later Group: System/Packages -Version: 4.16.0 +Version: 4.15.1 Release: 0 URL: https://rpm.org/ #Git-Clone: https://github.com/rpm-software-management/rpm -Source: http://ftp.rpm.org/releases/rpm-4.16.x/rpm-%{version}.tar.bz2 +Source: http://ftp.rpm.org/releases/rpm-4.15.x/rpm-%{version}.tar.bz2 Source1: RPM-HOWTO.tar.bz2 Source5: rpmsort Source8: rpmconfigcheck @@ -72,9 +72,8 @@ Source11: db-4.8.30.tar.bz2 Source12: baselibs.conf Source13: rpmconfigcheck.service Patch2: db.diff +Patch3: rpm-4.12.0.1-fix-bashisms.patch Patch5: usr-lib-sysimage-rpm.patch -# PATCH-FIX-UPSTREAM - https://github.com/rpm-software-management/rpm/pull/1391 -Patch6: finddebuginfo-check-res-file.patch # quilt patches start here Patch11: debugedit.diff Patch13: ignore-auxv.diff @@ -105,6 +104,7 @@ Patch51: specfilemacro.diff Patch55: debugsubpkg.diff Patch56: debuglink.diff Patch57: debuginfo-mono.patch +Patch58: lazystatfs.diff Patch60: safeugid.diff Patch61: noprereqdeprec.diff Patch66: remove-translations.diff @@ -126,8 +126,16 @@ Patch102: emptymanifest.diff Patch103: find-lang-qt-qm.patch Patch109: pythondistdeps.diff Patch117: findsupplements.diff +Patch118: db_ops_name.diff +Patch119: bdb_ro.diff +Patch120: disable_bdb.diff +Patch121: ndb_backport.diff Patch122: db_conversion.diff -Patch123: nextiteratorheaderblob.diff +Patch123: initgcrypt.diff +Patch124: gcryptdsa2.diff +Patch125: ndb_backport2.diff +Patch126: touch_backport.diff +Patch127: finddebuginfo-check-res-file.patch Patch6464: auto-config-update-aarch64-ppc64le.diff BuildRoot: %{_tmppath}/%{name}-%{version}-build # @@ -229,7 +237,6 @@ Provides and requires generator for .pl files and modules. %prep %setup -q -n rpm-%{version} rm -rf sqlite -cp /usr/share/libtool/build-aux/config.guess /usr/share/libtool/build-aux/config.sub . %if 0%{?!without_bdb:1} tar xjf %{SOURCE11} ln -s db-4.8.30 db @@ -240,20 +247,21 @@ chmod -R u+w db/* rm -f rpmdb/db.h cp config.guess config.sub db/dist/ %endif +%patch3 -p1 %patch5 -p1 -%patch6 -p1 %patch -P 11 -P 12 -P 13 -P 15 -P 16 -P 18 %patch -P 20 -P 21 -P 24 -P 25 -P 26 -P 27 -P 29 %patch -P 30 -P 32 -P 33 -P 34 -P 35 -P 36 -P 38 %patch -P 43 -P 45 -P 46 -P 47 -P 49 -%patch -P 51 -P 55 -P 56 -P 57 +%patch -P 51 -P 55 -P 56 -P 57 -P 58 %patch -P 60 -P 61 -P 66 -P 67 -P 68 -P 69 %patch -P 70 -P 71 -P 73 -P 75 -P 77 -P 78 %patch -P 85 %patch -P 93 -P 94 -P 99 %patch -P 100 -P 102 -P 103 %patch -P 109 -P 117 -%patch -P 122 -P 123 +%patch -P 118 -P 119 -P 120 -P 121 -P 122 -P 123 -P 124 -P 125 +%patch -P 126 -P 127 %ifarch aarch64 ppc64le riscv64 %patch6464 @@ -344,6 +352,7 @@ mkdir -p %{buildroot}%{_fillupdir} install -c -m0644 %{SOURCE9} %{buildroot}%{_fillupdir}/ rm -f %{buildroot}/usr/lib/rpm/cpanflute %{buildroot}/usr/lib/rpm/cpanflute2 install -m 755 %{SOURCE5} %{buildroot}/usr/lib/rpm +install -m 755 scripts/debuginfo.prov %{buildroot}/usr/lib/rpm rm -f %{buildroot}/usr/lib/locale %{buildroot}/usr/lib/rpmrc mkdir -p %{buildroot}/etc/rpm chmod 755 %{buildroot}/etc/rpm @@ -475,7 +484,7 @@ fi /usr/bin/rpmbuild /usr/lib/rpm/libtooldeps.sh /usr/lib/rpm/pkgconfigdeps.sh -/usr/lib/rpm/ocamldeps.sh +/usr/lib/rpm/pythondeps.sh /usr/lib/rpm/elfdeps /usr/lib/rpm/rpmdeps /usr/lib/rpm/debugedit diff --git a/rpmqpack.diff b/rpmqpack.diff index d8cead4..594d51e 100644 --- a/rpmqpack.diff +++ b/rpmqpack.diff @@ -1,6 +1,6 @@ ---- ./Makefile.am.orig 2020-09-30 12:47:19.181371209 +0000 -+++ ./Makefile.am 2020-09-30 12:47:25.797356566 +0000 -@@ -198,6 +198,10 @@ rpmgraph_LDADD = lib/librpm.la rpmio/lib +--- ./Makefile.am.orig 2017-12-01 15:04:09.723014378 +0000 ++++ ./Makefile.am 2017-12-01 15:04:13.396003910 +0000 +@@ -187,6 +187,10 @@ rpmgraph_LDADD = lib/librpm.la rpmio/lib dist_bin_SCRIPTS = scripts/gendiff @@ -11,19 +11,19 @@ rpmconfig_DATA = rpmrc rpmrc: $(top_srcdir)/rpmrc.in @$(SED) \ ---- ./doc/Makefile.am.orig 2020-09-30 12:47:25.797356566 +0000 -+++ ./doc/Makefile.am 2020-09-30 12:48:22.709230608 +0000 +--- ./doc/Makefile.am.orig 2017-12-01 15:04:13.397003907 +0000 ++++ ./doc/Makefile.am 2017-12-01 15:04:42.681920389 +0000 @@ -8,7 +8,7 @@ EXTRA_DIST += $(man_man1_DATA) man_man8dir = $(mandir)/man8 man_man8_DATA = rpm.8 rpm-misc.8 rpmbuild.8 rpmdeps.8 rpmgraph.8 rpm2cpio.8 -man_man8_DATA += rpmdb.8 rpmkeys.8 rpmsign.8 rpmspec.8 +man_man8_DATA += rpmdb.8 rpmkeys.8 rpmsign.8 rpmspec.8 rpmqpack.8 - + man_man8_DATA += rpm-plugin-systemd-inhibit.8 EXTRA_DIST += $(man_man8_DATA) ---- ./doc/rpmqpack.8.orig 2020-09-30 12:47:25.797356566 +0000 -+++ ./doc/rpmqpack.8 2020-09-30 12:47:25.797356566 +0000 +--- ./doc/rpmqpack.8.orig 2017-12-01 15:04:13.397003907 +0000 ++++ ./doc/rpmqpack.8 2017-12-01 15:04:13.397003907 +0000 @@ -0,0 +1,25 @@ +.TH RPMQPACK 8 "Mar 2002" +.SH NAME @@ -50,8 +50,8 @@ + +.SH AUTHOR +Michael Schroeder ---- ./rpmqpack.c.orig 2020-09-30 12:47:25.797356566 +0000 -+++ ./rpmqpack.c 2020-09-30 12:47:25.797356566 +0000 +--- ./rpmqpack.c.orig 2019-12-06 10:14:03.989178873 +0000 ++++ ./rpmqpack.c 2019-12-06 10:32:16.430275015 +0000 @@ -0,0 +1,60 @@ +#include +#include diff --git a/suspendlock.diff b/suspendlock.diff index f4178dc..beea68a 100644 --- a/suspendlock.diff +++ b/suspendlock.diff @@ -2,9 +2,9 @@ Suspend exclusive database lock when scriptlets get called, allowing read access in scriptlets. Only needed for DB_PRIVATE (aka global) locking. ---- ./lib/backend/db3.c.orig 2020-09-30 12:25:06.516375109 +0000 -+++ ./lib/backend/db3.c 2020-09-30 12:25:10.312366497 +0000 -@@ -549,6 +549,46 @@ static void db3_dbSetFSync(rpmdb rdb, in +--- ./lib/backend/db3.c.orig 2019-10-02 09:56:46.416347458 +0000 ++++ ./lib/backend/db3.c 2019-10-02 09:56:52.084335992 +0000 +@@ -552,6 +552,46 @@ static void db3_dbSetFSync(rpmdb rdb, in static int db3_Ctrl(rpmdb rdb, dbCtrlOp ctrl) { @@ -51,9 +51,9 @@ locking. return 0; } ---- ./lib/backend/dbi.h.orig 2020-09-30 12:25:06.516375109 +0000 -+++ ./lib/backend/dbi.h 2020-09-30 12:25:10.312366497 +0000 -@@ -18,7 +18,9 @@ typedef enum dbCtrlOp_e { +--- ./lib/backend/dbi.h.orig 2019-10-02 09:56:46.416347458 +0000 ++++ ./lib/backend/dbi.h 2019-10-02 09:56:52.084335992 +0000 +@@ -17,7 +17,9 @@ typedef enum dbCtrlOp_e { DB_CTRL_UNLOCK_RO = 2, DB_CTRL_LOCK_RW = 3, DB_CTRL_UNLOCK_RW = 4, @@ -64,9 +64,9 @@ locking. } dbCtrlOp; typedef struct dbiIndex_s * dbiIndex; ---- ./lib/rpmdb.c.orig 2020-09-30 12:25:06.516375109 +0000 -+++ ./lib/rpmdb.c 2020-09-30 12:25:10.312366497 +0000 -@@ -2637,6 +2637,12 @@ int rpmdbCtrl(rpmdb db, rpmdbCtrlOp ctrl +--- ./lib/rpmdb.c.orig 2019-10-02 09:56:46.416347458 +0000 ++++ ./lib/rpmdb.c 2019-10-02 09:56:52.084335992 +0000 +@@ -2644,6 +2644,12 @@ int rpmdbCtrl(rpmdb db, rpmdbCtrlOp ctrl case RPMDB_CTRL_INDEXSYNC: dbctrl = DB_CTRL_INDEXSYNC; break; @@ -79,9 +79,9 @@ locking. } return dbctrl ? dbCtrl(db, dbctrl) : 1; } ---- ./lib/rpmdb.h.orig 2020-05-28 10:04:25.037136686 +0000 -+++ ./lib/rpmdb.h 2020-09-30 12:25:10.312366497 +0000 -@@ -36,7 +36,9 @@ typedef enum rpmdbCtrlOp_e { +--- ./lib/rpmdb.h.orig 2019-06-26 14:17:31.412985694 +0000 ++++ ./lib/rpmdb.h 2019-10-02 09:56:52.088335984 +0000 +@@ -35,7 +35,9 @@ typedef enum rpmdbCtrlOp_e { RPMDB_CTRL_UNLOCK_RO = 2, RPMDB_CTRL_LOCK_RW = 3, RPMDB_CTRL_UNLOCK_RW = 4, @@ -92,17 +92,17 @@ locking. } rpmdbCtrlOp; /** \ingroup rpmdb ---- ./lib/transaction.c.orig 2020-09-30 07:48:01.215567727 +0000 -+++ ./lib/transaction.c 2020-09-30 12:25:10.312366497 +0000 -@@ -1692,6 +1692,7 @@ rpmRC runScript(rpmts ts, rpmte te, Head +--- ./lib/transaction.c.orig 2019-10-02 09:56:52.088335984 +0000 ++++ ./lib/transaction.c 2019-10-02 09:58:36.956123870 +0000 +@@ -1601,6 +1601,7 @@ rpmRC runScript(rpmts ts, rpmte te, Head rpmTagVal stag = rpmScriptTag(script); FD_t sfd = NULL; int warn_only = !(rpmScriptFlags(script) & RPMSCRIPT_FLAG_CRITICAL); + rpmdb rdb = rpmtsGetRdb(ts); - if (rpmChrootIn()) - return RPMRC_FAIL; -@@ -1706,10 +1707,12 @@ rpmRC runScript(rpmts ts, rpmte te, Head + /* Create a temporary transaction element for triggers from rpmdb */ + if (te == NULL) { +@@ -1612,10 +1613,12 @@ rpmRC runScript(rpmts ts, rpmte te, Head if (sfd == NULL) sfd = rpmtsScriptFd(ts); diff --git a/touch_backport.diff b/touch_backport.diff new file mode 100644 index 0000000..a3ba542 --- /dev/null +++ b/touch_backport.diff @@ -0,0 +1,64 @@ +--- ./lib/fsm.c.orig 2019-06-26 14:17:31.407985702 +0000 ++++ ./lib/fsm.c 2020-10-19 09:49:02.709129763 +0000 +@@ -926,10 +926,6 @@ int rpmPackageFilesInstall(rpmts ts, rpm + if (!skip) { + int setmeta = 1; + +- /* When touching we don't need any of this... */ +- if (action == FA_TOUCH) +- goto touch; +- + /* Directories replacing something need early backup */ + if (!suffix) { + rc = fsmBackup(fi, action); +@@ -941,6 +937,17 @@ int rpmPackageFilesInstall(rpmts ts, rpm + rc = RPMERR_ENOENT; + } + ++ /* See if the file was removed while our attention was elsewhere */ ++ if (rc == RPMERR_ENOENT && action == FA_TOUCH) { ++ rpmlog(RPMLOG_DEBUG, "file %s vanished unexpectedly\n", fpath); ++ action = FA_CREATE; ++ fsmDebug(fpath, action, &sb); ++ } ++ ++ /* When touching we don't need any of this... */ ++ if (action == FA_TOUCH) ++ goto touch; ++ + if (S_ISREG(sb.st_mode)) { + if (rc == RPMERR_ENOENT) { + rc = fsmMkfile(fi, fpath, files, psm, nodigest, +--- ./lib/transaction.c.orig 2020-10-19 09:47:25.761418056 +0000 ++++ ./lib/transaction.c 2020-10-19 09:48:20.837254277 +0000 +@@ -483,13 +483,6 @@ static void handleInstInstalledFile(cons + rpmfsSetAction(fs, fx, action); + } + +- /* Skip already existing files - if 'minimize_writes' is set. */ +- if ((!isCfgFile) && (rpmfsGetAction(fs, fx) == FA_UNKNOWN) && ts->min_writes) { +- if (rpmfileContentsEqual(otherFi, ofx, fi, fx)) { +- rpmfsSetAction(fs, fx, FA_TOUCH); +- } +- } +- + otherFileSize = rpmfilesFSize(otherFi, ofx); + + /* Only account for the last file of a hardlink set */ +@@ -499,6 +492,16 @@ static void handleInstInstalledFile(cons + + /* Add one to make sure the size is not zero */ + rpmfilesSetFReplacedSize(fi, fx, otherFileSize + 1); ++ ++ /* Just touch already existing files if minimize_writes is enabled */ ++ if (ts->min_writes) { ++ if ((!isCfgFile) && (rpmfsGetAction(fs, fx) == FA_UNKNOWN)) { ++ /* XXX fsm can't handle FA_TOUCH of hardlinked files */ ++ int nolinks = (nlink == 1 && rpmfilesFNlink(fi, fx) == 1); ++ if (nolinks && rpmfileContentsEqual(otherFi, ofx, fi, fx)) ++ rpmfsSetAction(fs, fx, FA_TOUCH); ++ } ++ } + } + + /**