Fix post build
This commit is contained in:
@@ -32,12 +32,12 @@ done
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Copy the overlay of the target.
|
# Copy the overlay of the target.
|
||||||
if [ -d ${PROJECT}/ovl ]; then
|
if [ -d ${BR_PROJECT}/ovl ]; then
|
||||||
mkdir -p ${BR_STAGING}/buildroot/target/usr/local/
|
mkdir -p ${BR_STAGING}/buildroot/target/usr/local/
|
||||||
cp -a ${BR_PROJECT}/ovl/* ${BR_STAGING}/buildroot/target/
|
cp -a ${BR_PROJECT}/ovl/* ${BR_STAGING}/buildroot/target/
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Finaly apply post build script of the target if the script exist.
|
# Finaly apply post build script of the target if the script exist.
|
||||||
if [ -e ${PROJECT}/post-build.sh ]; then
|
if [ -e ${BR_PROJECT}/post-build.sh ]; then
|
||||||
${PROJECT}/post-build.sh
|
${BR_PROJECT}/post-build.sh
|
||||||
fi
|
fi
|
||||||
|
|||||||
22
projects/x86_64_domo/post-build.sh
Executable file
22
projects/x86_64_domo/post-build.sh
Executable file
@@ -0,0 +1,22 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Catch Postbuild Error
|
||||||
|
function error {
|
||||||
|
|
||||||
|
echo "Postbuild Failed."
|
||||||
|
exit 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
set -e
|
||||||
|
trap error ERR
|
||||||
|
|
||||||
|
echo "==> POSTBUILD:"
|
||||||
|
|
||||||
|
echo "BR_STAGING: ${BR_STAGING}"
|
||||||
|
echo "BR_PROJECT: ${BR_PROJECT}"
|
||||||
|
|
||||||
|
# Copy the overlay of the target.
|
||||||
|
if [ -d ${PROJECT}/ovl ]; then
|
||||||
|
mkdir -p ${BR_STAGING}/buildroot/staging/usr/local/
|
||||||
|
cp -a ${BR_BOARD}/ovl/* ${BR_STAGING}/buildroot/staging/
|
||||||
|
fi
|
||||||
@@ -23,22 +23,24 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/*-------------------------------- INCLUDES ---------------------------------*/
|
/*-------------------------------- INCLUDES ---------------------------------*/
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <limits.h>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include <json-c/json.h>
|
#include <json-c/json.h>
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include <stdlib.h> /* getenv */
|
#include <stdlib.h> /* getenv */
|
||||||
#include <libubus.h>
|
#include <libubus.h>
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-------------------------------- DEFINES ---------------------------------*/
|
/*-------------------------------- DEFINES ---------------------------------*/
|
||||||
|
|
||||||
#define k_path_max 1024
|
#define k_dir_sep '/'
|
||||||
|
#define k_config_dir "share/domo/"
|
||||||
|
|
||||||
/*! ----------------------------------------------------------------------------
|
/*! ----------------------------------------------------------------------------
|
||||||
* @fn setup_ubus
|
* @fn setup_ubus
|
||||||
@@ -46,82 +48,86 @@ extern "C" {
|
|||||||
* @brief Setup the UBus Mechanism.
|
* @brief Setup the UBus Mechanism.
|
||||||
*/
|
*/
|
||||||
extern "C" {
|
extern "C" {
|
||||||
static struct ubus_context *setup_ubus (void)
|
static struct ubus_context *setup_ubus(void)
|
||||||
{
|
{
|
||||||
ubus_context *the_ctx;
|
ubus_context *the_ctx;
|
||||||
|
|
||||||
if (uloop_init() !=0) {
|
if (uloop_init() != 0)
|
||||||
|
{
|
||||||
|
|
||||||
fprintf(stderr, "Failed to init Uloop.\n");
|
fprintf(stderr, "Failed to init Uloop.\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
signal(SIGPIPE, SIG_IGN);
|
signal(SIGPIPE, SIG_IGN);
|
||||||
|
|
||||||
the_ctx = ubus_connect(NULL);
|
the_ctx = ubus_connect(NULL);
|
||||||
|
|
||||||
if (!the_ctx) {
|
if (!the_ctx)
|
||||||
|
{
|
||||||
|
|
||||||
fprintf(stderr, "Failed to connect to ubus\n");
|
fprintf(stderr, "Failed to connect to ubus\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ubus_add_uloop(the_ctx);
|
ubus_add_uloop(the_ctx);
|
||||||
|
|
||||||
return the_ctx;
|
return the_ctx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*! ----------------------------------------------------------------------------
|
/*! ----------------------------------------------------------------------------
|
||||||
* @fn is_path_absolute
|
* @fn get_config_path
|
||||||
*
|
*
|
||||||
* @brief return true if the patch is absolute.
|
* @brief This function return the config path from executable path.
|
||||||
*/
|
*/
|
||||||
static bool is_path_absolute (const char *a_path)
|
const std::string get_config_path(char *an_exec_path)
|
||||||
{
|
{
|
||||||
return a_path != NULL && a_path[0] == '/';
|
int the_pos;
|
||||||
|
std::string the_config_path;
|
||||||
|
std::string the_exec_path(an_exec_path);
|
||||||
|
|
||||||
|
the_pos = the_exec_path.rfind(k_dir_sep);
|
||||||
|
|
||||||
|
// get exec path.
|
||||||
|
the_config_path = the_exec_path.substr(0, the_pos + 1);
|
||||||
|
|
||||||
|
// remove last / is necessary.
|
||||||
|
if (the_config_path[the_config_path.size()-1] == k_dir_sep) {
|
||||||
|
the_config_path = the_exec_path.substr(0, the_config_path.size() - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove the binary directory.
|
||||||
|
the_pos = the_config_path.rfind(k_dir_sep);
|
||||||
|
the_config_path = the_config_path.substr(0, the_pos + 1);
|
||||||
|
|
||||||
|
the_config_path += k_config_dir;
|
||||||
|
|
||||||
|
return the_config_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
char * app_path (char * path, const char * argv0)
|
|
||||||
{
|
|
||||||
char buf[PATH_MAX];
|
|
||||||
char * pos;
|
|
||||||
if (argv0[0] == '/') { // run with absolute path
|
|
||||||
strcpy(buf, argv0);
|
|
||||||
} else { // run with relative path
|
|
||||||
if(NULL == getcwd(buf, PATH_MAX)) {
|
|
||||||
perror("getcwd error");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
strcat(buf, "/");
|
|
||||||
strcat(buf, argv0);
|
|
||||||
}
|
|
||||||
if (NULL == realpath(buf, path)) {
|
|
||||||
perror("realpath error");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
return path;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*! ----------------------------------------------------------------------------
|
/*! ----------------------------------------------------------------------------
|
||||||
* @fn main
|
* @fn main
|
||||||
*
|
*
|
||||||
* @brief Main function of Domo Daemon.
|
* @brief Main function of Domo Daemon.
|
||||||
*/
|
*/
|
||||||
int main (void)
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int the_ret = 0;
|
int the_ret = 0;
|
||||||
char path[k_path_max] = "";
|
std::string the_config_path;
|
||||||
struct ubus_context *the_ctx = NULL;
|
struct ubus_context *the_ctx = NULL;
|
||||||
|
|
||||||
/* Get the Path of the binary to load configs. */
|
/* Get the Path of the binary to load configs. */
|
||||||
|
the_config_path = get_config_path(argv[0]);
|
||||||
|
printf ("config path: %s\n", the_config_path.c_str());
|
||||||
|
return 0;
|
||||||
|
|
||||||
/* Setup the Ubus context. */
|
/* Setup the Ubus context. */
|
||||||
the_ctx = setup_ubus();
|
the_ctx = setup_ubus();
|
||||||
if (the_ctx == NULL) {
|
if (the_ctx == NULL)
|
||||||
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,45 +139,7 @@ int main (void)
|
|||||||
|
|
||||||
return the_ret;
|
return the_ret;
|
||||||
}
|
}
|
||||||
#if 0
|
|
||||||
tatic void
|
|
||||||
set_absolute_path(char *options[],
|
|
||||||
const char *option_name,
|
|
||||||
const char *path_to_civetweb_exe)
|
|
||||||
{
|
|
||||||
char path[PATH_MAX] = "", absolute[PATH_MAX] = "";
|
|
||||||
const char *option_value;
|
|
||||||
const char *p;
|
|
||||||
|
|
||||||
/* Check whether option is already set */
|
|
||||||
option_value = get_option(options, option_name);
|
|
||||||
|
|
||||||
/* If option is already set and it is an absolute path,
|
|
||||||
leave it as it is -- it's already absolute. */
|
|
||||||
if (option_value != NULL && !is_path_absolute(option_value)) {
|
|
||||||
/* Not absolute. Use the directory where civetweb executable lives
|
|
||||||
be the relative directory for everything.
|
|
||||||
Extract civetweb executable directory into path. */
|
|
||||||
if ((p = strrchr(path_to_civetweb_exe, DIRSEP)) == NULL) {
|
|
||||||
IGNORE_UNUSED_RESULT(getcwd(path, sizeof(path)));
|
|
||||||
} else {
|
|
||||||
snprintf(path,
|
|
||||||
sizeof(path) - 1,
|
|
||||||
"%.*s",
|
|
||||||
(int)(p - path_to_civetweb_exe),
|
|
||||||
path_to_civetweb_exe);
|
|
||||||
path[sizeof(path) - 1] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
strncat(path, "/", sizeof(path) - strlen(path) - 1);
|
|
||||||
strncat(path, option_value, sizeof(path) - strlen(path) - 1);
|
|
||||||
|
|
||||||
/* Absolutize the path, and set the option */
|
|
||||||
IGNORE_UNUSED_RESULT(abs_path(path, absolute, sizeof(absolute)));
|
|
||||||
set_option(options, option_name, absolute);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#if 0
|
#if 0
|
||||||
#include "ubus/capabilities.h"
|
#include "ubus/capabilities.h"
|
||||||
#include "ubus/capabilities_lights.h"
|
#include "ubus/capabilities_lights.h"
|
||||||
|
|||||||
Reference in New Issue
Block a user