1997-01-18 00:22:57 +08:00
|
|
|
#include "config.h"
|
1997-05-20 23:57:39 +08:00
|
|
|
#include "miscfn.h"
|
1997-01-18 00:22:57 +08:00
|
|
|
|
|
|
|
#if HAVE_ALLOCA_H
|
1996-09-26 03:14:17 +08:00
|
|
|
# include <alloca.h>
|
|
|
|
#endif
|
|
|
|
|
1996-01-09 03:31:44 +08:00
|
|
|
#include <errno.h>
|
1996-01-15 03:32:17 +08:00
|
|
|
#include <fcntl.h>
|
1996-01-09 03:31:44 +08:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
1997-01-18 00:22:57 +08:00
|
|
|
#include <signal.h>
|
1997-05-21 01:43:34 +08:00
|
|
|
#include <sys/time.h>
|
1997-05-16 23:32:57 +08:00
|
|
|
#include <sys/resource.h>
|
1996-01-15 03:32:17 +08:00
|
|
|
#include <sys/stat.h> /* needed for mkdir(2) prototype! */
|
1996-01-09 03:31:44 +08:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/wait.h>
|
1996-01-30 03:37:59 +08:00
|
|
|
#include <time.h>
|
1996-01-09 03:31:44 +08:00
|
|
|
#include <unistd.h>
|
1996-12-24 22:00:52 +08:00
|
|
|
#include <utime.h>
|
1996-01-09 03:31:44 +08:00
|
|
|
#include <zlib.h>
|
|
|
|
|
1997-05-06 04:46:58 +08:00
|
|
|
#include "cpio.h"
|
1996-01-09 03:31:44 +08:00
|
|
|
#include "header.h"
|
|
|
|
#include "install.h"
|
1996-01-30 03:37:59 +08:00
|
|
|
#include "md5.h"
|
1997-05-06 04:46:58 +08:00
|
|
|
#include "messages.h"
|
1996-02-15 06:20:08 +08:00
|
|
|
#include "misc.h"
|
1996-09-17 06:28:56 +08:00
|
|
|
#include "rpmdb.h"
|
1996-01-09 03:31:44 +08:00
|
|
|
#include "rpmlib.h"
|
|
|
|
|
1997-06-19 04:45:17 +08:00
|
|
|
enum instActions { UNKNOWN, CREATE, BACKUP, KEEP, SAVE, SKIP, ALTNAME };
|
1996-09-26 03:14:17 +08:00
|
|
|
enum fileTypes { XDIR, BDEV, CDEV, SOCK, PIPE, REG, LINK } ;
|
1996-01-23 05:13:12 +08:00
|
|
|
|
1997-05-06 23:27:46 +08:00
|
|
|
struct callbackInfo {
|
|
|
|
unsigned long archiveSize;
|
|
|
|
rpmNotifyFunction notify;
|
1997-05-07 02:19:19 +08:00
|
|
|
char ** specFilePtr;
|
1997-05-06 23:27:46 +08:00
|
|
|
};
|
|
|
|
|
1997-05-06 04:46:58 +08:00
|
|
|
struct fileMemory {
|
|
|
|
char ** md5s;
|
|
|
|
char ** links;
|
|
|
|
char ** names;
|
|
|
|
struct fileInfo * files;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct fileInfo {
|
|
|
|
char * cpioPath;
|
|
|
|
char * relativePath; /* relative to root */
|
|
|
|
char * md5;
|
|
|
|
char * link;
|
|
|
|
uid_t uid;
|
|
|
|
gid_t gid;
|
|
|
|
uint_32 flags;
|
|
|
|
uint_32 size;
|
|
|
|
mode_t mode;
|
|
|
|
char state;
|
|
|
|
enum instActions action;
|
|
|
|
int install;
|
1996-01-23 05:13:12 +08:00
|
|
|
} ;
|
|
|
|
|
1996-02-16 05:08:48 +08:00
|
|
|
struct replacedFile {
|
|
|
|
int recOffset, fileNumber;
|
|
|
|
} ;
|
|
|
|
|
1996-02-29 11:38:33 +08:00
|
|
|
enum fileTypes whatis(short mode);
|
1996-09-29 10:27:20 +08:00
|
|
|
static int filecmp(short mode1, char * md51, char * link1,
|
|
|
|
short mode2, char * md52, char * link2);
|
|
|
|
static enum instActions decideFileFate(char * filespec, short dbMode,
|
|
|
|
char * dbMd5, char * dbLink, short newMode,
|
1997-06-17 23:37:28 +08:00
|
|
|
char * newMd5, char * newLink, int newFlags,
|
|
|
|
int instFlags, int brokenMd5);
|
1997-05-07 02:19:19 +08:00
|
|
|
static int installArchive(int fd, struct fileInfo * files,
|
1997-05-06 04:46:58 +08:00
|
|
|
int fileCount, rpmNotifyFunction notify,
|
|
|
|
char ** specFile, int archiveSize);
|
1996-01-15 03:32:17 +08:00
|
|
|
static int packageAlreadyInstalled(rpmdb db, char * name, char * version,
|
1996-02-15 05:26:21 +08:00
|
|
|
char * release, int * recOffset, int flags);
|
1997-05-06 04:46:58 +08:00
|
|
|
static int instHandleSharedFiles(rpmdb db, int ignoreOffset,
|
|
|
|
struct fileInfo * files,
|
|
|
|
int fileCount, int * notErrors,
|
1996-02-16 05:08:48 +08:00
|
|
|
struct replacedFile ** repListPtr, int flags);
|
1996-08-29 12:16:07 +08:00
|
|
|
static int installSources(Header h, char * rootdir, int fd,
|
1996-11-19 02:02:36 +08:00
|
|
|
char ** specFilePtr, rpmNotifyFunction notify,
|
1996-08-29 12:16:07 +08:00
|
|
|
char * labelFormat);
|
1996-02-16 05:08:48 +08:00
|
|
|
static int markReplacedFiles(rpmdb db, struct replacedFile * replList);
|
1996-07-10 10:33:38 +08:00
|
|
|
static int relocateFilelist(Header * hp, char * defaultPrefix,
|
|
|
|
char * newPrefix, int * relocationSize);
|
1996-07-16 11:37:07 +08:00
|
|
|
static int archOkay(Header h);
|
|
|
|
static int osOkay(Header h);
|
1997-01-16 00:24:14 +08:00
|
|
|
static int ensureOlder(rpmdb db, Header new, int dbOffset);
|
1997-05-06 04:46:58 +08:00
|
|
|
static void assembleFileList(Header h, struct fileMemory * mem,
|
|
|
|
int * fileCountPtr, struct fileInfo ** files,
|
|
|
|
int stripPrefixLength);
|
|
|
|
static void freeFileMemory(struct fileMemory fileMem);
|
1996-02-15 04:09:14 +08:00
|
|
|
|
|
|
|
/* 0 success */
|
|
|
|
/* 1 bad magic */
|
|
|
|
/* 2 error */
|
1996-08-29 12:16:07 +08:00
|
|
|
int rpmInstallSourcePackage(char * rootdir, int fd, char ** specFile,
|
1996-11-19 02:02:36 +08:00
|
|
|
rpmNotifyFunction notify, char * labelFormat) {
|
1996-02-15 04:09:14 +08:00
|
|
|
int rc, isSource;
|
|
|
|
Header h;
|
1996-08-29 12:16:07 +08:00
|
|
|
int major, minor;
|
1996-02-15 04:09:14 +08:00
|
|
|
|
1996-11-19 02:02:36 +08:00
|
|
|
rc = rpmReadPackageHeader(fd, &h, &isSource, &major, &minor);
|
1996-02-15 04:09:14 +08:00
|
|
|
if (rc) return rc;
|
|
|
|
|
|
|
|
if (!isSource) {
|
1996-11-19 02:02:36 +08:00
|
|
|
rpmError(RPMERR_NOTSRPM, "source package expected, binary found");
|
1996-02-15 04:09:14 +08:00
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
1996-08-29 12:16:07 +08:00
|
|
|
if (major == 1) {
|
|
|
|
notify = NULL;
|
|
|
|
labelFormat = NULL;
|
|
|
|
h = NULL;
|
|
|
|
}
|
1996-03-30 03:40:08 +08:00
|
|
|
|
1996-08-29 12:16:07 +08:00
|
|
|
rc = installSources(h, rootdir, fd, specFile, notify, labelFormat);
|
1996-11-19 02:02:36 +08:00
|
|
|
if (h) headerFree(h);
|
1996-08-29 12:16:07 +08:00
|
|
|
|
|
|
|
return rc;
|
1996-02-15 04:09:14 +08:00
|
|
|
}
|
1996-01-09 03:31:44 +08:00
|
|
|
|
1997-05-06 04:46:58 +08:00
|
|
|
static void freeFileMemory(struct fileMemory fileMem) {
|
|
|
|
free(fileMem.files);
|
|
|
|
free(fileMem.md5s);
|
|
|
|
free(fileMem.links);
|
|
|
|
free(fileMem.names);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* files should not be preallocated */
|
|
|
|
static void assembleFileList(Header h, struct fileMemory * mem,
|
|
|
|
int * fileCountPtr, struct fileInfo ** filesPtr,
|
|
|
|
int stripPrefixLength) {
|
|
|
|
char ** fileOwners;
|
|
|
|
char ** fileGroups;
|
|
|
|
uint_32 * fileFlags;
|
|
|
|
uint_32 * fileSizes;
|
|
|
|
uint_16 * fileModes;
|
|
|
|
struct fileInfo * files;
|
|
|
|
struct fileInfo * file;
|
|
|
|
int fileCount;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
headerGetEntry(h, RPMTAG_FILENAMES, NULL, (void **) &mem->names,
|
|
|
|
fileCountPtr);
|
|
|
|
fileCount = *fileCountPtr;
|
|
|
|
files = *filesPtr = mem->files = malloc(sizeof(*mem->files) * fileCount);
|
|
|
|
|
|
|
|
headerGetEntry(h, RPMTAG_FILEMD5S, NULL, (void **) &mem->md5s, NULL);
|
|
|
|
headerGetEntry(h, RPMTAG_FILEUSERNAME, NULL, (void **) &fileOwners, NULL);
|
|
|
|
headerGetEntry(h, RPMTAG_FILEGROUPNAME, NULL, (void **) &fileGroups, NULL);
|
|
|
|
headerGetEntry(h, RPMTAG_FILEFLAGS, NULL, (void **) &fileFlags, NULL);
|
|
|
|
headerGetEntry(h, RPMTAG_FILEMODES, NULL, (void **) &fileModes, NULL);
|
|
|
|
headerGetEntry(h, RPMTAG_FILESIZES, NULL, (void **) &fileSizes, NULL);
|
|
|
|
headerGetEntry(h, RPMTAG_FILELINKTOS, NULL, (void **) &mem->links, NULL);
|
|
|
|
|
|
|
|
for (i = 0, file = files; i < fileCount; i++, file++) {
|
|
|
|
file->state = RPMFILE_STATE_NORMAL;
|
|
|
|
file->action = UNKNOWN;
|
|
|
|
file->install = 1;
|
|
|
|
|
|
|
|
file->relativePath = mem->names[i];
|
|
|
|
file->cpioPath = mem->names[i] + stripPrefixLength;
|
|
|
|
file->mode = fileModes[i];
|
|
|
|
file->md5 = mem->md5s[i];
|
|
|
|
file->link = mem->links[i];
|
|
|
|
file->size = fileSizes[i];
|
|
|
|
file->flags = fileFlags[i];
|
|
|
|
|
|
|
|
if (unameToUid(fileOwners[i], &files[i].uid)) {
|
|
|
|
rpmError(RPMERR_NOUSER, "user %s does not exist - using root",
|
|
|
|
fileOwners[i]);
|
|
|
|
files[i].uid = 0;
|
|
|
|
/* turn off the suid bit */
|
|
|
|
files[i].mode &= ~S_ISUID;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gnameToGid(fileGroups[i], &files[i].gid)) {
|
1997-06-26 22:35:27 +08:00
|
|
|
rpmError(RPMERR_NOGROUP, "group %s does not exist - using root",
|
1997-05-06 04:46:58 +08:00
|
|
|
fileGroups[i]);
|
|
|
|
files[i].gid = 0;
|
|
|
|
/* turn off the sgid bit */
|
|
|
|
files[i].mode &= ~S_ISGID;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
free(fileOwners);
|
|
|
|
free(fileGroups);
|
|
|
|
}
|
|
|
|
|
1996-01-09 03:31:44 +08:00
|
|
|
/* 0 success */
|
|
|
|
/* 1 bad magic */
|
|
|
|
/* 2 error */
|
1996-07-10 10:33:38 +08:00
|
|
|
int rpmInstallPackage(char * rootdir, rpmdb db, int fd, char * location,
|
1996-11-19 02:02:36 +08:00
|
|
|
int flags, rpmNotifyFunction notify, char * labelFormat,
|
1996-10-21 10:17:39 +08:00
|
|
|
char * netsharedPath) {
|
1996-08-29 12:16:07 +08:00
|
|
|
int rc, isSource, major, minor;
|
1996-01-15 03:32:17 +08:00
|
|
|
char * name, * version, * release;
|
1996-02-27 06:53:35 +08:00
|
|
|
Header h;
|
1996-08-29 12:16:07 +08:00
|
|
|
int fileCount, type, count;
|
1997-05-06 04:46:58 +08:00
|
|
|
struct fileInfo * files;
|
1996-01-30 03:37:59 +08:00
|
|
|
int_32 installTime;
|
1997-05-06 04:46:58 +08:00
|
|
|
char * fileStates;
|
1997-06-17 02:13:23 +08:00
|
|
|
int i, j;
|
1996-01-30 03:37:59 +08:00
|
|
|
int installFile = 0;
|
1996-02-15 05:26:21 +08:00
|
|
|
int otherOffset = 0;
|
1996-01-30 03:37:59 +08:00
|
|
|
char * ext = NULL, * newpath;
|
1996-12-06 05:11:17 +08:00
|
|
|
int rootLength = strlen(rootdir);
|
1996-02-16 05:08:48 +08:00
|
|
|
struct replacedFile * replacedList = NULL;
|
1996-10-21 10:17:39 +08:00
|
|
|
char * defaultPrefix;
|
1996-11-19 02:02:36 +08:00
|
|
|
dbiIndexSet matches;
|
1996-02-22 02:09:31 +08:00
|
|
|
int * oldVersions;
|
1996-02-21 05:54:02 +08:00
|
|
|
int * intptr;
|
1996-07-26 00:39:01 +08:00
|
|
|
char * archivePrefix, * tmpPath;
|
1996-06-28 22:38:12 +08:00
|
|
|
int scriptArg;
|
1996-12-11 23:39:57 +08:00
|
|
|
int hasOthers = 0;
|
1996-07-10 10:33:38 +08:00
|
|
|
int relocationSize = 1; /* strip at least first / for cpio */
|
1996-08-29 12:16:07 +08:00
|
|
|
uint_32 * archiveSizePtr;
|
1997-05-06 04:46:58 +08:00
|
|
|
struct fileMemory fileMem;
|
|
|
|
int freeFileMem = 0;
|
1997-07-18 03:18:15 +08:00
|
|
|
char * currDir = NULL, * tmpptr;
|
|
|
|
int currDirLen;
|
1996-01-09 03:31:44 +08:00
|
|
|
|
1996-02-22 02:09:31 +08:00
|
|
|
oldVersions = alloca(sizeof(int));
|
|
|
|
*oldVersions = 0;
|
|
|
|
|
1996-11-19 02:02:36 +08:00
|
|
|
rc = rpmReadPackageHeader(fd, &h, &isSource, &major, &minor);
|
1996-01-09 03:31:44 +08:00
|
|
|
if (rc) return rc;
|
|
|
|
|
1996-02-15 01:54:37 +08:00
|
|
|
if (isSource) {
|
1996-11-19 02:02:36 +08:00
|
|
|
if (flags & RPMINSTALL_TEST) {
|
1997-05-06 04:46:58 +08:00
|
|
|
rpmMessage(RPMMESS_DEBUG,
|
|
|
|
"stopping install as we're running --test\n");
|
1996-02-15 01:54:37 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1996-08-29 12:16:07 +08:00
|
|
|
if (major == 1) {
|
|
|
|
notify = NULL;
|
|
|
|
labelFormat = NULL;
|
|
|
|
h = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
rc = installSources(h, rootdir, fd, NULL, notify, labelFormat);
|
1996-11-19 02:02:36 +08:00
|
|
|
if (h) headerFree(h);
|
1996-03-30 03:40:08 +08:00
|
|
|
|
1996-08-29 12:16:07 +08:00
|
|
|
return rc;
|
1996-07-10 10:33:38 +08:00
|
|
|
}
|
|
|
|
|
1996-11-19 02:02:36 +08:00
|
|
|
headerGetEntry(h, RPMTAG_NAME, &type, (void **) &name, &fileCount);
|
|
|
|
headerGetEntry(h, RPMTAG_VERSION, &type, (void **) &version, &fileCount);
|
|
|
|
headerGetEntry(h, RPMTAG_RELEASE, &type, (void **) &release, &fileCount);
|
1996-07-11 23:48:21 +08:00
|
|
|
|
1996-11-19 02:02:36 +08:00
|
|
|
if (!headerGetEntry(h, RPMTAG_DEFAULTPREFIX, &type, (void *)
|
1996-07-10 10:33:38 +08:00
|
|
|
&defaultPrefix, &fileCount)) {
|
1996-07-10 22:11:19 +08:00
|
|
|
defaultPrefix = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (location && !defaultPrefix) {
|
1996-11-19 02:02:36 +08:00
|
|
|
rpmError(RPMERR_NORELOCATE, "package %s-%s-%s is not relocatable",
|
1996-07-10 10:33:38 +08:00
|
|
|
name, version, release);
|
1996-11-19 02:02:36 +08:00
|
|
|
headerFree(h);
|
1996-07-10 10:33:38 +08:00
|
|
|
return 2;
|
1996-07-10 22:11:19 +08:00
|
|
|
} else if (!location && defaultPrefix)
|
|
|
|
location = defaultPrefix;
|
1997-02-14 11:26:16 +08:00
|
|
|
|
|
|
|
/* We don't use these entries (and never have) and they are pretty
|
|
|
|
misleading. Let's just get rid of them so they don't confuse
|
|
|
|
anyone. */
|
|
|
|
if (headerIsEntry(h, RPMTAG_FILEUSERNAME))
|
|
|
|
headerRemoveEntry(h, RPMTAG_FILEUIDS);
|
|
|
|
if (headerIsEntry(h, RPMTAG_FILEGROUPNAME))
|
|
|
|
headerRemoveEntry(h, RPMTAG_FILEGIDS);
|
1996-07-10 22:11:19 +08:00
|
|
|
|
1996-07-10 10:33:38 +08:00
|
|
|
if (location) {
|
|
|
|
relocateFilelist(&h, defaultPrefix, location, &relocationSize);
|
1996-11-19 02:02:36 +08:00
|
|
|
headerGetEntry(h, RPMTAG_DEFAULTPREFIX, &type, (void *) &defaultPrefix,
|
1996-07-10 10:33:38 +08:00
|
|
|
&fileCount);
|
|
|
|
archivePrefix = alloca(strlen(rootdir) + strlen(location) + 2);
|
|
|
|
sprintf(archivePrefix, "%s/%s", rootdir, location);
|
1996-07-10 22:11:19 +08:00
|
|
|
} else {
|
1996-07-10 10:33:38 +08:00
|
|
|
archivePrefix = rootdir;
|
1996-07-10 22:11:19 +08:00
|
|
|
relocationSize = 1;
|
|
|
|
}
|
1996-07-10 10:33:38 +08:00
|
|
|
|
1996-11-19 02:02:36 +08:00
|
|
|
if (!(flags & RPMINSTALL_NOARCH) && !archOkay(h)) {
|
|
|
|
rpmError(RPMERR_BADARCH, "package %s-%s-%s is for a different "
|
1996-07-16 11:37:07 +08:00
|
|
|
"architecture", name, version, release);
|
1996-11-19 02:02:36 +08:00
|
|
|
headerFree(h);
|
1996-07-16 11:43:13 +08:00
|
|
|
return 2;
|
1996-07-16 11:37:07 +08:00
|
|
|
}
|
|
|
|
|
1996-11-19 02:02:36 +08:00
|
|
|
if (!(flags & RPMINSTALL_NOOS) && !osOkay(h)) {
|
|
|
|
rpmError(RPMERR_BADOS, "package %s-%s-%s is for a different "
|
1996-07-16 11:43:13 +08:00
|
|
|
"operating system", name, version, release);
|
1996-11-19 02:02:36 +08:00
|
|
|
headerFree(h);
|
1996-07-16 11:43:13 +08:00
|
|
|
return 2;
|
1996-02-27 06:45:24 +08:00
|
|
|
}
|
|
|
|
|
1996-10-21 10:17:39 +08:00
|
|
|
if (packageAlreadyInstalled(db, name, version, release, &otherOffset,
|
|
|
|
flags)) {
|
1996-11-19 02:02:36 +08:00
|
|
|
headerFree(h);
|
1996-10-21 10:17:39 +08:00
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
1996-11-19 02:02:36 +08:00
|
|
|
rpmMessage(RPMMESS_DEBUG, "package: %s-%s-%s files test = %d\n",
|
|
|
|
name, version, release, flags & RPMINSTALL_TEST);
|
1996-01-15 03:32:17 +08:00
|
|
|
|
1996-06-28 22:38:12 +08:00
|
|
|
rc = rpmdbFindPackage(db, name, &matches);
|
|
|
|
if (rc == -1) return 2;
|
1996-12-11 23:39:57 +08:00
|
|
|
if (rc) {
|
1996-06-28 22:38:12 +08:00
|
|
|
scriptArg = 1;
|
1996-12-11 23:39:57 +08:00
|
|
|
} else {
|
1996-12-11 23:53:58 +08:00
|
|
|
hasOthers = 1;
|
1996-06-28 22:38:12 +08:00
|
|
|
scriptArg = matches.count + 1;
|
1996-12-11 23:39:57 +08:00
|
|
|
}
|
1996-06-28 22:38:12 +08:00
|
|
|
|
1996-12-06 05:11:17 +08:00
|
|
|
/* This canonicalizes the root */
|
|
|
|
if (rootdir && rootdir[rootLength] == '/') {
|
|
|
|
char * newRootdir;
|
|
|
|
|
|
|
|
newRootdir = alloca(rootLength + 2);
|
|
|
|
strcpy(newRootdir, rootdir);
|
|
|
|
newRootdir[rootLength++] = '/';
|
|
|
|
newRootdir[rootLength] = '\0';
|
|
|
|
rootdir = newRootdir;
|
|
|
|
}
|
|
|
|
|
1996-12-11 23:39:57 +08:00
|
|
|
if (flags & RPMINSTALL_UPGRADE && hasOthers) {
|
1996-02-21 05:54:02 +08:00
|
|
|
/*
|
|
|
|
We need to get a list of all old version of this package. We let
|
|
|
|
this install procede normally then, but:
|
|
|
|
|
|
|
|
1) we don't report conflicts between the new package and
|
|
|
|
the old versions installed
|
|
|
|
2) when we're done, we uninstall the old versions
|
|
|
|
|
|
|
|
Note if the version being installed is already installed, we don't
|
|
|
|
put that in the list -- that situation is handled normally.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (!rc) {
|
|
|
|
intptr = oldVersions = alloca((matches.count + 1) * sizeof(int));
|
|
|
|
for (i = 0; i < matches.count; i++) {
|
1996-02-26 06:11:00 +08:00
|
|
|
if (matches.recs[i].recOffset != otherOffset) {
|
1996-11-19 02:02:36 +08:00
|
|
|
if (!(flags & RPMINSTALL_UPGRADETOOLD))
|
1997-01-16 00:24:14 +08:00
|
|
|
if (ensureOlder(db, h, matches.recs[i].recOffset)) {
|
1996-12-06 12:07:28 +08:00
|
|
|
headerFree(h);
|
|
|
|
dbiFreeIndexRecord(matches);
|
1996-04-16 05:09:40 +08:00
|
|
|
return 2;
|
1996-12-06 12:07:28 +08:00
|
|
|
}
|
1996-02-21 05:54:02 +08:00
|
|
|
*intptr++ = matches.recs[i].recOffset;
|
1996-02-26 06:11:00 +08:00
|
|
|
}
|
1996-02-21 05:54:02 +08:00
|
|
|
}
|
|
|
|
*intptr++ = 0;
|
|
|
|
}
|
1996-12-11 23:39:57 +08:00
|
|
|
}
|
1996-02-21 05:54:02 +08:00
|
|
|
|
1996-12-11 23:39:57 +08:00
|
|
|
if (hasOthers)
|
1996-12-07 04:25:36 +08:00
|
|
|
dbiFreeIndexRecord(matches);
|
1996-12-06 12:07:28 +08:00
|
|
|
|
1997-07-16 09:44:27 +08:00
|
|
|
if (rootdir) {
|
1997-07-18 03:18:15 +08:00
|
|
|
currDirLen = 50;
|
|
|
|
currDir = malloc(currDirLen);
|
|
|
|
while (!getcwd(currDir, currDirLen)) {
|
|
|
|
currDirLen += 50;
|
|
|
|
currDir = realloc(currDir, currDirLen);
|
|
|
|
}
|
|
|
|
|
|
|
|
tmpptr = currDir;
|
|
|
|
currDir = alloca(strlen(tmpptr) + 1);
|
|
|
|
strcpy(currDir, tmpptr);
|
|
|
|
free(tmpptr);
|
|
|
|
|
1997-07-16 09:44:27 +08:00
|
|
|
chdir("/");
|
|
|
|
chroot(rootdir);
|
|
|
|
}
|
|
|
|
|
1997-05-06 04:46:58 +08:00
|
|
|
if (headerIsEntry(h, RPMTAG_FILENAMES)) {
|
1996-10-21 10:17:39 +08:00
|
|
|
char ** netsharedPaths;
|
|
|
|
char ** nsp;
|
|
|
|
|
1997-05-06 04:46:58 +08:00
|
|
|
freeFileMem = 1;
|
|
|
|
assembleFileList(h, &fileMem, &fileCount, &files, relocationSize);
|
|
|
|
|
1996-10-21 10:17:39 +08:00
|
|
|
if (netsharedPath)
|
|
|
|
netsharedPaths = splitString(netsharedPath,
|
|
|
|
strlen(netsharedPath), ':');
|
|
|
|
else
|
|
|
|
netsharedPaths = NULL;
|
1996-01-23 05:13:12 +08:00
|
|
|
|
1996-01-30 03:37:59 +08:00
|
|
|
/* check for any config files that already exist. If they do, plan
|
|
|
|
on making a backup copy. If that's not the right thing to do
|
|
|
|
instHandleSharedFiles() below will take care of the problem */
|
|
|
|
for (i = 0; i < fileCount; i++) {
|
1996-12-06 05:11:17 +08:00
|
|
|
/* netsharedPaths are not relative to the current root (though
|
|
|
|
they do need to take the package prefix into account */
|
1997-06-17 02:13:23 +08:00
|
|
|
for (nsp = netsharedPaths; nsp && *nsp; nsp++) {
|
|
|
|
j = strlen(*nsp);
|
|
|
|
if (!strncmp(files[i].relativePath, *nsp, j) &&
|
|
|
|
(files[i].relativePath[j] == '\0' ||
|
|
|
|
files[i].relativePath[j] == '/'))
|
1997-05-06 04:46:58 +08:00
|
|
|
break;
|
1997-06-17 02:13:23 +08:00
|
|
|
}
|
1996-03-30 04:52:03 +08:00
|
|
|
|
1996-10-21 10:17:39 +08:00
|
|
|
if (nsp && *nsp) {
|
1996-11-19 02:02:36 +08:00
|
|
|
rpmMessage(RPMMESS_DEBUG, "file %s in netshared path\n",
|
1997-07-16 09:44:27 +08:00
|
|
|
files[i].relativePath);
|
1997-05-06 04:46:58 +08:00
|
|
|
files[i].action = SKIP;
|
|
|
|
files[i].state = RPMFILE_STATE_NETSHARED;
|
|
|
|
} else if ((files[i].flags & RPMFILE_DOC) &&
|
1996-11-19 02:02:36 +08:00
|
|
|
(flags & RPMINSTALL_NODOCS)) {
|
1997-05-06 04:46:58 +08:00
|
|
|
files[i].action = SKIP;
|
|
|
|
files[i].state = RPMFILE_STATE_NOTINSTALLED;
|
1996-10-21 10:17:39 +08:00
|
|
|
} else {
|
1997-05-06 04:46:58 +08:00
|
|
|
files[i].state = RPMFILE_STATE_NORMAL;
|
1996-10-21 10:17:39 +08:00
|
|
|
|
1997-05-06 04:46:58 +08:00
|
|
|
files[i].action = CREATE;
|
|
|
|
if ((files[i].flags & RPMFILE_CONFIG) &&
|
|
|
|
!S_ISDIR(files[i].mode)) {
|
1997-07-16 09:44:27 +08:00
|
|
|
if (exists(files[i].relativePath)) {
|
1997-06-19 04:45:17 +08:00
|
|
|
if (files[i].flags & RPMFILE_NOREPLACE) {
|
|
|
|
rpmMessage(RPMMESS_DEBUG,
|
|
|
|
"%s exists - creating with alternate name\n",
|
1997-07-16 09:44:27 +08:00
|
|
|
files[i].relativePath);
|
1997-06-19 04:45:17 +08:00
|
|
|
files[i].action = ALTNAME;
|
|
|
|
} else {
|
|
|
|
rpmMessage(RPMMESS_DEBUG,
|
|
|
|
"%s exists - backing up\n",
|
1997-07-16 09:44:27 +08:00
|
|
|
files[i].relativePath);
|
1997-06-19 04:45:17 +08:00
|
|
|
files[i].action = BACKUP;
|
|
|
|
}
|
1996-10-21 10:17:39 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1996-01-30 03:37:59 +08:00
|
|
|
}
|
|
|
|
|
1997-05-06 04:46:58 +08:00
|
|
|
rc = instHandleSharedFiles(db, otherOffset, files, fileCount,
|
|
|
|
oldVersions, &replacedList, flags);
|
1996-01-23 05:13:12 +08:00
|
|
|
|
|
|
|
if (rc) {
|
1997-07-16 09:44:27 +08:00
|
|
|
if (rootdir) {
|
|
|
|
chroot(".");
|
1997-07-18 03:18:15 +08:00
|
|
|
chdir(currDir);
|
1997-07-16 09:44:27 +08:00
|
|
|
}
|
1996-02-16 05:08:48 +08:00
|
|
|
if (replacedList) free(replacedList);
|
1997-05-06 04:46:58 +08:00
|
|
|
if (freeFileMem) freeFileMemory(fileMem);
|
1996-04-16 05:09:40 +08:00
|
|
|
return 2;
|
1996-01-23 05:13:12 +08:00
|
|
|
}
|
1997-05-06 04:46:58 +08:00
|
|
|
} else {
|
|
|
|
files = NULL;
|
1996-01-23 05:13:12 +08:00
|
|
|
}
|
1996-01-15 03:32:17 +08:00
|
|
|
|
1996-11-19 02:02:36 +08:00
|
|
|
if (flags & RPMINSTALL_TEST) {
|
1997-07-16 09:44:27 +08:00
|
|
|
if (rootdir) {
|
|
|
|
chroot(".");
|
1997-07-18 03:18:15 +08:00
|
|
|
chdir(currDir);
|
1997-07-16 09:44:27 +08:00
|
|
|
}
|
|
|
|
|
1996-11-19 02:02:36 +08:00
|
|
|
rpmMessage(RPMMESS_DEBUG, "stopping install as we're running --test\n");
|
1996-02-16 05:08:48 +08:00
|
|
|
if (replacedList) free(replacedList);
|
1997-05-06 04:46:58 +08:00
|
|
|
if (freeFileMem) freeFileMemory(fileMem);
|
1996-01-15 03:32:17 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1996-11-19 02:02:36 +08:00
|
|
|
rpmMessage(RPMMESS_DEBUG, "running preinstall script (if any)\n");
|
1997-07-16 09:44:27 +08:00
|
|
|
if (runScript("/", h, RPMTAG_PREIN, RPMTAG_PREINPROG, scriptArg,
|
1996-11-19 02:02:36 +08:00
|
|
|
flags & RPMINSTALL_NOSCRIPTS)) {
|
1996-02-16 05:08:48 +08:00
|
|
|
if (replacedList) free(replacedList);
|
1997-05-06 04:46:58 +08:00
|
|
|
if (freeFileMem) freeFileMemory(fileMem);
|
1997-07-16 09:44:27 +08:00
|
|
|
|
|
|
|
if (rootdir) {
|
|
|
|
chroot(".");
|
1997-07-18 03:18:15 +08:00
|
|
|
chdir(currDir);
|
1997-07-16 09:44:27 +08:00
|
|
|
}
|
|
|
|
|
1996-01-09 03:31:44 +08:00
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
1997-05-06 04:46:58 +08:00
|
|
|
if (files) {
|
1996-01-23 05:13:12 +08:00
|
|
|
for (i = 0; i < fileCount; i++) {
|
1997-05-06 04:46:58 +08:00
|
|
|
switch (files[i].action) {
|
1996-01-30 03:37:59 +08:00
|
|
|
case BACKUP:
|
|
|
|
ext = ".rpmorig";
|
|
|
|
installFile = 1;
|
|
|
|
break;
|
|
|
|
|
1997-06-19 04:45:17 +08:00
|
|
|
case ALTNAME:
|
|
|
|
ext = NULL;
|
|
|
|
installFile = 1;
|
|
|
|
|
1997-07-16 09:44:27 +08:00
|
|
|
newpath = alloca(strlen(files[i].relativePath) + 20);
|
|
|
|
strcpy(newpath, files[i].relativePath);
|
1997-06-19 04:45:17 +08:00
|
|
|
strcat(newpath, ".rpmnew");
|
|
|
|
rpmError(RPMMESS_ALTNAME, "warning: %s created as %s",
|
1997-07-16 09:44:27 +08:00
|
|
|
files[i].relativePath, newpath);
|
|
|
|
files[i].relativePath = newpath;
|
1997-06-19 04:45:17 +08:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
1996-01-30 03:37:59 +08:00
|
|
|
case SAVE:
|
|
|
|
ext = ".rpmsave";
|
|
|
|
installFile = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CREATE:
|
|
|
|
installFile = 1;
|
|
|
|
ext = NULL;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case KEEP:
|
|
|
|
installFile = 0;
|
1996-03-30 04:52:03 +08:00
|
|
|
ext = NULL;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SKIP:
|
|
|
|
installFile = 0;
|
1996-01-30 03:37:59 +08:00
|
|
|
ext = NULL;
|
|
|
|
break;
|
1997-05-06 04:46:58 +08:00
|
|
|
|
|
|
|
case UNKNOWN:
|
|
|
|
break;
|
1996-01-30 03:37:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (ext) {
|
1997-07-16 09:44:27 +08:00
|
|
|
newpath = alloca(strlen(files[i].relativePath) + 20);
|
|
|
|
strcpy(newpath, files[i].relativePath);
|
1996-01-30 03:37:59 +08:00
|
|
|
strcat(newpath, ext);
|
1996-11-19 02:02:36 +08:00
|
|
|
rpmError(RPMMESS_BACKUP, "warning: %s saved as %s",
|
1997-07-16 09:44:27 +08:00
|
|
|
files[i].relativePath, newpath);
|
1996-01-30 03:37:59 +08:00
|
|
|
|
1997-07-16 09:44:27 +08:00
|
|
|
if (rename(files[i].relativePath, newpath)) {
|
1996-11-19 02:02:36 +08:00
|
|
|
rpmError(RPMERR_RENAME, "rename of %s to %s failed: %s",
|
1997-07-16 09:44:27 +08:00
|
|
|
files[i].relativePath, newpath, strerror(errno));
|
1996-02-16 05:08:48 +08:00
|
|
|
if (replacedList) free(replacedList);
|
1997-05-06 04:46:58 +08:00
|
|
|
if (freeFileMem) freeFileMemory(fileMem);
|
1997-07-16 09:44:27 +08:00
|
|
|
|
|
|
|
if (rootdir) {
|
|
|
|
chroot(".");
|
1997-07-18 03:18:15 +08:00
|
|
|
chdir(currDir);
|
1997-07-16 09:44:27 +08:00
|
|
|
}
|
|
|
|
|
1996-04-16 05:09:40 +08:00
|
|
|
return 2;
|
1996-01-30 03:37:59 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1997-05-06 04:46:58 +08:00
|
|
|
if (!installFile) {
|
|
|
|
files[i].install = 0;
|
1996-01-30 03:37:59 +08:00
|
|
|
}
|
1996-01-23 05:13:12 +08:00
|
|
|
}
|
|
|
|
|
1996-07-26 00:39:01 +08:00
|
|
|
if (rootdir) {
|
1997-01-24 03:17:35 +08:00
|
|
|
tmpPath = alloca(strlen(rootdir) +
|
|
|
|
strlen(rpmGetVar(RPMVAR_TMPPATH)) + 20);
|
1996-07-26 00:39:01 +08:00
|
|
|
strcpy(tmpPath, rootdir);
|
1996-11-19 02:02:36 +08:00
|
|
|
strcat(tmpPath, rpmGetVar(RPMVAR_TMPPATH));
|
1996-07-26 00:39:01 +08:00
|
|
|
} else
|
1996-11-19 02:02:36 +08:00
|
|
|
tmpPath = rpmGetVar(RPMVAR_TMPPATH);
|
1996-07-26 00:39:01 +08:00
|
|
|
|
1997-05-06 04:46:58 +08:00
|
|
|
if (!headerGetEntry(h, RPMTAG_ARCHIVESIZE, &type,
|
|
|
|
(void *) &archiveSizePtr, &count))
|
1996-08-29 12:16:07 +08:00
|
|
|
archiveSizePtr = NULL;
|
|
|
|
|
1997-02-12 13:05:13 +08:00
|
|
|
if (labelFormat) {
|
|
|
|
printf(labelFormat, name, version, release);
|
|
|
|
fflush(stdout);
|
|
|
|
}
|
|
|
|
|
1996-01-15 03:32:17 +08:00
|
|
|
/* the file pointer for fd is pointing at the cpio archive */
|
1997-05-07 02:19:19 +08:00
|
|
|
if (installArchive(fd, files, fileCount, notify,
|
1997-05-06 04:46:58 +08:00
|
|
|
NULL, archiveSizePtr ? *archiveSizePtr : 0)) {
|
1996-11-19 02:02:36 +08:00
|
|
|
headerFree(h);
|
1996-02-16 05:08:48 +08:00
|
|
|
if (replacedList) free(replacedList);
|
1997-05-06 04:46:58 +08:00
|
|
|
if (freeFileMem) freeFileMemory(fileMem);
|
1997-07-16 09:44:27 +08:00
|
|
|
|
|
|
|
if (rootdir) {
|
|
|
|
chroot(".");
|
1997-07-18 03:18:15 +08:00
|
|
|
chdir(currDir);
|
1997-07-16 09:44:27 +08:00
|
|
|
}
|
|
|
|
|
1996-01-15 03:32:17 +08:00
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
1997-05-06 04:46:58 +08:00
|
|
|
if (files) {
|
|
|
|
fileStates = malloc(sizeof(*fileStates) * fileCount);
|
|
|
|
for (i = 0; i < fileCount; i++)
|
|
|
|
fileStates[i] = files[i].state;
|
1996-02-16 05:08:48 +08:00
|
|
|
|
1997-05-06 04:46:58 +08:00
|
|
|
headerAddEntry(h, RPMTAG_FILESTATES, RPM_CHAR_TYPE, fileStates,
|
|
|
|
fileCount);
|
1996-01-15 03:32:17 +08:00
|
|
|
|
1997-05-06 04:46:58 +08:00
|
|
|
free(fileStates);
|
|
|
|
if (freeFileMem) freeFileMemory(fileMem);
|
|
|
|
}
|
1996-01-09 03:31:44 +08:00
|
|
|
|
1996-01-30 03:37:59 +08:00
|
|
|
installTime = time(NULL);
|
1996-11-19 02:02:36 +08:00
|
|
|
headerAddEntry(h, RPMTAG_INSTALLTIME, RPM_INT32_TYPE, &installTime, 1);
|
1996-01-09 03:31:44 +08:00
|
|
|
}
|
|
|
|
|
1997-07-16 09:44:27 +08:00
|
|
|
if (rootdir) {
|
|
|
|
chroot(".");
|
1997-07-18 03:18:15 +08:00
|
|
|
chdir(currDir);
|
1997-07-16 09:44:27 +08:00
|
|
|
}
|
|
|
|
|
1996-02-16 05:08:48 +08:00
|
|
|
if (replacedList) {
|
|
|
|
rc = markReplacedFiles(db, replacedList);
|
|
|
|
free(replacedList);
|
|
|
|
|
|
|
|
if (rc) return rc;
|
|
|
|
}
|
|
|
|
|
1996-02-15 05:26:21 +08:00
|
|
|
/* if this package has already been installed, remove it from the database
|
|
|
|
before adding the new one */
|
|
|
|
if (otherOffset) {
|
|
|
|
rpmdbRemove(db, otherOffset, 1);
|
|
|
|
}
|
|
|
|
|
1996-01-09 03:31:44 +08:00
|
|
|
if (rpmdbAdd(db, h)) {
|
1996-11-19 02:02:36 +08:00
|
|
|
headerFree(h);
|
1996-01-09 03:31:44 +08:00
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
1996-11-19 02:02:36 +08:00
|
|
|
rpmMessage(RPMMESS_DEBUG, "running postinstall script (if any)\n");
|
1996-01-30 03:37:59 +08:00
|
|
|
|
1997-07-14 22:48:38 +08:00
|
|
|
if (runScript(rootdir, h, RPMTAG_POSTIN, RPMTAG_POSTINPROG, scriptArg,
|
1996-11-19 02:02:36 +08:00
|
|
|
flags & RPMINSTALL_NOSCRIPTS)) {
|
1996-04-16 05:09:40 +08:00
|
|
|
return 2;
|
1996-01-30 03:37:59 +08:00
|
|
|
}
|
|
|
|
|
1996-11-19 02:02:36 +08:00
|
|
|
if (flags & RPMINSTALL_UPGRADE) {
|
|
|
|
rpmMessage(RPMMESS_DEBUG, "removing old versions of package\n");
|
1996-02-21 05:54:02 +08:00
|
|
|
intptr = oldVersions;
|
|
|
|
while (*intptr) {
|
1996-07-10 10:33:38 +08:00
|
|
|
rpmRemovePackage(rootdir, db, *intptr, 0);
|
1996-02-21 05:54:02 +08:00
|
|
|
intptr++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1996-11-19 02:02:36 +08:00
|
|
|
headerFree(h);
|
1996-08-31 03:17:33 +08:00
|
|
|
|
1996-01-09 03:31:44 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1997-05-06 23:27:46 +08:00
|
|
|
static void callback(struct cpioCallbackInfo * cpioInfo, void * data) {
|
|
|
|
struct callbackInfo * ourInfo = data;
|
1997-05-07 02:19:19 +08:00
|
|
|
char * chptr;
|
1997-05-06 23:27:46 +08:00
|
|
|
|
1997-05-07 02:19:19 +08:00
|
|
|
if (ourInfo->notify)
|
|
|
|
ourInfo->notify(cpioInfo->bytesProcessed, ourInfo->archiveSize);
|
|
|
|
|
|
|
|
if (ourInfo->specFilePtr) {
|
|
|
|
chptr = cpioInfo->file + strlen(cpioInfo->file) - 5;
|
|
|
|
if (!strcmp(chptr, ".spec"))
|
|
|
|
*ourInfo->specFilePtr = strdup(cpioInfo->file);
|
|
|
|
}
|
1997-05-06 23:27:46 +08:00
|
|
|
}
|
1996-01-09 03:31:44 +08:00
|
|
|
|
1997-05-06 04:46:58 +08:00
|
|
|
/* NULL files means install all files */
|
1997-05-07 02:19:19 +08:00
|
|
|
static int installArchive(int fd, struct fileInfo * files,
|
1996-11-19 02:02:36 +08:00
|
|
|
int fileCount, rpmNotifyFunction notify,
|
1997-05-06 04:46:58 +08:00
|
|
|
char ** specFile, int archiveSize) {
|
1996-01-09 03:31:44 +08:00
|
|
|
gzFile stream;
|
1997-05-06 04:46:58 +08:00
|
|
|
int rc, i;
|
1997-05-07 02:19:19 +08:00
|
|
|
struct cpioFileMapping * map = NULL;
|
1997-07-14 22:48:38 +08:00
|
|
|
int mappedFiles = 0;
|
1997-05-06 04:46:58 +08:00
|
|
|
char * failedFile;
|
1997-05-06 23:27:46 +08:00
|
|
|
struct callbackInfo info;
|
1997-05-06 04:46:58 +08:00
|
|
|
|
|
|
|
if (!files) {
|
|
|
|
/* install all files */
|
|
|
|
fileCount = 0;
|
|
|
|
} else if (!fileCount) {
|
|
|
|
/* no files to install */
|
|
|
|
return 0;
|
1996-01-09 03:31:44 +08:00
|
|
|
}
|
|
|
|
|
1997-05-06 23:27:46 +08:00
|
|
|
info.archiveSize = archiveSize;
|
|
|
|
info.notify = notify;
|
1997-05-07 02:19:19 +08:00
|
|
|
info.specFilePtr = specFile;
|
1997-05-06 23:27:46 +08:00
|
|
|
|
1997-05-06 04:46:58 +08:00
|
|
|
if (specFile) *specFile = NULL;
|
1996-01-09 03:31:44 +08:00
|
|
|
|
1997-05-07 02:19:19 +08:00
|
|
|
if (files) {
|
|
|
|
map = alloca(sizeof(*map) * fileCount);
|
1997-05-23 23:18:15 +08:00
|
|
|
for (i = 0, mappedFiles = 0; i < fileCount; i++) {
|
|
|
|
if (!files[i].install) continue;
|
|
|
|
|
|
|
|
map[mappedFiles].archivePath = files[i].cpioPath;
|
1997-07-24 02:08:51 +08:00
|
|
|
map[mappedFiles].fsPath = files[i].relativePath;
|
1997-05-23 23:18:15 +08:00
|
|
|
map[mappedFiles].finalMode = files[i].mode;
|
|
|
|
map[mappedFiles].finalUid = files[i].uid;
|
|
|
|
map[mappedFiles].finalGid = files[i].gid;
|
|
|
|
map[mappedFiles].mapFlags = CPIO_MAP_PATH | CPIO_MAP_MODE |
|
|
|
|
CPIO_MAP_UID | CPIO_MAP_GID;
|
|
|
|
mappedFiles++;
|
1997-05-07 02:19:19 +08:00
|
|
|
}
|
|
|
|
|
1997-05-23 23:18:15 +08:00
|
|
|
qsort(map, mappedFiles, sizeof(*map), cpioFileMapCmp);
|
1996-01-23 05:13:12 +08:00
|
|
|
}
|
1996-01-09 03:31:44 +08:00
|
|
|
|
1997-05-06 04:46:58 +08:00
|
|
|
if (notify)
|
|
|
|
notify(0, archiveSize);
|
1996-11-23 06:24:59 +08:00
|
|
|
|
1997-05-06 04:46:58 +08:00
|
|
|
stream = gzdopen(fd, "r");
|
1997-05-23 23:18:15 +08:00
|
|
|
rc = cpioInstallArchive(stream, map, mappedFiles,
|
1997-05-07 02:19:19 +08:00
|
|
|
((notify && archiveSize) || specFile) ?
|
|
|
|
callback : NULL,
|
1997-05-06 23:27:46 +08:00
|
|
|
&info, &failedFile);
|
1996-05-07 11:21:44 +08:00
|
|
|
|
1997-05-06 04:46:58 +08:00
|
|
|
if (rc) {
|
1996-01-09 03:31:44 +08:00
|
|
|
/* this would probably be a good place to check if disk space
|
|
|
|
was used up - if so, we should return a different error */
|
1997-05-06 23:27:46 +08:00
|
|
|
rpmError(RPMERR_CPIO, "unpacking of archive failed on file %s: %d: %s",
|
|
|
|
failedFile, rc, strerror(errno));
|
1996-01-09 03:31:44 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
1997-05-06 23:27:46 +08:00
|
|
|
if (notify && archiveSize)
|
1997-05-06 04:46:58 +08:00
|
|
|
notify(archiveSize, archiveSize);
|
1997-05-06 23:27:46 +08:00
|
|
|
else if (notify) {
|
|
|
|
notify(100, 100);
|
|
|
|
}
|
1996-01-23 05:13:12 +08:00
|
|
|
|
1996-01-09 03:31:44 +08:00
|
|
|
return 0;
|
|
|
|
}
|
1996-01-15 03:32:17 +08:00
|
|
|
|
|
|
|
static int packageAlreadyInstalled(rpmdb db, char * name, char * version,
|
1996-02-15 05:26:21 +08:00
|
|
|
char * release, int * offset, int flags) {
|
1996-01-15 03:32:17 +08:00
|
|
|
char * secVersion, * secRelease;
|
|
|
|
Header sech;
|
|
|
|
int i;
|
1996-11-19 02:02:36 +08:00
|
|
|
dbiIndexSet matches;
|
1996-01-15 03:32:17 +08:00
|
|
|
int type, count;
|
|
|
|
|
|
|
|
if (!rpmdbFindPackage(db, name, &matches)) {
|
|
|
|
for (i = 0; i < matches.count; i++) {
|
|
|
|
sech = rpmdbGetRecord(db, matches.recs[i].recOffset);
|
|
|
|
if (!sech) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
1996-11-19 02:02:36 +08:00
|
|
|
headerGetEntry(sech, RPMTAG_VERSION, &type, (void **) &secVersion,
|
1996-01-15 03:32:17 +08:00
|
|
|
&count);
|
1996-11-19 02:02:36 +08:00
|
|
|
headerGetEntry(sech, RPMTAG_RELEASE, &type, (void **) &secRelease,
|
1996-01-15 03:32:17 +08:00
|
|
|
&count);
|
|
|
|
|
|
|
|
if (!strcmp(secVersion, version) && !strcmp(secRelease, release)) {
|
1996-02-15 05:26:21 +08:00
|
|
|
*offset = matches.recs[i].recOffset;
|
1996-11-19 02:02:36 +08:00
|
|
|
if (!(flags & RPMINSTALL_REPLACEPKG)) {
|
|
|
|
rpmError(RPMERR_PKGINSTALLED,
|
1996-01-15 03:32:17 +08:00
|
|
|
"package %s-%s-%s is already installed",
|
|
|
|
name, version, release);
|
1996-11-19 02:02:36 +08:00
|
|
|
headerFree(sech);
|
1996-01-15 03:32:17 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
1996-02-20 06:15:38 +08:00
|
|
|
|
1996-11-19 02:02:36 +08:00
|
|
|
headerFree(sech);
|
1996-01-15 03:32:17 +08:00
|
|
|
}
|
1996-12-06 12:07:28 +08:00
|
|
|
|
|
|
|
dbiFreeIndexRecord(matches);
|
1996-01-15 03:32:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1996-09-26 03:14:17 +08:00
|
|
|
static int filecmp(short mode1, char * md51, char * link1,
|
|
|
|
short mode2, char * md52, char * link2) {
|
1996-02-29 11:38:33 +08:00
|
|
|
enum fileTypes what1, what2;
|
|
|
|
|
|
|
|
what1 = whatis(mode1);
|
|
|
|
what2 = whatis(mode2);
|
|
|
|
|
|
|
|
if (what1 != what2) return 1;
|
|
|
|
|
|
|
|
if (what1 == LINK)
|
|
|
|
return strcmp(link1, link2);
|
|
|
|
else if (what1 == REG)
|
|
|
|
return strcmp(md51, md52);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1996-09-26 03:14:17 +08:00
|
|
|
static enum instActions decideFileFate(char * filespec, short dbMode,
|
1996-09-29 10:27:20 +08:00
|
|
|
char * dbMd5, char * dbLink, short newMode,
|
1997-06-17 23:37:28 +08:00
|
|
|
char * newMd5, char * newLink, int newFlags,
|
|
|
|
int instFlags, int brokenMd5) {
|
1996-02-29 11:38:33 +08:00
|
|
|
char buffer[1024];
|
|
|
|
char * dbAttr, * newAttr;
|
|
|
|
enum fileTypes dbWhat, newWhat, diskWhat;
|
|
|
|
struct stat sb;
|
1996-09-01 02:35:40 +08:00
|
|
|
int i, rc;
|
1996-02-29 11:38:33 +08:00
|
|
|
|
|
|
|
if (lstat(filespec, &sb)) {
|
1997-06-17 23:37:28 +08:00
|
|
|
/* the file doesn't exist on the disk create it unless the new
|
|
|
|
package has marked it as missingok */
|
|
|
|
if (!(instFlags & RPMINSTALL_ALLFILES) &&
|
|
|
|
(newFlags & RPMFILE_MISSINGOK)) {
|
|
|
|
rpmMessage(RPMMESS_DEBUG, "%s skipped due to missingok flag\n",
|
|
|
|
filespec);
|
|
|
|
return SKIP;
|
|
|
|
} else
|
|
|
|
return CREATE;
|
1996-02-29 11:38:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
diskWhat = whatis(sb.st_mode);
|
|
|
|
dbWhat = whatis(dbMode);
|
|
|
|
newWhat = whatis(newMode);
|
|
|
|
|
1997-04-15 22:42:12 +08:00
|
|
|
/* RPM >= 2.3.10 shouldn't create config directories -- we'll ignore
|
|
|
|
them in older packages as well */
|
|
|
|
if (newWhat == XDIR)
|
|
|
|
return CREATE;
|
|
|
|
|
1996-02-29 11:38:33 +08:00
|
|
|
if (diskWhat != newWhat) {
|
1997-06-19 04:45:17 +08:00
|
|
|
rpmMessage(RPMMESS_DEBUG,
|
|
|
|
"\tfile type on disk is different then package - saving\n");
|
1996-02-29 11:38:33 +08:00
|
|
|
return SAVE;
|
|
|
|
} else if (newWhat != dbWhat && diskWhat != dbWhat) {
|
1997-06-19 04:45:17 +08:00
|
|
|
rpmMessage(RPMMESS_DEBUG, "\tfile type in database is different then "
|
|
|
|
"disk and package file - saving\n");
|
1996-02-29 11:38:33 +08:00
|
|
|
return SAVE;
|
|
|
|
} else if (dbWhat != newWhat) {
|
1997-06-19 04:45:17 +08:00
|
|
|
rpmMessage(RPMMESS_DEBUG, "\tfile type changed - replacing\n");
|
1996-02-29 11:38:33 +08:00
|
|
|
return CREATE;
|
|
|
|
} else if (dbWhat != LINK && dbWhat != REG) {
|
1997-06-19 04:45:17 +08:00
|
|
|
rpmMessage(RPMMESS_DEBUG,
|
|
|
|
"\tcan't check file for changes - replacing\n");
|
1996-02-29 11:38:33 +08:00
|
|
|
return CREATE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dbWhat == REG) {
|
1996-09-01 02:35:40 +08:00
|
|
|
if (brokenMd5)
|
|
|
|
rc = mdfileBroken(filespec, buffer);
|
|
|
|
else
|
|
|
|
rc = mdfile(filespec, buffer);
|
|
|
|
|
|
|
|
if (rc) {
|
1996-02-29 11:38:33 +08:00
|
|
|
/* assume the file has been removed, don't freak */
|
1996-11-19 02:02:36 +08:00
|
|
|
rpmMessage(RPMMESS_DEBUG, " file not present - creating");
|
1996-02-29 11:38:33 +08:00
|
|
|
return CREATE;
|
|
|
|
}
|
|
|
|
dbAttr = dbMd5;
|
|
|
|
newAttr = newMd5;
|
|
|
|
} else /* dbWhat == LINK */ {
|
1996-08-09 00:46:15 +08:00
|
|
|
memset(buffer, 0, sizeof(buffer));
|
1996-02-29 11:38:33 +08:00
|
|
|
i = readlink(filespec, buffer, sizeof(buffer) - 1);
|
|
|
|
if (i == -1) {
|
|
|
|
/* assume the file has been removed, don't freak */
|
1996-11-19 02:02:36 +08:00
|
|
|
rpmMessage(RPMMESS_DEBUG, " file not present - creating");
|
1996-02-29 11:38:33 +08:00
|
|
|
return CREATE;
|
|
|
|
}
|
|
|
|
dbAttr = dbLink;
|
|
|
|
newAttr = newLink;
|
|
|
|
}
|
|
|
|
|
1996-09-01 02:35:40 +08:00
|
|
|
/* this order matters - we'd prefer to CREATE the file if at all
|
1996-03-01 09:59:26 +08:00
|
|
|
possible in case something else (like the timestamp) has changed */
|
1996-02-29 11:38:33 +08:00
|
|
|
|
|
|
|
if (!strcmp(dbAttr, buffer)) {
|
|
|
|
/* this config file has never been modified, so
|
|
|
|
just replace it */
|
1996-11-19 02:02:36 +08:00
|
|
|
rpmMessage(RPMMESS_DEBUG, " old == current, replacing "
|
1996-02-29 11:38:33 +08:00
|
|
|
"with new version\n");
|
|
|
|
return CREATE;
|
|
|
|
}
|
|
|
|
|
1996-03-01 09:59:26 +08:00
|
|
|
if (!strcmp(dbAttr, newAttr)) {
|
|
|
|
/* this file is the same in all versions of this package */
|
1996-11-19 02:02:36 +08:00
|
|
|
rpmMessage(RPMMESS_DEBUG, " old == new, keeping\n");
|
1996-03-01 09:59:26 +08:00
|
|
|
return KEEP;
|
|
|
|
}
|
|
|
|
|
1996-02-29 11:38:33 +08:00
|
|
|
/* the config file on the disk has been modified, but
|
|
|
|
the ones in the two packages are different. It would
|
|
|
|
be nice if RPM was smart enough to at least try and
|
|
|
|
merge the difference ala CVS, but... */
|
1996-11-19 02:02:36 +08:00
|
|
|
rpmMessage(RPMMESS_DEBUG, " files changed too much - backing up\n");
|
1996-02-29 11:38:33 +08:00
|
|
|
|
|
|
|
return SAVE;
|
|
|
|
}
|
|
|
|
|
1996-01-23 05:13:12 +08:00
|
|
|
/* return 0: okay, continue install */
|
|
|
|
/* return 1: problem, halt install */
|
|
|
|
|
1997-05-06 04:46:58 +08:00
|
|
|
static int instHandleSharedFiles(rpmdb db, int ignoreOffset,
|
|
|
|
struct fileInfo * files,
|
|
|
|
int fileCount, int * notErrors,
|
1996-02-16 05:08:48 +08:00
|
|
|
struct replacedFile ** repListPtr, int flags) {
|
1996-01-23 05:13:12 +08:00
|
|
|
struct sharedFile * sharedList;
|
1996-02-29 11:38:33 +08:00
|
|
|
int secNum, mainNum;
|
1996-01-23 05:13:12 +08:00
|
|
|
int sharedCount;
|
|
|
|
int i, type;
|
1996-02-21 05:54:02 +08:00
|
|
|
int * intptr;
|
|
|
|
Header sech = NULL;
|
1996-01-23 05:13:12 +08:00
|
|
|
int secOffset = 0;
|
|
|
|
int secFileCount;
|
1996-02-29 11:38:33 +08:00
|
|
|
char ** secFileMd5List, ** secFileList, ** secFileLinksList;
|
1996-01-23 05:13:12 +08:00
|
|
|
char * secFileStatesList;
|
1996-02-29 11:38:33 +08:00
|
|
|
int_16 * secFileModesList;
|
1996-01-30 03:37:59 +08:00
|
|
|
uint_32 * secFileFlagsList;
|
1996-01-23 05:13:12 +08:00
|
|
|
char * name, * version, * release;
|
|
|
|
int rc = 0;
|
1996-02-16 05:08:48 +08:00
|
|
|
struct replacedFile * replacedList;
|
|
|
|
int numReplacedFiles, numReplacedAlloced;
|
1996-10-21 10:17:39 +08:00
|
|
|
char state;
|
1997-05-06 04:46:58 +08:00
|
|
|
char ** fileList;
|
|
|
|
|
|
|
|
fileList = malloc(sizeof(*fileList) * fileCount);
|
|
|
|
for (i = 0; i < fileCount; i++)
|
1997-07-16 09:44:27 +08:00
|
|
|
fileList[i] = files[i].relativePath;
|
1996-01-23 05:13:12 +08:00
|
|
|
|
|
|
|
if (findSharedFiles(db, 0, fileList, fileCount, &sharedList,
|
|
|
|
&sharedCount)) {
|
1997-05-06 04:46:58 +08:00
|
|
|
free(fileList);
|
1996-01-23 05:13:12 +08:00
|
|
|
return 1;
|
|
|
|
}
|
1997-05-06 04:46:58 +08:00
|
|
|
free(fileList);
|
1996-01-23 05:13:12 +08:00
|
|
|
|
1996-02-16 05:08:48 +08:00
|
|
|
numReplacedAlloced = 10;
|
|
|
|
numReplacedFiles = 0;
|
|
|
|
replacedList = malloc(sizeof(*replacedList) * numReplacedAlloced);
|
|
|
|
|
1996-01-23 05:13:12 +08:00
|
|
|
for (i = 0; i < sharedCount; i++) {
|
1997-05-27 22:01:45 +08:00
|
|
|
/* if a file isn't going to be installed it doesn't matter who
|
|
|
|
it's shared with */
|
1997-06-17 02:13:23 +08:00
|
|
|
if (!files[sharedList[i].mainFileNumber].action == SKIP) continue;
|
1997-05-27 22:01:45 +08:00
|
|
|
|
1996-01-23 05:13:12 +08:00
|
|
|
if (secOffset != sharedList[i].secRecOffset) {
|
|
|
|
if (secOffset) {
|
1996-11-19 02:02:36 +08:00
|
|
|
headerFree(sech);
|
1996-01-23 05:13:12 +08:00
|
|
|
free(secFileMd5List);
|
1996-02-29 11:38:33 +08:00
|
|
|
free(secFileLinksList);
|
1996-01-23 05:13:12 +08:00
|
|
|
free(secFileList);
|
|
|
|
}
|
|
|
|
|
|
|
|
secOffset = sharedList[i].secRecOffset;
|
|
|
|
sech = rpmdbGetRecord(db, secOffset);
|
|
|
|
if (!sech) {
|
1996-11-19 02:02:36 +08:00
|
|
|
rpmError(RPMERR_DBCORRUPT, "cannot read header at %d for "
|
1996-01-23 05:13:12 +08:00
|
|
|
"uninstall", secOffset);
|
|
|
|
rc = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
1996-11-19 02:02:36 +08:00
|
|
|
headerGetEntry(sech, RPMTAG_NAME, &type, (void **) &name,
|
1996-01-23 05:13:12 +08:00
|
|
|
&secFileCount);
|
1996-11-19 02:02:36 +08:00
|
|
|
headerGetEntry(sech, RPMTAG_VERSION, &type, (void **) &version,
|
1996-01-23 05:13:12 +08:00
|
|
|
&secFileCount);
|
1996-11-19 02:02:36 +08:00
|
|
|
headerGetEntry(sech, RPMTAG_RELEASE, &type, (void **) &release,
|
1996-01-23 05:13:12 +08:00
|
|
|
&secFileCount);
|
|
|
|
|
1996-11-19 02:02:36 +08:00
|
|
|
rpmMessage(RPMMESS_DEBUG, "package %s-%s-%s contain shared files\n",
|
1996-01-23 05:13:12 +08:00
|
|
|
name, version, release);
|
|
|
|
|
1996-11-19 02:02:36 +08:00
|
|
|
if (!headerGetEntry(sech, RPMTAG_FILENAMES, &type,
|
1996-01-23 05:13:12 +08:00
|
|
|
(void **) &secFileList, &secFileCount)) {
|
1996-11-19 02:02:36 +08:00
|
|
|
rpmError(RPMERR_DBCORRUPT, "package %s contains no files",
|
1996-01-23 05:13:12 +08:00
|
|
|
name);
|
1996-11-19 02:02:36 +08:00
|
|
|
headerFree(sech);
|
1996-01-23 05:13:12 +08:00
|
|
|
rc = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
1996-11-19 02:02:36 +08:00
|
|
|
headerGetEntry(sech, RPMTAG_FILESTATES, &type,
|
1996-01-23 05:13:12 +08:00
|
|
|
(void **) &secFileStatesList, &secFileCount);
|
1996-11-19 02:02:36 +08:00
|
|
|
headerGetEntry(sech, RPMTAG_FILEMD5S, &type,
|
1996-01-23 05:13:12 +08:00
|
|
|
(void **) &secFileMd5List, &secFileCount);
|
1996-11-19 02:02:36 +08:00
|
|
|
headerGetEntry(sech, RPMTAG_FILEFLAGS, &type,
|
1996-01-30 03:37:59 +08:00
|
|
|
(void **) &secFileFlagsList, &secFileCount);
|
1996-11-19 02:02:36 +08:00
|
|
|
headerGetEntry(sech, RPMTAG_FILELINKTOS, &type,
|
1996-02-29 11:38:33 +08:00
|
|
|
(void **) &secFileLinksList, &secFileCount);
|
1996-11-19 02:02:36 +08:00
|
|
|
headerGetEntry(sech, RPMTAG_FILEMODES, &type,
|
1996-02-29 11:38:33 +08:00
|
|
|
(void **) &secFileModesList, &secFileCount);
|
1996-01-23 05:13:12 +08:00
|
|
|
}
|
|
|
|
|
1996-02-29 11:38:33 +08:00
|
|
|
secNum = sharedList[i].secFileNumber;
|
|
|
|
mainNum = sharedList[i].mainFileNumber;
|
1996-01-30 03:37:59 +08:00
|
|
|
|
1996-11-19 02:02:36 +08:00
|
|
|
rpmMessage(RPMMESS_DEBUG, "file %s is shared\n", secFileList[secNum]);
|
1996-02-24 00:21:06 +08:00
|
|
|
|
1996-02-21 05:54:02 +08:00
|
|
|
intptr = notErrors;
|
|
|
|
while (*intptr) {
|
|
|
|
if (*intptr == sharedList[i].secRecOffset) break;
|
|
|
|
intptr++;
|
|
|
|
}
|
|
|
|
|
1996-01-30 03:37:59 +08:00
|
|
|
/* if this instance of the shared file is already recorded as
|
|
|
|
replaced, just forget about it */
|
1996-10-21 10:17:39 +08:00
|
|
|
state = secFileStatesList[sharedList[i].secFileNumber];
|
|
|
|
if (state == RPMFILE_STATE_REPLACED) {
|
1996-11-19 02:02:36 +08:00
|
|
|
rpmMessage(RPMMESS_DEBUG, " old version already replaced\n");
|
1996-01-30 03:37:59 +08:00
|
|
|
continue;
|
1996-10-21 10:17:39 +08:00
|
|
|
} else if (state == RPMFILE_STATE_NOTINSTALLED) {
|
1996-11-19 02:02:36 +08:00
|
|
|
rpmMessage(RPMMESS_DEBUG, " other version never installed\n");
|
1996-03-30 04:52:03 +08:00
|
|
|
continue;
|
1996-01-30 03:37:59 +08:00
|
|
|
}
|
|
|
|
|
1997-05-06 04:46:58 +08:00
|
|
|
if (filecmp(files[mainNum].mode, files[mainNum].md5,
|
|
|
|
files[mainNum].link, secFileModesList[secNum],
|
1996-02-29 11:38:33 +08:00
|
|
|
secFileMd5List[secNum], secFileLinksList[secNum])) {
|
1996-11-19 02:02:36 +08:00
|
|
|
if (!(flags & RPMINSTALL_REPLACEFILES) && !(*intptr)) {
|
|
|
|
rpmError(RPMERR_PKGINSTALLED, "%s conflicts with file from "
|
1997-05-06 04:46:58 +08:00
|
|
|
"%s-%s-%s",
|
|
|
|
files[sharedList[i].mainFileNumber].relativePath,
|
|
|
|
name, version, release);
|
1996-02-29 11:38:33 +08:00
|
|
|
rc = 1;
|
1996-01-30 03:37:59 +08:00
|
|
|
} else {
|
1996-02-29 11:38:33 +08:00
|
|
|
if (numReplacedFiles == numReplacedAlloced) {
|
|
|
|
numReplacedAlloced += 10;
|
|
|
|
replacedList = realloc(replacedList,
|
|
|
|
sizeof(*replacedList) *
|
|
|
|
numReplacedAlloced);
|
1996-01-30 03:37:59 +08:00
|
|
|
}
|
1996-02-29 11:38:33 +08:00
|
|
|
|
|
|
|
replacedList[numReplacedFiles].recOffset =
|
|
|
|
sharedList[i].secRecOffset;
|
|
|
|
replacedList[numReplacedFiles].fileNumber =
|
|
|
|
sharedList[i].secFileNumber;
|
|
|
|
numReplacedFiles++;
|
|
|
|
|
1996-11-19 02:02:36 +08:00
|
|
|
rpmMessage(RPMMESS_DEBUG, "%s from %s-%s-%s will be replaced\n",
|
1997-05-06 04:46:58 +08:00
|
|
|
files[sharedList[i].mainFileNumber].relativePath,
|
1996-02-29 11:38:33 +08:00
|
|
|
name, version, release);
|
1996-01-30 03:37:59 +08:00
|
|
|
}
|
|
|
|
}
|
1996-02-29 11:38:33 +08:00
|
|
|
|
|
|
|
/* if this is a config file, we need to be carefull here */
|
1997-05-06 04:46:58 +08:00
|
|
|
if (files[sharedList[i].mainFileNumber].flags & RPMFILE_CONFIG ||
|
1996-07-28 07:35:07 +08:00
|
|
|
secFileFlagsList[sharedList[i].secFileNumber] & RPMFILE_CONFIG) {
|
1997-05-06 04:46:58 +08:00
|
|
|
files[sharedList[i].mainFileNumber].action =
|
1997-07-16 09:44:27 +08:00
|
|
|
decideFileFate(files[mainNum].relativePath,
|
1996-08-01 02:45:22 +08:00
|
|
|
secFileModesList[secNum],
|
1996-02-29 11:38:33 +08:00
|
|
|
secFileMd5List[secNum], secFileLinksList[secNum],
|
1997-05-06 04:46:58 +08:00
|
|
|
files[mainNum].mode, files[mainNum].md5,
|
|
|
|
files[mainNum].link,
|
1997-06-17 23:37:28 +08:00
|
|
|
files[sharedList[i].mainFileNumber].flags,
|
|
|
|
flags,
|
1996-11-19 02:02:36 +08:00
|
|
|
!headerIsEntry(sech, RPMTAG_RPMVERSION));
|
1996-02-29 11:38:33 +08:00
|
|
|
}
|
1996-01-23 05:13:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (secOffset) {
|
1996-11-19 02:02:36 +08:00
|
|
|
headerFree(sech);
|
1996-01-23 05:13:12 +08:00
|
|
|
free(secFileMd5List);
|
1996-02-29 11:38:33 +08:00
|
|
|
free(secFileLinksList);
|
1996-01-23 05:13:12 +08:00
|
|
|
free(secFileList);
|
|
|
|
}
|
|
|
|
|
1996-10-21 10:17:39 +08:00
|
|
|
if (sharedList) free(sharedList);
|
1996-02-16 05:08:48 +08:00
|
|
|
|
|
|
|
if (!numReplacedFiles)
|
|
|
|
free(replacedList);
|
|
|
|
else {
|
|
|
|
replacedList[numReplacedFiles].recOffset = 0; /* mark the end */
|
|
|
|
*repListPtr = replacedList;
|
|
|
|
}
|
1996-01-23 05:13:12 +08:00
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
1996-11-01 05:06:55 +08:00
|
|
|
/* 0 success */
|
|
|
|
/* 1 bad magic */
|
|
|
|
/* 2 error */
|
1996-08-29 12:16:07 +08:00
|
|
|
static int installSources(Header h, char * rootdir, int fd,
|
1996-11-19 02:02:36 +08:00
|
|
|
char ** specFilePtr, rpmNotifyFunction notify,
|
1996-08-29 12:16:07 +08:00
|
|
|
char * labelFormat) {
|
1996-02-15 01:54:37 +08:00
|
|
|
char * specFile;
|
|
|
|
char * sourceDir, * specDir;
|
1997-05-07 02:19:19 +08:00
|
|
|
int specFileIndex = -1;
|
1996-02-15 01:54:37 +08:00
|
|
|
char * realSourceDir, * realSpecDir;
|
|
|
|
char * instSpecFile, * correctSpecFile;
|
1997-05-07 02:19:19 +08:00
|
|
|
char * name, * release, * version;
|
|
|
|
int fileCount = 0;
|
1996-08-29 12:16:07 +08:00
|
|
|
uint_32 * archiveSizePtr = NULL;
|
|
|
|
int type, count;
|
1997-05-07 02:19:19 +08:00
|
|
|
struct fileMemory fileMem;
|
|
|
|
struct fileInfo * files;
|
|
|
|
int i;
|
|
|
|
char * chptr;
|
1997-05-16 23:25:31 +08:00
|
|
|
char * currDir;
|
|
|
|
int currDirLen;
|
1996-02-15 01:54:37 +08:00
|
|
|
|
1996-11-19 02:02:36 +08:00
|
|
|
rpmMessage(RPMMESS_DEBUG, "installing a source package\n");
|
1996-02-15 04:09:14 +08:00
|
|
|
|
1996-11-19 02:02:36 +08:00
|
|
|
sourceDir = rpmGetVar(RPMVAR_SOURCEDIR);
|
|
|
|
specDir = rpmGetVar(RPMVAR_SPECDIR);
|
1996-02-15 01:54:37 +08:00
|
|
|
|
1996-07-10 10:33:38 +08:00
|
|
|
realSourceDir = alloca(strlen(rootdir) + strlen(sourceDir) + 2);
|
|
|
|
strcpy(realSourceDir, rootdir);
|
1996-02-15 01:54:37 +08:00
|
|
|
strcat(realSourceDir, "/");
|
|
|
|
strcat(realSourceDir, sourceDir);
|
|
|
|
|
1996-07-10 10:33:38 +08:00
|
|
|
realSpecDir = alloca(strlen(rootdir) + strlen(specDir) + 2);
|
|
|
|
strcpy(realSpecDir, rootdir);
|
1996-02-15 01:54:37 +08:00
|
|
|
strcat(realSpecDir, "/");
|
|
|
|
strcat(realSpecDir, specDir);
|
|
|
|
|
1997-02-12 13:05:13 +08:00
|
|
|
if (access(realSourceDir, W_OK)) {
|
|
|
|
rpmError(RPMERR_CREATE, "cannot write to %s", realSourceDir);
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (access(realSpecDir, W_OK)) {
|
|
|
|
rpmError(RPMERR_CREATE, "cannot write to %s", realSpecDir);
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
1996-11-19 02:02:36 +08:00
|
|
|
rpmMessage(RPMMESS_DEBUG, "sources in: %s\n", realSourceDir);
|
|
|
|
rpmMessage(RPMMESS_DEBUG, "spec file in: %s\n", realSpecDir);
|
1996-02-15 01:54:37 +08:00
|
|
|
|
1997-05-07 02:19:19 +08:00
|
|
|
if (h && headerIsEntry(h, RPMTAG_FILENAMES)) {
|
|
|
|
/* we can't remap v1 packages */
|
|
|
|
assembleFileList(h, &fileMem, &fileCount, &files, 0);
|
|
|
|
|
|
|
|
for (i = 0; i < fileCount; i++)
|
1997-07-16 09:44:27 +08:00
|
|
|
files[i].relativePath = files[i].relativePath;
|
1997-05-07 02:19:19 +08:00
|
|
|
|
|
|
|
#if 0 /* Unfortunately this doesnt work as RPMs building code seems broken */
|
|
|
|
for (i = 0; i < fileCount; i++)
|
|
|
|
if (files[i].flags & RPMFILE_SPECFILE) break;
|
|
|
|
#endif
|
|
|
|
i = fileCount;
|
|
|
|
if (i == fileCount) {
|
|
|
|
/* find the spec file by name */
|
|
|
|
for (i = 0; i < fileCount; i++) {
|
|
|
|
chptr = files[i].cpioPath + strlen(files[i].cpioPath) - 5;
|
|
|
|
if (!strcmp(chptr, ".spec")) break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i < fileCount) {
|
|
|
|
specFileIndex = i;
|
|
|
|
|
1997-07-16 09:44:27 +08:00
|
|
|
files[i].relativePath = alloca(strlen(realSpecDir) +
|
1997-05-07 02:19:19 +08:00
|
|
|
strlen(files[i].cpioPath) + 5);
|
1997-07-16 09:44:27 +08:00
|
|
|
strcpy(files[i].relativePath, realSpecDir);
|
|
|
|
strcat(files[i].relativePath, "/");
|
|
|
|
strcat(files[i].relativePath, files[i].cpioPath);
|
1997-05-07 02:19:19 +08:00
|
|
|
} else {
|
|
|
|
rpmError(RPMERR_NOSPEC, "source package contains no .spec file");
|
|
|
|
if (fileCount > 0) freeFileMemory(fileMem);
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
}
|
1996-07-26 00:39:01 +08:00
|
|
|
|
1996-08-29 12:16:07 +08:00
|
|
|
if (labelFormat && h) {
|
1996-11-19 02:02:36 +08:00
|
|
|
headerGetEntry(h, RPMTAG_NAME, &type, (void *) &name, &count);
|
|
|
|
headerGetEntry(h, RPMTAG_VERSION, &type, (void *) &version, &count);
|
|
|
|
headerGetEntry(h, RPMTAG_RELEASE, &type, (void *) &release, &count);
|
1997-05-06 04:46:58 +08:00
|
|
|
if (!headerGetEntry(h, RPMTAG_ARCHIVESIZE, &type,
|
|
|
|
(void *) &archiveSizePtr, &count))
|
1996-08-29 12:16:07 +08:00
|
|
|
archiveSizePtr = NULL;
|
|
|
|
printf(labelFormat, name, version, release);
|
|
|
|
fflush(stdout);
|
|
|
|
}
|
|
|
|
|
1997-05-16 23:25:31 +08:00
|
|
|
currDirLen = 50;
|
|
|
|
currDir = malloc(currDirLen);
|
|
|
|
while (!getcwd(currDir, currDirLen)) {
|
|
|
|
currDirLen += 50;
|
|
|
|
currDir = realloc(currDir, currDirLen);
|
|
|
|
}
|
|
|
|
|
1997-05-07 02:19:19 +08:00
|
|
|
chdir(realSourceDir);
|
|
|
|
if (installArchive(fd, fileCount > 0 ? files : NULL,
|
|
|
|
fileCount, notify,
|
|
|
|
specFileIndex >=0 ? NULL : &specFile,
|
|
|
|
archiveSizePtr ? *archiveSizePtr : 0)) {
|
|
|
|
if (fileCount > 0) freeFileMemory(fileMem);
|
1997-05-16 23:25:31 +08:00
|
|
|
free(currDir);
|
1996-11-01 05:06:55 +08:00
|
|
|
return 2;
|
1996-02-15 01:54:37 +08:00
|
|
|
}
|
|
|
|
|
1997-05-16 23:25:31 +08:00
|
|
|
chdir(currDir);
|
|
|
|
free(currDir);
|
1996-02-15 01:54:37 +08:00
|
|
|
|
1997-05-07 02:19:19 +08:00
|
|
|
if (specFileIndex == -1) {
|
|
|
|
if (!specFile) {
|
|
|
|
rpmError(RPMERR_NOSPEC, "source package contains no .spec file");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This logic doesn't work is realSpecDir and realSourceDir are on
|
|
|
|
different filesystems, but we only do this on v1 source packages
|
|
|
|
so I don't really care much. */
|
|
|
|
instSpecFile = alloca(strlen(realSourceDir) + strlen(specFile) + 2);
|
|
|
|
strcpy(instSpecFile, realSourceDir);
|
|
|
|
strcat(instSpecFile, "/");
|
|
|
|
strcat(instSpecFile, specFile);
|
|
|
|
|
|
|
|
correctSpecFile = alloca(strlen(realSpecDir) + strlen(specFile) + 2);
|
|
|
|
strcpy(correctSpecFile, realSpecDir);
|
|
|
|
strcat(correctSpecFile, "/");
|
|
|
|
strcat(correctSpecFile, specFile);
|
|
|
|
|
|
|
|
free(specFile);
|
|
|
|
|
|
|
|
rpmMessage(RPMMESS_DEBUG,
|
|
|
|
"renaming %s to %s\n", instSpecFile, correctSpecFile);
|
|
|
|
if (rename(instSpecFile, correctSpecFile)) {
|
|
|
|
rpmError(RPMERR_RENAME, "rename of %s to %s failed: %s",
|
|
|
|
instSpecFile, correctSpecFile, strerror(errno));
|
1996-11-01 05:06:55 +08:00
|
|
|
return 2;
|
1997-05-07 02:19:19 +08:00
|
|
|
}
|
1996-02-15 01:54:37 +08:00
|
|
|
|
1997-05-07 02:19:19 +08:00
|
|
|
if (specFilePtr)
|
|
|
|
*specFilePtr = strdup(correctSpecFile);
|
|
|
|
} else {
|
|
|
|
if (specFilePtr)
|
1997-07-16 09:44:27 +08:00
|
|
|
*specFilePtr = strdup(files[specFileIndex].relativePath);
|
1997-05-07 02:19:19 +08:00
|
|
|
|
|
|
|
if (fileCount > 0) freeFileMemory(fileMem);
|
|
|
|
}
|
1996-02-15 04:09:14 +08:00
|
|
|
|
1996-02-15 01:54:37 +08:00
|
|
|
return 0;
|
|
|
|
}
|
1996-02-16 05:08:48 +08:00
|
|
|
|
|
|
|
static int markReplacedFiles(rpmdb db, struct replacedFile * replList) {
|
|
|
|
struct replacedFile * fileInfo;
|
|
|
|
Header secHeader = NULL, sh;
|
|
|
|
char * secStates;
|
|
|
|
int type, count;
|
|
|
|
|
|
|
|
int secOffset = 0;
|
|
|
|
|
|
|
|
for (fileInfo = replList; fileInfo->recOffset; fileInfo++) {
|
|
|
|
if (secOffset != fileInfo->recOffset) {
|
|
|
|
if (secHeader) {
|
|
|
|
/* ignore errors here - just do the best we can */
|
|
|
|
|
|
|
|
rpmdbUpdateRecord(db, secOffset, secHeader);
|
1996-11-19 02:02:36 +08:00
|
|
|
headerFree(secHeader);
|
1996-02-16 05:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
secOffset = fileInfo->recOffset;
|
|
|
|
sh = rpmdbGetRecord(db, secOffset);
|
|
|
|
if (!sh) {
|
|
|
|
secOffset = 0;
|
|
|
|
} else {
|
1996-11-19 02:02:36 +08:00
|
|
|
secHeader = headerCopy(sh); /* so we can modify it */
|
|
|
|
headerFree(sh);
|
1996-02-16 05:08:48 +08:00
|
|
|
}
|
|
|
|
|
1997-05-06 04:46:58 +08:00
|
|
|
headerGetEntry(secHeader, RPMTAG_FILESTATES, &type,
|
|
|
|
(void **) &secStates, &count);
|
1996-02-16 05:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* by now, secHeader is the right header to modify, secStates is
|
|
|
|
the right states list to modify */
|
|
|
|
|
|
|
|
secStates[fileInfo->fileNumber] = RPMFILE_STATE_REPLACED;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (secHeader) {
|
|
|
|
/* ignore errors here - just do the best we can */
|
|
|
|
|
|
|
|
rpmdbUpdateRecord(db, secOffset, secHeader);
|
1996-11-19 02:02:36 +08:00
|
|
|
headerFree(secHeader);
|
1996-02-16 05:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
1996-02-26 06:11:00 +08:00
|
|
|
|
1997-01-16 00:24:14 +08:00
|
|
|
int rpmVersionCompare(Header first, Header second) {
|
|
|
|
char * one, * two;
|
|
|
|
int rc;
|
1996-02-26 06:11:00 +08:00
|
|
|
|
1997-01-16 00:24:14 +08:00
|
|
|
if (!headerGetEntry(first, RPMTAG_SERIAL, NULL, (void **) &one, NULL))
|
|
|
|
one = NULL;
|
|
|
|
if (!headerGetEntry(second, RPMTAG_SERIAL, NULL, (void **) &two, NULL))
|
|
|
|
two = NULL;
|
|
|
|
|
|
|
|
if (one && !two)
|
|
|
|
return 1;
|
1997-07-24 22:41:55 +08:00
|
|
|
else if (!one && two)
|
|
|
|
return -1;
|
1997-01-16 00:24:14 +08:00
|
|
|
else if (one && two)
|
|
|
|
return rpmvercmp(one, two);
|
1996-02-26 06:11:00 +08:00
|
|
|
|
1997-01-16 00:24:14 +08:00
|
|
|
headerGetEntry(first, RPMTAG_VERSION, NULL, (void **) &one, NULL);
|
1997-01-17 00:18:48 +08:00
|
|
|
headerGetEntry(second, RPMTAG_VERSION, NULL, (void **) &two, NULL);
|
1996-02-26 06:11:00 +08:00
|
|
|
|
1997-01-16 00:24:14 +08:00
|
|
|
rc = rpmvercmp(one, two);
|
|
|
|
if (rc)
|
|
|
|
return rc;
|
|
|
|
|
|
|
|
headerGetEntry(first, RPMTAG_RELEASE, NULL, (void **) &one, NULL);
|
1997-01-17 00:18:48 +08:00
|
|
|
headerGetEntry(second, RPMTAG_RELEASE, NULL, (void **) &two, NULL);
|
1997-01-16 00:24:14 +08:00
|
|
|
|
|
|
|
return rpmvercmp(one, two);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ensureOlder(rpmdb db, Header new, int dbOffset) {
|
|
|
|
Header old;
|
|
|
|
char * name, * version, * release;
|
|
|
|
int result, rc = 0;
|
|
|
|
|
|
|
|
old = rpmdbGetRecord(db, dbOffset);
|
|
|
|
if (!old) return 1;
|
|
|
|
|
|
|
|
result = rpmVersionCompare(old, new);
|
1996-02-26 06:11:00 +08:00
|
|
|
if (result < 0)
|
|
|
|
rc = 0;
|
1997-01-16 00:24:14 +08:00
|
|
|
else if (result > 0) {
|
1996-02-26 06:11:00 +08:00
|
|
|
rc = 1;
|
1997-01-16 00:24:14 +08:00
|
|
|
headerGetEntry(old, RPMTAG_NAME, NULL, (void **) &name, NULL);
|
|
|
|
headerGetEntry(old, RPMTAG_VERSION, NULL, (void **) &version, NULL);
|
|
|
|
headerGetEntry(old, RPMTAG_RELEASE, NULL, (void **) &release, NULL);
|
|
|
|
rpmError(RPMERR_OLDPACKAGE, "package %s-%s-%s (which is newer) is "
|
|
|
|
"already installed", name, version, release);
|
1996-02-26 06:11:00 +08:00
|
|
|
}
|
|
|
|
|
1997-01-16 00:24:14 +08:00
|
|
|
headerFree(old);
|
1996-02-26 06:11:00 +08:00
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
1996-02-29 11:38:33 +08:00
|
|
|
|
|
|
|
enum fileTypes whatis(short mode) {
|
|
|
|
enum fileTypes result;
|
|
|
|
|
|
|
|
if (S_ISDIR(mode))
|
1996-09-26 03:14:17 +08:00
|
|
|
result = XDIR;
|
1996-02-29 11:38:33 +08:00
|
|
|
else if (S_ISCHR(mode))
|
|
|
|
result = CDEV;
|
|
|
|
else if (S_ISBLK(mode))
|
|
|
|
result = BDEV;
|
|
|
|
else if (S_ISLNK(mode))
|
|
|
|
result = LINK;
|
|
|
|
else if (S_ISSOCK(mode))
|
|
|
|
result = SOCK;
|
|
|
|
else if (S_ISFIFO(mode))
|
|
|
|
result = PIPE;
|
|
|
|
else
|
|
|
|
result = REG;
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
1996-07-10 10:33:38 +08:00
|
|
|
|
|
|
|
static int relocateFilelist(Header * hp, char * defaultPrefix,
|
|
|
|
char * newPrefix, int * relocationLength) {
|
1997-02-14 11:26:16 +08:00
|
|
|
Header h = *hp;
|
1996-07-10 10:33:38 +08:00
|
|
|
char ** newFileList, ** fileList;
|
1997-02-14 11:26:16 +08:00
|
|
|
int fileCount, i;
|
1996-07-10 10:33:38 +08:00
|
|
|
int defaultPrefixLength;
|
|
|
|
int newPrefixLength;
|
|
|
|
|
|
|
|
/* a trailing '/' in the defaultPrefix or in the newPrefix would really
|
|
|
|
confuse us */
|
|
|
|
defaultPrefix = strcpy(alloca(strlen(defaultPrefix) + 1), defaultPrefix);
|
|
|
|
stripTrailingSlashes(defaultPrefix);
|
|
|
|
newPrefix = strcpy(alloca(strlen(newPrefix) + 1), newPrefix);
|
|
|
|
stripTrailingSlashes(newPrefix);
|
|
|
|
|
1996-11-19 02:02:36 +08:00
|
|
|
rpmMessage(RPMMESS_DEBUG, "relocating files from %s to %s\n", defaultPrefix,
|
1996-07-10 10:33:38 +08:00
|
|
|
newPrefix);
|
|
|
|
|
1996-07-10 22:11:19 +08:00
|
|
|
if (!strcmp(newPrefix, defaultPrefix)) {
|
1997-02-14 11:26:16 +08:00
|
|
|
headerAddEntry(h, RPMTAG_INSTALLPREFIX, RPM_STRING_TYPE,
|
|
|
|
defaultPrefix, 1);
|
1996-07-10 22:11:19 +08:00
|
|
|
*relocationLength = strlen(defaultPrefix) + 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1996-07-10 10:33:38 +08:00
|
|
|
defaultPrefixLength = strlen(defaultPrefix);
|
|
|
|
newPrefixLength = strlen(newPrefix);
|
|
|
|
|
1997-02-14 11:26:16 +08:00
|
|
|
/* packages may have empty filelists */
|
|
|
|
if (!headerGetEntry(h, RPMTAG_FILENAMES, NULL, (void *) &fileList,
|
|
|
|
&fileCount))
|
1996-07-10 10:33:38 +08:00
|
|
|
return 0;
|
1997-02-14 11:26:16 +08:00
|
|
|
else if (!fileCount)
|
1996-07-10 10:33:38 +08:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
newFileList = alloca(sizeof(char *) * fileCount);
|
|
|
|
for (i = 0; i < fileCount; i++) {
|
1997-01-16 06:45:36 +08:00
|
|
|
if (!strcmp(fileList[i], defaultPrefix)) {
|
|
|
|
/* special case as there is no '/' on this */
|
|
|
|
newFileList[i] = newPrefix;
|
|
|
|
} else if (!strncmp(fileList[i], defaultPrefix, defaultPrefixLength)) {
|
1996-07-10 10:33:38 +08:00
|
|
|
newFileList[i] = alloca(strlen(fileList[i]) + newPrefixLength -
|
|
|
|
defaultPrefixLength + 2);
|
|
|
|
sprintf(newFileList[i], "%s/%s", newPrefix,
|
|
|
|
fileList[i] + defaultPrefixLength + 1);
|
|
|
|
} else {
|
1997-01-16 06:45:36 +08:00
|
|
|
rpmMessage(RPMMESS_DEBUG, "BAD - unprefixed file in relocatable "
|
|
|
|
"package");
|
1996-07-10 10:33:38 +08:00
|
|
|
newFileList[i] = alloca(strlen(fileList[i]) -
|
|
|
|
defaultPrefixLength + 2);
|
|
|
|
sprintf(newFileList[i], "/%s", fileList[i] +
|
|
|
|
defaultPrefixLength + 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1997-02-14 11:26:16 +08:00
|
|
|
headerModifyEntry(h, RPMTAG_FILENAMES, RPM_STRING_ARRAY_TYPE,
|
|
|
|
newFileList, fileCount);
|
|
|
|
headerAddEntry(h, RPMTAG_INSTALLPREFIX, RPM_STRING_TYPE, newPrefix, 1);
|
1996-07-10 10:33:38 +08:00
|
|
|
|
|
|
|
*relocationLength = newPrefixLength + 1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
1996-07-16 11:37:07 +08:00
|
|
|
|
|
|
|
static int archOkay(Header h) {
|
|
|
|
int_8 * pkgArchNum;
|
|
|
|
void * pkgArch;
|
1997-07-23 09:06:03 +08:00
|
|
|
int type, count, archNum;
|
1996-07-16 11:37:07 +08:00
|
|
|
|
|
|
|
/* make sure we're trying to install this on the proper architecture */
|
1996-11-19 02:02:36 +08:00
|
|
|
headerGetEntry(h, RPMTAG_ARCH, &type, (void **) &pkgArch, &count);
|
|
|
|
if (type == RPM_INT8_TYPE) {
|
1996-07-16 11:37:07 +08:00
|
|
|
/* old arch handling */
|
1997-07-23 09:06:03 +08:00
|
|
|
rpmGetArchInfo(NULL, &archNum);
|
1996-07-16 11:37:07 +08:00
|
|
|
pkgArchNum = pkgArch;
|
1997-07-23 09:06:03 +08:00
|
|
|
if (archNum != *pkgArchNum) {
|
1996-07-16 11:37:07 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* new arch handling */
|
1997-07-23 09:06:03 +08:00
|
|
|
if (!rpmMachineScore(RPM_MACHTABLE_INSTARCH, pkgArch)) {
|
1996-07-16 11:37:07 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int osOkay(Header h) {
|
|
|
|
void * pkgOs;
|
|
|
|
int type, count;
|
|
|
|
|
|
|
|
/* make sure we're trying to install this on the proper os */
|
1996-11-19 02:02:36 +08:00
|
|
|
headerGetEntry(h, RPMTAG_OS, &type, (void **) &pkgOs, &count);
|
|
|
|
if (type == RPM_INT8_TYPE) {
|
1996-07-19 05:42:12 +08:00
|
|
|
/* v1 packages and v2 packages both used improper OS numbers, so just
|
|
|
|
deal with it hope things work */
|
1996-07-20 06:31:37 +08:00
|
|
|
return 1;
|
1996-07-16 11:37:07 +08:00
|
|
|
} else {
|
|
|
|
/* new os handling */
|
1997-07-23 09:06:03 +08:00
|
|
|
if (!rpmMachineScore(RPM_MACHTABLE_INSTOS, pkgOs)) {
|
1996-07-16 11:37:07 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|