diff --git a/recipes/pkg/python3/README b/recipes/pkg/python3/README
new file mode 100644
index 0000000..4cdbaec
--- /dev/null
+++ b/recipes/pkg/python3/README
@@ -0,0 +1,5 @@
+
+ Python interpreter version 3
+
+This package runs a non-interactive python interpreter. The programm will execute
+a file `hello.py` provided a File_system session.
diff --git a/recipes/pkg/python3/archives b/recipes/pkg/python3/archives
new file mode 100644
index 0000000..21d2448
--- /dev/null
+++ b/recipes/pkg/python3/archives
@@ -0,0 +1,6 @@
+_/raw/python3
+_/src/libc
+_/src/libpython3
+_/src/python3
+_/src/vfs
+_/src/vfs_jitterentropy
diff --git a/recipes/pkg/python3/hash b/recipes/pkg/python3/hash
new file mode 100644
index 0000000..5e77dfc
--- /dev/null
+++ b/recipes/pkg/python3/hash
@@ -0,0 +1 @@
+2018-07-03 c2dd737dddf6f94e923806cb769d47b26a0d8d17
diff --git a/recipes/pkg/python3/runtime b/recipes/pkg/python3/runtime
new file mode 100644
index 0000000..d05ad81
--- /dev/null
+++ b/recipes/pkg/python3/runtime
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/recipes/raw/python3/content.mk b/recipes/raw/python3/content.mk
new file mode 100644
index 0000000..3c99449
--- /dev/null
+++ b/recipes/raw/python3/content.mk
@@ -0,0 +1,4 @@
+content: python3.config
+
+python3.config:
+ cp $(REP_DIR)/recipes/raw/python3/$@ $@
diff --git a/recipes/raw/python3/hash b/recipes/raw/python3/hash
new file mode 100644
index 0000000..e59f1a8
--- /dev/null
+++ b/recipes/raw/python3/hash
@@ -0,0 +1 @@
+2018-07-03 37f7f0945ff5a585afff1c4f4c43cab0a104e2bb
diff --git a/recipes/raw/python3/python3.config b/recipes/raw/python3/python3.config
new file mode 100644
index 0000000..6f30556
--- /dev/null
+++ b/recipes/raw/python3/python3.config
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/recipes/src/libpython3/hash b/recipes/src/libpython3/hash
index 3ba03b5..a91ba76 100644
--- a/recipes/src/libpython3/hash
+++ b/recipes/src/libpython3/hash
@@ -1 +1 @@
-2018-06-26 ed89744a780cb71d1c3f2fdfe52d6c90bc87c919
+2018-07-03 9f3f71ff1b0534b62b1a5328962a45487bbf83a3
diff --git a/recipes/src/python3/hash b/recipes/src/python3/hash
index b248eaa..c7842bd 100644
--- a/recipes/src/python3/hash
+++ b/recipes/src/python3/hash
@@ -1 +1 @@
-2018-06-26 beb1cff416381790963ca24d3d2d1d0d3b24d1c8
+2018-07-03 4fc9571da9b41bf0c36391cecd5f630e91923695
diff --git a/run/python3.run b/run/python3.run
index eed58c0..27cff3f 100644
--- a/run/python3.run
+++ b/run/python3.run
@@ -8,6 +8,11 @@
if {![have_spec x86]} {
puts "Run script is only supported on x86"; exit 0 }
+proc depot_user {} { return [get_cmd_arg --depot-user local] }
+
+create_boot_directory
+
+import_from_depot [depot_user]/pkg/python3
#
# Build
@@ -15,13 +20,11 @@ if {![have_spec x86]} {
build {
core init
- app/python3
- lib/vfs/jitterentropy
drivers/timer
drivers/rtc
+ server/dynamic_rom
}
-create_boot_directory
#
# Generate config
@@ -49,11 +52,41 @@ set config {
-
-
+
+
+
-
-
+
+
+print(" \r\n\r");
+print(" -============================-");
+print(" || ||");
+print(" || Python Core 3 ||");
+print(" || ||");
+print(" || Genode 18.05 ||");
+print(" || ||");
+print(" -============================-");
+print(" \r");
+print(" 2018 by Genode Labs www.genode-labs.com");
+print(" \r\n\r");
+
+
+
+print("Hello again")
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -65,19 +98,7 @@ set config {
-
-print(" \r\n\r");
-print(" -============================-");
-print(" || ||");
-print(" || Python Core 3 ||");
-print(" || ||");
-print(" || Genode 17.11 ||");
-print(" || ||");
-print(" -============================-");
-print(" \r");
-print(" 2018 by Genode Labs www.genode-labs.com");
-print(" \r\n\r");
-
+
@@ -92,15 +113,12 @@ install_config $config
#
# generic modules
-set boot_modules {
+append boot_modules {
core init
- ld.lib.so libc.lib.so libm.lib.so python3.lib.so
- python3
- vfs_jitterentropy.lib.so
+ ld.lib.so
timer
rtc_drv
- python3.tar
- vfs.lib.so
+ dynamic_rom
}
build_boot_image $boot_modules
@@ -111,7 +129,7 @@ build_boot_image $boot_modules
append qemu_args " -nographic "
-run_genode_until {.*Executed .*} 60
+run_genode_until {.*Hello again.*} 60
grep_output {python3\] }
compare_output_to {
@@ -120,7 +138,7 @@ compare_output_to {
[init -> python3] || ||
[init -> python3] || Python Core 3 ||
[init -> python3] || ||
-[init -> python3] || Genode 17.11 ||
+[init -> python3] || Genode 18.05 ||
[init -> python3] || ||
[init -> python3] -============================-
[init -> python3]
diff --git a/src/app/python3/main.cc b/src/app/python3/main.cc
index a56080c..01a8512 100644
--- a/src/app/python3/main.cc
+++ b/src/app/python3/main.cc
@@ -25,6 +25,7 @@
namespace Python
{
+ struct Rom_watcher;
struct Main;
}
@@ -33,8 +34,10 @@ struct Python::Main
Genode::Env &_env;
Genode::Attached_rom_dataspace _config = { _env, "config" };
+ Genode::Constructible _update { };
- void _handle_config()
+
+ int _execute()
{
enum {
MAX_NAME_LEN = 128
@@ -42,14 +45,24 @@ struct Python::Main
char filename[MAX_NAME_LEN];
- if (_config.xml().has_sub_node("file")) {
- Genode::Xml_node script = _config.xml().sub_node("file");
+ Genode::Xml_node script = _config.xml().sub_node("file");
+ script.attribute("name").value(filename, sizeof(filename));
- script.attribute("name").value(filename, sizeof(filename));
- } else {
- Genode::error("Need as argument!");
- return;
- }
+ FILE * fp = fopen(filename, "r");
+
+ Genode::log("Starting python ...");
+ int res = PyRun_SimpleFile(fp, filename);
+ Genode::log("Executed '", Genode::Cstring(filename), "'");
+
+ fclose(fp);
+ return res;
+ }
+
+ void _initialize()
+ {
+ enum {
+ MAX_NAME_LEN = 128
+ };
wchar_t wbuf[MAX_NAME_LEN];
@@ -70,26 +83,59 @@ struct Python::Main
Py_VerboseFlag = 1;
}
- mbstowcs(wbuf, filename, strlen(filename));
-
- FILE * fp = fopen(filename, "r");
- //fp._flags = __SRD;
- Py_SetProgramName(wbuf);
//don't need the 'site' module
Py_NoSiteFlag = 1;
//don't support interactive mode, yet
Py_InteractiveFlag = 0;
Py_Initialize();
+ }
- Genode::log("Starting python ...");
- PyRun_SimpleFile(fp, filename);
- Genode::log("Executed '", Genode::Cstring(filename), "'");
+ void _finalize()
+ {
Py_Finalize();
}
+ void _handle_config()
+ {
+ _initialize();
+
+ if (_config.xml().has_sub_node("file")) {
+ Genode::Xml_node filenode = _config.xml().sub_node("file");
+ if (filenode.has_attribute("on-rom-update")) {
+ char rom_name[128];
+ filenode.attribute("on-rom-update").value(rom_name, sizeof(rom_name));
+
+ _update.construct(_env, rom_name);
+ _update->sigh(_trigger_handler);
+
+ if (_update->dataspace().valid())
+ _execute();
+
+ return;
+ }
+ else {
+ _execute();
+ }
+ }
+ else {
+ Genode::error("Need as argument!");
+ }
+
+ /* if there was a on-rom-update attribute, we finalize and wait for next config update */
+ _finalize();
+ }
+
+ void _handle_trigger()
+ {
+ Libc::with_libc([&] () { _execute(); });
+ }
+
Genode::Signal_handler _config_handler {
_env.ep(), *this, &Main::_handle_config };
+ Genode::Signal_handler _trigger_handler {
+ _env.ep(), *this, &Main::_handle_trigger };
+
Main(Genode::Env &env) : _env(env)
{
_config.sigh(_config_handler);