Don't attempt to use chroot() on systems that don't support it.
This has the added bonus of allowing us to use popen() rather than
fork()/exec() for improved portability. Of course, the loss of an
install root is a major reduction of functionality but it's hard to
see what else we could substitute for chroot().
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.
35 #include <curl/curl.h>
41 static const char system_repo_filename[] = "system.rzdb";
42 static const char next_repo_filename[] = "system-next.rzdb";
43 static const char rawhide_repo_filename[] = "rawhide.rzdb";
44 static const char updated_repo_filename[] = "system-updated.rzdb";
45 static const char *install_root = "";
46 static const char *repo_filename = system_repo_filename;
47 static const char *yum_url;
49 #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
51 static struct razor_package_iterator *
52 create_iterator_from_argv(struct razor_set *set, int argc, const char *argv[])
54 struct razor_package_query *query;
55 struct razor_package_iterator *iter;
56 struct razor_package *package;
57 const char *name, *pattern;
61 return razor_package_iterator_create(set);
63 query = razor_package_query_create(set);
65 for (i = 0; i < argc; i++) {
66 iter = razor_package_iterator_create(set);
69 while (razor_package_iterator_next(iter, &package,
70 RAZOR_DETAIL_NAME, &name,
72 if (fnmatch(pattern, name, 0) != 0)
75 razor_package_query_add_package(query, package);
78 razor_package_iterator_destroy(iter);
82 "no package matches \"%s\"\n", pattern);
85 return razor_package_query_finish(query);
88 #define LIST_PACKAGES_ONLY_NAMES 0x01
91 list_packages(struct razor_package_iterator *iter, uint32_t flags)
93 struct razor_package *package;
94 const char *name, *version, *arch;
96 while (razor_package_iterator_next(iter, &package,
97 RAZOR_DETAIL_NAME, &name,
98 RAZOR_DETAIL_VERSION, &version,
99 RAZOR_DETAIL_ARCH, &arch,
100 RAZOR_DETAIL_LAST)) {
101 if (flags & LIST_PACKAGES_ONLY_NAMES)
102 printf("%s\n", name);
104 printf("%s-%s.%s\n", name, version, arch);
109 command_list(int argc, const char *argv[])
111 struct razor_package_iterator *pi;
112 struct razor_set *set;
116 if (i < argc && strcmp(argv[i], "--only-names") == 0) {
117 flags |= LIST_PACKAGES_ONLY_NAMES;
121 set = razor_root_open_read_only(install_root);
125 pi = create_iterator_from_argv(set, argc - i, argv + i);
126 list_packages(pi, flags);
127 razor_package_iterator_destroy(pi);
128 razor_set_destroy(set);
134 list_package_properties(struct razor_set *set,
135 struct razor_package *package, uint32_t type)
137 struct razor_property_iterator *pi;
138 struct razor_property *property;
139 const char *name, *version;
142 pi = razor_property_iterator_create(set, package);
143 while (razor_property_iterator_next(pi, &property,
144 &name, &flags, &version)) {
145 if ((flags & RAZOR_PROPERTY_TYPE_MASK) != type)
148 if (version[0] != '\0')
150 razor_property_relation_to_string(property),
153 if (flags & ~(RAZOR_PROPERTY_RELATION_MASK | RAZOR_PROPERTY_TYPE_MASK)) {
155 if (flags & RAZOR_PROPERTY_PRE)
157 if (flags & RAZOR_PROPERTY_POST)
159 if (flags & RAZOR_PROPERTY_PREUN)
161 if (flags & RAZOR_PROPERTY_POSTUN)
167 razor_property_iterator_destroy(pi);
171 list_properties(int argc, const char *argv[], uint32_t type)
173 struct razor_set *set;
174 struct razor_package *package;
175 struct razor_package_iterator *pi;
176 const char *name, *version, *arch;
178 set = razor_root_open_read_only(install_root);
182 pi = create_iterator_from_argv(set, argc, argv);
183 while (razor_package_iterator_next(pi, &package,
184 RAZOR_DETAIL_NAME, &name,
185 RAZOR_DETAIL_VERSION, &version,
186 RAZOR_DETAIL_ARCH, &arch,
188 list_package_properties(set, package, type);
189 razor_package_iterator_destroy(pi);
190 razor_set_destroy(set);
196 command_list_requires(int argc, const char *argv[])
198 return list_properties(argc, argv, RAZOR_PROPERTY_REQUIRES);
202 command_list_provides(int argc, const char *argv[])
204 return list_properties(argc, argv, RAZOR_PROPERTY_PROVIDES);
208 command_list_obsoletes(int argc, const char *argv[])
210 return list_properties(argc, argv, RAZOR_PROPERTY_OBSOLETES);
214 command_list_conflicts(int argc, const char *argv[])
216 return list_properties(argc, argv, RAZOR_PROPERTY_CONFLICTS);
220 command_list_files(int argc, const char *argv[])
222 struct razor_set *set;
224 set = razor_root_open_read_only(install_root);
228 if (razor_set_open_files(set, "system-files.rzdb"))
231 razor_set_list_files(set, argv[0]);
232 razor_set_destroy(set);
238 command_list_file_packages(int argc, const char *argv[])
240 struct razor_set *set;
241 struct razor_package_iterator *pi;
243 set = razor_root_open_read_only(install_root);
247 pi = razor_package_iterator_create_for_file(set, argv[0]);
248 list_packages(pi, 0);
249 razor_package_iterator_destroy(pi);
251 razor_set_destroy(set);
257 command_list_package_files(int argc, const char *argv[])
259 struct razor_set *set;
260 struct razor_package_iterator *pi;
261 struct razor_package *package;
262 const char *name, *version, *arch;
264 set = razor_root_open_read_only(install_root);
268 pi = create_iterator_from_argv(set, argc, argv);
269 while (razor_package_iterator_next(pi, &package,
270 RAZOR_DETAIL_NAME, &name,
271 RAZOR_DETAIL_VERSION, &version,
272 RAZOR_DETAIL_ARCH, &arch,
274 razor_set_list_package_files(set, package);
275 razor_package_iterator_destroy(pi);
277 razor_set_destroy(set);
283 list_property_packages(const char *ref_name,
284 const char *ref_version,
287 struct razor_set *set;
288 struct razor_property *property;
289 struct razor_property_iterator *prop_iter;
290 struct razor_package_iterator *pkg_iter;
291 const char *name, *version;
294 if (ref_name == NULL)
297 set = razor_root_open_read_only(install_root);
301 prop_iter = razor_property_iterator_create(set, NULL);
302 while (razor_property_iterator_next(prop_iter, &property,
303 &name, &flags, &version)) {
304 if (strcmp(ref_name, name) != 0)
307 (flags & RAZOR_PROPERTY_RELATION_MASK) == RAZOR_PROPERTY_EQUAL &&
308 strcmp(ref_version, version) != 0)
310 if ((flags & RAZOR_PROPERTY_TYPE_MASK) != type)
314 razor_package_iterator_create_for_property(set,
316 list_packages(pkg_iter, 0);
317 razor_package_iterator_destroy(pkg_iter);
319 razor_property_iterator_destroy(prop_iter);
321 razor_set_destroy(set);
327 command_what_requires(int argc, const char *argv[])
329 return list_property_packages(argv[0], argv[1],
330 RAZOR_PROPERTY_REQUIRES);
334 command_what_provides(int argc, const char *argv[])
336 return list_property_packages(argv[0], argv[1],
337 RAZOR_PROPERTY_PROVIDES);
341 show_progress(void *clientp,
342 double dltotal, double dlnow, double ultotal, double ulnow)
344 const char *file = clientp;
346 if (!dlnow < dltotal)
347 fprintf(stderr, "\rdownloading %s, %dkB/%dkB",
348 file, (int) dlnow / 1024, (int) dltotal / 1024);
354 download_if_missing(const char *url, const char *file)
366 curl = curl_easy_init();
370 curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, error);
371 curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0);
372 curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, show_progress);
373 curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, file);
375 if (stat(file, &buf) < 0) {
376 fp = fopen(file, "w");
379 "failed to open %s for writing\n", file);
382 curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
383 curl_easy_setopt(curl, CURLOPT_URL, url);
384 res = curl_easy_perform(curl);
386 if (res != CURLE_OK) {
387 fprintf(stderr, "curl error: %s\n", error);
391 res = curl_easy_getinfo(curl,
392 CURLINFO_RESPONSE_CODE, &response);
393 if (res != CURLE_OK) {
394 fprintf(stderr, "curl error: %s\n", error);
398 if (response != 200) {
399 fprintf(stderr, " - failed %ld\n", response);
403 fprintf(stderr, "\n");
406 curl_easy_cleanup(curl);
409 #endif /* HAVE_CURL */
412 #define YUM_URL "http://download.fedora.redhat.com" \
413 "/pub/fedora/linux/development/i386/os"
416 command_import_yum(int argc, const char *argv[])
418 struct razor_set *set;
421 printf("downloading from %s.\n", yum_url);
422 snprintf(buffer, sizeof buffer,
423 "%s/repodata/primary.xml.gz", yum_url);
424 if (download_if_missing(buffer, "primary.xml.gz") < 0)
426 snprintf(buffer, sizeof buffer,
427 "%s/repodata/filelists.xml.gz", yum_url);
428 if (download_if_missing(buffer, "filelists.xml.gz") < 0)
431 set = razor_set_create_from_yum();
434 razor_set_write(set, rawhide_repo_filename, RAZOR_REPO_FILE_MAIN);
435 razor_set_write(set, "rawhide-details.rzdb", RAZOR_REPO_FILE_DETAILS);
436 razor_set_write(set, "rawhide-files.rzdb", RAZOR_REPO_FILE_FILES);
437 razor_set_destroy(set);
438 printf("wrote %s\n", rawhide_repo_filename);
445 command_import_rpmdb(int argc, const char *argv[])
447 struct razor_set *set;
448 struct razor_root *root;
450 root = razor_root_open(install_root);
454 set = razor_set_create_from_rpmdb();
458 razor_root_update(root, set);
460 return razor_root_commit(root);
465 mark_packages_for_update(struct razor_transaction *trans,
466 struct razor_set *set, const char *pattern)
468 struct razor_package_iterator *pi;
469 struct razor_package *package;
473 pi = razor_package_iterator_create(set);
474 while (razor_package_iterator_next(pi, &package,
475 RAZOR_DETAIL_NAME, &name,
476 RAZOR_DETAIL_LAST)) {
477 if (pattern && fnmatch(pattern, name, 0) == 0) {
478 razor_transaction_update_package(trans, package);
482 razor_package_iterator_destroy(pi);
488 mark_packages_for_removal(struct razor_transaction *trans,
489 struct razor_set *set, const char *pattern)
491 struct razor_package_iterator *pi;
492 struct razor_package *package;
496 pi = razor_package_iterator_create(set);
497 while (razor_package_iterator_next(pi, &package,
498 RAZOR_DETAIL_NAME, &name,
499 RAZOR_DETAIL_LAST)) {
500 if (pattern && fnmatch(pattern, name, 0) == 0) {
501 razor_transaction_remove_package(trans, package);
505 razor_package_iterator_destroy(pi);
511 command_update(int argc, const char *argv[])
513 struct razor_set *set, *upstream;
514 struct razor_transaction *trans;
517 set = razor_root_open_read_only(install_root);
521 upstream = razor_set_open(rawhide_repo_filename);
522 if (upstream == NULL ||
523 razor_set_open_details(upstream, "rawhide-details.rzdb") ||
524 razor_set_open_files(upstream, "rawhide-files.rzdb"))
527 trans = razor_transaction_create(set, upstream);
529 razor_transaction_update_all(trans);
530 for (i = 0; i < argc; i++) {
531 if (mark_packages_for_update(trans, set, argv[i]) == 0) {
532 fprintf(stderr, "no match for %s\n", argv[i]);
537 razor_transaction_resolve(trans);
538 errors = razor_transaction_describe(trans);
540 fprintf(stderr, "unresolved dependencies\n");
544 set = razor_transaction_finish(trans);
545 razor_set_write(set, updated_repo_filename, RAZOR_REPO_FILE_MAIN);
546 razor_set_destroy(set);
547 razor_set_destroy(upstream);
548 printf("wrote system-updated.rzdb\n");
554 command_remove(int argc, const char *argv[])
556 struct razor_set *set, *upstream;
557 struct razor_transaction *trans;
560 set = razor_root_open_read_only(install_root);
564 upstream = razor_set_create();
565 trans = razor_transaction_create(set, upstream);
566 for (i = 0; i < argc; i++) {
567 if (mark_packages_for_removal(trans, set, argv[i]) == 0) {
568 fprintf(stderr, "no match for %s\n", argv[i]);
573 errors = razor_transaction_resolve(trans);
577 set = razor_transaction_finish(trans);
578 razor_set_write(set, updated_repo_filename, RAZOR_REPO_FILE_MAIN);
579 razor_set_destroy(set);
580 razor_set_destroy(upstream);
581 printf("wrote system-updated.rzdb\n");
587 print_diff(enum razor_diff_action action,
588 struct razor_package *package,
594 if (action == RAZOR_DIFF_ACTION_ADD)
595 printf("install %s-%s.%s\n", name, version, arch);
596 if (action == RAZOR_DIFF_ACTION_REMOVE)
597 printf("remove %s-%s.%s\n", name, version, arch);
601 command_diff(int argc, const char *argv[])
603 struct razor_set *set, *updated;
605 set = razor_root_open_read_only(install_root);
606 updated = razor_set_open(updated_repo_filename);
607 if (set == NULL || updated == NULL)
610 razor_set_diff(set, updated, print_diff, NULL);
612 razor_set_destroy(set);
613 razor_set_destroy(updated);
619 command_import_rpms(int argc, const char *argv[])
623 struct razor_importer *importer;
624 struct razor_set *set;
625 struct razor_rpm *rpm;
626 int len, imported_count = 0;
628 const char *dirname = argv[0];
630 if (dirname == NULL) {
631 fprintf(stderr, "usage: razor import-rpms DIR\n");
635 dir = opendir(dirname);
637 fprintf(stderr, "couldn't read dir %s\n", dirname);
641 importer = razor_importer_create();
643 while (de = readdir(dir), de != NULL) {
644 len = strlen(de->d_name);
645 if (len < 5 || strcmp(de->d_name + len - 4, ".rpm") != 0)
647 snprintf(filename, sizeof filename,
648 "%s/%s", dirname, de->d_name);
649 rpm = razor_rpm_open(filename);
652 "failed to open rpm \"%s\"\n", filename);
655 if (razor_importer_add_rpm(importer, rpm)) {
656 fprintf(stderr, "couldn't import %s\n", filename);
659 razor_rpm_close(rpm);
661 printf("\rimporting %d", ++imported_count);
666 razor_importer_destroy(importer);
670 printf("\nsaving\n");
671 set = razor_importer_finish(importer);
673 razor_set_write(set, repo_filename, RAZOR_REPO_FILE_MAIN);
674 razor_set_write(set, "system-details.rzdb", RAZOR_REPO_FILE_DETAILS);
675 razor_set_write(set, "system-files.rzdb", RAZOR_REPO_FILE_FILES);
676 razor_set_destroy(set);
677 printf("wrote %s\n", repo_filename);
683 rpm_filename(const char *name, const char *version, const char *arch)
685 static char file[PATH_MAX];
689 v = strchr(version, ':');
695 snprintf(file, sizeof file, "%s-%s.%s.rpm", name, v, arch);
701 download_packages(struct razor_set *system, struct razor_set *next)
703 struct razor_install_iterator *ii;
704 struct razor_package *package;
705 struct razor_set *set;
706 enum razor_install_action action;
707 const char *name, *version, *arch;
708 char file[PATH_MAX], url[256];
709 int errors = 0, count;
711 ii = razor_set_create_install_iterator(system, next);
712 while (razor_install_iterator_next(ii, &set, &package,
714 if (action == RAZOR_INSTALL_ACTION_REMOVE)
717 razor_package_get_details(set, package,
718 RAZOR_DETAIL_NAME, &name,
719 RAZOR_DETAIL_VERSION, &version,
720 RAZOR_DETAIL_ARCH, &arch,
723 snprintf(url, sizeof url,
725 yum_url, rpm_filename(name, version, arch));
726 snprintf(file, sizeof file,
727 "rpms/%s", rpm_filename(name, version, arch));
728 if (download_if_missing(url, file) < 0)
731 razor_install_iterator_destroy(ii);
734 fprintf(stderr, "failed to download %d packages\n", errors);
742 install_packages(struct razor_set *system, struct razor_set *next)
744 struct razor_install_iterator *ii;
745 struct razor_package *package;
746 struct razor_set *set;
747 enum razor_install_action action;
748 struct razor_rpm *rpm;
749 const char *name, *version, *arch;
753 ii = razor_set_create_install_iterator(system, next);
754 while (razor_install_iterator_next(ii, &set, &package,
756 if (action == RAZOR_INSTALL_ACTION_REMOVE)
759 razor_package_get_details(set, package,
760 RAZOR_DETAIL_NAME, &name,
761 RAZOR_DETAIL_VERSION, &version,
762 RAZOR_DETAIL_ARCH, &arch,
765 printf("install %s-%s\n", name, version);
767 snprintf(file, sizeof file,
768 "rpms/%s", rpm_filename(name, version, arch));
769 rpm = razor_rpm_open(file);
771 fprintf(stderr, "failed to open rpm %s\n", file);
774 if (razor_rpm_install(rpm, install_root) < 0) {
776 "failed to install rpm %s\n", file);
779 razor_rpm_close(rpm);
781 razor_install_iterator_destroy(ii);
787 command_install(int argc, const char *argv[])
789 struct razor_root *root;
790 struct razor_set *system, *upstream, *next;
791 struct razor_transaction *trans;
792 int i = 0, dependencies = 1;
794 if (i < argc && strcmp(argv[i], "--no-dependencies") == 0) {
799 root = razor_root_open(install_root);
803 system = razor_root_get_system_set(root);
804 upstream = razor_set_open(rawhide_repo_filename);
805 if (upstream == NULL ||
806 razor_set_open_details(upstream, "rawhide-details.rzdb") ||
807 razor_set_open_files(upstream, "rawhide-files.rzdb")) {
808 fprintf(stderr, "couldn't open rawhide repo\n");
809 razor_root_close(root);
813 trans = razor_transaction_create(system, upstream);
815 for (; i < argc; i++) {
816 if (mark_packages_for_update(trans, upstream, argv[i]) == 0) {
817 fprintf(stderr, "no package matched %s\n", argv[i]);
818 razor_root_close(root);
824 razor_transaction_resolve(trans);
825 if (razor_transaction_describe(trans) > 0) {
826 razor_root_close(root);
831 next = razor_transaction_finish(trans);
833 razor_root_update(root, next);
835 if (mkdir("rpms", 0777) && errno != EEXIST) {
836 fprintf(stderr, "failed to create rpms directory.\n");
837 razor_root_close(root);
841 if (download_packages(system, next) < 0) {
842 razor_root_close(root);
846 install_packages(system, next);
848 razor_set_destroy(next);
849 razor_set_destroy(upstream);
851 return razor_root_commit(root);
855 command_init(int argc, const char *argv[])
857 return razor_root_create(install_root);
861 command_download(int argc, const char *argv[])
863 struct razor_set *set;
864 struct razor_package_iterator *pi;
865 struct razor_package *package;
866 const char *pattern = argv[0], *name, *version, *arch;
867 char url[256], file[256];
870 if (mkdir("rpms", 0777) && errno != EEXIST) {
871 fprintf(stderr, "failed to create rpms directory.\n");
875 set = razor_set_open(rawhide_repo_filename);
876 pi = razor_package_iterator_create(set);
877 while (razor_package_iterator_next(pi, &package,
878 RAZOR_DETAIL_NAME, &name,
879 RAZOR_DETAIL_VERSION, &version,
880 RAZOR_DETAIL_ARCH, &arch,
881 RAZOR_DETAIL_LAST)) {
882 if (pattern && fnmatch(pattern, name, 0) != 0)
886 snprintf(url, sizeof url,
887 "%s/Packages/%s-%s.%s.rpm",
888 yum_url, name, version, arch);
889 snprintf(file, sizeof file,
890 "rpms/%s-%s.%s.rpm", name, version, arch);
891 download_if_missing(url, file);
893 razor_package_iterator_destroy(pi);
894 razor_set_destroy(set);
897 fprintf(stderr, "no packages matched \"%s\"\n", pattern);
898 else if (matches == 1)
899 fprintf(stderr, "downloaded 1 package\n");
901 fprintf(stderr, "downloaded %d packages\n", matches);
907 command_info(int argc, const char *argv[])
909 struct razor_set *set;
910 struct razor_package_iterator *pi;
911 struct razor_package *package;
912 const char *pattern = argv[0], *name, *version, *arch;
913 const char *summary, *description, *url, *license;
915 set = razor_root_open_read_only(install_root);
919 pi = razor_package_iterator_create(set);
920 while (razor_package_iterator_next(pi, &package,
921 RAZOR_DETAIL_NAME, &name,
922 RAZOR_DETAIL_VERSION, &version,
923 RAZOR_DETAIL_ARCH, &arch,
924 RAZOR_DETAIL_LAST)) {
925 if (pattern && fnmatch(pattern, name, 0) != 0)
928 razor_package_get_details (set, package,
929 RAZOR_DETAIL_SUMMARY, &summary,
930 RAZOR_DETAIL_DESCRIPTION, &description,
931 RAZOR_DETAIL_URL, &url,
932 RAZOR_DETAIL_LICENSE, &license,
935 printf ("Name: %s\n", name);
936 printf ("Arch: %s\n", arch);
937 printf ("Version: %s\n", version);
938 printf ("URL: %s\n", url);
939 printf ("License: %s\n", license);
940 printf ("Summary: %s\n", summary);
941 printf ("Description:\n");
942 printf ("%s\n", description);
945 razor_package_iterator_destroy(pi);
946 razor_set_destroy(set);
951 #define SEARCH_MAX 256
954 command_search(int argc, const char *argv[])
956 struct razor_set *set;
957 struct razor_package_iterator *pi;
958 struct razor_package *package;
959 char pattern[SEARCH_MAX];
960 const char *name, *version, *arch;
961 const char *summary, *description, *url, *license;
964 fprintf(stderr, "must specify a search term\n");
968 snprintf(pattern, sizeof pattern, "*%s*", argv[0]);
970 set = razor_set_open(rawhide_repo_filename);
974 if (razor_set_open_details(set, "rawhide-details.rzdb"))
977 pi = razor_package_iterator_create(set);
978 while (razor_package_iterator_next(pi, &package,
979 RAZOR_DETAIL_NAME, &name,
980 RAZOR_DETAIL_VERSION, &version,
981 RAZOR_DETAIL_ARCH, &arch,
982 RAZOR_DETAIL_SUMMARY, &summary,
983 RAZOR_DETAIL_DESCRIPTION, &description,
984 RAZOR_DETAIL_URL, &url,
985 RAZOR_DETAIL_LICENSE, &license,
986 RAZOR_DETAIL_LAST)) {
987 if (!fnmatch(pattern, name, FNM_CASEFOLD) ||
988 !fnmatch(pattern, url, FNM_CASEFOLD) ||
989 !fnmatch(pattern, summary, FNM_CASEFOLD) ||
990 !fnmatch(pattern, description, FNM_CASEFOLD))
991 printf("%s-%s.%s: %s\n", name, version, arch, summary);
993 razor_package_iterator_destroy(pi);
994 razor_set_destroy(set);
1001 const char *description;
1002 int (*func)(int argc, const char *argv[]);
1003 } razor_commands[] = {
1004 { "list", "list all packages", command_list },
1005 { "list-requires", "list all requires for the given package", command_list_requires },
1006 { "list-provides", "list all provides for the given package", command_list_provides },
1007 { "list-obsoletes", "list all obsoletes for the given package", command_list_obsoletes },
1008 { "list-conflicts", "list all conflicts for the given package", command_list_conflicts },
1009 { "list-files", "list files for package set", command_list_files },
1010 { "list-file-packages", "list packages owning file", command_list_file_packages },
1011 { "list-package-files", "list files in package", command_list_package_files },
1012 { "what-requires", "list the packages that have the given requires", command_what_requires },
1013 { "what-provides", "list the packages that have the given provides", command_what_provides },
1014 { "import-yum", "import yum metadata files", command_import_yum },
1016 { "import-rpmdb", "import the system rpm database", command_import_rpmdb },
1018 { "import-rpms", "import rpms from the given directory", command_import_rpms },
1019 { "update", "update all or specified packages", command_update },
1020 { "remove", "remove specified packages", command_remove },
1021 { "diff", "show diff between two package sets", command_diff },
1022 { "install", "install rpm", command_install },
1023 { "init", "init razor root", command_init },
1024 { "download", "download packages", command_download },
1025 { "info", "display package details", command_info },
1026 { "search", "search package details", command_search }
1035 for (i = 0; i < ARRAY_SIZE(razor_commands); i++)
1036 printf(" %-20s%s\n",
1037 razor_commands[i].name, razor_commands[i].description);
1043 main(int argc, const char *argv[])
1048 repo = getenv("RAZOR_REPO");
1050 repo_filename = repo;
1052 root = getenv("RAZOR_ROOT");
1054 install_root = root;
1056 yum_url = getenv("YUM_URL");
1057 if (yum_url == NULL)
1063 for (i = 0; i < ARRAY_SIZE(razor_commands); i++)
1064 if (strcmp(razor_commands[i].name, argv[1]) == 0)
1065 return razor_commands[i].func(argc - 2, argv + 2);