summaryrefslogtreecommitdiff
path: root/image
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2023-03-25 22:28:50 -0500
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2023-03-25 22:28:50 -0500
commit9fb439ac12c81a3d58eecd30de2b2655b27c6f38 (patch)
tree4a47e775a0efb7e0844e87c5d2244f29184de3e6 /image
parent3cb887f0bd51a18011dc31957ddf9e4a4ae28790 (diff)
downloadhorizon-9fb439ac12c81a3d58eecd30de2b2655b27c6f38.tar.gz
horizon-9fb439ac12c81a3d58eecd30de2b2655b27c6f38.tar.bz2
horizon-9fb439ac12c81a3d58eecd30de2b2655b27c6f38.tar.xz
horizon-9fb439ac12c81a3d58eecd30de2b2655b27c6f38.zip
image: C++2x and Boost.Filesystem fixes
* Ensure that Boost.Filesystem is still usable. * Don't use a reference to a temporary in loops. Fixes: #333
Diffstat (limited to 'image')
-rw-r--r--image/backends/CMakeLists.txt1
-rw-r--r--image/backends/iso.cc18
-rw-r--r--image/creator.cc2
3 files changed, 11 insertions, 10 deletions
diff --git a/image/backends/CMakeLists.txt b/image/backends/CMakeLists.txt
index 790895e..910d6f4 100644
--- a/image/backends/CMakeLists.txt
+++ b/image/backends/CMakeLists.txt
@@ -13,6 +13,7 @@ endif()
if(BUILD_ISO)
list(APPEND BACKEND_SRCS iso.cc)
+ include_directories(${Boost_INCLUDE_DIR})
endif(BUILD_ISO)
add_library(hi-backends ${BACKEND_SRCS})
diff --git a/image/backends/iso.cc b/image/backends/iso.cc
index c70f004..4b27cc8 100644
--- a/image/backends/iso.cc
+++ b/image/backends/iso.cc
@@ -57,7 +57,7 @@ const std::vector<std::string> data_dirs() {
return dirs;
}
-const fs::path find_data_file(std::string name) {
+const fs::path find_data_file(const std::string &name) {
error_code ec;
for(const auto &p : data_dirs()) {
fs::path src = fs::path(p).append("horizon").append("iso").append(name);
@@ -87,7 +87,7 @@ bool copy_volume_icon_to(fs::path ir_dir) {
}
bool write_etc_mtab_to(fs::path target) {
- std::ofstream mtab(target.append("etc/conf.d/mtab"));
+ std::ofstream mtab(target.append("etc/conf.d/mtab").string());
if(!mtab) {
output_error("CD backend", "failed to open mtab configuration");
return false;
@@ -103,7 +103,7 @@ bool write_etc_mtab_to(fs::path target) {
}
bool write_fstab_to(fs::path target) {
- std::ofstream fstab{target.append("etc/fstab")};
+ std::ofstream fstab{target.append("etc/fstab").string()};
if(!fstab) {
output_error("CD backend", "failed to open fstab");
return false;
@@ -138,7 +138,7 @@ bool write_etc_issue_to(fs::path target) {
}
/* We don't have a file, so write out our default. */
- std::ofstream issue(dest);
+ std::ofstream issue(dest.string());
if(!issue) {
output_error("CD backend", "failed to open issue file");
return false;
@@ -189,7 +189,7 @@ public:
/* try to umount first, just in case
* We don't care if the call fails.
*/
- for(const std::string &mount : {"dev", "proc", "sys"}) {
+ for(const std::string mount : {"dev", "proc", "sys"}) {
const std::string path = this->ir_dir + "/target/" + mount;
::umount(path.c_str());
}
@@ -278,7 +278,7 @@ public:
/* REQ: ISO.10 */
output_info("CD backend", "enabling required services");
const std::string targetsi = target + "/etc/runlevels/sysinit/";
- for(const std::string &svc : {"udev", "udev-trigger", "lvmetad"}) {
+ for(const std::string svc : {"udev", "udev-trigger", "lvmetad"}) {
fs::create_symlink("/etc/init.d/" + svc, targetsi + svc, ec);
if(ec && ec.value() != EEXIST) {
output_error("CD backend", "could not enable service " + svc,
@@ -354,7 +354,7 @@ public:
for(const auto &dent :
fs::recursive_directory_iterator(target + "/usr/share/kernel", ec))
{
- if(dent.is_regular_file() &&
+ if(fs::is_regular_file(dent.path()) &&
dent.path().filename().string() == "kernel.release") {
kverpath = dent.path().string();
break;
@@ -391,7 +391,7 @@ public:
fs::path candidate{fs::path{path}.append("horizon")
.append("iso").append("post-" + my_arch + ".sh")};
if(fs::exists(candidate, ec)) {
- postscript = candidate;
+ postscript = candidate.string();
break;
}
}
@@ -431,7 +431,7 @@ public:
{
const fs::path param_file = find_data_file("iso-params-" + my_arch);
if(param_file.has_filename()) {
- std::ifstream params{param_file};
+ std::ifstream params{param_file.string()};
if(!params) {
output_warning("CD backend", "couldn't read ISO params");
} else {
diff --git a/image/creator.cc b/image/creator.cc
index 6ee1f8a..0d97ff1 100644
--- a/image/creator.cc
+++ b/image/creator.cc
@@ -249,7 +249,7 @@ int main(int argc, char *argv[]) {
trouble: /* delete the Script and exit */
/* ensure that our target mounts are unmounted */
run_command("umount", {"-R", (ir_dir + "/target/sys")});
- umount((ir_dir + "/target/proc").c_str());
+ ::umount((ir_dir + "/target/proc").c_str());
run_command("umount", {"-R", (ir_dir + "/target/dev")});
delete my_script;