### Install and Test Zabbix Get Utility Source: https://github.com/uptane/aktualizr/blob/master/docs/ota-client-guide/modules/ROOT/pages/device-monitoring-with-zabbix.adoc Installs the zabbix-get utility using apt-get and then uses it to test the accessibility of the Zabbix agent on the QEMU image. ```bash sudo apt-get install zabbix-get ``` ```bash zabbix_get -s localhost -p 10555 -k agent.ping ``` -------------------------------- ### Aktualizr Command Line Usage Examples Source: https://context7.com/uptane/aktualizr/llms.txt Illustrates various command-line invocations for the aktualizr client, covering daemon mode, single update cycles, specific actions like checking, downloading, and installing updates, as well as campaign management (checking, accepting, declining). It also shows how to access help and set logging levels. ```bash # Run as daemon (default - polls server periodically) aktualizr -c /etc/sota/sota.toml # Run one complete update cycle then exit aktualizr -c /etc/sota/sota.toml once # Check for updates only aktualizr -c /etc/sota/sota.toml check # Download available updates aktualizr -c /etc/sota/sota.toml download # Install downloaded updates aktualizr -c /etc/sota/sota.toml install # Check for campaigns aktualizr -c /etc/sota/sota.toml campaign_check # Accept a campaign aktualizr -c /etc/sota/sota.toml campaign_accept --campaign-id "campaign-uuid" # Decline a campaign aktualizr -c /etc/sota/sota.toml campaign_decline --campaign-id "campaign-uuid" # Command line options aktualizr --help aktualizr --version aktualizr -c /etc/sota/sota.toml --loglevel 1 # Debug logging aktualizr -c /etc/sota/sota.toml --hwinfo-file /etc/hwinfo.json ``` -------------------------------- ### Custom Installation with File Handle Source: https://github.com/uptane/aktualizr/blob/master/docs/ota-client-guide/modules/ROOT/pages/libaktualizr-update-secondary.adoc This snippet demonstrates an alternative method for installation where a file handle to the downloaded target is obtained, allowing for custom installation logic. ```APIDOC ## Custom Installation with File Handle ### Description Provides an alternative to the direct `Install` method by obtaining a file handle to a downloaded target. This allows for custom installation procedures to be implemented by the user. ### Method N/A (Code Example) ### Endpoint N/A (Code Example) ### Parameters N/A ### Request Example ```cpp // Assuming 'aktualizr' is an initialized Aktualizr object and 'update_result' contains downloaded updates for (auto& target : update_result.updates) { std::cout << "Installing file " << target.filename(); auto handle = aktualizr.GetStoredTarget(target); custom_install(handle); // custom_install is a user-defined function } ``` ### Response N/A ``` -------------------------------- ### Command Line Usage Source: https://context7.com/uptane/aktualizr/llms.txt Provides examples and explanations for using the aktualizr command-line client in various modes, including daemon, single update cycle, checking, downloading, installing, and campaign management. Also includes options for help, version, logging, and hardware info. ```APIDOC ## Command Line Usage The aktualizr command-line client supports multiple run modes for different update workflows. ```bash # Run as daemon (default - polls server periodically) aktualizr -c /etc/sota/sota.toml # Run one complete update cycle then exit aktualizr -c /etc/sota/sota.toml once # Check for updates only aktualizr -c /etc/sota/sota.toml check # Download available updates aktualizr -c /etc/sota/sota.toml download # Install downloaded updates aktualizr -c /etc/sota/sota.toml install # Check for campaigns aktualizr -c /etc/sota/sota.toml campaign_check # Accept a campaign aktualizr -c /etc/sota/sota.toml campaign_accept --campaign-id "campaign-uuid" # Decline a campaign aktualizr -c /etc/sota/sota.toml campaign_decline --campaign-id "campaign-uuid" # Command line options aktualizr --help aktualizr --version aktualizr -c /etc/sota/sota.toml --loglevel 1 # Debug logging aktualizr -c /etc/sota/sota.toml --hwinfo-file /etc/hwinfo.json ``` ``` -------------------------------- ### Install Targets on ECUs Source: https://context7.com/uptane/aktualizr/llms.txt Demonstrates how to trigger an installation of downloaded targets using the Aktualizr API. It handles the asynchronous installation process and parses results for both the primary device and individual ECUs. ```cpp #include "libaktualizr/aktualizr.h" #include "libaktualizr/results.h" void install_updates(Aktualizr& aktualizr, const std::vector& updates) { std::future install_future = aktualizr.Install(updates); result::Install install_result = install_future.get(); if (install_result.dev_report.isSuccess()) { std::cout << "Installation successful!" << std::endl; } else if (install_result.dev_report.needCompletion()) { std::cout << "Reboot required to complete installation" << std::endl; } else { std::cerr << "Installation failed: " << install_result.dev_report.description << std::endl; } for (const auto& ecu_report : install_result.ecu_reports) { std::cout << "ECU " << ecu_report.serial.ToString() << ": " << ecu_report.install_res.result_code << std::endl; } } ``` -------------------------------- ### Configure and Install aktualizr-info Executable Source: https://github.com/uptane/aktualizr/blob/master/src/aktualizr_info/CMakeLists.txt Defines the source files for the aktualizr-info utility, links it against the core aktualizr library, and specifies the installation destination for the resulting binary. ```cmake set(AKTUALIZR_INFO_SRC main.cc aktualizr_info_config.cc) set(AKTUALIZR_INFO_HEADERS aktualizr_info_config.h) add_executable(aktualizr-info ${AKTUALIZR_INFO_SRC}) target_link_libraries(aktualizr-info aktualizr_lib) install(TARGETS aktualizr-info COMPONENT aktualizr RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) ``` -------------------------------- ### Download and Install Updates Source: https://github.com/uptane/aktualizr/blob/master/docs/ota-client-guide/modules/ROOT/pages/libaktualizr-update-secondary.adoc This snippet shows how to initiate the download of available updates and subsequently install them. ```APIDOC ## Download and Install Updates ### Description Downloads the specified software updates and then installs them on the secondary ECU. It also includes an example of setting up a signal handler to monitor download progress. ### Method N/A (Code Example) ### Endpoint N/A (Code Example) ### Parameters N/A ### Request Example ```cpp // Assuming 'aktualizr' is an initialized Aktualizr object and 'update_result' contains available updates // Set up a signal handler for download progress std::function)> handler = event_handler; aktualizr.SetSignalHandler(handler); // Download the updates aktualizr.Download(update_result.updates).get(); // Install the updates aktualizr.Install(update_result.updates).get(); // Example event_handler function void event_handler(const std::shared_ptr &event) { if (event->variant == "DownloadProgressReport") { const auto download_progress = dynamic_cast(event.get()); std::cout << "Download progress for file " << download_progress->target.filename() << ": " << download_progress->progress << "%\n"; } } ``` ### Response N/A ``` -------------------------------- ### Install garage-deploy on Ubuntu 16.04 Source: https://github.com/uptane/aktualizr/blob/master/docs/ota-client-guide/modules/ROOT/pages/install-garage-sign-deploy.adoc Installs the garage-deploy tool on Ubuntu 16.04 by downloading the .deb package and using apt to install it. This method is specific to Ubuntu 16.04. ```bash wget https://github.com/advancedtelematic/aktualizr/releases/download/{aktualizr-version}/garage_deploy-ubuntu_16.04.deb sudo apt install ./garage_deploy-ubuntu_16.04.deb ``` -------------------------------- ### C API Functions Source: https://context7.com/uptane/aktualizr/llms.txt This section details the C API functions available for integrating Aktualizr into C applications or for FFI from other languages. It includes examples of creating an Aktualizr instance, setting event handlers, initializing, checking for updates, downloading, installing, and cleaning up. ```APIDOC ## C API Functions The C API provides bindings for use in C applications or FFI from other languages. ```c #include "libaktualizr-c.h" int main() { // Create aktualizr from config path Aktualizr *aktualizr = Aktualizr_create_from_path("/etc/sota/sota.toml"); if (!aktualizr) { printf("Failed to create aktualizr\n"); return 1; } // Set event handler void my_event_handler(const char* event_name) { printf("Event: %s\n", event_name); } Aktualizr_set_signal_handler(aktualizr, my_event_handler); // Initialize if (Aktualizr_initialize(aktualizr) != 0) { printf("Initialization failed\n"); Aktualizr_destroy(aktualizr); return 1; } // Send device data Aktualizr_send_device_data(aktualizr); // Check for updates Updates *updates = Aktualizr_updates_check(aktualizr); if (updates) { size_t num_targets = Aktualizr_get_targets_num(updates); printf("Found %zu updates\n", num_targets); for (size_t i = 0; i < num_targets; i++) { Target *target = Aktualizr_get_nth_target(updates, i); const char *name = Aktualizr_get_target_name(target); printf(" Target: %s\n", name); // Download and install Aktualizr_download_target(aktualizr, target); Aktualizr_install_target(aktualizr, target); Aktualizr_free_target_name(name); } Aktualizr_updates_free(updates); } // Send manifest Aktualizr_send_manifest(aktualizr, NULL); // Or run a complete cycle // Aktualizr_uptane_cycle(aktualizr); // Cleanup Aktualizr_destroy(aktualizr); return 0; } ``` ``` -------------------------------- ### Install garage-deploy on Ubuntu 18.04 Source: https://github.com/uptane/aktualizr/blob/master/docs/ota-client-guide/modules/ROOT/pages/install-garage-sign-deploy.adoc Installs the garage-deploy tool on Ubuntu 18.04 by downloading the .deb package and using apt to install it. This is a direct installation method for a specific OS version. ```bash wget https://github.com/advancedtelematic/aktualizr/releases/download/{aktualizr-version}/garage_deploy-ubuntu_18.04.deb sudo apt install ./garage_deploy-ubuntu_18.04.deb ``` -------------------------------- ### Build Aktualizr from Source Source: https://github.com/uptane/aktualizr/blob/master/docs/ota-client-guide/modules/ROOT/pages/simulate-device-basic.adoc Commands to install build dependencies, clone the repository, and compile Aktualizr from source code. ```shell sudo apt install asn1c build-essential clang clang-format-11 clang-tidy-11 cmake curl doxygen graphviz lcov libarchive-dev libboost-dev libboost-filesystem-dev libboost-log-dev libboost-program-options-dev libcurl4-openssl-dev libostree-dev libp11-3 libp11-dev libpthread-stubs0-dev libsodium-dev libsqlite3-dev libssl-dev python3-dev python3-openssl python3-venv sqlite3 valgrind git clone --recursive -b {aktualizr-version} https://github.com/advancedtelematic/aktualizr cd aktualizr mkdir build cd build cmake .. make install ``` -------------------------------- ### Install Aktualizr on Ubuntu 16.04 Source: https://github.com/uptane/aktualizr/blob/master/docs/ota-client-guide/modules/ROOT/pages/simulate-device-basic.adoc Commands to download, install, and disable the system service for Aktualizr on Ubuntu 16.04. ```shell wget https://github.com/advancedtelematic/aktualizr/releases/download/{aktualizr-version}/aktualizr-ubuntu_16.04.deb sudo apt install ./aktualizr-ubuntu_16.04.deb sudo systemctl stop aktualizr.service sudo systemctl disable aktualizr.service ``` -------------------------------- ### Install Aktualizr on macOS using Homebrew (Development) Source: https://github.com/uptane/aktualizr/blob/master/README.adoc Installs the latest development version (current HEAD) of aktualizr on macOS using Homebrew. Ensure any previous release versions are unlinked before installing. ```bash brew tap advancedtelematic/otaconnect brew install --HEAD aktualizr ``` -------------------------------- ### Setup Raspberry Pi Build Environment Source: https://github.com/uptane/aktualizr/blob/master/docs/ota-client-guide/modules/ROOT/pages/posix-secondaries-bitbaking.adoc Command to initialize the build environment for Raspberry Pi 3 targets. ```bash source meta-updater/scripts/envsetup.sh raspberrypi3 ``` -------------------------------- ### Download Progress Event Handler Example Source: https://github.com/uptane/aktualizr/blob/master/docs/ota-client-guide/modules/ROOT/pages/libaktualizr-update-secondary.adoc An example implementation of an event handler function that processes download progress reports. It specifically looks for 'DownloadProgressReport' events and prints the progress. ```cpp void event_handler(const std::shared_ptr &event) { if (event->variant == "DownloadProgressReport") { const auto download_progress = dynamic_cast(event.get()); std::cout << "Download progress for file " << download_progress->target.filename() << ": " << download_progress->progress << "%\n"; } } ``` -------------------------------- ### Install Aktualizr on macOS using Homebrew (Release) Source: https://github.com/uptane/aktualizr/blob/master/README.adoc Installs the latest release version of aktualizr on macOS using the Homebrew package manager. This is useful for testing with a fake device. ```bash brew tap advancedtelematic/otaconnect brew install aktualizr ``` -------------------------------- ### Retrieve Installation Log (C++) Source: https://context7.com/uptane/aktualizr/llms.txt Provides C++ code to fetch the installation history across all ECUs, ordered chronologically. This is valuable for auditing purposes and for implementing rollback mechanisms. The log contains entries detailing each ECU and its installed firmware versions. ```cpp #include "libaktualizr/aktualizr.h" void view_installation_history(Aktualizr& aktualizr) { Aktualizr::InstallationLog log = aktualizr.GetInstallationLog(); for (const auto& entry : log) { std::cout << "ECU: " << entry.ecu.ToString() << std::endl; for (const auto& install : entry.installs) { std::cout << " - " << install.filename() << " (version: " << install.custom_version() << ")" << std::endl; } } } ``` -------------------------------- ### Initialize and Manage libaktualizr API Source: https://github.com/uptane/aktualizr/blob/master/docs/ota-client-guide/modules/ROOT/pages/libaktualizr-getstarted.adoc Examples of core C++ API methods for constructing an Aktualizr instance, adding secondary ECUs, and initializing the service. ```cpp // Construct an aktualizr instance Aktualizr::Aktualizr(boost::filesystem::path config); // Add a new Secondary ECU void Aktualizr::AddSecondary(const std::shared_ptr &secondary); // Initialize aktualizr void Aktualizr::Initialize(); ``` -------------------------------- ### Client Configuration: Force Install Completion (Development) Source: https://github.com/uptane/aktualizr/blob/master/docs/ota-client-guide/modules/ROOT/pages/recommended-clientconfig.adoc Enables 'force_install_completion' to true in the client configuration for development. This ensures that the installation process is always marked as complete, which can be useful for testing update workflows. It is set using the 'force_install_completion' parameter. ```ini force_install_completion = "true" ``` -------------------------------- ### Install Software from Target Files in C++ Source: https://github.com/uptane/aktualizr/blob/master/docs/ota-client-guide/modules/ROOT/pages/libaktualizr-getstarted.adoc Installs software from previously downloaded target files. The function takes a vector of `Uptane::Target` objects representing the updates to install and returns a future that resolves to a `result::Install` object. ```cpp std::future Aktualizr::Install(const std::vector &updates) ``` -------------------------------- ### Creating U-Boot Initialization Script for OSTree Source: https://github.com/uptane/aktualizr/blob/master/docs/ota-client-guide/modules/ROOT/pages/add-meta-updater-to-vendors-sdk.adoc Provides a Yocto bbappend example to generate a U-Boot script that points the bootloader to the OSTree-managed boot configuration. ```bash DEPENDS += "u-boot-mkimage-native" do_deploy_append_qoriq() { cat > ${DEPLOYDIR}/ls1043ardb_boot.txt << EOF load mmc 0:2 ${load_addr} /boot/loader/uEnv.txt env import -t ${fileaddr} ${filesize} load mmc 0:2 ${load_addr} /boot${kernel_image} bootm ${load_addr} EOF mkimage -A arm64 -O linux -T script -d ${DEPLOYDIR}/ls1043ardb_boot.txt ${DEPLOYDIR}/ls1043ardb_boot.scr } ``` -------------------------------- ### Install Aktualizr on Ubuntu 18.04 Source: https://github.com/uptane/aktualizr/blob/master/docs/ota-client-guide/modules/ROOT/pages/simulate-device-basic.adoc Commands to download, install, and disable the system service for Aktualizr on Ubuntu 18.04. ```shell wget https://github.com/advancedtelematic/aktualizr/releases/download/{aktualizr-version}/aktualizr-ubuntu_18.04.deb sudo apt install ./aktualizr-ubuntu_18.04.deb sudo systemctl stop aktualizr.service sudo systemctl disable aktualizr.service ``` -------------------------------- ### Build and Install garage-deploy from Source (Debian-based) Source: https://github.com/uptane/aktualizr/blob/master/docs/ota-client-guide/modules/ROOT/pages/install-garage-sign-deploy.adoc Builds the garage-deploy tool from source for other Debian-based distributions or versions not directly supported by pre-built packages. It involves cloning the repository, installing dependencies, configuring with CMake, and packaging. ```bash git clone --branch {aktualizr-version} --recursive https://github.com/advancedtelematic/aktualizr sudo apt install asn1c build-essential clang clang-format-11 clang-tidy-11 cmake curl \ doxygen graphviz lcov libarchive-dev libboost-dev libboost-filesystem-dev libboost-log-dev \ libboost-program-options-dev libcurl4-openssl-dev libostree-dev libp11-2 libp11-dev \ libpthread-stubs0-dev libsodium-dev libsqlite3-dev libssl-dev libsystemd-dev cd aktualizr mkdir build cd build cmake -DBUILD_SOTA_TOOLS=ON .. make package sudo apt install ./garage_deploy.deb ``` -------------------------------- ### Install Debian/Ubuntu Dependencies for Aktualizr Source: https://github.com/uptane/aktualizr/blob/master/README.adoc This command installs the minimal required packages on Debian/Ubuntu systems to build and run the aktualizr client. It includes essential development tools and libraries like cmake, curl, and openssl. ```bash sudo apt install asn1c build-essential cmake curl libarchive-dev libboost-dev libboost-filesystem-dev libboost-log-dev libboost-program-options-dev libcurl4-openssl-dev libpthread-stubs0-dev libsodium-dev libsqlite3-dev libssl-dev python3 ``` -------------------------------- ### Launch Aktualizr Primary and Secondary Processes Source: https://github.com/uptane/aktualizr/blob/master/docs/ota-client-guide/modules/ROOT/pages/posix-secondaries.adoc Commands to start the Primary and Secondary ECU processes using specific configuration files. ```bash $AKT_PRIMARY -c $AKT_PROJ_HOME/config/sota-local-with-secondaries.toml $AKT_SECNDR -c $AKT_PROJ_HOME/config/posix-secondary.toml ``` -------------------------------- ### Build garage-deploy Binary from Source (Non-Debian) Source: https://github.com/uptane/aktualizr/blob/master/docs/ota-client-guide/modules/ROOT/pages/install-garage-sign-deploy.adoc Builds the garage-deploy binary directly from source for non-Debian-based distributions. This process requires installing dependencies and then compiling the specific 'garage-deploy' target. ```bash git clone --branch {aktualizr-version} --recursive https://github.com/advancedtelematic/aktualizr cd aktualizr mkdir build cd build cmake -DBUILD_SOTA_TOOLS=ON .. make garage-deploy sudo apt install ./garage_deploy.deb ``` -------------------------------- ### Get Stored Target and Custom Install Source: https://github.com/uptane/aktualizr/blob/master/docs/ota-client-guide/modules/ROOT/pages/libaktualizr-update-secondary.adoc Retrieves a file handle to a downloaded target and allows for a custom installation process. This provides flexibility for managing installations outside of the default mechanism. ```cpp for (auto& target : update_result.updates) { std::cout << "Installing file " << target.filename(); auto handle = aktualizr.GetStoredTarget(target); custom_install(handle); } ``` -------------------------------- ### Run Aktualizr Indefinitely in C++ Source: https://github.com/uptane/aktualizr/blob/master/docs/ota-client-guide/modules/ROOT/pages/libaktualizr-getstarted.adoc Starts Aktualizr in an asynchronous loop to continuously check for and install updates at regular intervals. The process runs indefinitely until the Aktualizr instance is destroyed. This function returns a future that completes when the destructor is called. ```cpp std::future Aktualizr::RunForever() ``` -------------------------------- ### Run Aktualizr in Development Mode Source: https://github.com/uptane/aktualizr/blob/master/docs/ota-client-guide/modules/ROOT/pages/debugging-tips.adoc Commands to initialize the provisioning directory and execute the Aktualizr primary binary using a local configuration file. This is intended for testing installation processes without a full production environment. ```bash mkdir sota-prov src/aktualizr_primary/aktualizr --config ../config/sota-local.toml ``` -------------------------------- ### Initialize and Manage Uptane Repository via CLI Source: https://github.com/uptane/aktualizr/blob/master/docs/ota-client-guide/modules/ROOT/pages/uptane-generator.adoc Demonstrates the core workflow for generating a new repository, adding image targets, and preparing device-specific Director metadata using the uptane-generator tool. ```bash uptane-generator --path --command generate uptane-generator --path --command image --filename --targetname --hwid uptane-generator --path --command addtarget --targetname --hwid --serial uptane-generator --path --command signtargets ``` -------------------------------- ### Build Aktualizr with CMake Source: https://context7.com/uptane/aktualizr/llms.txt This snippet demonstrates how to clone the Aktualizr repository, create a build directory, configure the project using CMake with specific build options (Release, OSTree, P11, SOTA_TOOLS), compile the project, run tests, and install the built components. It utilizes standard bash commands for version control, build system configuration, and compilation. ```bash git clone --recursive https://github.com/uptane/aktualizr cd aktualizr mkdir build && cd build cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_OSTREE=ON -DBUILD_P11=ON -DBUILD_SOTA_TOOLS=ON .. make -j$(nproc) make check sudo make install ``` -------------------------------- ### Initialize Device Provisioning Source: https://github.com/uptane/aktualizr/blob/master/docs/ota-client-guide/modules/ROOT/pages/libaktualizr-update-secondary.adoc Calls the Initialize method on the Aktualizr instance to provision the device on the backend. This step is crucial for establishing communication and registration with the update server. ```cpp aktualizr.Initialize(); ``` -------------------------------- ### Configure Wic Kickstart for OSTree Source: https://github.com/uptane/aktualizr/blob/master/docs/ota-client-guide/modules/ROOT/pages/setup-boot-image-for-ostree.adoc A sample WKS file configuration for an NXP board, demonstrating how to define raw partitions for firmware and the root filesystem using the otaimage source. ```bash part BL2 --source rawcopy2 --sourceparams="file=atf/bl2_sd.pbl" --ondisk mmcblk --no-table --align 4 part BL3 --source rawcopy2 --sourceparams="file=atf/fip_uboot.bin" --ondisk mmcblk --no-table --align 1024 part fman-ucode --source rawcopy2 --sourceparams="file=fsl_fman_ucode_ls1043_r1.1_108_4_9.bin" --ondisk mmcblk --no-table --align 9216 part qe-ucode --source rawcopy2 --sourceparams="file=boot/fsl_qe_ucode_1021_10_A.bin" --ondisk mmcblk --no-table --align 9472 part uboot-scr --source bootimg-partition --ondisk mmcblk --fstype=msdos --fixed-size=100M --align 65540 part / --source otaimage --ondisk mmcblk --fstype=ext4 --label root --align 167940 bootloader --ptable msdos ``` -------------------------------- ### View garage-deploy help options Source: https://github.com/uptane/aktualizr/blob/master/docs/ota-client-guide/modules/ROOT/pages/cross-deploy-images.adoc Displays the available command-line arguments and options for the garage-deploy utility. ```bash garage-deploy --help ``` -------------------------------- ### Install Updates Source: https://github.com/uptane/aktualizr/blob/master/docs/ota-client-guide/modules/ROOT/pages/libaktualizr-update-secondary.adoc Installs the downloaded updates if the secondary ECU type supports it. This operation is performed asynchronously. ```cpp aktualizr.Install(update_result.updates).get(); ``` -------------------------------- ### Initialize Aktualizr Instance Source: https://github.com/uptane/aktualizr/blob/master/docs/ota-client-guide/modules/ROOT/pages/libaktualizr-update-secondary.adoc Creates an Aktualizr instance by providing the path to the configuration file. This is the first step in interacting with the libAktualizr API. ```cpp boost::filesystem::path cfg_path("/var/sota/sota_local.toml"); Aktualizr aktualizr(cfg_path); ``` -------------------------------- ### C API for Aktualizr Operations Source: https://context7.com/uptane/aktualizr/llms.txt Demonstrates how to use the C API to interact with Aktualizr. This includes creating an instance, setting event handlers, initializing the service, checking for updates, downloading and installing targets, and sending manifest data. It requires the libaktualizr-c.h header and assumes a configuration file exists at /etc/sota/sota.toml. ```c #include "libaktualizr-c.h" int main() { // Create aktualizr from config path Aktualizr *aktualizr = Aktualizr_create_from_path("/etc/sota/sota.toml"); if (!aktualizr) { printf("Failed to create aktualizr\n"); return 1; } // Set event handler void my_event_handler(const char* event_name) { printf("Event: %s\n", event_name); } Aktualizr_set_signal_handler(aktualizr, my_event_handler); // Initialize if (Aktualizr_initialize(aktualizr) != 0) { printf("Initialization failed\n"); Aktualizr_destroy(aktualizr); return 1; } // Send device data Aktualizr_send_device_data(aktualizr); // Check for updates Updates *updates = Aktualizr_updates_check(aktualizr); if (updates) { size_t num_targets = Aktualizr_get_targets_num(updates); printf("Found %zu updates\n", num_targets); for (size_t i = 0; i < num_targets; i++) { Target *target = Aktualizr_get_nth_target(updates, i); const char *name = Aktualizr_get_target_name(target); printf(" Target: %s\n", name); // Download and install Aktualizr_download_target(aktualizr, target); Aktualizr_install_target(aktualizr, target); Aktualizr_free_target_name(name); } Aktualizr_updates_free(updates); } // Send manifest Aktualizr_send_manifest(aktualizr, NULL); // Or run a complete cycle // Aktualizr_uptane_cycle(aktualizr); // Cleanup Aktualizr_destroy(aktualizr); return 0; } ``` -------------------------------- ### Install Zabbix Server Dependencies on Ubuntu Source: https://github.com/uptane/aktualizr/blob/master/docs/ota-client-guide/modules/ROOT/pages/device-monitoring-with-zabbix.adoc Commands to install Apache, MySQL, and PHP components required for the Zabbix frontend and backend. ```bash sudo apt-get update sudo apt-get install apache2 libapache2-mod-php sudo apt-get install mysql-server sudo apt-get install php php-mbstring php-gd php-xml php-bcmath php-ldap php-mysql ``` -------------------------------- ### Create OpenSSL Configuration Files Source: https://github.com/uptane/aktualizr/blob/master/docs/ota-client-guide/modules/ROOT/pages/generate-devicecert.adoc Generates the necessary .cnf and .ext configuration files required for signing device certificates with specific key usage constraints. ```bash cat < ${fleet_name}/devices/device_cert.cnf [req] prompt = no distinguished_name = dn req_extensions = ext [dn] CN=$ENV::device_id [ext] keyUsage=critical, digitalSignature extendedKeyUsage=critical, clientAuth EOF cat < ${fleet_name}/devices/device_cert.ext keyUsage=critical, digitalSignature extendedKeyUsage=critical, clientAuth EOF ``` -------------------------------- ### Switching Build Architectures in Aktualizr Source: https://github.com/uptane/aktualizr/blob/master/docs/ota-client-guide/modules/ROOT/pages/troubleshooting.adoc Demonstrates the incorrect and correct approach to switching build architectures for Aktualizr. The incorrect method involves sourcing the environment script without updating configuration files. The correct approach requires deleting or renaming existing configuration files (`local.conf`, `bblayers.conf`) and re-generating them for the new architecture, while also preserving customizations. ```bash # Incorrect approach source meta-updater/scripts/envsetup.sh raspberrypi3 { build an image ... } cd .. source meta-updater/scripts/envsetup.sh qemux86-64 ``` ```bash # Correct approach: Delete/rename old configs and re-generate # Example for switching to qemux86-64 after raspberrypi3 rm meta-updater/build/conf/local.conf rm meta-updater/build/conf/bblayers.conf source meta-updater/scripts/envsetup.sh qemux86-64 # Add back custom configurations to local.conf and bblayers.conf ``` -------------------------------- ### Install Yocto Prerequisites on Debian Source: https://github.com/uptane/aktualizr/blob/master/docs/ota-client-guide/modules/ROOT/pages/build-raspberry.adoc Installs all required packages for the Yocto Project build host on a Debian-based Linux distribution. This ensures the build environment has the necessary tools and libraries. ```bash sudo apt install gawk wget git diffstat unzip texinfo gcc-multilib build-essential chrpath socat cpio python python3 python3-pip python3-pexpect python-dev xz-utils debianutils iputils-ping cpu-checker default-jre parted ``` -------------------------------- ### Initialize Aktualizr and Configure Secondary ECU Source: https://github.com/uptane/aktualizr/blob/master/docs/ota-client-guide/modules/ROOT/pages/libaktualizr-update-secondary.adoc This snippet demonstrates how to initialize the Aktualizr client with a configuration file and add a secondary ECU configuration. ```APIDOC ## Initialize Aktualizr and Configure Secondary ECU ### Description Initializes the Aktualizr client with a configuration file and sets up a secondary ECU configuration, including its type, serial, hardware ID, and paths for keys and metadata. ### Method N/A (Code Example) ### Endpoint N/A (Code Example) ### Parameters N/A ### Request Example ```cpp boost::filesystem::path cfg_path("/var/sota/sota_local.toml"); Aktualizr aktualizr(cfg_path); Uptane::SecondaryConfig sconfig; sconfig.secondary_type = Uptane::SecondaryType::kVirtual; sconfig.ecu_serial = "9b6abd606a761074df0092606465ddc9"; sconfig.ecu_hardware_id = "TCU"; sconfig.full_client_dir = "/var/sota/ecus/tcu"; sconfig.ecu_private_key = "sec.private"; sconfig.ecu_public_key = "sec.public"; sconfig.target_name_path = "target_name"; sconfig.metadata_path = "/var/sota/ecus/tcu/metadata"; auto secondary = std::make_shared(sconfig); aktualizr.AddSecondary(secondary); ``` ### Response N/A ``` -------------------------------- ### Install 32-bit ARM Dependencies on Ubuntu/Debian Source: https://github.com/uptane/aktualizr/blob/master/docs/ota-client-guide/modules/ROOT/pages/pushing-updates.adoc Configures the host system to support 32-bit architecture and installs the necessary development libraries required for building specific packages on ARM targets. ```bash sudo dpkg --add-architecture i386 sudo apt update sudo apt install g++-multilib libssl-dev:i386 libcrypto++-dev:i386 zlib1g-dev:i386 ``` -------------------------------- ### Initialize and Sync AGL Repositories Source: https://github.com/uptane/aktualizr/blob/master/docs/ota-client-guide/modules/ROOT/pages/build-agl.adoc Initializes the Yocto build environment by downloading the AGL repositories using a specific manifest file for the 'icefish' release. This step is crucial for setting up the project structure and dependencies. ```bash mkdir myproject cd myproject repo init -b icefish -m icefish_9.0.1.xml -u https://gerrit.automotivelinux.org/gerrit/AGL/AGL-repo repo sync ``` -------------------------------- ### Accept a Campaign for Installation in C++ Source: https://github.com/uptane/aktualizr/blob/master/docs/ota-client-guide/modules/ROOT/pages/libaktualizr-getstarted.adoc Accepts a specific campaign, identified by its `campaign_id`, allowing the associated update to be installed on the device. This function returns a future that resolves to void upon successful acceptance. ```cpp std::future Aktualizr::CampaignAccept(const std::string &campaign_id) ``` -------------------------------- ### Set up AGL Environment Script Source: https://github.com/uptane/aktualizr/blob/master/docs/ota-client-guide/modules/ROOT/pages/build-agl.adoc Configures the build environment by sourcing the AGL setup script. This script prepares the necessary environment variables and configurations for building AGL images. The target architecture must be specified. ```bash source meta-agl/scripts/aglsetup.sh -m agl-sota <1> ``` -------------------------------- ### C++ Database Migration Test Example Source: https://github.com/uptane/aktualizr/blob/master/docs/ota-client-guide/modules/ROOT/pages/schema-migrations.adoc This example shows how to write an explicit database migration test in C++. It is recommended for migrations that manipulate existing data in a non-trivial way, similar to the 'DbMigration18to19' test. ```cpp // Example of a database migration test in C++ // Similar to DbMigration18to19 // Realistic data should be used for testing complex manipulations. ``` -------------------------------- ### Install Python Development Headers for Bitbake Source: https://github.com/uptane/aktualizr/blob/master/docs/ota-client-guide/modules/ROOT/pages/troubleshooting.adoc Provides the command to install the necessary Python development headers on Ubuntu systems when encountering build errors related to missing 'Python.h'. This ensures that Bitbake can correctly compile Python-dependent components. ```bash sudo apt-get update sudo apt-get install libpython2.7-dev ``` -------------------------------- ### Build Yocto Image with Bitbake Source: https://github.com/uptane/aktualizr/blob/master/docs/ota-client-guide/modules/ROOT/pages/build-raspberry.adoc Initiates the Yocto image build process using the 'bitbake' command. The example specifically builds the 'core-image-minimal' image. The description notes that this process can take a significant amount of time, ranging from minutes with a build mirror to hours when building from scratch. ```shell bitbake core-image-minimal ``` -------------------------------- ### Trigger Individual Aktualizr Update Stages Source: https://github.com/uptane/aktualizr/blob/master/docs/ota-client-guide/modules/ROOT/pages/aktualizr-runningmodes-finegrained-commandline-control.adoc Aktualizr allows for granular control over the update process. These commands trigger specific stages: checking for metadata, downloading available updates, installing downloaded updates, and reporting installation status. ```bash aktualizr check ``` ```bash aktualizr download ``` ```bash aktualizr install ``` -------------------------------- ### Initialize Aktualizr Client Source: https://context7.com/uptane/aktualizr/llms.txt Initializes the Aktualizr client and attempts device provisioning. This function must be called after creating an Aktualizr instance and before performing other operations. It can handle re-attempts for provisioning if it fails initially. Secondary ECUs should be added prior to calling this method. ```cpp #include "libaktualizr/aktualizr.h" #include "libaktualizr/config.h" int main() { // Load configuration from TOML file Config config("/etc/sota/sota.toml"); // Create Aktualizr instance Aktualizr aktualizr(config); // Initialize the client (attempts provisioning if needed) aktualizr.Initialize(); return 0; } ``` ```cpp #include "libaktualizr/aktualizr.h" void setup_aktualizr(Aktualizr& aktualizr) { try { // Initialize - this provisions the device if not already done aktualizr.Initialize(); std::cout << "Aktualizr initialized successfully" << std::endl; } catch (const std::runtime_error& e) { std::cerr << "Initialization failed: " << e.what() << std::endl; } } ``` -------------------------------- ### Client Configuration: Force Install Completion (Production) Source: https://github.com/uptane/aktualizr/blob/master/docs/ota-client-guide/modules/ROOT/pages/recommended-clientconfig.adoc Disables 'force_install_completion' to false in the client configuration for production. This ensures that the installation status accurately reflects the actual completion of the update process, which is important for reliable operation. It is set using the 'force_install_completion' parameter. ```ini force_install_completion = "false" ```