1.1 --- a/main.c Thu Nov 08 17:14:19 2007 -0500
1.2 +++ b/main.c Sat Dec 29 19:00:25 2007 -0500
1.3 @@ -298,6 +298,7 @@
1.4 struct dirent *de;
1.5 struct razor_importer *importer;
1.6 struct razor_set *set;
1.7 + struct razor_rpm *rpm;
1.8 int len;
1.9 char filename[256];
1.10 const char *dirname = argv[0];
1.11 @@ -321,10 +322,17 @@
1.12 continue;
1.13 snprintf(filename, sizeof filename,
1.14 "%s/%s", dirname, de->d_name);
1.15 - if (razor_importer_add_rpm(importer, filename)) {
1.16 + rpm = razor_rpm_open(filename);
1.17 + if (rpm == NULL) {
1.18 + fprintf(stderr,
1.19 + "failed to open rpm \"%s\"\n", filename);
1.20 + continue;
1.21 + }
1.22 + if (razor_importer_add_rpm(importer, rpm)) {
1.23 fprintf(stderr, "couldn't import %s\n", filename);
1.24 break;
1.25 }
1.26 + razor_rpm_close(rpm);
1.27 }
1.28
1.29 if (de != NULL) {
1.30 @@ -341,6 +349,44 @@
1.31 return 0;
1.32 }
1.33
1.34 +static int
1.35 +command_install(int argc, const char *argv[])
1.36 +{
1.37 + struct razor_rpm *rpm;
1.38 + const char *filename = argv[0];
1.39 + struct stat buf;
1.40 + const char root[] = "install";
1.41 +
1.42 + if (stat(root, &buf) < 0) {
1.43 + if (mkdir(root, 0777) < 0) {
1.44 + fprintf(stderr,
1.45 + "could not create install root \"%s\"\n",
1.46 + root);
1.47 + return -1;
1.48 + }
1.49 + fprintf(stderr, "created install root \"%s\"\n", root);
1.50 + } else if (!S_ISDIR(buf.st_mode)) {
1.51 + fprintf(stderr,
1.52 + "install root \"%s\" exists, but is not a directory\n",
1.53 + root);
1.54 + return -1;
1.55 + }
1.56 +
1.57 + rpm = razor_rpm_open(filename);
1.58 + if (rpm == NULL) {
1.59 + fprintf(stderr, "failed to open rpm %s\n", filename);
1.60 + return -1;
1.61 + }
1.62 + if (razor_rpm_install(rpm, root) < 0) {
1.63 + fprintf(stderr, "failed to install rpm %s\n", filename);
1.64 + return -1;
1.65 + }
1.66 +
1.67 + razor_rpm_close(rpm);
1.68 +
1.69 + return 0;
1.70 +}
1.71 +
1.72 static struct {
1.73 const char *name;
1.74 const char *description;
1.75 @@ -361,7 +407,8 @@
1.76 { "import-rpms", "import rpms from the given directory", command_import_rpms },
1.77 { "validate", "validate a package set", command_validate },
1.78 { "update", "update all or specified packages", command_update },
1.79 - { "diff", "show diff between two package sets", command_diff }
1.80 + { "diff", "show diff between two package sets", command_diff },
1.81 + { "install", "install rpm", command_install }
1.82 };
1.83
1.84 static int