diff --git a/pkg/main.c b/pkg/main.c index 4016509..8978414 100644 --- a/pkg/main.c +++ b/pkg/main.c @@ -555,58 +555,62 @@ main(int argc, char **argv) cmdargv = argv; cmdargc = argc; - if (argc < 2) - usage(NULL, NULL); + if (strcmp(getprogname(), "pkg") == 0 || + strcmp(getprogname(), "pkg-static") == 0) { + + if (argc < 2) + usage(NULL, NULL); #ifndef NO_LIBJAIL - while ((ch = getopt(argc, argv, "dj:c:C:R:lNvq")) != -1) { + while ((ch = getopt(argc, argv, "dj:c:C:R:lNvq")) != -1) { #else - while ((ch = getopt(argc, argv, "d:c:C:R:lNvq")) != -1) { + while ((ch = getopt(argc, argv, "d:c:C:R:lNvq")) != -1) { #endif - switch (ch) { - case 'd': - debug++; - break; - case 'c': - chroot_path = optarg; - break; - case 'C': - conffile = optarg; - break; - case 'R': - reposdir = optarg; - break; + switch (ch) { + case 'd': + debug++; + break; + case 'c': + chroot_path = optarg; + break; + case 'C': + conffile = optarg; + break; + case 'R': + reposdir = optarg; + break; #ifndef NO_LIBJAIL - case 'j': - jail_str = optarg; - break; + case 'j': + jail_str = optarg; + break; #endif - case 'l': - show_commands = true; - break; - case 'N': - activation_test = true; - break; - case 'v': - version++; - break; - default: - break; + case 'l': + show_commands = true; + break; + case 'N': + activation_test = true; + break; + case 'v': + version++; + break; + default: + break; + } } - } - argc -= optind; - argv += optind; + argc -= optind; + argv += optind; - if (version == 1) - show_version_info(version); + if (version == 1) + show_version_info(version); - if (show_commands && version == 0) { - show_command_names(); - exit(EX_OK); - } + if (show_commands && version == 0) { + show_command_names(); + exit(EX_OK); + } - if (argc == 0 && version == 0 && !activation_test) - usage(conffile, reposdir); + if (argc == 0 && version == 0 && !activation_test) + usage(conffile, reposdir); + } umask(022); pkg_event_register(&event_callback, &debug);