diff --git a/.gitmodules b/.gitmodules index 4521013..7facb89 100644 --- a/.gitmodules +++ b/.gitmodules @@ -6,16 +6,19 @@ url = ../../zwsd_common_lib/zcmake.git [submodule "dep/zwebservice"] path = dep/zwebservice - url = ../../zlinux_demo_projects/zwebservice.git + url = ../../z2nd_lib/zwebservice.git [submodule "dep/zservice_container"] path = dep/zservice_container - url = ../../zlinux_demo_projects/zservice_container.git + url = ../../z2nd_lib/zservice_container.git [submodule "dep/websocketpp"] path = dep/websocketpp - url = ../../zlinux_demo_projects/websocketpp.git + url = ../../z2nd_lib/websocketpp.git [submodule "dep/asio1.12.2"] path = dep/asio1.12.2 - url = ../../zlinux_demo_projects/asio1.12.2.git + url = ../../z2nd_lib/asio1.12.2.git [submodule "dep/zclipp"] path = dep/zclipp - url = ../../zlinux_demo_projects/zclipp.git + url = ../../z2nd_lib/zclipp.git +[submodule "dep/zlinuxcomponents"] + path = dep/zlinuxcomponents + url = zwsd@192.168.1.3:z2nd_lib/zlinuxcomponents.git \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 0286516..094d3c7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,12 +41,13 @@ include(dep/asio1.12.2/module.cmake) include(dep/websocketpp/module.cmake) include(dep/zservice_container/module.cmake) include(dep/zwebservice/module.cmake) +include(dep/zlinuxcomponents/module.cmake) zadd_executable( TARGET app.out INSTALL - app + ./app LINK_LIBRARIES pthread INCLUDE_DIRECTORIES diff --git a/README.md b/README.md index b90dc93..19b6aa1 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,7 @@ build/ 应用程序编译目录 # 配置ssh-key,免密登录 ./sh/iflytool.sh --ip ssh_copy_id + ``` ## 唤醒词引擎环境测试 diff --git a/env/rootfs/.mark b/env/rootfs/.mark new file mode 100644 index 0000000..e69de29 diff --git a/sh/iflytool.sh b/sh/iflytool.sh index e367f3f..b5ef844 100755 --- a/sh/iflytool.sh +++ b/sh/iflytool.sh @@ -34,7 +34,9 @@ function do_flash_to_targetboard() { function do_flashapp_to_targetboard() { # 杀死目标程序 + set +e ssh ${TARGET_USER}@${IP} "killall app.out" + set -e # 拷贝目标程序 scp -r ${PROJECT_PATH}/build/app/app.out ${TARGET_USER}@${IP}:/app/ } @@ -173,7 +175,10 @@ if [ "$is_flash" = true ] || [ "$is_reboot" = true ]; then exit 1 fi fi - +# flashapp +if [ "$is_flashapp" = true ]; then + is_build=true +fi # 检查build目录是否存在 if [ ! -d "${PROJECT_PATH}/build" ]; then echo "build directory not exist, please run envsetup first" diff --git a/src/main.cpp b/src/main.cpp index c1b20a9..e1d9530 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4,6 +4,7 @@ #include "spdlog/spdlog.h" #include "version.hpp" #include "zclipp/include/clipp.h" +#include "zlinuxcomponents/rootfs_auto_update.hpp" #include "zservice_container/zservice_container.hpp" #include "zwebservice/zwebservice.hpp" // @@ -12,6 +13,8 @@ #include "service/light_control_service.hpp" #include "service/main_control_service.hpp" #include "service/report_service.hpp" +// +#include "dirent.h" using namespace iflytop; using namespace core; using namespace std; @@ -51,6 +54,7 @@ int main(int argc, char *argv[]) { /*********************************************************************************************************************** * =======================================================Main======================================================== * ***********************************************************************************************************************/ + int Main::main(int argc, char *argv[]) { string g_host_server_ip; string g_device_id; @@ -64,6 +68,8 @@ int Main::main(int argc, char *argv[]) { } #endif + logger->info("system setup start."); + spdlog::flush_on(spdlog::level::debug); logger->info("#"); @@ -71,11 +77,27 @@ int Main::main(int argc, char *argv[]) { logger->info("# version:{}", VERSION); logger->info("#"); - BUILD_AND_REG_SERRVICE(Config); GET_SERVICE(Config)->initialize(); if (!g_device_id.empty()) GET_SERVICE(Config)->set_deviceId(g_device_id); + + /** + * @brief 比较rootfs目录中的文件和系统中对应路径的文件是否一致,如果不一致则替换 + * + * 例如 + * ./rootfs/etc/asound.conf 和 /etc/asound.conf 不一致,则替换 + * + */ + auto rootfsAutoUpdate = make_shared(); + rootfsAutoUpdate->compareAndReplace(); + logger->info("rootfs changed:{}", rootfsAutoUpdate->isChanged() ? "yes" : "no"); + if (rootfsAutoUpdate->isChanged()) { + logger->info("reboot system."); + logger->warn("not auto reboot, please reboot manually."); + // system("reboot"); + } + #if 0 BUILD_AND_REG_SERRVICE(DeviceIOService); #else