summaryrefslogtreecommitdiff
path: root/hscript/disk.cc
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2020-03-11 11:44:42 -0500
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2020-03-11 11:44:42 -0500
commitb8f4ce3bdb1f3ea76eef1c0c4fd7dd5d29259336 (patch)
treea95e0ccf5242a2c1a52b118dd04138a64d3f7546 /hscript/disk.cc
parentbcff79985ebe4c2d09eda749a99a005dc65b6b52 (diff)
downloadhorizon-b8f4ce3bdb1f3ea76eef1c0c4fd7dd5d29259336.tar.gz
horizon-b8f4ce3bdb1f3ea76eef1c0c4fd7dd5d29259336.tar.bz2
horizon-b8f4ce3bdb1f3ea76eef1c0c4fd7dd5d29259336.tar.xz
horizon-b8f4ce3bdb1f3ea76eef1c0c4fd7dd5d29259336.zip
hscript: Make target directory configurable
This is the first step towards creating images using Horizon.
Diffstat (limited to 'hscript/disk.cc')
-rw-r--r--hscript/disk.cc15
1 files changed, 9 insertions, 6 deletions
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");