diff options
author | A. Wilcox <AWilcox@Wilcox-Tech.com> | 2019-10-31 13:54:18 -0500 |
---|---|---|
committer | A. Wilcox <AWilcox@Wilcox-Tech.com> | 2019-10-31 13:54:18 -0500 |
commit | a3504832b357f6bd97f51560dbbf8a933583dc70 (patch) | |
tree | 26533fd27d36ca4b10e9c472a3d82d3f6d63fe8b | |
parent | 36199bc708785688306bf6c027ea3eb0f7a4d88b (diff) | |
download | horizon-a3504832b357f6bd97f51560dbbf8a933583dc70.tar.gz horizon-a3504832b357f6bd97f51560dbbf8a933583dc70.tar.bz2 horizon-a3504832b357f6bd97f51560dbbf8a933583dc70.tar.xz horizon-a3504832b357f6bd97f51560dbbf8a933583dc70.zip |
hscript: Add Keymap code
-rw-r--r-- | hscript/meta.cc | 16 | ||||
-rw-r--r-- | hscript/meta.hh | 8 | ||||
-rw-r--r-- | hscript/script.cc | 20 |
3 files changed, 41 insertions, 3 deletions
diff --git a/hscript/meta.cc b/hscript/meta.cc index 3b3ee3d..dfd147a 100644 --- a/hscript/meta.cc +++ b/hscript/meta.cc @@ -261,7 +261,6 @@ Key *Language::parseFromData(const std::string &data, int lineno, int *errors, return new Language(lineno, data); } - bool Language::execute(ScriptOptions opts) const { output_info("installfile:" + std::to_string(this->lineno()), "language: setting default system language to " + @@ -302,6 +301,21 @@ bool Language::execute(ScriptOptions opts) const { } +Key *Keymap::parseFromData(const std::string &data, int lineno, int *, int *) { + return new Keymap(lineno, data); +} + +bool Keymap::validate(ScriptOptions) const { + /* TODO XXX */ + /* Will require console-setup to be installed on the validating machine. */ + return true; +} + +bool Keymap::execute(ScriptOptions) const { + return true; +} + + Key *Firmware::parseFromData(const std::string &data, int lineno, int *errors, int *warnings) { bool value; diff --git a/hscript/meta.hh b/hscript/meta.hh index b2e1963..25ff931 100644 --- a/hscript/meta.hh +++ b/hscript/meta.hh @@ -55,6 +55,14 @@ public: }; class Keymap : public StringKey { +private: + Keymap(int _line, const std::string &keymap) : + StringKey(_line, keymap) {} +public: + static Key *parseFromData(const std::string &data, int lineno, int *errors, + int *warnings); + bool validate(ScriptOptions) const override; + bool execute(ScriptOptions) const override; }; class Firmware : public BooleanKey { diff --git a/hscript/script.cc b/hscript/script.cc index f1fa5d6..dae014c 100644 --- a/hscript/script.cc +++ b/hscript/script.cc @@ -91,7 +91,8 @@ struct Script::ScriptPrivate { std::unique_ptr<RootPassphrase> rootpw; /*! The system language. */ std::unique_ptr<Language> lang; - /* keymap */ + /*! The system keymap. */ + std::unique_ptr<Keymap> keymap; /*! The system timezone. */ std::unique_ptr<Timezone> tzone; @@ -151,6 +152,8 @@ struct Script::ScriptPrivate { return store_rootpw(obj, lineno, errors, warnings, opts); } else if(key_name == "language") { return store_lang(obj, lineno, errors, warnings, opts); + } else if(key_name == "keymap") { + return store_keymap(obj, lineno, errors, warnings, opts); } else if(key_name == "firmware") { return store_firmware(obj, lineno, errors, warnings, opts); } else if(key_name == "timezone") { @@ -293,6 +296,18 @@ struct Script::ScriptPrivate { return true; } + bool store_keymap(Keys::Key *obj, int lineno, int *errors, int *, + ScriptOptions) { + if(this->keymap) { + DUPLICATE_ERROR(this->keymap, std::string("keymap"), + this->keymap->value()) + return false; + } + std::unique_ptr<Keymap> k(dynamic_cast<Keymap *>(obj)); + this->keymap = std::move(k); + return true; + } + bool store_timezone(Keys::Key *obj, int lineno, int *errors, int *, ScriptOptions) { if(this->tzone) { @@ -722,7 +737,8 @@ bool Script::validate() const { /* REQ: Runner.Validate.language */ if(internal->lang && !internal->lang->validate(this->opts)) failures++; - /* keymap */ + /* REQ: Runner.Validate.keymap */ + if(internal->keymap && !internal->keymap->validate(this->opts)) failures++; #ifdef NON_LIBRE_FIRMWARE /* REQ: Runner.Validate.firmware */ |