Skip to content

Commit

Permalink
Include busybox at the end of PATH
Browse files Browse the repository at this point in the history
  • Loading branch information
ruanformigoni committed Oct 16, 2024
1 parent 8a5ae6d commit 9a56858
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
11 changes: 9 additions & 2 deletions src/boot/boot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,17 @@ void relocate(char** argv)
"Failed to create directory {}"_fmt(path_dir_app_bin)
);

// Create busybox dir
fs::path path_dir_busybox = path_dir_app_bin / "busybox";
ethrow_if(not fs::exists(path_dir_busybox) and not fs::create_directories(path_dir_busybox),
"Failed to create directory {}"_fmt(path_dir_busybox)
);

// Set variables
ns_env::set("FIM_DIR_GLOBAL", path_dir_base.c_str(), ns_env::Replace::Y);
ns_env::set("FIM_DIR_APP", path_dir_app.c_str(), ns_env::Replace::Y);
ns_env::set("FIM_DIR_APP_BIN", path_dir_app_bin.c_str(), ns_env::Replace::Y);
ns_env::set("FIM_DIR_BUSYBOX", path_dir_busybox.c_str(), ns_env::Replace::Y);
ns_env::set("FIM_FILE_BINARY", path_absolute.c_str(), ns_env::Replace::Y);

// Create instance directory
Expand Down Expand Up @@ -190,7 +197,7 @@ void relocate(char** argv)
ethrow_if(not file_binary.is_open(), "Could not open flatimage binary file");
std::tie(offset_beg, offset_end) = f_write_from_header(path_dir_instance / "fim_boot" , 0);
std::tie(offset_beg, offset_end) = f_write_from_offset(file_binary, path_dir_app_bin / "bash", offset_end);
std::tie(offset_beg, offset_end) = f_write_from_offset(file_binary, path_dir_app_bin / "busybox", offset_end);
std::tie(offset_beg, offset_end) = f_write_from_offset(file_binary, path_dir_busybox / "busybox", offset_end);
std::tie(offset_beg, offset_end) = f_write_from_offset(file_binary, path_dir_app_bin / "bwrap", offset_end);
std::tie(offset_beg, offset_end) = f_write_from_offset(file_binary, path_dir_app_bin / "ciopfs", offset_end);
std::tie(offset_beg, offset_end) = f_write_from_offset(file_binary, path_file_dwarfs_aio, offset_end);
Expand All @@ -210,7 +217,7 @@ void relocate(char** argv)
// Create busybox symlinks, allow (symlinks exists) errors
for(auto const& busybox_applet : arr_busybox_applet)
{
fs::create_symlink(path_dir_app_bin / "busybox", path_dir_app_bin / busybox_applet, ec);
fs::create_symlink(path_dir_busybox / "busybox", path_dir_busybox / busybox_applet, ec);
} // for

// Filesystem starts here
Expand Down
5 changes: 4 additions & 1 deletion src/boot/config/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ struct FlatimageConfig
fs::path path_dir_mount;
fs::path path_dir_app;
fs::path path_dir_app_bin;
fs::path path_dir_busybox;
fs::path path_dir_instance;
fs::path path_file_binary;
fs::path path_dir_binary;
Expand Down Expand Up @@ -108,6 +109,7 @@ inline FlatimageConfig config()
config.path_dir_binary = config.path_file_binary.parent_path();
config.path_dir_app = ns_env::get_or_throw("FIM_DIR_APP");
config.path_dir_app_bin = ns_env::get_or_throw("FIM_DIR_APP_BIN");
config.path_dir_busybox = ns_env::get_or_throw("FIM_DIR_BUSYBOX");
config.path_dir_instance = ns_env::get_or_throw("FIM_DIR_INSTANCE");
config.path_dir_mount = ns_env::get_or_throw("FIM_DIR_MOUNT");
config.path_file_bashrc = config.path_dir_app / ".bashrc";
Expand Down Expand Up @@ -142,8 +144,9 @@ inline FlatimageConfig config()
ns_env::set("BWRAP_LOG", config.path_dir_mount.string() + ".bwrap.log", ns_env::Replace::Y);

// Environment
config.env_path = config.path_dir_app_bin.string() + ":" + ns_env::get_or_throw("PATH");
config.env_path = config.path_dir_app_bin.string() + ":" + ns_env::get_or_else("PATH", "");
config.env_path += ":/sbin:/usr/sbin:/usr/local/sbin:/bin:/usr/bin:/usr/local/bin";
config.env_path += ":{}"_fmt(config.path_dir_busybox.string());
ns_env::set("PATH", config.env_path, ns_env::Replace::Y);

// Compression level configuration (goes from 0 to 10, default is 7)
Expand Down

0 comments on commit 9a56858

Please sign in to comment.