Fix yum importer.
9 static const char *repo_filename = "system.repo";
10 static const char *rawhide_repo_filename = "rawhide.repo";
11 static const char *updated_repo_filename = "system-updated.repo";
14 command_list(int argc, const char *argv[])
16 struct razor_set *set;
18 set = razor_set_open(repo_filename);
19 razor_set_list(set, argv[0]);
20 razor_set_destroy(set);
26 command_list_requires(int argc, const char *argv[])
28 struct razor_set *set;
30 set = razor_set_open(repo_filename);
31 razor_set_list_requires(set, argv[0]);
32 razor_set_destroy(set);
38 command_list_provides(int argc, const char *argv[])
40 struct razor_set *set;
42 set = razor_set_open(repo_filename);
43 razor_set_list_provides(set, argv[0]);
44 razor_set_destroy(set);
50 command_list_files(int argc, const char *argv[])
52 struct razor_set *set;
54 set = razor_set_open(repo_filename);
57 razor_set_list_files(set, argv[0]);
58 razor_set_destroy(set);
64 command_list_file_packages(int argc, const char *argv[])
66 struct razor_set *set;
68 set = razor_set_open(repo_filename);
71 razor_set_list_file_packages(set, argv[0]);
72 razor_set_destroy(set);
78 command_list_package_files(int argc, const char *argv[])
80 struct razor_set *set;
82 set = razor_set_open(repo_filename);
85 razor_set_list_package_files(set, argv[0]);
86 razor_set_destroy(set);
92 command_what_requires(int argc, const char *argv[])
94 struct razor_set *set;
96 set = razor_set_open(repo_filename);
97 razor_set_list_requires_packages(set, argv[0], argv[1]);
98 razor_set_destroy(set);
104 command_what_provides(int argc, const char *argv[])
106 struct razor_set *set;
108 set = razor_set_open(repo_filename);
109 razor_set_list_provides_packages(set, argv[0], argv[1]);
110 razor_set_destroy(set);
116 command_import_yum(int argc, const char *argv[])
118 struct razor_set *set;
120 set = razor_set_create_from_yum_filelist(STDIN_FILENO);
123 razor_set_write(set, rawhide_repo_filename);
124 razor_set_destroy(set);
125 printf("wrote %s\n", rawhide_repo_filename);
131 command_import_rpmdb(int argc, const char *argv[])
133 struct razor_set *set;
135 set = razor_set_create_from_rpmdb();
138 razor_set_write(set, repo_filename);
139 razor_set_destroy(set);
140 printf("wrote %s\n", repo_filename);
146 command_validate(int argc, const char *argv[])
148 struct razor_set *set;
150 set = razor_set_open(repo_filename);
153 razor_set_list_unsatisfied(set);
154 razor_set_destroy(set);
160 command_update(int argc, const char *argv[])
162 struct razor_set *set, *upstream;
164 set = razor_set_open(repo_filename);
165 upstream = razor_set_open(rawhide_repo_filename);
166 if (set == NULL || upstream == NULL)
168 set = razor_set_update(set, upstream, argc, argv);
169 razor_set_write(set, updated_repo_filename);
170 razor_set_destroy(set);
171 razor_set_destroy(upstream);
172 printf("wrote system-updated.repo\n");
178 print_diff(const char *name,
179 const char *old_version, const char *new_version, void *data)
182 printf("removing %s %s\n", name, old_version);
184 printf("install %s %s\n", name, new_version);
188 command_diff(int argc, const char *argv[])
190 struct razor_set *set, *updated;
192 set = razor_set_open(repo_filename);
193 updated = razor_set_open(updated_repo_filename);
194 if (set == NULL || updated == NULL)
197 razor_set_diff(set, updated, print_diff, NULL);
199 razor_set_destroy(set);
200 razor_set_destroy(updated);
207 const char *description;
208 int (*func)(int argc, const char *argv[]);
209 } razor_commands[] = {
210 { "list", "list all packages", command_list },
211 { "list-requires", "list all requires or requires for the given package", command_list_requires },
212 { "list-provides", "list all provides or provides for the give package", command_list_provides },
213 { "list-files", "list files for package set", command_list_files },
214 { "list-file-packages", "list packages owning file", command_list_file_packages },
215 { "list-package-files", "list files in package", command_list_package_files },
216 { "what-requires", "list the packages that have the given requires", command_what_requires },
217 { "what-provides", "list the packages that have the given provides", command_what_provides },
218 { "import-yum", "import yum filelist.xml on stdin", command_import_yum },
219 { "import-rpmdb", "import the system rpm database", command_import_rpmdb },
220 { "validate", "validate a package set", command_validate },
221 { "update", "update all or specified packages", command_update },
222 { "diff", "show diff between two package sets", command_diff }
231 for (i = 0; i < ARRAY_SIZE(razor_commands); i++)
233 razor_commands[i].name, razor_commands[i].description);
239 main(int argc, const char *argv[])
244 repo = getenv("RAZOR_REPO");
246 repo_filename = repo;
251 for (i = 0; i < ARRAY_SIZE(razor_commands); i++)
252 if (strcmp(razor_commands[i].name, argv[1]) == 0)
253 return razor_commands[i].func(argc - 2, argv + 2);