build(packaging): add PX4 SITL .deb packages

Add cmake/cpack infrastructure for building .deb packages from
px4_sitl_sih and px4_sitl_default targets. Includes install rules,
package scripts, Gazebo wrapper, and CI workflow.

Signed-off-by: Ramon Roche <mrpollo@gmail.com>
This commit is contained in:
Ramon Roche
2026-04-02 15:03:04 -06:00
parent ebe0b727d8
commit 1079c57fd0
16 changed files with 940 additions and 41 deletions
+51 -4
View File
@@ -259,6 +259,32 @@ int main(int argc, char **argv)
PX4_INFO("instance: %i", instance);
}
#if defined(PX4_INSTALL_PREFIX)
// When installed as a .deb package, default to the baked-in install prefix.
// Working directory defaults to XDG_DATA_HOME/px4/rootfs/<instance>.
if (commands_file.empty() && data_path.empty() && working_directory.empty()
&& dir_exists(PX4_INSTALL_PREFIX"/etc")
) {
data_path = PX4_INSTALL_PREFIX"/etc";
const char *xdg_data_home = getenv("XDG_DATA_HOME");
std::string state_base;
if (xdg_data_home) {
state_base = xdg_data_home;
} else {
const char *home = getenv("HOME");
state_base = std::string(home ? home : "/tmp") + "/.local/share";
}
working_directory = state_base + "/px4/rootfs";
working_directory_default = true;
}
#endif // PX4_INSTALL_PREFIX
#if defined(PX4_BINARY_DIR)
// data_path & working_directory: if no commands specified or in current working directory),
@@ -745,13 +771,34 @@ std::string pwd()
return (getcwd(temp, PATH_MAX) ? std::string(temp) : std::string(""));
}
static int mkdir_p(const std::string &path)
{
std::string tmp = path;
for (size_t i = 1; i < tmp.size(); ++i) {
if (tmp[i] == '/') {
tmp[i] = '\0';
if (mkdir(tmp.c_str(), S_IRWXU | S_IRWXG | S_IRWXO) != 0 && errno != EEXIST) {
return -1;
}
tmp[i] = '/';
}
}
if (mkdir(tmp.c_str(), S_IRWXU | S_IRWXG | S_IRWXO) != 0 && errno != EEXIST) {
return -1;
}
return 0;
}
int change_directory(const std::string &directory)
{
// create directory
// create directory (including intermediate components)
if (!dir_exists(directory)) {
int ret = mkdir(directory.c_str(), S_IRWXU | S_IRWXG | S_IRWXO);
if (ret == -1) {
if (mkdir_p(directory) != 0) {
PX4_ERR("Error creating directory: %s (%s)", directory.c_str(), strerror(errno));
return -1;
}