summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hscript/disk.cc1
-rw-r--r--hscript/script.cc47
2 files changed, 45 insertions, 3 deletions
diff --git a/hscript/disk.cc b/hscript/disk.cc
index 72604d9..ecd0afa 100644
--- a/hscript/disk.cc
+++ b/hscript/disk.cc
@@ -414,6 +414,7 @@ Key *Partition::parseFromData(const std::string &data, int lineno, int *errors,
bool Partition::validate(ScriptOptions opts) const {
#ifdef HAS_INSTALL_ENV
if(opts.test(InstallEnvironment)) {
+ /* REQ: Runner.Validate.partition.Block */
return is_block_device("partition", this->lineno(), this->device());
}
#endif /* HAS_INSTALL_ENV */
diff --git a/hscript/script.cc b/hscript/script.cc
index 050bb01..33e8c6d 100644
--- a/hscript/script.cc
+++ b/hscript/script.cc
@@ -695,6 +695,9 @@ bool Script::validate() const {
std::set<std::string> seen_diskids, seen_labels, seen_parts, seen_pvs,
seen_vg_names, seen_vg_pvs, seen_lvs, seen_fses, seen_mounts;
std::map<const std::string, int> seen_iface;
+#ifdef HAS_INSTALL_ENV
+ error_code ec;
+#endif /* HAS_INSTALL_ENV */
/* REQ: Runner.Validate.network */
if(!this->internal->network->validate(this->opts)) failures++;
@@ -838,7 +841,9 @@ bool Script::validate() const {
}
/* REQ: Runner.Validate.partition.Unique */
- std::string name = part->device() + std::to_string(part->partno());
+ const std::string &dev = part->device();
+ const std::string maybe_p(::isdigit(dev[dev.size() - 1]) ? "p" : "");
+ std::string name = dev + maybe_p + std::to_string(part->partno());
if(seen_parts.find(name) != seen_parts.end()) {
failures++;
output_error("installfile:" + std::to_string(part->lineno()),
@@ -864,6 +869,19 @@ bool Script::validate() const {
+ pv->value());
}
seen_pvs.insert(pv->value());
+
+ /* REQ: Runner.Validate.lvm_pv.Block */
+ if(opts.test(InstallEnvironment)) {
+#ifdef HAS_INSTALL_ENV
+ if(!fs::exists(pv->value(), ec) &&
+ seen_parts.find(pv->value()) == seen_parts.end()) {
+ failures++;
+ output_error("installfile:" + std::to_string(pv->lineno()),
+ "lvm_pv: device " + pv->value() +
+ " does not exist");
+ }
+#endif /* HAS_INSTALL_ENV */
+ }
}
/* REQ: Runner.Validate.lvm_vg */
@@ -944,6 +962,16 @@ bool Script::validate() const {
}
}
+#define CHECK_EXIST_PART_LV(device, key, line) \
+ if(!fs::exists(device, ec) &&\
+ seen_parts.find(device) == seen_parts.end() &&\
+ seen_lvs.find(device.substr(5)) == seen_lvs.end()) {\
+ failures++;\
+ output_error("installfile:" + std::to_string(line),\
+ std::string(key) + ": device " + device +\
+ " does not exist");\
+ }
+
/* REQ: Runner.Validate.fs */
for(auto &fs : this->internal->fses) {
if(!fs->validate(this->opts)) {
@@ -959,6 +987,13 @@ bool Script::validate() const {
"created on " + fs->device());
}
seen_fses.insert(fs->device());
+
+ /* REQ: Runner.Validate.fs.Block */
+ if(opts.test(InstallEnvironment)) {
+#ifdef HAS_INSTALL_ENV
+ CHECK_EXIST_PART_LV(fs->device(), "fs", fs->lineno())
+#endif /* HAS_INSTALL_ENV */
+ }
}
/* REQ: Runner.Validate.mount */
@@ -977,11 +1012,17 @@ bool Script::validate() const {
" is a duplicate");
}
seen_mounts.insert(mount->mountpoint());
- if(this->opts.test(InstallEnvironment)) {
- /* TODO: Runner.Validate.mount.Block for not-yet-created devs. */
+
+ /* REQ: Runner.Validate.mount.Block */
+ if(opts.test(InstallEnvironment)) {
+#ifdef HAS_INSTALL_ENV
+ CHECK_EXIST_PART_LV(mount->device(), "mount", mount->lineno())
+#endif /* HAS_INSTALL_ENV */
}
}
+#undef CHECK_EXIST_PART_LV
+
/* REQ: Runner.Validate.mount.Root */
if(seen_mounts.find("/") == seen_mounts.end()) {
failures++;