int fileCount, notifyFunction notify,
char ** installArchive);
static int packageAlreadyInstalled(rpmdb db, char * name, char * version,
- char * release, int flags);
+ char * release, int * recOffset, int flags);
static int setFileOwnerships(char * prefix, char ** fileList,
char ** fileOwners, char ** fileGroups,
int fileCount);
int i;
int archiveFileCount = 0;
int installFile = 0;
+ int otherOffset = 0;
char * ext = NULL, * newpath;
int prefixLength = strlen(prefix);
char ** prefixedFileList = NULL;
message(MESS_DEBUG, "package: %s-%s-%s files test = %d\n",
name, version, release, flags & INSTALL_TEST);
- if (packageAlreadyInstalled(db, name, version, release, flags)) {
+ if (packageAlreadyInstalled(db, name, version, release, &otherOffset,
+ flags)) {
freeHeader(h);
return 2;
}
addEntry(h, RPMTAG_INSTALLTIME, INT32_TYPE, &installTime, 1);
}
+ /* if this package has already been installed, remove it from the database
+ before adding the new one */
+ if (otherOffset) {
+ rpmdbRemove(db, otherOffset, 1);
+ }
+
if (rpmdbAdd(db, h)) {
freeHeader(h);
return 2;
}
static int packageAlreadyInstalled(rpmdb db, char * name, char * version,
- char * release, int flags) {
+ char * release, int * offset, int flags) {
char * secVersion, * secRelease;
Header sech;
int i;
freeHeader(sech);
if (!strcmp(secVersion, version) && !strcmp(secRelease, release)) {
+ *offset = matches.recs[i].recOffset;
if (!(flags & INSTALL_REPLACEPKG)) {
error(RPMERR_PKGINSTALLED,
"package %s-%s-%s is already installed",