Commit 14359501 authored by Michal 'vorner' Vaner's avatar Michal 'vorner' Vaner

migrator: Embed the top-level config

The same one as with pkgupdate.

Also, make the embed list generation generic, so we avoid copy paste.
parent e5841274
LIBRARIES += src/lib/libupdater
OPKG_AUTOLOAD := $(abspath $(wildcard $(S)/src/lib/autoload/*.lua))
$(O)/.gen/src/lib/lautoload.embedlist: $(S)/src/lib/gen_embed.sh $(S)/src/lib/embed_types.h $(OPKG_AUTOLOAD)
$(O)/.gen/src/%.embedlist: $(S)/src/lib/gen_embed.sh $(S)/src/lib/embed_types.h $(EMBEDS)
$(M) GEN $@
$(Q)mkdir -p $(dir $@)
$(Q)$< .lua autoload $(S)/src/lib/embed_types.h $(OPKG_AUTOLOAD) >$@
$(Q)$< "$(SUFFIX)" $(basename $(notdir $@)) $(S)/src/lib/embed_types.h $(abspath $(EMBEDS)) >$@
$(O)/.gen/src/lib/lautoload.embedlist: EMBEDS := $(wildcard $(S)/src/lib/autoload/*.lua)
$(O)/.gen/src/lib/lautoload.embedlist: SUFFIX := .lua
libupdater_MODULES := \
arguments \
......
......@@ -47,7 +47,7 @@
static const char *crash_file = "/tmp/updater_crash.log";
// From the embed file, lua things that are auto-loaded
extern struct file_index_element autoload[];
extern struct file_index_element lautoload[];
struct interpreter {
lua_State *state;
......@@ -843,7 +843,7 @@ const char *interpreter_include(struct interpreter *interpreter, const char *cod
}
const char *interpreter_autoload(struct interpreter *interpreter) {
for (struct file_index_element *el = autoload; el->name; el ++) {
for (struct file_index_element *el = lautoload; el->name; el ++) {
const char *underscore = rindex(el->name, '_');
// Use the part after the last underscore as the name
const char *name = underscore ? underscore + 1 : el->name;
......
BINARIES += src/migrator/pkgmigrate
# TODO: What about the embedded config?
# Borrow the file from there. But for now, we embed just this one.
$(O)/.gen/src/migrator/uriinternal.embedlist: EMBEDS := $(S)/src/pkgupdate/internal/entry.lua
pkgmigrate_MODULES := \
main
main \
uriinternal.embed
pkgmigrate_LOCAL_LIBS := updater
......@@ -26,6 +26,8 @@
#include <string.h>
#include <errno.h>
extern struct file_index_element uriinternal[];
static const enum cmd_op_type cmd_op_allowed[] = {
COT_BATCH, COT_NO_OP, COT_ROOT_DIR, COT_SYSLOG_LEVEL, COT_STDERR_LEVEL, COT_SYSLOG_NAME, COT_OUTPUT, COT_LAST
};
......@@ -42,7 +44,7 @@ int main(int argc, char *argv[]) {
// Parse the arguments
struct cmd_op *ops = cmd_args_parse(argc, argv, cmd_op_allowed);
struct cmd_op *op = ops;
const char *top_level_config = NULL;
const char *top_level_config = "internal:entry_lua";
const char *root_dir = NULL;
const char *output = "/etc/updater/auto.lua";
bool batch = false, early_exit = false;
......@@ -92,8 +94,7 @@ int main(int argc, char *argv[]) {
// The interpreter and other environment
struct events *events = events_new();
// TODO: Internal URIs?
struct interpreter *interpreter = interpreter_create(events, NULL);
struct interpreter *interpreter = interpreter_create(events, uriinternal);
const char *error = interpreter_autoload(interpreter);
ASSERT_MSG(!error, "%s", error);
......
BINARIES += src/pkgupdate/pkgupdate
PKGUPDATE_EMBED := $(abspath $(wildcard $(S)/src/pkgupdate/internal/*))
$(O)/.gen/src/pkgupdate/uriinternal.embedlist: $(S)/src/lib/gen_embed.sh $(S)/src/lib/embed_types.h $(PKGUPDATE_EMBED)
$(M) GEN $@
$(Q)mkdir -p $(dir $@)
$(Q)$< "" uriinternal $(S)/src/lib/embed_types.h $(PKGUPDATE_EMBED) >$@
$(O)/.gen/src/pkgupdate/uriinternal.embedlist: EMBEDS := $(wildcard $(S)/src/pkgupdate/internal/*)
pkgupdate_MODULES := \
main \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment