summaryrefslogtreecommitdiff
path: root/python/upgrade.c
diff options
context:
space:
mode:
authorjbj <devnull@localhost>2000-04-12 18:21:40 +0000
committerjbj <devnull@localhost>2000-04-12 18:21:40 +0000
commitbb472e02e1bde04b02702cf72473f9a5dbcb983d (patch)
tree64027c6a563adb11c34b30a606262c8eaed1a89e /python/upgrade.c
parenta4a828e3a5ff469d0695028d8b11ca67210da100 (diff)
downloadlibrpm-tizen-bb472e02e1bde04b02702cf72473f9a5dbcb983d.tar.gz
librpm-tizen-bb472e02e1bde04b02702cf72473f9a5dbcb983d.tar.bz2
librpm-tizen-bb472e02e1bde04b02702cf72473f9a5dbcb983d.zip
Convert to rpm-3.1 API.
CVS patchset: 3672 CVS date: 2000/04/12 18:21:40
Diffstat (limited to 'python/upgrade.c')
-rw-r--r--python/upgrade.c132
1 files changed, 119 insertions, 13 deletions
diff --git a/python/upgrade.c b/python/upgrade.c
index 4f7a5e365..413480ffa 100644
--- a/python/upgrade.c
+++ b/python/upgrade.c
@@ -96,8 +96,6 @@ static void compareFileList(int availFileCount, char **availBaseNames,
static void addLostFiles(rpmdb db, struct pkgSet *psp, struct hash_table *ht)
{
- int num;
- Header h;
char *name;
struct packageInfo **pack;
struct packageInfo key;
@@ -107,15 +105,31 @@ static void addLostFiles(rpmdb db, struct pkgSet *psp, struct hash_table *ht)
int_32 * installedDirIndexes;
int installedFileCount;
- num = rpmdbFirstRecNum(db);
- while (num) {
+ { Header h = NULL;
+
+#ifdef DYING
+ int num;
+
+ for (num = rpmdbFirstRecNum(db);
+ num > 0;
+ num = rpmdbNextRecNum(db, num))
+ {
+ if (h) {
+ headerFree(h);
+ h = NULL;
+ }
h = rpmdbGetRecord(db, num);
+#else
+ rpmdbMatchIterator mi;
+
+ mi = rpmdbInitIterator(db, RPMDBI_PACKAGES, NULL, 0);
+ while ((h = rpmdbNextIterator(mi)) != NULL) {
+#endif
+
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 */
- headerFree(h);
- num = rpmdbNextRecNum(db, num);
continue;
}
key.name = name;
@@ -138,16 +152,23 @@ static void addLostFiles(rpmdb db, struct pkgSet *psp, struct hash_table *ht)
free(installedDirs);
}
}
-
+#ifndef DYING
+ }
+
+ rpmdbFreeIterator(mi);
+#else
+ }
+ if (h) {
headerFree(h);
- num = rpmdbNextRecNum(db, num);
+ h = NULL;
}
+#endif
+ }
}
static int findPackagesWithObsoletes(rpmdb db, struct pkgSet *psp)
{
- dbiIndexSet matches;
- int rc, count, obsoletesCount;
+ int count, obsoletesCount;
struct packageInfo **pip;
char **obsoletes;
@@ -162,6 +183,10 @@ static int findPackagesWithObsoletes(rpmdb db, struct pkgSet *psp)
if (headerGetEntryMinMemory((*pip)->h, RPMTAG_OBSOLETES, NULL,
(void **) &obsoletes, &obsoletesCount)) {
while (obsoletesCount--) {
+#ifdef DYING
+ dbiIndexSet matches;
+ int rc;
+
rc = rpmdbFindPackage(db, obsoletes[obsoletesCount], &matches);
if (!rc) {
if (dbiIndexSetCount(matches)) {
@@ -172,6 +197,12 @@ static int findPackagesWithObsoletes(rpmdb db, struct pkgSet *psp)
dbiFreeIndexSet(matches);
}
+#else
+ if (rpmdbCountPackages(db, obsoletes[obsoletesCount]) > 0) {
+ (*pip)->selected = 1;
+ break;
+ }
+#endif
}
free(obsoletes);
@@ -193,8 +224,11 @@ static int findUpgradePackages(rpmdb db, struct pkgSet *psp,
int skipThis;
Header h, installedHeader;
char *name;
+#ifdef DYING
dbiIndexSet matches;
- int rc, i, count;
+ int rc, i;
+#endif
+ int count;
char **installedFiles, **availFiles;
char **installedDirs, ** availDirs;
int_32 * installedDirIndexes, * availDirIndexes;
@@ -214,6 +248,7 @@ static int findUpgradePackages(rpmdb db, struct pkgSet *psp,
}
DEBUG (("Avail: %s\n", name));
+#ifdef DYING
rc = rpmdbFindPackage(db, name, &matches);
if (rc == 0) {
@@ -239,6 +274,27 @@ static int findUpgradePackages(rpmdb db, struct pkgSet *psp,
skipThis = 1;
DEBUG (("Not installed\n"))
}
+#else
+ { rpmdbMatchIterator mi;
+
+ mi = rpmdbInitIterator(db, RPMDBI_NAME, name, 0);
+ skipThis = (mi ? 0 : 1);
+ 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;
+ break;
+ }
+ }
+ rpmdbFreeIterator(mi);
+ rpmErrorSetCallback(NULL);
+ if (! skipThis) {
+ DEBUG (("No newer version installed\n"))
+ }
+ }
+#endif
if (skipThis) {
DEBUG (("DO NOT INSTALL\n"))
@@ -257,6 +313,7 @@ static int findUpgradePackages(rpmdb db, struct pkgSet *psp,
(void **) &availDirIndexes, NULL);
}
+#ifdef DYING
for (i = 0; i < dbiIndexSetCount(matches); i++) {
/* Compare the file lists */
installedHeader =
@@ -280,6 +337,31 @@ static int findUpgradePackages(rpmdb db, struct pkgSet *psp,
}
headerFree(installedHeader);
}
+#else
+ { rpmdbMatchIterator mi;
+ mi = rpmdbInitIterator(db, RPMDBI_NAME, name, 0);
+ while((installedHeader = rpmdbNextIterator(mi)) != NULL) {
+ if (headerGetEntryMinMemory(installedHeader, RPMTAG_BASENAMES,
+ NULL, (void **) &installedFiles,
+ &installedFileCount)) {
+ headerGetEntryMinMemory(installedHeader, RPMTAG_DIRNAMES,
+ NULL, (void **) &installedDirs, NULL);
+ headerGetEntryMinMemory(installedHeader, RPMTAG_DIRINDEXES,
+ NULL, (void **) &installedDirIndexes, NULL);
+
+ compareFileList(availFileCount, availFiles,
+ availDirs, availDirIndexes,
+ installedFileCount, installedFiles,
+ installedDirs, installedDirIndexes,
+ ht);
+
+ free(installedFiles);
+ free(installedDirs);
+ }
+ }
+ rpmdbFreeIterator(mi);
+ }
+#endif
if (availFiles) {
free(availFiles);
@@ -287,9 +369,11 @@ static int findUpgradePackages(rpmdb db, struct pkgSet *psp,
}
}
+#ifdef DYING
if (rc == 0) {
dbiFreeIndexSet(matches);
}
+#endif
DEBUG (("\n\n"))
@@ -422,11 +506,10 @@ static void printCount(struct pkgSet *psp)
static int unmarkPackagesAlreadyInstalled(rpmdb db, struct pkgSet *psp)
{
- dbiIndexSet matches;
Header h, installedHeader;
char *name;
struct packageInfo **pip;
- int count, rc, i;
+ int count;
count = psp->numPackages;
pip = psp->packages;
@@ -441,6 +524,11 @@ static int unmarkPackagesAlreadyInstalled(rpmdb db, struct pkgSet *psp)
/*logMessage("Failed with bad header");*/
return(-1);
}
+#ifdef DYING
+ { dbiIndexSet matches;
+ int rc;
+ int i;
+
rc = rpmdbFindPackage(db, name, &matches);
if (rc == 0) {
rpmErrorSetCallback(errorFunction);
@@ -460,6 +548,24 @@ static int unmarkPackagesAlreadyInstalled(rpmdb db, struct pkgSet *psp)
dbiFreeIndexSet(matches);
}
}
+#else
+ { rpmdbMatchIterator mi;
+
+ mi = rpmdbInitIterator(db, RPMDBI_NAME, name, 0);
+ 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;
+ break;
+ }
+ }
+ rpmdbFreeIterator(mi);
+ rpmErrorSetCallback(NULL);
+ }
+#endif
+ }
pip++;
}