Add pyko, not linked to build.

This commit is contained in:
Joris Vink 2018-04-09 13:05:38 +02:00
parent 9c337ded1e
commit bf4361092c
6 changed files with 119 additions and 0 deletions

6
pyko/.gitignore vendored Normal file
View File

@ -0,0 +1,6 @@
*.o
.flavor
.objs
pyko.so
assets.h
cert

19
pyko/Makefile Normal file
View File

@ -0,0 +1,19 @@
# pyko Makefile
BIN=pyko
PREFIX?=/usr/local
INSTALL_DIR=$(PREFIX)/bin
KODEV?=../kodev/kodev
build:
$(KODEV) build
clean:
$(KODEV) clean
install:
install -m 555 $(BIN) $(INSTALL_DIR)/$(BIN)
uninstall:
rm -f $(INSTALL_DIR)/$(BIN)

39
pyko/README.md Normal file
View File

@ -0,0 +1,39 @@
About
-----
Pyko is a single binary kore build aimed at starting kore python applications
in a more easy and straight forward manner.
Building
--------
This kore application builds with PYTHON=1 and PGSQL=1 automatically.
See the kore README file on what dependencies are required for this.
From the root kore directory run:
```
$ make -C kodev
$ make -C pyko
$ sudo make -C pyko install
```
App layout
----------
Your python application directory must have the following layout:
```
app/
kore.conf <- actual kore configuration
__init__.py <- usual python init stuff
```
Usage
-----
```
$ pyko -frn python_app
```
```
-f = foreground
-n = skip chroot
-r = skip privilege drop
```

17
pyko/conf/build.conf Normal file
View File

@ -0,0 +1,17 @@
# pyko build config
single_binary=yes
kore_source=../
kore_flavor=PYTHON=1 PGSQL=1
cflags=-std=c99 -pedantic
cflags=-Wall -Wmissing-declarations -Wshadow
cflags=-Wstrict-prototypes -Wmissing-prototypes
cflags=-Wpointer-arith -Wcast-qual -Wsign-compare
dev {
cflags=-g
}
prod {
}

1
pyko/conf/pyko.conf Normal file
View File

@ -0,0 +1 @@
# pyko configuration

37
pyko/src/pyko.c Normal file
View File

@ -0,0 +1,37 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <kore/kore.h>
#include <stdio.h>
#include <limits.h>
void
kore_parent_configure(int argc, char **argv)
{
struct stat st;
int len;
FILE *fp;
char config[PATH_MAX];
if (argc != 1)
fatal("Usage: pyko [python app]");
if (stat(argv[0], &st) == -1)
fatal("stat(%s): %s", argv[0], errno_s);
if (!S_ISDIR(st.st_mode))
fatal("python module directory required");
len = snprintf(config, sizeof(config), "%s/kore.conf", argv[0]);
if (len == -1 || (size_t)len >= sizeof(config))
fatal("failed to create configuration path");
if ((fp = fopen(config, "r")) == NULL)
fatal("failed to open configuration '%s'", config);
kore_module_load(argv[0], NULL, KORE_MODULE_PYTHON);
/* kore_parse_config_file() will call fclose(). */
kore_parse_config_file(fp);
}