1.1 --- a/main.c Wed Nov 07 00:33:56 2007 -0500
1.2 +++ b/main.c Thu Nov 08 17:14:19 2007 -0500
1.3 @@ -5,7 +5,7 @@
1.4 #include <sys/types.h>
1.5 #include <sys/stat.h>
1.6 #include <unistd.h>
1.7 -
1.8 +#include <dirent.h>
1.9 #include <curl/curl.h>
1.10 #include "razor.h"
1.11
1.12 @@ -292,9 +292,51 @@
1.13 }
1.14
1.15 static int
1.16 -command_dump_rpm(int argc, const char *argv[])
1.17 +command_import_rpms(int argc, const char *argv[])
1.18 {
1.19 - razor_rpm_dump(argv[0]);
1.20 + DIR *dir;
1.21 + struct dirent *de;
1.22 + struct razor_importer *importer;
1.23 + struct razor_set *set;
1.24 + int len;
1.25 + char filename[256];
1.26 + const char *dirname = argv[0];
1.27 +
1.28 + if (dirname == NULL) {
1.29 + fprintf(stderr, "usage: razor import-rpms DIR\n");
1.30 + return -1;
1.31 + }
1.32 +
1.33 + dir = opendir(dirname);
1.34 + if (dir == NULL) {
1.35 + fprintf(stderr, "couldn't read dir %s\n", dirname);
1.36 + return -1;
1.37 + }
1.38 +
1.39 + importer = razor_importer_new();
1.40 +
1.41 + while (de = readdir(dir), de != NULL) {
1.42 + len = strlen(de->d_name);
1.43 + if (len < 5 || strcmp(de->d_name + len - 4, ".rpm") != 0)
1.44 + continue;
1.45 + snprintf(filename, sizeof filename,
1.46 + "%s/%s", dirname, de->d_name);
1.47 + if (razor_importer_add_rpm(importer, filename)) {
1.48 + fprintf(stderr, "couldn't import %s\n", filename);
1.49 + break;
1.50 + }
1.51 + }
1.52 +
1.53 + if (de != NULL) {
1.54 + razor_importer_destroy(importer);
1.55 + return -1;
1.56 + }
1.57 +
1.58 + set = razor_importer_finish(importer);
1.59 +
1.60 + razor_set_write(set, repo_filename);
1.61 + razor_set_destroy(set);
1.62 + printf("wrote %s\n", repo_filename);
1.63
1.64 return 0;
1.65 }
1.66 @@ -306,20 +348,20 @@
1.67 } razor_commands[] = {
1.68 { "list", "list all packages", command_list },
1.69 { "list-requires", "list all requires for the given package", command_list_requires },
1.70 - { "list-provides", "list all provides for the give package", command_list_provides },
1.71 - { "list-obsoletes", "list all obsoletes for the give package", command_list_obsoletes },
1.72 - { "list-conflicts", "list all conflicts for the give package", command_list_conflicts },
1.73 + { "list-provides", "list all provides for the given package", command_list_provides },
1.74 + { "list-obsoletes", "list all obsoletes for the given package", command_list_obsoletes },
1.75 + { "list-conflicts", "list all conflicts for the given package", command_list_conflicts },
1.76 { "list-files", "list files for package set", command_list_files },
1.77 { "list-file-packages", "list packages owning file", command_list_file_packages },
1.78 { "list-package-files", "list files in package", command_list_package_files },
1.79 { "what-requires", "list the packages that have the given requires", command_what_requires },
1.80 { "what-provides", "list the packages that have the given provides", command_what_provides },
1.81 - { "import-yum", "import yum filelist.xml on stdin", command_import_yum },
1.82 + { "import-yum", "import yum metadata files", command_import_yum },
1.83 { "import-rpmdb", "import the system rpm database", command_import_rpmdb },
1.84 + { "import-rpms", "import rpms from the given directory", command_import_rpms },
1.85 { "validate", "validate a package set", command_validate },
1.86 { "update", "update all or specified packages", command_update },
1.87 - { "diff", "show diff between two package sets", command_diff },
1.88 - { "dump", "dump rpm file contents", command_dump_rpm }
1.89 + { "diff", "show diff between two package sets", command_diff }
1.90 };
1.91
1.92 static int