commit 555856ab0a5890e197addc04f847f565529b1483
parent b7163f35ce389c33f283ba9adf3954adc495820d
Author: Joris Vink <joris@coders.se>
Date: Thu, 26 Sep 2019 16:41:52 +0200
fix usage for python builds.
while here, force a module or script as a cli argument and
fix kodev run to pass the config if inside of a module.
Diffstat:
2 files changed, 27 insertions(+), 22 deletions(-)
diff --git a/src/cli.c b/src/cli.c
@@ -1546,13 +1546,19 @@ cli_compile_kore(void *arg)
static void
cli_run_kore_python(void)
{
- char *args[3], *cmd;
+ char *args[5], *cmd;
+ char pwd[MAXPATHLEN];
(void)cli_vasprintf(&cmd, "%s/bin/kore", prefix);
+ if (getcwd(pwd, sizeof(pwd)) == NULL)
+ fatal("could not get cwd: %s", errno_s);
+
args[0] = cmd;
- args[1] = "-frn";
- args[2] = NULL;
+ args[1] = "-frnc";
+ args[2] = "kore.conf";
+ args[3] = pwd;
+ args[4] = NULL;
execvp(args[0], args);
fatal("failed to start '%s': %s", args[0], errno_s);
diff --git a/src/kore.c b/src/kore.c
@@ -97,27 +97,31 @@ static void kore_server_start(int, char *[]);
static void
usage(void)
{
- fprintf(stderr, "Usage: %s [options]\n", __progname);
+#if !defined(KORE_SINGLE_BINARY) && defined(KORE_USE_PYTHON)
+ printf("Usage: %s [options] [app | app.py]\n", __progname);
+#else
+ printf("Usage: %s [options]\n", __progname);
+#endif
- fprintf(stderr, "\n");
- fprintf(stderr, "Available options:\n");
+ printf("\n");
+ printf("Available options:\n");
#if !defined(KORE_SINGLE_BINARY)
- fprintf(stderr, "\t-c\tconfiguration to use\n");
+ printf("\t-c\tconfiguration to use\n");
#endif
#if defined(KORE_DEBUG)
- fprintf(stderr, "\t-d\trun with debug on\n");
+ printf("\t-d\trun with debug on\n");
#endif
- fprintf(stderr, "\t-f\tstart in foreground\n");
- fprintf(stderr, "\t-h\tthis help text\n");
- fprintf(stderr, "\t-n\tdo not chroot\n");
- fprintf(stderr, "\t-q\tonly log errors\n");
- fprintf(stderr, "\t-r\tdo not drop privileges\n");
- fprintf(stderr, "\t-v\tdisplay %s build information\n", __progname);
+ printf("\t-f\tstart in foreground\n");
+ printf("\t-h\tthis help text\n");
+ printf("\t-n\tdo not chroot\n");
+ printf("\t-q\tonly log errors\n");
+ printf("\t-r\tdo not drop privileges\n");
+ printf("\t-v\tdisplay %s build information\n", __progname);
#if !defined(KORE_SINGLE_BINARY)
- fprintf(stderr, "\nFind more information on https://kore.io\n");
+ printf("\nFind more information on https://kore.io\n");
#else
- fprintf(stderr, "\nBuilt using https://kore.io\n");
+ printf("\nBuilt using https://kore.io\n");
#endif
exit(1);
@@ -162,7 +166,6 @@ main(int argc, char *argv[])
int ch, flags;
#if !defined(KORE_SINGLE_BINARY) && defined(KORE_USE_PYTHON)
struct stat st;
- char pwd[MAXPATHLEN];
#endif
flags = 0;
@@ -223,13 +226,9 @@ main(int argc, char *argv[])
argc--;
argv++;
} else {
- if (getcwd(pwd, sizeof(pwd)) == NULL)
- fatal("getcwd: %s", errno_s);
- kore_pymodule = pwd;
+ usage();
}
- config_file = NULL;
-
if (lstat(kore_pymodule, &st) == -1)
fatal("failed to stat '%s': %s", kore_pymodule, errno_s);