diff options
Diffstat (limited to 'install.c')
-rw-r--r-- | install.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/install.c b/install.c new file mode 100644 index 000000000..942f4c64d --- /dev/null +++ b/install.c @@ -0,0 +1,35 @@ +#include <fcntl.h> + +#include "install.h" +#include "lib/rpmlib.h" + +void doInstall(char * prefix, int test, int installFlags) { + printf("I can't install packages yet"); +} + +void doUninstall(char * prefix, char * arg, int test, int uninstallFlags) { + rpmdb db; + dbIndexSet matches; + int i; + + if (!rpmdbOpen(prefix, &db, O_RDWR | O_EXCL, 0644)) { + fprintf(stderr, "cannot open %s/var/lib/rpm/packages.rpm\n", prefix); + exit(1); + } + + if (rpmdbFindPackage(db, arg, &matches)) { + fprintf(stderr, "package %s is not installed\n", arg); + } else { + if (matches.count > 1) { + fprintf(stderr, "\"%s\" specifies multiple packages\n", arg); + rpmdbClose(db); + } + for (i = 0; i < matches.count; i++) { + rpmRemovePackage(prefix, db, matches.recs[i].recOffset, test); + } + + freeDBIndexRecord(matches); + } + + rpmdbClose(db); +} |