From b8f4ce3bdb1f3ea76eef1c0c4fd7dd5d29259336 Mon Sep 17 00:00:00 2001 From: "A. Wilcox" Date: Wed, 11 Mar 2020 11:44:42 -0500 Subject: hscript: Make target directory configurable This is the first step towards creating images using Horizon. --- hscript/disk.cc | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'hscript/disk.cc') diff --git a/hscript/disk.cc b/hscript/disk.cc index e1111f6..1f6d3b3 100644 --- a/hscript/disk.cc +++ b/hscript/disk.cc @@ -783,7 +783,8 @@ bool Mount::validate() const { } bool Mount::execute() const { - const std::string actual_mount = "/target" + this->mountpoint(); + const std::string actual_mount(script->targetDirectory() + + this->mountpoint()); const char *fstype = nullptr; #ifdef HAS_INSTALL_ENV error_code ec; @@ -853,24 +854,26 @@ bool Mount::execute() const { "defaults" : this->options()); if(script->options().test(Simulate)) { if(this->mountpoint() == "/") { - std::cout << "mkdir -p /target/etc" << std::endl; + std::cout << "mkdir -p " << script->targetDirectory() << "/etc" + << std::endl; } std::cout << "printf '%s\\t%s\\t%s\\t%s\\t0\\t" << pass << "\\" << "n' " << this->device() << " " << this->mountpoint() << " " << fstype << " " << fstab_opts - << " >> /target/etc/fstab" << std::endl; + << " >> " << script->targetDirectory() << "/etc/fstab" + << std::endl; } #ifdef HAS_INSTALL_ENV else { if(this->mountpoint() == "/") { - fs::create_directory("/target/etc", ec); + fs::create_directory(script->targetDirectory() + "/etc", ec); if(ec) { output_error("installfile:" + std::to_string(this->lineno()), "mount: failed to create /etc for target", ec.message()); return false; } - fs::permissions("/target/etc", rwxr_xr_x, + fs::permissions(script->targetDirectory() + "/etc", rwxr_xr_x, #if defined(FS_IS_STDCXX) fs::perm_options::replace, #endif @@ -881,7 +884,7 @@ bool Mount::execute() const { ec.message()); } } - std::ofstream fstab_f("/target/etc/fstab"); + std::ofstream fstab_f(script->targetDirectory() + "/etc/fstab"); if(!fstab_f) { output_error("installfile:" + std::to_string(this->lineno()), "mount: failure opening /etc/fstab for writing"); -- cgit v1.2.3-60-g2f50