2 * Copyright (C) 2008 Kristian Høgsberg <krh@redhat.com>
3 * Copyright (C) 2008 Red Hat, Inc
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
31 #include <curl/curl.h>
36 static const char system_repo_filename[] = "system.rzdb";
37 static const char next_repo_filename[] = "system-next.rzdb";
38 static const char rawhide_repo_filename[] = "rawhide.rzdb";
39 static const char updated_repo_filename[] = "system-updated.rzdb";
40 static const char *install_root = "";
41 static const char *repo_filename = system_repo_filename;
42 static const char *yum_url;
44 #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
46 static struct razor_package_iterator *
47 create_iterator_from_argv(struct razor_set *set, int argc, const char *argv[])
49 struct razor_package_query *query;
50 struct razor_package_iterator *iter;
51 struct razor_package *package;
52 const char *name, *pattern;
56 return razor_package_iterator_create(set);
58 query = razor_package_query_create(set);
60 for (i = 0; i < argc; i++) {
61 iter = razor_package_iterator_create(set);
64 while (razor_package_iterator_next(iter, &package,
65 RAZOR_DETAIL_NAME, &name,
67 if (fnmatch(pattern, name, 0) != 0)
70 razor_package_query_add_package(query, package);
73 razor_package_iterator_destroy(iter);
77 "no package matches \"%s\"\n", pattern);
80 return razor_package_query_finish(query);
83 #define LIST_PACKAGES_ONLY_NAMES 0x01
86 list_packages(struct razor_package_iterator *iter, uint32_t flags)
88 struct razor_package *package;
89 const char *name, *version, *arch;
91 while (razor_package_iterator_next(iter, &package,
92 RAZOR_DETAIL_NAME, &name,
93 RAZOR_DETAIL_VERSION, &version,
94 RAZOR_DETAIL_ARCH, &arch,
96 if (flags & LIST_PACKAGES_ONLY_NAMES)
99 printf("%s-%s.%s\n", name, version, arch);
104 command_list(int argc, const char *argv[])
106 struct razor_package_iterator *pi;
107 struct razor_set *set;
111 if (i < argc && strcmp(argv[i], "--only-names") == 0) {
112 flags |= LIST_PACKAGES_ONLY_NAMES;
116 set = razor_root_open_read_only(install_root);
120 pi = create_iterator_from_argv(set, argc - i, argv + i);
121 list_packages(pi, flags);
122 razor_package_iterator_destroy(pi);
123 razor_set_destroy(set);
129 list_package_properties(struct razor_set *set,
130 struct razor_package *package, uint32_t type)
132 struct razor_property_iterator *pi;
133 struct razor_property *property;
134 const char *name, *version;
137 pi = razor_property_iterator_create(set, package);
138 while (razor_property_iterator_next(pi, &property,
139 &name, &flags, &version)) {
140 if ((flags & RAZOR_PROPERTY_TYPE_MASK) != type)
143 if (version[0] != '\0')
145 razor_property_relation_to_string(property),
148 if (flags & ~(RAZOR_PROPERTY_RELATION_MASK | RAZOR_PROPERTY_TYPE_MASK)) {
150 if (flags & RAZOR_PROPERTY_PRE)
152 if (flags & RAZOR_PROPERTY_POST)
154 if (flags & RAZOR_PROPERTY_PREUN)
156 if (flags & RAZOR_PROPERTY_POSTUN)
162 razor_property_iterator_destroy(pi);
166 list_properties(int argc, const char *argv[], uint32_t type)
168 struct razor_set *set;
169 struct razor_package *package;
170 struct razor_package_iterator *pi;
171 const char *name, *version, *arch;
173 set = razor_root_open_read_only(install_root);
177 pi = create_iterator_from_argv(set, argc, argv);
178 while (razor_package_iterator_next(pi, &package,
179 RAZOR_DETAIL_NAME, &name,
180 RAZOR_DETAIL_VERSION, &version,
181 RAZOR_DETAIL_ARCH, &arch,
183 list_package_properties(set, package, type);
184 razor_package_iterator_destroy(pi);
185 razor_set_destroy(set);
191 command_list_requires(int argc, const char *argv[])
193 return list_properties(argc, argv, RAZOR_PROPERTY_REQUIRES);
197 command_list_provides(int argc, const char *argv[])
199 return list_properties(argc, argv, RAZOR_PROPERTY_PROVIDES);
203 command_list_obsoletes(int argc, const char *argv[])
205 return list_properties(argc, argv, RAZOR_PROPERTY_OBSOLETES);
209 command_list_conflicts(int argc, const char *argv[])
211 return list_properties(argc, argv, RAZOR_PROPERTY_CONFLICTS);
215 command_list_files(int argc, const char *argv[])
217 struct razor_set *set;
219 set = razor_root_open_read_only(install_root);
223 if (razor_set_open_files(set, "system-files.rzdb"))
226 razor_set_list_files(set, argv[0]);
227 razor_set_destroy(set);
233 command_list_file_packages(int argc, const char *argv[])
235 struct razor_set *set;
236 struct razor_package_iterator *pi;
238 set = razor_root_open_read_only(install_root);
242 pi = razor_package_iterator_create_for_file(set, argv[0]);
243 list_packages(pi, 0);
244 razor_package_iterator_destroy(pi);
246 razor_set_destroy(set);
252 command_list_package_files(int argc, const char *argv[])
254 struct razor_set *set;
255 struct razor_package_iterator *pi;
256 struct razor_package *package;
257 const char *name, *version, *arch;
259 set = razor_root_open_read_only(install_root);
263 pi = create_iterator_from_argv(set, argc, argv);
264 while (razor_package_iterator_next(pi, &package,
265 RAZOR_DETAIL_NAME, &name,
266 RAZOR_DETAIL_VERSION, &version,
267 RAZOR_DETAIL_ARCH, &arch,
269 razor_set_list_package_files(set, package);
270 razor_package_iterator_destroy(pi);
272 razor_set_destroy(set);
278 list_property_packages(const char *ref_name,
279 const char *ref_version,
282 struct razor_set *set;
283 struct razor_property *property;
284 struct razor_property_iterator *prop_iter;
285 struct razor_package_iterator *pkg_iter;
286 const char *name, *version;
289 if (ref_name == NULL)
292 set = razor_root_open_read_only(install_root);
296 prop_iter = razor_property_iterator_create(set, NULL);
297 while (razor_property_iterator_next(prop_iter, &property,
298 &name, &flags, &version)) {
299 if (strcmp(ref_name, name) != 0)
302 (flags & RAZOR_PROPERTY_RELATION_MASK) == RAZOR_PROPERTY_EQUAL &&
303 strcmp(ref_version, version) != 0)
305 if ((flags & RAZOR_PROPERTY_TYPE_MASK) != type)
309 razor_package_iterator_create_for_property(set,
311 list_packages(pkg_iter, 0);
312 razor_package_iterator_destroy(pkg_iter);
314 razor_property_iterator_destroy(prop_iter);
316 razor_set_destroy(set);
322 command_what_requires(int argc, const char *argv[])
324 return list_property_packages(argv[0], argv[1],
325 RAZOR_PROPERTY_REQUIRES);
329 command_what_provides(int argc, const char *argv[])
331 return list_property_packages(argv[0], argv[1],
332 RAZOR_PROPERTY_PROVIDES);
336 show_progress(void *clientp,
337 double dltotal, double dlnow, double ultotal, double ulnow)
339 const char *file = clientp;
341 if (!dlnow < dltotal)
342 fprintf(stderr, "\rdownloading %s, %dkB/%dkB",
343 file, (int) dlnow / 1024, (int) dltotal / 1024);
349 download_if_missing(const char *url, const char *file)
358 curl = curl_easy_init();
362 curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, error);
363 curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0);
364 curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, show_progress);
365 curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, file);
367 if (stat(file, &buf) < 0) {
368 fp = fopen(file, "w");
371 "failed to open %s for writing\n", file);
374 curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
375 curl_easy_setopt(curl, CURLOPT_URL, url);
376 res = curl_easy_perform(curl);
378 if (res != CURLE_OK) {
379 fprintf(stderr, "curl error: %s\n", error);
383 res = curl_easy_getinfo(curl,
384 CURLINFO_RESPONSE_CODE, &response);
385 if (res != CURLE_OK) {
386 fprintf(stderr, "curl error: %s\n", error);
390 if (response != 200) {
391 fprintf(stderr, " - failed %ld\n", response);
395 fprintf(stderr, "\n");
398 curl_easy_cleanup(curl);
403 #define YUM_URL "http://download.fedora.redhat.com" \
404 "/pub/fedora/linux/development/i386/os"
407 command_import_yum(int argc, const char *argv[])
409 struct razor_set *set;
412 printf("downloading from %s.\n", yum_url);
413 snprintf(buffer, sizeof buffer,
414 "%s/repodata/primary.xml.gz", yum_url);
415 if (download_if_missing(buffer, "primary.xml.gz") < 0)
417 snprintf(buffer, sizeof buffer,
418 "%s/repodata/filelists.xml.gz", yum_url);
419 if (download_if_missing(buffer, "filelists.xml.gz") < 0)
422 set = razor_set_create_from_yum();
425 razor_set_write(set, rawhide_repo_filename, RAZOR_REPO_FILE_MAIN);
426 razor_set_write(set, "rawhide-details.rzdb", RAZOR_REPO_FILE_DETAILS);
427 razor_set_write(set, "rawhide-files.rzdb", RAZOR_REPO_FILE_FILES);
428 razor_set_destroy(set);
429 printf("wrote %s\n", rawhide_repo_filename);
436 command_import_rpmdb(int argc, const char *argv[])
438 struct razor_set *set;
439 struct razor_root *root;
441 root = razor_root_open(install_root);
445 set = razor_set_create_from_rpmdb();
449 razor_root_update(root, set);
451 return razor_root_commit(root);
456 mark_packages_for_update(struct razor_transaction *trans,
457 struct razor_set *set, const char *pattern)
459 struct razor_package_iterator *pi;
460 struct razor_package *package;
464 pi = razor_package_iterator_create(set);
465 while (razor_package_iterator_next(pi, &package,
466 RAZOR_DETAIL_NAME, &name,
467 RAZOR_DETAIL_LAST)) {
468 if (pattern && fnmatch(pattern, name, 0) == 0) {
469 razor_transaction_update_package(trans, package);
473 razor_package_iterator_destroy(pi);
479 mark_packages_for_removal(struct razor_transaction *trans,
480 struct razor_set *set, const char *pattern)
482 struct razor_package_iterator *pi;
483 struct razor_package *package;
487 pi = razor_package_iterator_create(set);
488 while (razor_package_iterator_next(pi, &package,
489 RAZOR_DETAIL_NAME, &name,
490 RAZOR_DETAIL_LAST)) {
491 if (pattern && fnmatch(pattern, name, 0) == 0) {
492 razor_transaction_remove_package(trans, package);
496 razor_package_iterator_destroy(pi);
502 command_update(int argc, const char *argv[])
504 struct razor_set *set, *upstream;
505 struct razor_transaction *trans;
508 set = razor_root_open_read_only(install_root);
512 upstream = razor_set_open(rawhide_repo_filename);
513 if (upstream == NULL ||
514 razor_set_open_details(upstream, "rawhide-details.rzdb") ||
515 razor_set_open_files(upstream, "rawhide-files.rzdb"))
518 trans = razor_transaction_create(set, upstream);
520 razor_transaction_update_all(trans);
521 for (i = 0; i < argc; i++) {
522 if (mark_packages_for_update(trans, set, argv[i]) == 0) {
523 fprintf(stderr, "no match for %s\n", argv[i]);
528 razor_transaction_resolve(trans);
529 errors = razor_transaction_describe(trans);
531 fprintf(stderr, "unresolved dependencies\n");
535 set = razor_transaction_finish(trans);
536 razor_set_write(set, updated_repo_filename, RAZOR_REPO_FILE_MAIN);
537 razor_set_destroy(set);
538 razor_set_destroy(upstream);
539 printf("wrote system-updated.rzdb\n");
545 command_remove(int argc, const char *argv[])
547 struct razor_set *set, *upstream;
548 struct razor_transaction *trans;
551 set = razor_root_open_read_only(install_root);
555 upstream = razor_set_create();
556 trans = razor_transaction_create(set, upstream);
557 for (i = 0; i < argc; i++) {
558 if (mark_packages_for_removal(trans, set, argv[i]) == 0) {
559 fprintf(stderr, "no match for %s\n", argv[i]);
564 errors = razor_transaction_resolve(trans);
568 set = razor_transaction_finish(trans);
569 razor_set_write(set, updated_repo_filename, RAZOR_REPO_FILE_MAIN);
570 razor_set_destroy(set);
571 razor_set_destroy(upstream);
572 printf("wrote system-updated.rzdb\n");
578 print_diff(enum razor_diff_action action,
579 struct razor_package *package,
585 if (action == RAZOR_DIFF_ACTION_ADD)
586 printf("install %s-%s.%s\n", name, version, arch);
587 if (action == RAZOR_DIFF_ACTION_REMOVE)
588 printf("remove %s-%s.%s\n", name, version, arch);
592 command_diff(int argc, const char *argv[])
594 struct razor_set *set, *updated;
596 set = razor_root_open_read_only(install_root);
597 updated = razor_set_open(updated_repo_filename);
598 if (set == NULL || updated == NULL)
601 razor_set_diff(set, updated, print_diff, NULL);
603 razor_set_destroy(set);
604 razor_set_destroy(updated);
610 command_import_rpms(int argc, const char *argv[])
614 struct razor_importer *importer;
615 struct razor_set *set;
616 struct razor_rpm *rpm;
617 int len, imported_count = 0;
619 const char *dirname = argv[0];
621 if (dirname == NULL) {
622 fprintf(stderr, "usage: razor import-rpms DIR\n");
626 dir = opendir(dirname);
628 fprintf(stderr, "couldn't read dir %s\n", dirname);
632 importer = razor_importer_create();
634 while (de = readdir(dir), de != NULL) {
635 len = strlen(de->d_name);
636 if (len < 5 || strcmp(de->d_name + len - 4, ".rpm") != 0)
638 snprintf(filename, sizeof filename,
639 "%s/%s", dirname, de->d_name);
640 rpm = razor_rpm_open(filename);
643 "failed to open rpm \"%s\"\n", filename);
646 if (razor_importer_add_rpm(importer, rpm)) {
647 fprintf(stderr, "couldn't import %s\n", filename);
650 razor_rpm_close(rpm);
652 printf("\rimporting %d", ++imported_count);
657 razor_importer_destroy(importer);
661 printf("\nsaving\n");
662 set = razor_importer_finish(importer);
664 razor_set_write(set, repo_filename, RAZOR_REPO_FILE_MAIN);
665 razor_set_write(set, "system-details.rzdb", RAZOR_REPO_FILE_DETAILS);
666 razor_set_write(set, "system-files.rzdb", RAZOR_REPO_FILE_FILES);
667 razor_set_destroy(set);
668 printf("wrote %s\n", repo_filename);
674 rpm_filename(const char *name, const char *version, const char *arch)
676 static char file[PATH_MAX];
680 v = strchr(version, ':');
686 snprintf(file, sizeof file, "%s-%s.%s.rpm", name, v, arch);
692 download_packages(struct razor_set *system, struct razor_set *next)
694 struct razor_install_iterator *ii;
695 struct razor_package *package;
696 struct razor_set *set;
697 enum razor_install_action action;
698 const char *name, *version, *arch;
699 char file[PATH_MAX], url[256];
700 int errors = 0, count;
702 ii = razor_set_create_install_iterator(system, next);
703 while (razor_install_iterator_next(ii, &set, &package,
705 if (action == RAZOR_INSTALL_ACTION_REMOVE)
708 razor_package_get_details(set, package,
709 RAZOR_DETAIL_NAME, &name,
710 RAZOR_DETAIL_VERSION, &version,
711 RAZOR_DETAIL_ARCH, &arch,
714 snprintf(url, sizeof url,
716 yum_url, rpm_filename(name, version, arch));
717 snprintf(file, sizeof file,
718 "rpms/%s", rpm_filename(name, version, arch));
719 if (download_if_missing(url, file) < 0)
722 razor_install_iterator_destroy(ii);
725 fprintf(stderr, "failed to download %d packages\n", errors);
733 install_packages(struct razor_set *system, struct razor_set *next)
735 struct razor_install_iterator *ii;
736 struct razor_package *package;
737 struct razor_set *set;
738 enum razor_install_action action;
739 struct razor_rpm *rpm;
740 const char *name, *version, *arch;
744 ii = razor_set_create_install_iterator(system, next);
745 while (razor_install_iterator_next(ii, &set, &package,
747 if (action == RAZOR_INSTALL_ACTION_REMOVE)
750 razor_package_get_details(set, package,
751 RAZOR_DETAIL_NAME, &name,
752 RAZOR_DETAIL_VERSION, &version,
753 RAZOR_DETAIL_ARCH, &arch,
756 printf("install %s-%s\n", name, version);
758 snprintf(file, sizeof file,
759 "rpms/%s", rpm_filename(name, version, arch));
760 rpm = razor_rpm_open(file);
762 fprintf(stderr, "failed to open rpm %s\n", file);
765 if (razor_rpm_install(rpm, install_root) < 0) {
767 "failed to install rpm %s\n", file);
770 razor_rpm_close(rpm);
772 razor_install_iterator_destroy(ii);
778 command_install(int argc, const char *argv[])
780 struct razor_root *root;
781 struct razor_set *system, *upstream, *next;
782 struct razor_transaction *trans;
783 int i = 0, dependencies = 1;
785 if (i < argc && strcmp(argv[i], "--no-dependencies") == 0) {
790 root = razor_root_open(install_root);
794 system = razor_root_get_system_set(root);
795 upstream = razor_set_open(rawhide_repo_filename);
796 if (upstream == NULL ||
797 razor_set_open_details(upstream, "rawhide-details.rzdb") ||
798 razor_set_open_files(upstream, "rawhide-files.rzdb")) {
799 fprintf(stderr, "couldn't open rawhide repo\n");
800 razor_root_close(root);
804 trans = razor_transaction_create(system, upstream);
806 for (; i < argc; i++) {
807 if (mark_packages_for_update(trans, upstream, argv[i]) == 0) {
808 fprintf(stderr, "no package matched %s\n", argv[i]);
809 razor_root_close(root);
815 razor_transaction_resolve(trans);
816 if (razor_transaction_describe(trans) > 0) {
817 razor_root_close(root);
822 next = razor_transaction_finish(trans);
824 razor_root_update(root, next);
826 if (mkdir("rpms", 0777) && errno != EEXIST) {
827 fprintf(stderr, "failed to create rpms directory.\n");
828 razor_root_close(root);
832 if (download_packages(system, next) < 0) {
833 razor_root_close(root);
837 install_packages(system, next);
839 razor_set_destroy(next);
840 razor_set_destroy(upstream);
842 return razor_root_commit(root);
846 command_init(int argc, const char *argv[])
848 return razor_root_create(install_root);
852 command_download(int argc, const char *argv[])
854 struct razor_set *set;
855 struct razor_package_iterator *pi;
856 struct razor_package *package;
857 const char *pattern = argv[0], *name, *version, *arch;
858 char url[256], file[256];
861 if (mkdir("rpms", 0777) && errno != EEXIST) {
862 fprintf(stderr, "failed to create rpms directory.\n");
866 set = razor_set_open(rawhide_repo_filename);
867 pi = razor_package_iterator_create(set);
868 while (razor_package_iterator_next(pi, &package,
869 RAZOR_DETAIL_NAME, &name,
870 RAZOR_DETAIL_VERSION, &version,
871 RAZOR_DETAIL_ARCH, &arch,
872 RAZOR_DETAIL_LAST)) {
873 if (pattern && fnmatch(pattern, name, 0) != 0)
877 snprintf(url, sizeof url,
878 "%s/Packages/%s-%s.%s.rpm",
879 yum_url, name, version, arch);
880 snprintf(file, sizeof file,
881 "rpms/%s-%s.%s.rpm", name, version, arch);
882 download_if_missing(url, file);
884 razor_package_iterator_destroy(pi);
885 razor_set_destroy(set);
888 fprintf(stderr, "no packages matched \"%s\"\n", pattern);
889 else if (matches == 1)
890 fprintf(stderr, "downloaded 1 package\n");
892 fprintf(stderr, "downloaded %d packages\n", matches);
898 command_info(int argc, const char *argv[])
900 struct razor_set *set;
901 struct razor_package_iterator *pi;
902 struct razor_package *package;
903 const char *pattern = argv[0], *name, *version, *arch;
904 const char *summary, *description, *url, *license;
906 set = razor_root_open_read_only(install_root);
910 pi = razor_package_iterator_create(set);
911 while (razor_package_iterator_next(pi, &package,
912 RAZOR_DETAIL_NAME, &name,
913 RAZOR_DETAIL_VERSION, &version,
914 RAZOR_DETAIL_ARCH, &arch,
915 RAZOR_DETAIL_LAST)) {
916 if (pattern && fnmatch(pattern, name, 0) != 0)
919 razor_package_get_details (set, package,
920 RAZOR_DETAIL_SUMMARY, &summary,
921 RAZOR_DETAIL_DESCRIPTION, &description,
922 RAZOR_DETAIL_URL, &url,
923 RAZOR_DETAIL_LICENSE, &license,
926 printf ("Name: %s\n", name);
927 printf ("Arch: %s\n", arch);
928 printf ("Version: %s\n", version);
929 printf ("URL: %s\n", url);
930 printf ("License: %s\n", license);
931 printf ("Summary: %s\n", summary);
932 printf ("Description:\n");
933 printf ("%s\n", description);
936 razor_package_iterator_destroy(pi);
937 razor_set_destroy(set);
942 #define SEARCH_MAX 256
945 command_search(int argc, const char *argv[])
947 struct razor_set *set;
948 struct razor_package_iterator *pi;
949 struct razor_package *package;
950 char pattern[SEARCH_MAX];
951 const char *name, *version, *arch;
952 const char *summary, *description, *url, *license;
955 fprintf(stderr, "must specify a search term\n");
959 snprintf(pattern, sizeof pattern, "*%s*", argv[0]);
961 set = razor_set_open(rawhide_repo_filename);
965 if (razor_set_open_details(set, "rawhide-details.rzdb"))
968 pi = razor_package_iterator_create(set);
969 while (razor_package_iterator_next(pi, &package,
970 RAZOR_DETAIL_NAME, &name,
971 RAZOR_DETAIL_VERSION, &version,
972 RAZOR_DETAIL_ARCH, &arch,
973 RAZOR_DETAIL_SUMMARY, &summary,
974 RAZOR_DETAIL_DESCRIPTION, &description,
975 RAZOR_DETAIL_URL, &url,
976 RAZOR_DETAIL_LICENSE, &license,
977 RAZOR_DETAIL_LAST)) {
978 if (!fnmatch(pattern, name, FNM_CASEFOLD) ||
979 !fnmatch(pattern, url, FNM_CASEFOLD) ||
980 !fnmatch(pattern, summary, FNM_CASEFOLD) ||
981 !fnmatch(pattern, description, FNM_CASEFOLD))
982 printf("%s-%s.%s: %s\n", name, version, arch, summary);
984 razor_package_iterator_destroy(pi);
985 razor_set_destroy(set);
992 const char *description;
993 int (*func)(int argc, const char *argv[]);
994 } razor_commands[] = {
995 { "list", "list all packages", command_list },
996 { "list-requires", "list all requires for the given package", command_list_requires },
997 { "list-provides", "list all provides for the given package", command_list_provides },
998 { "list-obsoletes", "list all obsoletes for the given package", command_list_obsoletes },
999 { "list-conflicts", "list all conflicts for the given package", command_list_conflicts },
1000 { "list-files", "list files for package set", command_list_files },
1001 { "list-file-packages", "list packages owning file", command_list_file_packages },
1002 { "list-package-files", "list files in package", command_list_package_files },
1003 { "what-requires", "list the packages that have the given requires", command_what_requires },
1004 { "what-provides", "list the packages that have the given provides", command_what_provides },
1005 { "import-yum", "import yum metadata files", command_import_yum },
1007 { "import-rpmdb", "import the system rpm database", command_import_rpmdb },
1009 { "import-rpms", "import rpms from the given directory", command_import_rpms },
1010 { "update", "update all or specified packages", command_update },
1011 { "remove", "remove specified packages", command_remove },
1012 { "diff", "show diff between two package sets", command_diff },
1013 { "install", "install rpm", command_install },
1014 { "init", "init razor root", command_init },
1015 { "download", "download packages", command_download },
1016 { "info", "display package details", command_info },
1017 { "search", "search package details", command_search }
1026 for (i = 0; i < ARRAY_SIZE(razor_commands); i++)
1027 printf(" %-20s%s\n",
1028 razor_commands[i].name, razor_commands[i].description);
1034 main(int argc, const char *argv[])
1039 repo = getenv("RAZOR_REPO");
1041 repo_filename = repo;
1043 root = getenv("RAZOR_ROOT");
1045 install_root = root;
1047 yum_url = getenv("YUM_URL");
1048 if (yum_url == NULL)
1054 for (i = 0; i < ARRAY_SIZE(razor_commands); i++)
1055 if (strcmp(razor_commands[i].name, argv[1]) == 0)
1056 return razor_commands[i].func(argc - 2, argv + 2);