wrote doInstall()
CVS patchset: 176 CVS date: 1996/01/08 19:21:55
This commit is contained in:
parent
88b6fc3f3a
commit
bd01c5d1ed
42
install.c
42
install.c
|
@ -1,18 +1,54 @@
|
|||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "install.h"
|
||||
#include "lib/rpmlib.h"
|
||||
#include "messages.h"
|
||||
|
||||
void doInstall(char * prefix, int test, int installFlags) {
|
||||
printf("I can't install packages yet");
|
||||
void doInstall(char * prefix, char * arg, int test, int installFlags) {
|
||||
rpmdb db;
|
||||
int fd;
|
||||
int mode, rc;
|
||||
|
||||
if (test)
|
||||
mode = O_RDONLY;
|
||||
else
|
||||
mode = O_RDWR | O_EXCL;
|
||||
|
||||
if (!rpmdbOpen(prefix, &db, mode, 0644)) {
|
||||
fprintf(stderr, "error: cannot open %s/var/lib/rpm/packages.rpm\n", prefix);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
message(MESS_DEBUG, "installing %s\n", arg);
|
||||
fd = open(arg, O_RDONLY);
|
||||
if (fd < 0) {
|
||||
rpmdbClose(db);
|
||||
fprintf(stderr, "error: cannot open %s\n", arg);
|
||||
return;
|
||||
}
|
||||
|
||||
rc = rpmInstallPackage(prefix, db, fd, test);
|
||||
if (rc == 1) {
|
||||
fprintf(stderr, "error: %s is not a RPM package\n", arg);
|
||||
}
|
||||
|
||||
close(fd);
|
||||
rpmdbClose(db);
|
||||
}
|
||||
|
||||
void doUninstall(char * prefix, char * arg, int test, int uninstallFlags) {
|
||||
rpmdb db;
|
||||
dbIndexSet matches;
|
||||
int i;
|
||||
int mode;
|
||||
|
||||
if (!rpmdbOpen(prefix, &db, O_RDWR | O_EXCL, 0644)) {
|
||||
if (test)
|
||||
mode = O_RDONLY;
|
||||
else
|
||||
mode = O_RDWR | O_EXCL;
|
||||
|
||||
if (!rpmdbOpen(prefix, &db, mode, 0644)) {
|
||||
fprintf(stderr, "cannot open %s/var/lib/rpm/packages.rpm\n", prefix);
|
||||
exit(1);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue