summaryrefslogtreecommitdiff
path: root/hscript/meta.cc
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2019-10-19 21:35:27 -0500
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2019-10-19 21:35:27 -0500
commit02a2ad393de6cbea726514226e3419db6517307c (patch)
tree000fb00ec7ec9a4a963a21ae3e2a770a5de8179f /hscript/meta.cc
parentf1ef45bd84b57b40b701e094a9b49daac3761f9f (diff)
downloadhorizon-02a2ad393de6cbea726514226e3419db6517307c.tar.gz
horizon-02a2ad393de6cbea726514226e3419db6517307c.tar.bz2
horizon-02a2ad393de6cbea726514226e3419db6517307c.tar.xz
horizon-02a2ad393de6cbea726514226e3419db6517307c.zip
hscript: Implement Firmware, and add tests
Diffstat (limited to 'hscript/meta.cc')
-rw-r--r--hscript/meta.cc34
1 files changed, 34 insertions, 0 deletions
diff --git a/hscript/meta.cc b/hscript/meta.cc
index 0248af9..b7da9d2 100644
--- a/hscript/meta.cc
+++ b/hscript/meta.cc
@@ -167,6 +167,40 @@ Key *PkgInstall::parseFromData(const std::string &data, int lineno, int *errors,
}
+Key *Firmware::parseFromData(const std::string &data, int lineno, int *errors,
+ int *warnings) {
+ bool value;
+ if(!BooleanKey::parse(data, "installfile:" + std::to_string(lineno),
+ "firmware", &value)) {
+ if(errors) *errors += 1;
+ return nullptr;
+ }
+
+ if(value) {
+#ifdef NON_LIBRE_FIRMWARE
+ output_warning("installfile:" + std::to_string(lineno),
+ "firmware: You have requested non-libre firmware. "
+ "This may cause security issues, system instability, "
+ "and many other issues. You should not enable this "
+ "option unless your system absolutely requires it.");
+#else
+ if(errors) *errors += 1;
+ output_error("installfile:" + std::to_string(lineno),
+ "firmware: You have requested non-libre firmware, "
+ "but this version of Horizon does not support "
+ "non-libre firmware.", "Installation cannot proceed.");
+ return nullptr;
+#endif
+ }
+ return new Firmware(lineno, value);
+}
+
+bool Firmware::execute(ScriptOptions) const {
+ /* By itself, this does nothing. */
+ return true;
+}
+
+
/* LCOV_EXCL_START */
bool PkgInstall::validate(ScriptOptions) const {
/* Any validation errors would have occurred above. */