summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2023-10-28 23:50:57 -0500
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2023-10-28 23:50:57 -0500
commit6899f2497dd2dc45a0d48e5d9621c19f4ca4fe7b (patch)
tree9ef5665b52d3a72f0da8c284b1ef9936c0276958
parent505d3d3adf3eeb717b2ee63a695b761226a67a38 (diff)
downloadhorizon-6899f2497dd2dc45a0d48e5d9621c19f4ca4fe7b.tar.gz
horizon-6899f2497dd2dc45a0d48e5d9621c19f4ca4fe7b.tar.bz2
horizon-6899f2497dd2dc45a0d48e5d9621c19f4ca4fe7b.tar.xz
horizon-6899f2497dd2dc45a0d48e5d9621c19f4ca4fe7b.zip
image: Allow custom paths for qemu-static binaries
This allows one to use i.e. /opt/qemu/bin or /usr/gxemul/bin for the qemu static binaries used to generate foreign-architecture images.
-rw-r--r--image/creator.110
-rw-r--r--image/creator.cc17
2 files changed, 22 insertions, 5 deletions
diff --git a/image/creator.1 b/image/creator.1
index 5673f75..2de51a1 100644
--- a/image/creator.1
+++ b/image/creator.1
@@ -1,4 +1,4 @@
-.Dd May 16, 2020
+.Dd October 28, 2023
.Dt HSCRIPT-IMAGE 1
.Os "Adélie Linux"
.Sh NAME
@@ -6,6 +6,7 @@
.Nd create an image based on a HorizonScript for later deployment
.Sh SYNOPSIS
.Nm
+.Op Fl e Ar DIRECTORY
.Op Fl h
.Op Fl i Ar DIRECTORY
.Op Fl n
@@ -80,6 +81,13 @@ as the argument to
.Fl t .
.It Fl v
Displays the version information for this utility, and then exits.
+.It Fl e Ar DIRECTORY
+Sets the qemu-static binary directory to
+.Ar DIRECTORY .
+This must be equivalent to the configuration of binfmt-misc on the host.
+The default is
+.Pa /usr/bin ,
+and typically should not be changed unless you have a very good reason.
.It Ar INSTALLFILE
Specifies the location of the HorizonScript to use for configuring the image.
You may specify
diff --git a/image/creator.cc b/image/creator.cc
index 0d97ff1..ce2c537 100644
--- a/image/creator.cc
+++ b/image/creator.cc
@@ -49,7 +49,7 @@ int main(int argc, char *argv[]) {
bool needs_help{}, disable_pretty{}, version_only{};
int exit_code = EXIT_SUCCESS;
std::string if_path{"/etc/horizon/installfile"}, ir_dir{"/tmp/horizon-image"},
- output_path{"image.tar"}, type_code{"tar"};
+ output_path{"image.tar"}, type_code{"tar"}, emul_dir{"/usr/bin"};
BasicBackend *backend = nullptr;
std::map<std::string, std::string> backend_opts;
Horizon::ScriptOptions opts;
@@ -66,6 +66,7 @@ int main(int argc, char *argv[]) {
target.add_options()
("output,o", value<std::string>()->default_value("image.tar"), "Desired filename for the output file.")
("ir-dir,i", value<std::string>()->default_value("/tmp/horizon-image"), "Where to store intermediate files.")
+ ("emul-dir,e", value<std::string>()->default_value("/usr/bin"), "Where qemu-static binaries are stored.")
;
options_description backconfig{"Backend configuration options"};
backconfig.add_options()
@@ -134,6 +135,14 @@ int main(int argc, char *argv[]) {
ir_dir = fs::absolute(ir_dir).string();
}
+ if(!vm["emul-dir"].empty()) {
+ emul_dir = vm["emul-dir"].as<std::string>();
+ }
+
+ if(fs::path(emul_dir).is_relative()) {
+ emul_dir = fs::absolute(emul_dir).string();
+ }
+
if(!vm["output"].empty()) {
output_path = vm["output"].as<std::string>();
}
@@ -222,11 +231,11 @@ int main(int argc, char *argv[]) {
if(archkey) {
const Horizon::Keys::Arch *arch =
dynamic_cast<const Horizon::Keys::Arch *>(archkey);
- qpath = "/usr/bin/qemu-" + arch_xlate(arch->value());
+ qpath = emul_dir + "/qemu-" + arch_xlate(arch->value());
error_code ec;
if(fs::exists(qpath, ec)) {
- fs::create_directories(ir_dir + "/target/usr/bin", ec);
- if(!ec) fs::copy_file(qpath, ir_dir + "/target/" + qpath, ec);
+ fs::create_directories(ir_dir + "/target" + emul_dir, ec);
+ if(!ec) fs::copy_file(qpath, ir_dir + "/target" + qpath, ec);
}
}