rpm-razor.c
author Kristian H?gsberg <krh@redhat.com>
Tue Jun 03 15:21:22 2008 -0400 (2008-06-03)
changeset 215 85381bba83df
child 216 b97c130460a5
permissions -rw-r--r--
Start rpm commandline compatible wrapper.
     1 /*
     2  * Copyright (C) 2008  Kristian Høgsberg <krh@redhat.com>
     3  * Copyright (C) 2008  Red Hat, Inc
     4  *
     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.
     9  *
    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.
    14  *
    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.
    18  */
    19 
    20 #include <stdlib.h>
    21 #include <string.h>
    22 #include <stdio.h>
    23 #include "razor.h"
    24 
    25 enum option_type {
    26 	OPTION_LAST,
    27 	OPTION_GROUP,
    28 	OPTION_BOOL,
    29 	OPTION_STRING
    30 };
    31 
    32 struct option {
    33 	enum option_type type;
    34 	const char *name;
    35 	char short_name;
    36 	const char *arg_name;
    37 	const char *description;
    38 	void *data;
    39 };
    40 
    41 static int option_all;
    42 
    43 static const struct option query_options[] = {
    44 	{ OPTION_BOOL, "configfiles", 'c', NULL, "list all configuration files", NULL },
    45 	{ OPTION_BOOL, "docfiles", 'd', NULL, "list all documentation files", NULL },
    46 	{ OPTION_BOOL, "dump", 0, NULL, "dump basic file information", NULL },
    47 	{ OPTION_BOOL, "list", 0, NULL, "list files in package", NULL },
    48 	{ OPTION_STRING, "queryformat", 0, "QUERYFORMAT", "use the following query format", NULL },
    49 	{ OPTION_BOOL, "state", 's', NULL, "display the states of the listed files", NULL },
    50 	{ OPTION_BOOL, "all", 'a', NULL, "query/verify all packages", &option_all },
    51 	{ OPTION_BOOL, "file", 'f', NULL, "query/verify package(s) owning file", NULL },
    52 	{ OPTION_BOOL, "group", 'g', NULL, "query/verify package(s) in group", NULL },
    53 	{ OPTION_BOOL, "package", 'p', NULL, "query/verify a package file", NULL },
    54 	{ OPTION_BOOL, "ftswalk", 'W', NULL, "query/verify package(s) from TOP file tree walk", NULL },
    55 	{ OPTION_BOOL, "pkgid", 0, NULL, "query/verify package(s) with package identifier", NULL },
    56 	{ OPTION_BOOL, "hdrid", 0, NULL, "query/verify package(s) with header identifier", NULL },
    57 	{ OPTION_BOOL, "fileid", 0, NULL, "query/verify package(s) with file identifier", NULL },
    58 	{ OPTION_BOOL, "specfile", 0, NULL, "query a spec file", NULL, },
    59 	{ OPTION_BOOL, "triggeredby", 0, NULL, "query the package(s) triggered by the package", NULL },
    60 	{ OPTION_BOOL, "whatrequires", 0, NULL, "query/verify the package(s) which require a dependency", NULL },
    61 	{ OPTION_BOOL, "whatprovides", 0, NULL, "query/verify the package(s) which provide a dependency", NULL },
    62 	{ OPTION_BOOL, "nomanifest", 0, NULL, "do not process non-package files as manifests", NULL },
    63 	{ }
    64 };
    65 
    66 static const struct option verify_options[] = {
    67 	{ OPTION_BOOL, "nomd5", 0, NULL, "don't verify MD5 digest of files", NULL },
    68 	{ OPTION_BOOL, "nofiles", 0, NULL, "don't verify files in package", NULL },
    69 	{ OPTION_BOOL, "nodeps", 0, NULL, "don't verify package dependencies", NULL },
    70 	{ OPTION_BOOL, "noscript", 0, NULL, "don't execute verify script(s)", NULL, },
    71 	{ OPTION_BOOL, "all", 'a', NULL, "query/verify all packages", NULL },
    72 	{ OPTION_BOOL, "file", 'f', NULL, "query/verify package(s) owning file", NULL },
    73 	{ OPTION_BOOL, "group", 'g', NULL, "query/verify package(s) in group", NULL },
    74 	{ OPTION_BOOL, "package", 'p', NULL, "query/verify a package file", NULL },
    75 	{ OPTION_BOOL, "ftswalk", 'W', NULL, "query/verify package(s) from TOP file tree walk", NULL },
    76 	{ OPTION_BOOL, "pkgid", 0, NULL, "query/verify package(s) with package identifier", NULL },
    77 	{ OPTION_BOOL, "hdrid", 0, NULL, "query/verify package(s) with header identifier", NULL },
    78 	{ OPTION_BOOL, "fileid", 0, NULL, "query/verify package(s) with file identifier", NULL },
    79 	{ OPTION_BOOL, "specfile", 0, NULL, "query a spec file", NULL },
    80 	{ OPTION_BOOL, "triggeredby", 0, NULL, "query the package(s) triggered by the package", NULL },
    81 	{ OPTION_BOOL, "whatrequires", 0, NULL, "query/verify the package(s) which require a dependency", NULL },
    82 	{ OPTION_BOOL, "whatprovides", 0, NULL, "query/verify the package(s) which provide a dependency", NULL },
    83 	{ OPTION_BOOL, "nomanifest", 0, NULL, "do not process non-package files as manifests", NULL },
    84 	{ }
    85 };
    86 
    87 static const struct option ftw_options[] = {
    88 	{ OPTION_BOOL, "comfollow", 0, NULL, "FTS_COMFOLLOW: follow command line symlinks", NULL },
    89 	{ OPTION_BOOL, "logical", 0, NULL, "FTS_LOGICAL: logical walk", NULL },
    90 	{ OPTION_BOOL, "nochdir", 0, NULL, "FTS_NOCHDIR: don't change directories", NULL },
    91 	{ OPTION_BOOL, "nostat", 0, NULL, "FTS_NOSTAT: don't get stat info", NULL },
    92 	{ OPTION_BOOL, "physical", 0, NULL, "FTS_PHYSICAL: physical walk", NULL },
    93 	{ OPTION_BOOL, "seedot", 0, NULL, "FTS_SEEDOT: return dot and dot-dot", NULL },
    94 	{ OPTION_BOOL, "xdev", 0, NULL, "FTS_XDEV: don't cross devices", NULL },
    95 	{ OPTION_BOOL, "whiteout", 0, NULL, "FTS_WHITEOUT: return whiteout information", NULL },
    96 	{ }
    97 };
    98 
    99 static const struct option signature_options[] = {
   100 	{ OPTION_BOOL, "addsign", 0, NULL, "sign package(s) (identical to --resign)", NULL, },
   101 	{ OPTION_BOOL, "checksig", 'K', NULL, "verify package signature(s)", NULL, },
   102 	{ OPTION_BOOL, "delsign", 0, NULL, "delete package signatures", NULL, },
   103 	{ OPTION_BOOL, "import", 0, NULL, "import an armored public key", NULL, },
   104 	{ OPTION_BOOL, "resign", 0, NULL, "sign package(s) (identical to --addsign)", NULL, },
   105 	{ OPTION_BOOL, "nodigest", 0, NULL, "don't verify package digest(s)", NULL, },
   106 	{ OPTION_BOOL, "nosignature", 0, NULL, "don't verify package signature(s)", NULL },
   107 	{ }
   108 };
   109 
   110 static const struct option database_options[] = {
   111 	{ OPTION_BOOL, "initdb", 0, NULL, "initialize database", NULL },
   112 	{ OPTION_BOOL, "rebuilddb", 0, NULL, "rebuild database inverted lists from installed package headers", NULL },
   113 	{ }
   114 };
   115 
   116 static int option_erase, option_install, option_upgrade;
   117 
   118 static const struct option install_options[] = {
   119 	{ OPTION_BOOL, "aid", 0, NULL, "add suggested packages to transaction", NULL, },
   120 	{ OPTION_BOOL, "allfiles", 0, NULL, "install all files, even configurations which might otherwise be skipped", NULL, },
   121 	{ OPTION_BOOL, "allmatches", 0, NULL, "remove all packages which match <package> (normally an error is generated if <package> specified multiple packages)", NULL, },
   122 	{ OPTION_BOOL, "badreloc", 0, NULL, "relocate files in non-relocatable package", NULL },
   123 	{ OPTION_BOOL, "erase", 'e', "<package>", "erase (uninstall) package", &option_erase },
   124 	{ OPTION_BOOL, "excludedocs", 0, NULL, "do not install documentation", NULL, },
   125 	{ OPTION_BOOL, "excludepath", 0, "<path>", "skip files with leading component <path> ", NULL, },
   126 	{ OPTION_BOOL, "fileconflicts", 0, NULL, "detect file conflicts between packages", NULL, },
   127 	{ OPTION_BOOL, "force", 0, NULL, "short hand for --replacepkgs --replacefiles", NULL },
   128 	{ OPTION_BOOL, "freshen", 'F', "<packagefile>+", "upgrade package(s) if already installed", NULL },
   129 	{ OPTION_BOOL, "hash", 'h', NULL, "print hash marks as package installs (good with -v)", NULL },
   130 	{ OPTION_BOOL, "ignorearch", 0, NULL, "don't verify package architecture", NULL, },
   131 	{ OPTION_BOOL, "ignoreos", 0, NULL, "don't verify package operating system", NULL, },
   132 	{ OPTION_BOOL, "ignoresize", 0, NULL, "don't check disk space before installing", NULL },
   133 	{ OPTION_BOOL, "install", 'i', NULL, "install package(s)", &option_install },
   134 	{ OPTION_BOOL, "justdb", 0, NULL, "update the database, but do not modify the filesystem", NULL, },
   135 	{ OPTION_BOOL, "nodeps", 0, NULL, "do not verify package dependencies", NULL, },
   136 	{ OPTION_BOOL, "nomd5", 0, NULL, "don't verify MD5 digest of files", NULL, },
   137 	{ OPTION_BOOL, "nocontexts", 0, NULL, "don't install file security contexts", NULL, },
   138 	{ OPTION_BOOL, "noorder", 0, NULL, "do not reorder package installation to satisfy dependencies", NULL, },
   139 	{ OPTION_BOOL, "nosuggest", 0, NULL, "do not suggest missing dependency resolution(s)", NULL, },
   140 	{ OPTION_BOOL, "noscripts", 0, NULL, "do not execute package scriptlet(s)", NULL, },
   141 	{ OPTION_BOOL, "notriggers", 0, NULL, "do not execute any scriptlet(s) triggered by this package", NULL, },
   142 	{ OPTION_BOOL, "oldpackage", 0, NULL, "upgrade to an old version of the package (--force on upgrades does this automatically)", NULL },
   143 	{ OPTION_BOOL, "percent", 0, NULL, "print percentages as package installs", NULL, },
   144 	{ OPTION_STRING, "prefix", 0, "<dir>", "relocate the package to <dir>, if relocatable", NULL, },
   145 	{ OPTION_STRING, "relocate", 0, "<old>=<new>", "relocate files from path <old> to <new>", NULL, },
   146 	{ OPTION_BOOL, "repackage", 0, NULL, "save erased package files by repackaging", NULL, },
   147 	{ OPTION_BOOL, "replacefiles", 0, NULL, "ignore file conflicts between packages", NULL, },
   148 	{ OPTION_BOOL, "replacepkgs", 0, NULL, "reinstall if the package is already present", NULL, },
   149 	{ OPTION_BOOL, "test", 0, NULL, "don't install, but tell if it would work or not", NULL },
   150 	{ OPTION_BOOL, "upgrade", 'U', "<packagefile>+", "upgrade package(s)", &option_upgrade },
   151 	{ }
   152 };
   153 
   154 static int option_version;
   155 
   156 static const struct option common_options[] = {
   157 	{ OPTION_STRING, "define", 'D', "MACRO EXPR", "define MACRO with value EXPR", NULL, },
   158 	{ OPTION_STRING, "eval", 'E', "EXPR", "print macro expansion of EXPR", NULL },
   159 	{ OPTION_STRING, "macros", 0, "<FILE:...>", "read <FILE:...> instead of default file(s)", NULL },
   160 	{ OPTION_BOOL, "nodigest", 0, NULL, "don't verify package digest(s)", NULL, },
   161 	{ OPTION_BOOL, "nosignature", 0, NULL, "don't verify package signature(s)", NULL, },
   162 	{ OPTION_STRING, "rcfile", 0, "<FILE:...>", "read <FILE:...> instead of default file(s)", NULL },
   163 	{ OPTION_STRING, "root", 'r', "ROOT", "use ROOT as top level directory (default: \"/\")", NULL },
   164 	{ OPTION_BOOL, "querytags", 0, NULL, "display known query tags", NULL, },
   165 	{ OPTION_BOOL, "showrc", 0, NULL, "display final rpmrc and macro configuration", NULL, },
   166 	{ OPTION_BOOL, "quiet", 0, NULL, "provide less detailed output", NULL },
   167 	{ OPTION_BOOL, "verbose", 'v', NULL, "provide more detailed output", NULL },
   168 	{ OPTION_BOOL, "version", 0, NULL, "print the version of rpm being used", &option_version },
   169 	{ }
   170 };
   171 
   172 static const struct option alias_options[] = {
   173 	{ OPTION_BOOL, "scripts", 0, NULL, "list install/erase scriptlets from package(s)", NULL, },
   174 	{ OPTION_BOOL, "setperms", 0, NULL, "set permissions of files in a package", NULL, },
   175 	{ OPTION_BOOL, "setugids", 0, NULL, "set user/group ownership of files in a package", NULL, },
   176 	{ OPTION_BOOL, "conflicts", 0, NULL, "list capabilities this package conflicts with", NULL, },
   177 	{ OPTION_BOOL, "obsoletes", 0, NULL, "list other packages removed by installing this package", NULL, },
   178 	{ OPTION_BOOL, "provides", 0, NULL, "list capabilities that this package provides", NULL, },
   179 	{ OPTION_BOOL, "requires", 0, NULL, "list capabilities required by package(s)", NULL, },
   180 	{ OPTION_BOOL, "info", 0, NULL, "list descriptive information from package(s)", NULL, },
   181 	{ OPTION_BOOL, "changelog", 0, NULL, "list change logs for this package", NULL, },
   182 	{ OPTION_BOOL, "xml", 0, NULL, "list metadata in xml", NULL, },
   183 	{ OPTION_BOOL, "triggers", 0, NULL, "list trigger scriptlets from package(s)", NULL, },
   184 	{ OPTION_BOOL, "last", 0, NULL, "list package(s) by install time, most recent first", NULL, },
   185 	{ OPTION_BOOL, "dupes", 0, NULL, "list duplicated packages", NULL, },
   186 	{ OPTION_BOOL, "filesbypkg", 0, NULL, "list all files from each package", NULL, },
   187 	{ OPTION_BOOL, "fileclass", 0, NULL, "list file names with classes", NULL, },
   188 	{ OPTION_BOOL, "filecolor", 0, NULL, "list file names with colors", NULL, },
   189 	{ OPTION_BOOL, "filecontext", 0, NULL, "list file names with security context from header", NULL, },
   190 	{ OPTION_BOOL, "fscontext", 0, NULL, "list file names with security context from file system", NULL, },
   191 	{ OPTION_BOOL, "recontext", 0, NULL, "list file names with security context from policy RE", NULL, },
   192 	{ OPTION_BOOL, "fileprovide", 0, NULL, "list file names with provides", NULL, },
   193 	{ OPTION_BOOL, "filerequire", 0, NULL, "list file names with requires", NULL, },
   194 	{ OPTION_BOOL, "redhatprovides", 0, NULL, "find package name that contains a provided capability (needs rpmdb-redhat package installed)", NULL, },
   195 	{ OPTION_BOOL, "redhatrequires", 0, NULL, "find package name that contains a required capability (needs rpmdb-redhat package installed)", NULL, },
   196 	{ OPTION_STRING, "buildpolicy", 0, "<policy>", "set buildroot <policy> (e.g. compress man pages)", NULL, },
   197 	{ OPTION_BOOL, "with", 0, "<option>", "enable configure <option> for build", NULL, },
   198 	{ OPTION_BOOL, "without", 0, "<option>", "disable configure <option> for build", NULL },
   199 	{ }
   200 };
   201 
   202 static int option_help, option_usage;
   203 
   204 static const struct option help_options[] = {
   205 	{ OPTION_BOOL, "help", '?', NULL, "Show this help message", &option_help },
   206 	{ OPTION_BOOL, "usage", 0, NULL, "Display brief usage message", &option_usage},
   207 	{ }
   208 };
   209 
   210 static int option_query, option_verify;
   211 
   212 static const struct option rpm_options[] = {
   213 	{ OPTION_BOOL, "query", 'q', NULL, "Query rpm database", &option_query },
   214 	{ OPTION_BOOL, "verify", 'V', NULL, "Verify rpm database", &option_verify },
   215 	{ OPTION_GROUP, NULL, 0, NULL, "Query options (with -q or --query):", &query_options },
   216 	{ OPTION_GROUP, NULL, 0, NULL, "Verify options (with -V or --verify):", &verify_options },
   217 	{ OPTION_GROUP, NULL, 0, NULL, "File tree walk options (with --ftswalk):", &ftw_options },
   218 	{ OPTION_GROUP, NULL, 0, NULL, "Signature options:", &signature_options },
   219 	{ OPTION_GROUP, NULL, 0, NULL, "Database options:", &database_options },
   220 	{ OPTION_GROUP, NULL, 0, NULL, "Install/Upgrade/Erase options:", &install_options },
   221 	{ OPTION_GROUP, NULL, 0, NULL, "Common options for all rpm modes and executables:", &common_options },
   222 	{ OPTION_GROUP, NULL, 0, NULL, "Options implemented via popt alias/exec:", &alias_options },
   223 	{ OPTION_GROUP, NULL, 0, NULL, "Help options", &help_options },
   224 	{ }
   225 };
   226 
   227 static void
   228 command_query(int argc, const char *argv[])
   229 {
   230 	if (argc == 0 && !option_all) {
   231 		printf("no arguments given for query\n");
   232 		exit(1);
   233 	}
   234 
   235 	printf("command query - not implemented\n");
   236 }
   237 
   238 static void
   239 command_verify(int argc, const char *argv[])
   240 {
   241 	if (argc == 0) {
   242 		printf("no arguments given for verify\n");
   243 		exit(1);
   244 	}
   245 
   246 	printf("command verify - not implemented\n");
   247 }
   248 
   249 static void
   250 command_erase(int argc, const char *argv[])
   251 {
   252 	if (argc == 0) {
   253 		printf("no packages given for erase\n");
   254 		exit(1);
   255 	}
   256 
   257 	printf("command erase - not implemented\n");
   258 }
   259 
   260 static void
   261 command_install(int argc, const char *argv[])
   262 {
   263 	if (argc == 0) {
   264 		printf("no packages given for install\n");
   265 		exit(1);
   266 	}
   267 
   268 	printf("command install - not implemented\n");
   269 }
   270 
   271 static void
   272 command_update(int argc, const char *argv[])
   273 {
   274 	if (argc == 0) {
   275 		printf("no packages given for update\n");
   276 		exit(1);
   277 	}
   278 
   279 	printf("command update - not implemented\n");
   280 }
   281 
   282 static const struct option *
   283 find_option(const struct option *options, const char *s)
   284 {
   285 	const struct option *o;
   286 	int i;
   287 
   288 	for (i = 0; options[i].type != OPTION_LAST; i++) {
   289 		switch (options[i].type) {
   290 		case OPTION_GROUP:
   291 			o = find_option(options[i].data, s);
   292 			if (o != NULL)
   293 				return o;
   294 			break;
   295 
   296 		case OPTION_BOOL:
   297 		case OPTION_STRING:
   298 			if (s[0] == '-' &&
   299 			    s[1] == options[i].short_name && s[2] == '\0')
   300 				return &options[i];
   301 			if (s[0] == '-' && s[1] == '-' &&
   302 			    strcmp(options[i].name, s + 2) == 0)
   303 				return &options[i];
   304 			break;
   305 
   306 		case OPTION_LAST:
   307 			break;
   308 		}
   309 	}
   310 
   311 	return NULL;
   312 }
   313 
   314 static int
   315 parse_options(const struct option *options, int argc, const char **argv)
   316 {
   317 	const struct option *o;
   318 	int i, j;
   319 
   320 	/* FIXME: Bundling... rpm -Uvh must work :) */
   321 
   322 	for (i = 1, j = 0; i < argc; i++) {
   323 		if (argv[i][0] != '-') {
   324 			argv[j++] = argv[i];
   325 			continue;
   326 		}
   327 		o = find_option(options, argv[i]);
   328 		if (o == NULL) {
   329 			printf("unknown option: \"%s\"\n", argv[i]);
   330 			continue;
   331 		}
   332 		if (o->data == NULL) {
   333 			printf("option \"%s\" not supported\n", argv[i]);
   334 			continue;
   335 		}
   336 		switch (o->type) {
   337 		case OPTION_BOOL:
   338 			*(int *) o->data = 1;
   339 			break;
   340 
   341 		case OPTION_STRING:
   342 			*(const char **) o->data =
   343 				argv[i] + strlen(o->name) + 3;
   344 			break;
   345 
   346 		case OPTION_LAST:
   347 		case OPTION_GROUP:
   348 			/* Shouldn't happen. */
   349 			break;
   350 		}
   351 	}
   352 
   353 	return j;
   354 }
   355 
   356 static void
   357 print_options_help(const struct option *options)
   358 {
   359 	int i;
   360 
   361 	for (i = 0; options[i].type != OPTION_LAST; i++) {
   362 		switch (options[i].type) {
   363 		case OPTION_GROUP:
   364 			printf("%s\n", options[i].description);
   365 			print_options_help(options[i].data);
   366 			printf("\n");
   367 			break;
   368 
   369 		case OPTION_BOOL:
   370 		case OPTION_STRING:
   371 			printf("  ");
   372 			if (options[i].short_name)
   373 				printf("-%c", options[i].short_name);
   374 			if (options[i].short_name && options[i].name)
   375 				printf(", ");
   376 			if (options[i].name)
   377 				printf("--%s", options[i].name);
   378 			if (options[i].arg_name)
   379 				printf("=%s", options[i].arg_name);
   380 			if (options[i].description)
   381 				printf("\t\t%s", options[i].description);
   382 			printf("\n");
   383 			break;
   384 
   385 		case OPTION_LAST:
   386 			break;
   387 		}
   388 	}
   389 }
   390 
   391 static void
   392 print_options_usage(const struct option *options)
   393 {
   394 	int i;
   395 
   396 	for (i = 0; options[i].type != OPTION_LAST; i++) {
   397 		switch (options[i].type) {
   398 		case OPTION_GROUP:
   399 			print_options_usage(options[i].data);
   400 			break;
   401 
   402 		case OPTION_BOOL:
   403 			printf("[");
   404 			if (options[i].short_name)
   405 				printf("-%c", options[i].short_name);
   406 			if (options[i].short_name && options[i].name)
   407 				printf("|");
   408 			if (options[i].name)
   409 				printf("--%s", options[i].name);
   410 			printf("] ");
   411 			break;
   412 
   413 		case OPTION_STRING:
   414 			printf("[");
   415 			if (options[i].short_name)
   416 				printf("-%c", options[i].short_name);
   417 			if (options[i].short_name && options[i].name)
   418 				printf("|");
   419 			if (options[i].name)
   420 				printf("--%s", options[i].name);
   421 			if (options[i].arg_name)
   422 				printf("=%s", options[i].arg_name);
   423 			printf("] ");
   424 			break;
   425 
   426 
   427 			break;
   428 
   429 		case OPTION_LAST:
   430 			break;
   431 		}
   432 	}
   433 }
   434 
   435 int
   436 main(int argc, const char *argv[])
   437 {
   438 	argc = parse_options(rpm_options, argc, argv);
   439 
   440 	if (option_version) {
   441 		printf("razor rpm version hoopla.\n");
   442 		exit(0);
   443 	}
   444 
   445 	if (option_help) {
   446 		printf("Usage: rpm [OPTION...]\n");
   447 		print_options_help(rpm_options);
   448 		exit(0);
   449 	}
   450 
   451 	if (option_usage) {
   452 		printf("Usage: rpm [OPTION...]\n");
   453 		print_options_usage(rpm_options);
   454 		printf("\n");
   455 		exit(0);
   456 	}
   457 
   458 	if (option_query + option_verify +
   459 	    option_erase + option_install + option_upgrade > 1) {
   460 		printf("specify only one of query, verify, erase, install "
   461 		       "or upgrade\n");
   462 		exit(1);
   463 	}
   464 	    
   465 	if (option_query) {
   466 		command_query(argc, argv);
   467 	} else if (option_verify) {
   468 		command_verify(argc, argv);
   469 	} else if (option_erase) {
   470 		command_erase(argc, argv);
   471 	} else if (option_install) {
   472 		command_install(argc, argv);
   473 	} else if (option_upgrade) {
   474 		command_update(argc, argv);
   475 	} else {
   476 		print_options_usage(rpm_options);
   477 		printf("\n");
   478 		exit(0);
   479 	}
   480 
   481 	return 0;
   482 }