summaryrefslogtreecommitdiff
path: root/hscript/meta.cc
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2020-05-29 09:53:03 -0500
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2020-05-29 09:53:03 -0500
commit073961cfff9e249d92c240eabcf5d24a7b4a7bab (patch)
tree49367845ef3ff948ff966cb740db0b93aa5e0759 /hscript/meta.cc
parentfd5d356c39eea3138bcb0d0cd1128642afc74a9c (diff)
downloadhorizon-073961cfff9e249d92c240eabcf5d24a7b4a7bab.tar.gz
horizon-073961cfff9e249d92c240eabcf5d24a7b4a7bab.tar.bz2
horizon-073961cfff9e249d92c240eabcf5d24a7b4a7bab.tar.xz
horizon-073961cfff9e249d92c240eabcf5d24a7b4a7bab.zip
hscript: Hostname: Create /etc if it doesn't exist
Without this, errors are seen generating Alpine images.
Diffstat (limited to 'hscript/meta.cc')
-rw-r--r--hscript/meta.cc8
1 files changed, 8 insertions, 0 deletions
diff --git a/hscript/meta.cc b/hscript/meta.cc
index ab8bdb5..dc17290 100644
--- a/hscript/meta.cc
+++ b/hscript/meta.cc
@@ -104,11 +104,19 @@ bool Hostname::execute() const {
/* Runner.Execute.hostname.Write. */
output_info(pos, "hostname: write '" + actual + "' to /etc/hostname");
if(script->options().test(Simulate)) {
+ std::cout << "mkdir -p " << script->targetDirectory() << "/etc"
+ << std::endl;
std::cout << "printf '%s' " << actual << " > "
<< script->targetDirectory() << "/etc/hostname" << std::endl;
}
#ifdef HAS_INSTALL_ENV
else {
+ error_code ec;
+ fs::create_directory(script->targetDirectory() + "/etc", ec);
+ if(ec && ec.value() != EEXIST) {
+ output_error(pos, "hostname: could not create /etc", ec.message());
+ return false;
+ }
std::ofstream hostname_f(script->targetDirectory() + "/etc/hostname",
std::ios_base::trunc);
if(!hostname_f) {