summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--opkg-opk/main.c44
1 files changed, 38 insertions, 6 deletions
diff --git a/opkg-opk/main.c b/opkg-opk/main.c
index cab68e9..e0123b5 100644
--- a/opkg-opk/main.c
+++ b/opkg-opk/main.c
@@ -38,6 +38,7 @@
extern const char *PACKAGE_VERSION_GIT;
+/* TODO: Options -o, -u, -g, and -r */
static const char *_OPTSTRING = "bc:d:s:f:F:lLhV";
#ifdef HAVE_GETOPT_LONG
static const struct option _LONGOPTS[] = {
@@ -218,7 +219,9 @@ int
main(int argc, char *argv[])
{
struct opkg_opk_opk *opk;
+ int want_build;
int build;
+ int build_dirs;
int opt_f;
int opt_F;
int opt_l;
@@ -242,12 +245,14 @@ main(int argc, char *argv[])
return EXIT_FAILURE;
}
- opterr = 0;
- build = 0;
- opt_f = 0;
- opt_F = 0;
- opt_l = 0;
- opt_L = 0;
+ opterr = 0;
+ want_build = 0;
+ build = 0;
+ build_dirs = 0;
+ opt_f = 0;
+ opt_F = 0;
+ opt_l = 0;
+ opt_L = 0;
#ifdef HAVE_GETOPT_LONG
while ((opt = getopt_long(argc, argv, _OPTSTRING, _LONGOPTS, NULL))
!= -1) {
@@ -259,12 +264,16 @@ main(int argc, char *argv[])
build = 1;
break;
case 'c':
+ ++build_dirs;
opkg_opk_opk_control_dir(opk, optarg);
break;
case 'd':
+ ++build_dirs;
+ want_build = 1;
opkg_opk_opk_data_dir(opk, optarg);
break;
case 's':
+ want_build = 1;
if (opkg_opk_opk_specials_read(opk, optarg) !=
OPKG_OPK_OK) {
opkg_opk_error(_("Failed to read "
@@ -275,6 +284,7 @@ main(int argc, char *argv[])
}
break;
case 'f':
+ want_build = -1;
if (opt_l > 0) {
_opt_mutex(argv[0], 'f', 'l');
opkg_opk_opk_free(opk);
@@ -288,6 +298,7 @@ main(int argc, char *argv[])
}
break;
case 'F':
+ want_build = -1;
if (opt_L > 0) {
_opt_mutex(argv[0], 'F', 'L');
opkg_opk_opk_free(opk);
@@ -301,6 +312,7 @@ main(int argc, char *argv[])
}
break;
case 'l':
+ want_build = -1;
if (opt_f > 0) {
_opt_mutex(argv[0], 'f', 'l');
opkg_opk_opk_free(opk);
@@ -310,6 +322,7 @@ main(int argc, char *argv[])
opkg_opk_opk_list_control(opk);
break;
case 'L':
+ want_build = -1;
if (opt_F > 0) {
_opt_mutex(argv[0], 'F', 'L');
opkg_opk_opk_free(opk);
@@ -334,6 +347,25 @@ main(int argc, char *argv[])
return EXIT_FAILURE;
}
}
+ if (want_build < 0 && build > 0) {
+ opkg_opk_error(_("Options -f, -F, -l, and -L "
+ "are invalid with -b"));
+ _help_tip(argv[0]);
+ opkg_opk_opk_free(opk);
+ return EXIT_FAILURE;
+ } else if (want_build > 0 && build <= 0) {
+ opkg_opk_error(_("Options -d and -s are only valid with -b"));
+ /* TODO: opkg_opk_error(_("Options -d, -s, -o, -u, -g, and -r "
+ "are only valid with -b")); */
+ _help_tip(argv[0]);
+ opkg_opk_opk_free(opk);
+ return EXIT_FAILURE;
+ } else if (build > 0 && build_dirs < 2) {
+ opkg_opk_error(_("Options -c and -d are required with -b"));
+ _help_tip(argv[0]);
+ opkg_opk_opk_free(opk);
+ return EXIT_FAILURE;
+ } /* TODO: Options -u and -g are invalid with -r */
argc -= optind;
argv += optind;