TODO: Add pipelined download and install idea.
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);
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_what_requires(int argc, const char *argv[])
66 struct razor_set *set;
68 set = razor_set_open(repo_filename);
69 razor_set_list_requires_packages(set, argv[0], argv[1]);
70 razor_set_destroy(set);
76 command_what_provides(int argc, const char *argv[])
78 struct razor_set *set;
80 set = razor_set_open(repo_filename);
81 razor_set_list_provides_packages(set, argv[0], argv[1]);
82 razor_set_destroy(set);
88 command_import_yum(int argc, const char *argv[])
90 struct razor_set *set;
92 set = razor_set_create_from_yum_filelist(STDIN_FILENO);
95 razor_set_write(set, rawhide_repo_filename);
96 razor_set_destroy(set);
97 printf("wrote %s\n", rawhide_repo_filename);
103 command_import_rpmdb(int argc, const char *argv[])
105 struct razor_set *set;
107 set = razor_set_create_from_rpmdb();
110 razor_set_write(set, repo_filename);
111 razor_set_destroy(set);
112 printf("wrote %s\n", repo_filename);
118 command_validate(int argc, const char *argv[])
120 struct razor_set *set;
122 set = razor_set_open(repo_filename);
125 razor_set_list_unsatisfied(set);
126 razor_set_destroy(set);
132 command_update(int argc, const char *argv[])
134 struct razor_set *set, *upstream;
136 set = razor_set_open(repo_filename);
137 upstream = razor_set_open(rawhide_repo_filename);
138 if (set == NULL || upstream == NULL)
140 set = razor_set_update(set, upstream, argc, argv);
141 razor_set_write(set, updated_repo_filename);
142 razor_set_destroy(set);
143 razor_set_destroy(upstream);
144 printf("wrote system-updated.repo\n");
150 print_diff(const char *name,
151 const char *old_version, const char *new_version, void *data)
154 printf("removing %s %s\n", name, old_version);
156 printf("install %s %s\n", name, new_version);
160 command_diff(int argc, const char *argv[])
162 struct razor_set *set, *updated;
164 set = razor_set_open(repo_filename);
165 updated = razor_set_open(updated_repo_filename);
166 if (set == NULL || updated == NULL)
169 razor_set_diff(set, updated, print_diff, NULL);
171 razor_set_destroy(set);
172 razor_set_destroy(updated);
179 const char *description;
180 int (*func)(int argc, const char *argv[]);
181 } razor_commands[] = {
182 { "list", "list all packages", command_list },
183 { "list-requires", "list all requires or requires for the given package", command_list_requires },
184 { "list-provides", "list all provides or provides for the give package", command_list_provides },
185 { "list-files", "list files for package set", command_list_files },
186 { "what-requires", "list the packages that have the given requires", command_what_requires },
187 { "what-provides", "list the packages that have the given provides", command_what_provides },
188 { "import-yum", "import yum filelist.xml on stdin", command_import_yum },
189 { "import-rpmdb", "import the system rpm database", command_import_rpmdb },
190 { "validate", "validate a package set", command_validate },
191 { "update", "update all or specified packages", command_update },
192 { "diff", "show diff between two package sets", command_diff }
201 for (i = 0; i < ARRAY_SIZE(razor_commands); i++)
203 razor_commands[i].name, razor_commands[i].description);
209 main(int argc, const char *argv[])
214 repo = getenv("RAZOR_REPO");
216 repo_filename = repo;
221 for (i = 0; i < ARRAY_SIZE(razor_commands); i++)
222 if (strcmp(razor_commands[i].name, argv[1]) == 0)
223 return razor_commands[i].func(argc - 2, argv + 2);