Fix post build
This commit is contained in:
@@ -32,12 +32,12 @@ done
|
||||
fi
|
||||
|
||||
# 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/
|
||||
cp -a ${BR_PROJECT}/ovl/* ${BR_STAGING}/buildroot/target/
|
||||
fi
|
||||
|
||||
# Finaly apply post build script of the target if the script exist.
|
||||
if [ -e ${PROJECT}/post-build.sh ]; then
|
||||
${PROJECT}/post-build.sh
|
||||
if [ -e ${BR_PROJECT}/post-build.sh ]; then
|
||||
${BR_PROJECT}/post-build.sh
|
||||
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 ---------------------------------*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <limits.h>
|
||||
#include <cstdio>
|
||||
#include <string>
|
||||
|
||||
#include <json-c/json.h>
|
||||
|
||||
extern "C" {
|
||||
#include <stdlib.h> /* getenv */
|
||||
#include <stdlib.h> /* getenv */
|
||||
#include <libubus.h>
|
||||
}
|
||||
|
||||
/*-------------------------------- DEFINES ---------------------------------*/
|
||||
|
||||
#define k_path_max 1024
|
||||
|
||||
#define k_dir_sep '/'
|
||||
#define k_config_dir "share/domo/"
|
||||
|
||||
/*! ----------------------------------------------------------------------------
|
||||
* @fn setup_ubus
|
||||
@@ -46,11 +48,12 @@ extern "C" {
|
||||
* @brief Setup the UBus Mechanism.
|
||||
*/
|
||||
extern "C" {
|
||||
static struct ubus_context *setup_ubus (void)
|
||||
static struct ubus_context *setup_ubus(void)
|
||||
{
|
||||
ubus_context *the_ctx;
|
||||
|
||||
if (uloop_init() !=0) {
|
||||
if (uloop_init() != 0)
|
||||
{
|
||||
|
||||
fprintf(stderr, "Failed to init Uloop.\n");
|
||||
return NULL;
|
||||
@@ -60,7 +63,8 @@ static struct ubus_context *setup_ubus (void)
|
||||
|
||||
the_ctx = ubus_connect(NULL);
|
||||
|
||||
if (!the_ctx) {
|
||||
if (!the_ctx)
|
||||
{
|
||||
|
||||
fprintf(stderr, "Failed to connect to ubus\n");
|
||||
return NULL;
|
||||
@@ -72,56 +76,58 @@ static struct ubus_context *setup_ubus (void)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*! ----------------------------------------------------------------------------
|
||||
* @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
|
||||
*
|
||||
* @brief Main function of Domo Daemon.
|
||||
*/
|
||||
int main (void)
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int the_ret = 0;
|
||||
char path[k_path_max] = "";
|
||||
std::string the_config_path;
|
||||
struct ubus_context *the_ctx = NULL;
|
||||
|
||||
/* 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. */
|
||||
the_ctx = setup_ubus();
|
||||
if (the_ctx == NULL) {
|
||||
if (the_ctx == NULL)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -133,45 +139,7 @@ int main (void)
|
||||
|
||||
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
|
||||
#include "ubus/capabilities.h"
|
||||
#include "ubus/capabilities_lights.h"
|
||||
|
||||
Reference in New Issue
Block a user