summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorjbj <devnull@localhost>2002-12-29 19:28:30 +0000
committerjbj <devnull@localhost>2002-12-29 19:28:30 +0000
commit98fc9d533c9d5698c558a54d47d7087bb8f25a96 (patch)
tree75508b369ac4dc0fb7b9e40ad1c19193a703f003 /python
parente4cac6608a15d6fa9e1ee7895ba86efc9f2e9922 (diff)
downloadlibrpm-tizen-98fc9d533c9d5698c558a54d47d7087bb8f25a96.tar.gz
librpm-tizen-98fc9d533c9d5698c558a54d47d7087bb8f25a96.tar.bz2
librpm-tizen-98fc9d533c9d5698c558a54d47d7087bb8f25a96.zip
- python: eliminate hash.[ch] and upgrade.[ch], methods too.
CVS patchset: 5983 CVS date: 2002/12/29 19:28:30
Diffstat (limited to 'python')
-rw-r--r--python/Makefile.am11
-rw-r--r--python/hash.c204
-rw-r--r--python/hash.h33
-rw-r--r--python/rpmmodule.c5
-rw-r--r--python/upgrade.c533
-rw-r--r--python/upgrade.h22
6 files changed, 9 insertions, 799 deletions
diff --git a/python/Makefile.am b/python/Makefile.am
index 3859bfa76..270a7ca2a 100644
--- a/python/Makefile.am
+++ b/python/Makefile.am
@@ -20,10 +20,9 @@ INCLUDES = -I. \
@WITH_LIBELF_INCLUDE@ \
@INCPATH@
-noinst_HEADERS = hash.h header-py.h \
+noinst_HEADERS = header-py.h \
rpmal-py.h rpmbc-py.h rpmds-py.h rpmdb-py.h rpmfd-py.h rpmfts-py.h \
- rpmfi-py.h rpmmi-py.h rpmrc-py.h rpmte-py.h rpmts-py.h \
- upgrade.h
+ rpmfi-py.h rpmmi-py.h rpmrc-py.h rpmte-py.h rpmts-py.h
mylibs= \
$(top_builddir)/lib/.libs/librpm.so \
@@ -52,7 +51,7 @@ poptmodule_so_SOURCES = poptmodule.c
poptmodule_so_LDFLAGS = $(mylibs) $(LIBS) -shared -Wl,-soname,poptmodule.so
noinst_LTLIBRARIES = librpmmodule.la
-librpmmodule_la_SOURCES = rpmmodule.c hash.c upgrade.c header-py.c \
+librpmmodule_la_SOURCES = rpmmodule.c header-py.c \
rpmal-py.c rpmbc-py.c rpmds-py.c rpmdb-py.c rpmfd-py.c rpmfts-py.c \
rpmfi-py.c rpmmi-py.c rpmrc-py.c rpmte-py.c rpmts-py.c
@@ -65,11 +64,11 @@ _rpmdb.so$(EXEEXT): _rpmdb.lo
poptmodule.so$(EXEEXT): poptmodule.lo
$(CC) -o $@ poptmodule.lo $(poptmodule_so_LDFLAGS)
-# rpmmodule.c hash.c upgrade.c header-py.c \
+# rpmmodule.c header-py.c \
# rpmal-py.c rpmds-py.c rpmdb-py.c rpmfd-py.c rpmfi-py.c rpmmi-py.c \
# rpmrc-py.c rpmte-py.c rpmts-py.c
# rpmmodule.c header-py.c
-splint_srcs = hash.c upgrade.c \
+splint_srcs = \
rpmal-py.c rpmbc-py.c rpmds-py.c rpmdb-py.c rpmfd-py.c rpmfts-py.c \
rpmfi-py.c rpmmi-py.c rpmrc-py.c rpmte-py.c rpmts-py.c
diff --git a/python/hash.c b/python/hash.c
deleted file mode 100644
index f3b88c4b0..000000000
--- a/python/hash.c
+++ /dev/null
@@ -1,204 +0,0 @@
-/** \ingroup python
- * \file python/hash.c
- */
-
-#include "system.h"
-
-#include "hash.h"
-
-#include "debug.h"
-
-#define CHUNK 1
-
-struct filePath {
- char * dir;
- char * base;
-} ;
-
-struct bucket {
- struct filePath * data;
- int allocated;
- int firstFree; /* as in data[firstFree] */
-};
-
-struct hash_table {
- int size;
- int entries;
- int overHead;
- struct bucket *bucket;
-};
-
-struct hash_table *htNewTable(int size)
-{
- struct hash_table *res;
- int i = 0;
-
- res = malloc(sizeof(struct hash_table));
- res->bucket = malloc(sizeof(struct bucket) * size);
- res->size = size;
- res->entries = 0;
- res->overHead = sizeof(struct bucket) * size + CHUNK * sizeof(char *);
-
- while (i < size) {
- res->bucket[i].data = malloc(CHUNK * sizeof(*res->bucket[i].data));
- res->bucket[i].allocated = CHUNK;
- res->bucket[i].firstFree = 0;
- i++;
- }
-
- return res;
-}
-
-void htFreeHashTable(struct hash_table *ht)
-{
- struct bucket * b;
- int item;
-
- b = ht->bucket;
- while (ht->size--) {
- for (item = 0; item < b->firstFree; item++) {
- free(b->data[item].dir);
- free(b->data[item].base);
- }
- free(b->data);
- b++;
- }
- free(ht->bucket);
- free(ht);
-}
-
-void htHashStats(const struct hash_table *t)
-{
- int i = 0;
- int empty = 0;
-
- while (i < t->size) {
- if (t->bucket[i].firstFree != 0) {
- /*printf("Bucket %d used %d\n", i, t->bucket[i].firstFree);*/
- } else {
- empty++;
- }
- i++;
- }
-
- printf("Total Buckets : %d\n", t->size);
- printf("Empty Buckets : %d\n", empty);
- printf("Total Entries : %d\n", t->entries);
- printf("Total Overhead: %d\n", t->overHead);
- printf("Avergage Depth: %f\n", (double)t->entries / (double)t->size);
-}
-
-static unsigned int htHashStrings(const char * s, const char * t)
-{
- unsigned int res = 0;
-
- while (*s != '\0')
- res = ((res<<1) + (int)(*(s++)));
- while (*t != '\0')
- res = ((res<<1) + (int)(*(t++)));
-
- return res;
-}
-
-/* returns bucket # containing item, or -1 */
-static int in_table_aux(struct hash_table *t, int hash, const char * dir,
- const char * base)
-{
- int x;
-
- x = 0;
- while (x < t->bucket[hash].firstFree) {
- if (! strcmp(t->bucket[hash].data[x].dir, dir) &&
- ! strcmp(t->bucket[hash].data[x].base, base)) {
- return x;
- }
- x++;
- }
-
- return -1;
-}
-
-int htInTable(struct hash_table *t, const char * dir, const char * base)
-{
- int hash;
-
- hash = htHashStrings(dir, base) % t->size;
-
- if (in_table_aux(t, hash, dir, base) == -1)
- return 0;
- return 1;
-}
-
-void htAddToTable(struct hash_table *t, const char * dir, const char * base)
-{
- static int hash = 1;
-
- if (!dir || !base)
- return;
-
- hash = htHashStrings(dir, base) % t->size;
- if (in_table_aux(t, hash, dir, base) != -1)
- return;
-
- if (t->bucket[hash].firstFree == t->bucket[hash].allocated) {
- t->bucket[hash].allocated += CHUNK;
- t->bucket[hash].data =
- realloc(t->bucket[hash].data,
- t->bucket[hash].allocated * sizeof(*(t->bucket->data)));
- /*printf("Bucket %d grew to %d\n", hash, t->bucket[hash].allocated);*/
- t->overHead += sizeof(char *) * CHUNK;
- }
- /*printf("In bucket %d, item %d\n", hash, t->bucket[hash].firstFree);*/
- t->bucket[hash].data[t->bucket[hash].firstFree].dir = strdup(dir);
- t->bucket[hash].data[t->bucket[hash].firstFree++].base = strdup(base);
- t->entries++;
-}
-
-void htRemoveFromTable(struct hash_table *t, const char * dir,
- const char * base) {
- int hash;
- int item;
- int last;
-
- hash = htHashStrings(dir, base) % t->size;
- if ((item = in_table_aux(t, hash, dir, base)) == -1) {
- return;
- }
-
- free(t->bucket[hash].data[item].dir);
- free(t->bucket[hash].data[item].base);
-
- last = --t->bucket[hash].firstFree;
- t->bucket[hash].data[item] = t->bucket[hash].data[last];
-}
-
-int htNumEntries(struct hash_table *t) {
- return t->entries;
-}
-
-void htIterStart(htIterator * iter) {
- iter->bucket = 0;
- iter->item = -1;
-}
-
-int htIterGetNext(struct hash_table * t, htIterator * iter,
- const char ** dir, const char ** base) {
- iter->item++;
-
- while (iter->bucket < t->size) {
- if (iter->item < t->bucket[iter->bucket].firstFree) {
- *dir = t->bucket[iter->bucket].data[iter->item].dir;
- *base = t->bucket[iter->bucket].data[iter->item].base;
-
- return 1;
- }
-
- iter->item++;
- if (iter->item >= t->bucket[iter->bucket].firstFree) {
- iter->bucket++;
- iter->item = 0;
- }
- }
-
- return 0;
-}
diff --git a/python/hash.h b/python/hash.h
deleted file mode 100644
index c60957064..000000000
--- a/python/hash.h
+++ /dev/null
@@ -1,33 +0,0 @@
-#ifndef H_HASH
-#define H_HASH
-
-/** \ingroup python
- * \file python/hash.h
- */
-
-struct hash_table;
-typedef struct hash_table * hashTable;
-
-struct ht_iterator {
- int bucket;
- int item;
-};
-
-typedef struct ht_iterator htIterator;
-
-/*@only@*/ /*@null@*/ struct hash_table * htNewTable(int size);
-void htFreeHashTable(/*@only@*/ struct hash_table *ht);
-void htHashStats(const struct hash_table *t);
-int htInTable(struct hash_table *t, const char * dir, const char * base);
-void htAddToTable(struct hash_table *t, const char * dir, const char * base);
-void htPrintHashStats(struct hash_table *t);
-int htNumEntries(struct hash_table *t);
-void htRemoveFromTable(struct hash_table *t, const char * dir,
- const char * base);
-
-/* these use static storage */
-void htIterStart(htIterator * iter);
-int htIterGetNext(struct hash_table * t, htIterator * iter,
- const char ** dir, const char ** base);
-
-#endif
diff --git a/python/rpmmodule.c b/python/rpmmodule.c
index b2df040f0..251775a49 100644
--- a/python/rpmmodule.c
+++ b/python/rpmmodule.c
@@ -17,7 +17,6 @@
#include "legacy.h"
#include "misc.h"
#include "header_internal.h"
-#include "upgrade.h"
#include "header-py.h"
#include "rpmal-py.h"
@@ -58,6 +57,7 @@ static PyObject * archScore(PyObject * self, PyObject * args)
return Py_BuildValue("i", score);
}
+#ifdef DYING
/**
*/
static int psGetArchScore(Header h)
@@ -180,6 +180,7 @@ static PyObject * findUpgradeSet(PyObject * self, PyObject * args)
return result;
}
+#endif
/**
*/
@@ -296,8 +297,10 @@ static PyMethodDef rpmModuleMethods[] = {
{ "archscore", (PyCFunction) archScore, METH_VARARGS,
NULL },
+#ifdef DYING
{ "findUpgradeSet", (PyCFunction) findUpgradeSet, METH_VARARGS,
NULL },
+#endif
{ "headerLoad", (PyCFunction) hdrLoad, METH_VARARGS,
NULL },
{ "rhnLoad", (PyCFunction) rhnLoad, METH_VARARGS,
diff --git a/python/upgrade.c b/python/upgrade.c
deleted file mode 100644
index 5832ea001..000000000
--- a/python/upgrade.c
+++ /dev/null
@@ -1,533 +0,0 @@
-/** \ingroup python
- * \file python/upgrade.c
- */
-
-#include "system.h"
-
-#include <fcntl.h>
-
-#include <glob.h> /* XXX rpmio.h */
-#include <dirent.h> /* XXX rpmio.h */
-
-#include <rpmlib.h>
-#include "rpmdb.h"
-
-#include "hash.h"
-#include "upgrade.h"
-
-#include "debug.h"
-
-#define MAXPKGS 1024
-
-#define USEDEBUG 0
-
-#define DEBUG(x) { \
- if (USEDEBUG) \
- printf x; \
- }
-
-#if 0
-static void printMemStats(char *mess)
-{
- char buf[1024];
- printf("%s\n", mess);
- sprintf(buf, "cat /proc/%d/status | grep VmSize", getpid());
- system(buf);
-}
-#endif
-
-/*@access Header@*/ /* compared with NULL. */
-/*@access rpmdbMatchIterator@*/ /* compared with NULL. */
-
-int pkgCompare(void * first, void * second); /* XXX make gcc shut up. */
-int pkgCompare(void * first, void * second) {
- struct packageInfo ** a = first;
- struct packageInfo ** b = second;
-
- /* put packages w/o names at the end */
- if (!(*a)->name) return 1;
- if (!(*b)->name) return -1;
-
- return xstrcasecmp((*a)->name, (*b)->name);
-}
-
-
-/* Adds all files in the second file list which are not in the first
- file list to the hash table. */
-static void compareFileList(int availFileCount, char ** availBaseNames,
- char ** availDirNames, int * availDirIndexes,
- int instFileCount, char ** instBaseNames,
- char ** instDirNames, int * instDirIndexes,
- struct hash_table *ht)
-{
- int installedX, availX, rc;
- char * availDir, * availBase;
- char * instDir, * instBase;
- static int i = 0;
-
- availX = 0;
- installedX = 0;
- while (installedX < instFileCount) {
- instBase = instBaseNames[installedX];
- instDir = instDirNames[instDirIndexes[installedX]];
-
- if (availX == availFileCount) {
- /* All the rest have moved */
- DEBUG(("=> %d: %s%s\n", i++, instDir, instBase))
- if (strncmp(instDir, "/etc/rc.d/", 10))
- htAddToTable(ht, instDir, instBase);
- installedX++;
- } else {
- availBase = availBaseNames[availX];
- availDir = availDirNames[availDirIndexes[availX]];
-
- rc = strcmp(availDir, instDir);
- if (!rc)
- rc = strcmp(availBase, instBase);
-
- if (rc > 0) {
- /* Avail > Installed -- file has moved */
- DEBUG(("=> %d: %s%s\n", i++, instDir, instBase))
- if (strncmp(instDir, "/etc/rc.d/", 10))
- htAddToTable(ht, instDir, instBase);
- installedX++;
- } else if (rc < 0) {
- /* Avail < Installed -- avail has some new files */
- availX++;
- } else {
- /* Files are equal -- file not moved */
- availX++;
- installedX++;
- }
- }
- }
-}
-
-static void addLostFiles(rpmdb db, struct pkgSet *psp, struct hash_table *ht)
-{
- char *name;
- struct packageInfo **pack;
- struct packageInfo key;
- struct packageInfo *keyaddr = &key;
- char **installedFiles;
- char **installedDirs;
- int_32 * installedDirIndexes;
- int installedFileCount;
- Header h = NULL;
- rpmdbMatchIterator mi;
-
- mi = rpmdbInitIterator(db, RPMDBI_PACKAGES, NULL, 0);
- while ((h = rpmdbNextIterator(mi)) != NULL) {
-
- (void) headerGetEntry(h, RPMTAG_NAME, NULL, (void **) &name, NULL);
- if (name && !strcmp(name, "metroess")) {
- /* metro was removed from 5.1, but leave it if it's already
- installed */
- continue;
- }
- key.name = name;
-
- pack = bsearch(&keyaddr, psp->packages, psp->numPackages,
- sizeof(*psp->packages), (void *)pkgCompare);
- if (!pack) {
- if (headerGetEntryMinMemory(h, RPMTAG_BASENAMES, NULL,
- (const void **) &installedFiles, &installedFileCount)
- && headerGetEntryMinMemory(h, RPMTAG_DIRINDEXES, NULL,
- (const void **) &installedDirIndexes, NULL)
- && headerGetEntryMinMemory(h, RPMTAG_DIRNAMES, NULL,
- (const void **) &installedDirs, NULL))
- {
-
- compareFileList(0, NULL, NULL, NULL, installedFileCount,
- installedFiles, installedDirs,
- installedDirIndexes, ht);
-
- free(installedFiles);
- free(installedDirs);
- }
- }
- }
-
- mi = rpmdbFreeIterator(mi);
-}
-
-static int findPackagesWithObsoletes(rpmdb db, struct pkgSet *psp)
-{
- int count, obsoletesCount;
- struct packageInfo **pip;
- char **obsoletes;
-
- count = psp->numPackages;
- pip = psp->packages;
- while (count--) {
- if ((*pip)->selected != 0) {
- pip++;
- continue;
- }
-
- if (headerGetEntryMinMemory((*pip)->h, RPMTAG_OBSOLETENAME, NULL,
- (const void **) &obsoletes, &obsoletesCount)) {
- while (obsoletesCount--) {
- if (rpmdbCountPackages(db, obsoletes[obsoletesCount]) > 0) {
- (*pip)->selected = 1;
- /*@innerbreak@*/ break;
- }
- }
-
- free(obsoletes);
- }
-
- pip++;
- }
-
- return 0;
-}
-
-static void errorFunction(void)
-{
-}
-
-static int findUpgradePackages(rpmdb db, struct pkgSet *psp,
- struct hash_table *ht)
-{
- int skipThis;
- Header h, installedHeader;
- char *name;
- int count;
- char **installedFiles;
- char ** availFiles = NULL;
- char ** installedDirs;
- char ** availDirs = NULL;
- int_32 * installedDirIndexes;
- int_32 * availDirIndexes = NULL;
- int installedFileCount, availFileCount;
- struct packageInfo **pip;
-
- count = psp->numPackages;
- pip = psp->packages;
- while (count--) {
- h = (*pip)->h;
- name = NULL;
- if (!headerGetEntry(h, RPMTAG_NAME, NULL, (void **) &name, NULL) ||
- name == NULL)
- {
- /* bum header */
- /*logMessage("Failed with bad header");*/
- return(-1);
- }
-
- DEBUG (("Avail: %s\n", name));
-
- { rpmdbMatchIterator mi;
-
- mi = rpmdbInitIterator(db, RPMTAG_NAME, name, 0);
- skipThis = (mi != NULL ? 0 : 1);
- (void) rpmErrorSetCallback(errorFunction);
- while ((installedHeader = rpmdbNextIterator(mi)) != NULL) {
- if (rpmVersionCompare(installedHeader, h) >= 0) {
- /* already have a newer version installed */
- DEBUG (("Already have newer version\n"))
- skipThis = 1;
- /*@innerbreak@*/ break;
- }
- }
- mi = rpmdbFreeIterator(mi);
- (void) rpmErrorSetCallback(NULL);
- if (! skipThis) {
- DEBUG (("No newer version installed\n"))
- }
- }
-
- if (skipThis) {
- DEBUG (("DO NOT INSTALL\n"))
- } else {
- DEBUG (("UPGRADE\n"))
- (*pip)->selected = 1;
-
- if (!headerGetEntryMinMemory(h, RPMTAG_BASENAMES, NULL,
- (const void **) &availFiles, &availFileCount)) {
- availFiles = NULL;
- availFileCount = 0;
- } else {
- (void) headerGetEntryMinMemory(h, RPMTAG_DIRNAMES, NULL,
- (const void **) &availDirs, NULL);
- (void) headerGetEntryMinMemory(h, RPMTAG_DIRINDEXES, NULL,
- (const void **) &availDirIndexes, NULL);
- }
-
- { rpmdbMatchIterator mi;
- mi = rpmdbInitIterator(db, RPMTAG_NAME, name, 0);
- while((installedHeader = rpmdbNextIterator(mi)) != NULL) {
- if (headerGetEntryMinMemory(installedHeader, RPMTAG_BASENAMES,
- NULL, (const void **) &installedFiles,
- &installedFileCount)
- && headerGetEntryMinMemory(installedHeader, RPMTAG_DIRNAMES,
- NULL, (const void **) &installedDirs, NULL)
- && headerGetEntryMinMemory(installedHeader, RPMTAG_DIRINDEXES,
- NULL, (const void **) &installedDirIndexes, NULL))
- {
-
- compareFileList(availFileCount, availFiles,
- availDirs, availDirIndexes,
- installedFileCount, installedFiles,
- installedDirs, installedDirIndexes,
- ht);
-
- free(installedFiles);
- free(installedDirs);
- }
- }
- mi = rpmdbFreeIterator(mi);
- }
-
- if (availFiles) {
- free(availFiles);
- free(availDirs);
- }
- }
-
- DEBUG (("\n\n"))
-
- pip++;
- }
-
- return 0;
-}
-
-static int removeMovedFilesAlreadyHandled(struct pkgSet *psp,
- struct hash_table *ht)
-{
- char *name;
- int i, count;
- Header h;
- char ** availFiles, ** availDirs;
- int_32 * availDirIndexes;
- int availFileCount;
- struct packageInfo **pip;
-
- count = psp->numPackages;
- pip = psp->packages;
- while (count--) {
- h = (*pip)->h;
- if ((*pip)->selected != 0) {
- name = NULL;
- (void) headerGetEntry(h, RPMTAG_NAME, NULL, (void **) &name, NULL);
-
- if (headerGetEntryMinMemory(h, RPMTAG_BASENAMES, NULL,
- (const void **) &availFiles, &availFileCount)
-
- && headerGetEntryMinMemory(h, RPMTAG_DIRNAMES, NULL,
- (const void **) &availDirs, NULL)
- && headerGetEntryMinMemory(h, RPMTAG_DIRINDEXES, NULL,
- (const void **) &availDirIndexes, NULL))
- {
-
- for (i = 0; i < availFileCount; i++) {
- if (htInTable(ht, availDirs[availDirIndexes[i]],
- availFiles[i])) {
- htRemoveFromTable(ht, availDirs[availDirIndexes[i]],
- availFiles[i]);
- DEBUG (("File already in %s: %s%s\n", name,
- availDirs[availDirIndexes[i]], availFiles[i]))
- /*@innerbreak@*/ break;
- }
- }
-
- free(availFiles);
- free(availDirs);
- }
- }
-
- pip++;
- }
-
- return 0;
-}
-
-static int findPackagesWithRelocatedFiles(struct pkgSet *psp,
- struct hash_table *ht)
-{
- char *name;
- int i, count;
- Header h;
- char **availFiles, **availDirs;
- int_32 * availDirIndexes;
- int availFileCount;
- struct packageInfo **pip;
- int_16 * availFileModes;
-
- count = psp->numPackages;
- pip = psp->packages;
- while (count--) {
- h = (*pip)->h;
- if (! (*pip)->selected) {
- name = NULL;
- (void) headerGetEntry(h, RPMTAG_NAME, NULL, (void **) &name, NULL);
-
- if (headerGetEntry(h, RPMTAG_BASENAMES, NULL,
- (void **) &availFiles, &availFileCount)
- && headerGetEntryMinMemory(h, RPMTAG_DIRNAMES, NULL,
- (const void **) &availDirs, NULL)
- && headerGetEntryMinMemory(h, RPMTAG_DIRINDEXES, NULL,
- (const void **) &availDirIndexes, NULL)
- && headerGetEntryMinMemory(h, RPMTAG_FILEMODES, NULL,
- (const void **) &availFileModes, NULL))
- {
-
- for (i = 0; i < availFileCount; i++) {
- if (S_ISDIR(availFileModes[i])) /*@innercontinue@*/ continue;
-
- if (htInTable(ht, availDirs[availDirIndexes[i]],
- availFiles[i])) {
- htRemoveFromTable(ht, availDirs[availDirIndexes[i]],
- availFiles[i]);
- DEBUG (("Found file in %s: %s%s\n", name,
- availDirs[availDirIndexes[i]], availFiles[i]))
- (*pip)->selected = 1;
- }
- }
- free(availFiles);
- free(availDirs);
- }
- }
-
- pip++;
- }
-
- return 0;
-}
-
-/*
-static void printCount(struct pkgSet *psp)
-{
- int i, upgradeCount;
- struct packageInfo *pip;
-
- upgradeCount = 0;
- pip = psp->packages;
- i = psp->numPackages;
- while (i--) {
- if (pip->selected) {
- upgradeCount++;
- }
- pip++;
- }
- logMessage("marked %d packages for upgrade", upgradeCount);
-}
-*/
-
-static int unmarkPackagesAlreadyInstalled(rpmdb db, struct pkgSet *psp)
-{
- Header h, installedHeader;
- char *name;
- struct packageInfo **pip;
- int count;
-
- count = psp->numPackages;
- pip = psp->packages;
- while (count--) {
- if ((*pip)->selected != 0) {
- h = (*pip)->h;
- /* If this package is already installed, don't bother */
- name = NULL;
- if (!headerGetEntry(h, RPMTAG_NAME, NULL, (void **) &name, NULL) ||
- name == NULL)
- {
- /* bum header */
- /*logMessage("Failed with bad header");*/
- return(-1);
- }
- { rpmdbMatchIterator mi;
-
- mi = rpmdbInitIterator(db, RPMTAG_NAME, name, 0);
- (void) rpmErrorSetCallback(errorFunction);
- while((installedHeader = rpmdbNextIterator(mi)) != NULL) {
- if (rpmVersionCompare(installedHeader, h) >= 0) {
- /* already have a newer version installed */
- DEBUG (("Already have newer version\n"))
- (*pip)->selected = 0;
- /*@innerbreak@*/ break;
- }
- }
- mi = rpmdbFreeIterator(mi);
- (void) rpmErrorSetCallback(NULL);
- }
- }
-
- pip++;
- }
-
- return 0;
-}
-
-static void emptyErrorCallback(void) {
-}
-
-int ugFindUpgradePackages(struct pkgSet *psp, char *installRoot)
-{
- rpmdb db;
- struct hash_table *hashTable;
- rpmErrorCallBackType old;
-
- /*logDebugMessage(("ugFindUpgradePackages() ..."));*/
-
-/* rpmReadConfigFiles(NULL, NULL); */
-
- rpmSetVerbosity(RPMMESS_FATALERROR);
- old = rpmErrorSetCallback(emptyErrorCallback);
-
- if (rpmdbOpen(installRoot, &db, O_RDONLY, 0644)) {
- /*logMessage("failed opening %s/var/lib/rpm/packages.rpm",
- installRoot);*/
- return(-1);
- }
-
- (void) rpmErrorSetCallback(old);
- rpmSetVerbosity(RPMMESS_NORMAL);
-
- hashTable = htNewTable(1103);
- if (hashTable == NULL) return (-1);
-
- /* For all packages that are installed, if there is no package */
- /* available by that name, add the package's files to the hash table */
- addLostFiles(db, psp, hashTable);
- /*logDebugMessage(("added lost files"));
- printCount(psp);*/
-
- /* Find packges that are new, and mark them in installThisPackage, */
- /* updating availPkgs with the count. Also add files to the hash */
- /* table that do not exist in the new package - they may have moved */
- if (findUpgradePackages(db, psp, hashTable)) {
- (void) rpmdbClose(db);
- return(-1);
- }
- /*logDebugMessage(("found basic packages to upgrade"));
- printCount(psp);
- hash_stats(hashTable);*/
-
- /* Remove any files that were added to the hash table that are in */
- /* some other package marked for upgrade. */
- (void) removeMovedFilesAlreadyHandled(psp, hashTable);
- /*logDebugMessage(("removed extra files which have moved"));
- printCount(psp);*/
-
- (void) findPackagesWithRelocatedFiles(psp, hashTable);
- /*logDebugMessage(("found packages with relocated files"));
- printCount(psp);*/
-
- (void) findPackagesWithObsoletes(db, psp);
- /*logDebugMessage(("found packages that obsolete installed packages"));
- printCount(psp);*/
-
- (void) unmarkPackagesAlreadyInstalled(db, psp);
- /*logDebugMessage(("unmarked packages already installed"));
- printCount(psp);*/
-
- htFreeHashTable(hashTable);
-
- /*printMemStats("Done");*/
-
- (void) rpmdbClose(db);
-
- return 0;
-}
diff --git a/python/upgrade.h b/python/upgrade.h
deleted file mode 100644
index f9539c843..000000000
--- a/python/upgrade.h
+++ /dev/null
@@ -1,22 +0,0 @@
-#ifndef H_UPGRADE
-#define H_UPGRADE
-
-/** \ingroup python
- * \file python/upgrade.h
- */
-
-struct packageInfo {
- Header h;
- char selected;
- char * name;
- void * data;
-} ;
-
-struct pkgSet {
- struct packageInfo ** packages;
- int numPackages;
-};
-
-int ugFindUpgradePackages(struct pkgSet *psp, char *installRoot);
-
-#endif