### Compile and Install libappimageupdate on Ubuntu 18.04 Source: https://github.com/appimage/appimageupdate/blob/main/BUILDING.md This snippet compiles and installs the libappimageupdate library on Ubuntu 18.04. It first installs necessary development packages, clones the AppImageUpdate repository, configures the build with CMake, and then compiles and installs the library. Dependencies include wget, git, cmake, g++, libcurl4-openssl-dev, libx11-dev, libz-dev, libfuse-dev, and librsvg2-dev. ```bash # Compile and install libappimageupdate sudo apt -y install wget git cmake g++ libcurl4-openssl-dev libx11-dev libz-dev libfuse-dev librsvg2-dev git clone --recursive https://github.com/AppImage/AppImageUpdate cd AppImageUpdate/ mkdir build/ cd build/ cmake -DBUILD_QT_UI=OFF -DCMAKE_INSTALL_PREFIX=/usr .. make -j$(nproc) sudo make install cd .. # Also compile and install libappimage sudo apt -y install libssl-dev libinotifytools0-dev libarchive-dev libfuse-dev liblzma-dev git clone --recursive https://github.com/AppImage/AppImageKit cd AppImageKit/ mkdir build/ cd build/ cmake -DUSE_SYSTEM_XZ=ON -DUSE_SYSTEM_INOTIFY_TOOLS=ON -DUSE_SYSTEM_LIBARCHIVE=ON -DUSE_SYSTEM_GTEST=OFF -DCMAKE_INSTALL_PREFIX=/usr .. make -j$(nproc) sudo make install ``` -------------------------------- ### Compile and Install libappimageupdate on CentOS 7 Source: https://github.com/appimage/appimageupdate/blob/main/BUILDING.md This snippet compiles and installs the libappimageupdate library on CentOS 7. It begins by enabling the EPEL repository, then installs required development packages using yum. The AppImageUpdate repository is cloned, and the library is built and installed using cmake3 and make. Dependencies include wget, rpm, git, cmake3, gcc-c++, curl-devel, libX11-devel, zlib-devel, fuse-devel, librsvg2-devel, and cairo-devel. ```bash # Compile and install libappimageupdate wget http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm rpm -ivh epel-release-latest-7.noarch.rpm yum install git cmake3 gcc-c++ curl-devel libX11-devel zlib-devel fuse-devel librsvg2-devel cairo-devel git clone --recursive https://github.com/AppImage/AppImageUpdate cd AppImageUpdate/ mkdir build/ cd build/ cmake3 -DBUILD_QT_UI=OFF -DCMAKE_INSTALL_PREFIX=/usr .. make -j$(nproc) sudo make install cd .. # Also compile libappimage; work in progress git clone https://github.com/AppImage/AppImageKit cd AppImageKit/ mkdir build cd build cmake3 -DUSE_SYSTEM_XZ=ON -DUSE_SYSTEM_INOTIFY_TOOLS=ON -DUSE_SYSTEM_LIBARCHIVE=ON -DUSE_SYSTEM_GTEST=ON .. make -j$(nproc) # Section to be completed ``` -------------------------------- ### Start Asynchronous AppImage Update (C++) Source: https://context7.com/appimage/appimageupdate/llms.txt Illustrates how to initiate an asynchronous update process using the `start` method of the Updater class. The code monitors the update progress using `isDone`, `hasError`, and `progress`, and retrieves the path to the new file upon successful completion. ```cpp #include "appimage/update.h" #include #include #include #include int main() { appimage::update::Updater updater("/path/to/MyApp.AppImage"); // Check if update is needed first bool updateAvailable = false; if (!updater.checkForChanges(updateAvailable) || !updateAvailable) { std::cout << "No update needed." << std::endl; return 0; } // Start the update process if (!updater.start()) { std::cerr << "Failed to start update!" << std::endl; return 1; } std::cout << "Starting update..." << std::endl; // Monitor progress until done while (!updater.isDone()) { std::this_thread::sleep_for(std::chrono::milliseconds(100)); double progress = 0; if (updater.progress(progress)) { std::cout << "\r" << std::fixed << std::setprecision(1) << (progress * 100.0) << "% complete" << std::flush; } // Print status messages std::string message; while (updater.nextStatusMessage(message)) { std::cout << "\n" << message << std::endl; } } std::cout << std::endl; if (updater.hasError()) { std::cerr << "Update failed!" << std::endl; return 1; } std::string newFilePath; if (updater.pathToNewFile(newFilePath)) { std::cout << "Update successful! New file: " << newFilePath << std::endl; } return 0; } ``` -------------------------------- ### Define Installation and RPATH Settings Source: https://github.com/appimage/appimageupdate/blob/main/src/qt-ui/CMakeLists.txt Configures target properties for RPATH to ensure correct library loading at runtime and defines installation rules for libraries and headers. ```cmake set_target_properties(libappimageupdate-qt PROPERTIES INSTALL_RPATH "$ORIGIN") install(TARGETS libappimageupdate-qt EXPORT AppImageUpdateTargets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/appimage/update ) ``` -------------------------------- ### start Source: https://context7.com/appimage/appimageupdate/llms.txt Initiates the asynchronous update process for the AppImage. ```APIDOC ## Method: start ### Description Begins the update process in a background thread. The process can be monitored using progress, isDone, and hasError methods. ### Response - **Success Response (200)** - **return** (bool) - Returns true if the update process started successfully. ### Response Example ```cpp if (updater.start()) { // Update process running in background } ``` ``` -------------------------------- ### Build AppImageUpdate from Source Source: https://context7.com/appimage/appimageupdate/llms.txt Provides the sequence of commands to clone, install dependencies on Ubuntu/Debian, and compile the project with optional Qt support. ```bash # Clone with submodules git clone --recursive https://github.com/AppImage/AppImageUpdate cd AppImageUpdate # Install dependencies (Ubuntu/Debian) sudo apt install cmake g++ libcurl4-openssl-dev libx11-dev libz-dev libfuse-dev librsvg2-dev # Build mkdir build && cd build cmake -DBUILD_QT_UI=OFF -DCMAKE_INSTALL_PREFIX=/usr .. make -j$(nproc) # Install sudo make install # Build with Qt UI support cmake -DBUILD_QT_UI=ON -DCMAKE_INSTALL_PREFIX=/usr .. ``` -------------------------------- ### Define Executable and Link Libraries (CMake) Source: https://github.com/appimage/appimageupdate/blob/main/src/cli/CMakeLists.txt This snippet defines the 'appimageupdatetool' executable, linking it to 'main.cpp' and essential libraries like 'libappimageupdate' and 'util'. It conditionally links 'zsync2' if not using a system-wide installation. The rpath is set to ensure proper library loading at runtime. ```cmake add_executable(appimageupdatetool main.cpp) target_link_libraries(appimageupdatetool libappimageupdate util) if(NOT USE_SYSTEM_ZSYNC2) target_link_libraries(appimageupdatetool ${ZSYNC2_LIBRARY_NAME}) endif() set_target_properties(appimageupdatetool PROPERTIES INSTALL_RPATH "$ORIGIN/../${CMAKE_INSTALL_LIBDIR}") install( TARGETS appimageupdatetool RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT APPIMAGEUPDATETOOL ) ``` -------------------------------- ### Check for argagg Header (CMake) Source: https://github.com/appimage/appimageupdate/blob/main/CMakeLists.txt Verifies the presence of the 'argagg' header file by attempting to compile a test C++ file. If the header is not found, the build process is halted with an error message, prompting the user to install it. ```cmake try_compile(HAVE_ARGAGG "${PROJECT_BINARY_DIR}/tests" "${PROJECT_SOURCE_DIR}/cmake/tests/try_argagg.cpp" OUTPUT_VARIABLE ARGAGG_OUT CMAKE_FLAGS "-DINCLUDE_DIRECTORIES=${CMAKE_REQUIRED_INCLUDES}") if(NOT HAVE_ARGAGG) message(FATAL_ERROR "${ARGAGG_OUT} argagg header not found on system, please install") endif() ``` -------------------------------- ### Initialize Updater with APPIMAGE Environment Variable (C++) Source: https://github.com/appimage/appimageupdate/wiki/Self-updating-AppImages Demonstrates how to initialize the `appimage::update::Updater` class using the APPIMAGE environment variable. This is crucial for self-updating applications. Error handling should be added for robustness. ```cpp #include #include int main() { const char* appimage_path = std::getenv("APPIMAGE"); if (appimage_path) { appimage::update::Updater updater(appimage_path); // ... use updater ... } else { // Handle error: APPIMAGE environment variable not set } return 0; } ``` -------------------------------- ### Run AppImage update process Source: https://github.com/appimage/appimageupdate/wiki/Example:-Step-by-step-walkthrough-with-`appimageupdatetool` Executes the appimageupdatetool to check for and apply updates to a specified AppImage file. The command outputs the update progress, ZSync status, and the final exit code. ```bash time appimageupdatetool ~/AppImages/zsync2-105-7fd1caa-x86_64.AppImage ; echo $? ``` -------------------------------- ### Integrate Sanitizers via FetchContent Source: https://github.com/appimage/appimageupdate/blob/main/src/qt-ui/CMakeLists.txt A helper function that dynamically fetches and includes the sanitizers-cmake module to enable runtime error detection during development. It uses FetchContent_Populate to manually configure the module path. ```cmake function(import_sanitizers) include(FetchContent) FetchContent_Declare(args GIT_REPOSITORY https://github.com/arsenm/sanitizers-cmake GIT_TAG c3dc841) FetchContent_Populate(args) FetchContent_GetProperties(args SOURCE_DIR args_source_dir) set(CMAKE_MODULE_PATH "${args_source_dir}/cmake;${CMAKE_MODULE_PATH}") find_package(Sanitizers REQUIRED) endfunction() if(ENABLE_SANITIZERS) import_sanitizers() add_sanitizers(AppImageUpdate) endif() ``` -------------------------------- ### Initialize Updater Class Constructor (C++) Source: https://context7.com/appimage/appimageupdate/llms.txt Demonstrates how to initialize the Updater class from the libappimageupdate library. It takes the path to an AppImage and an optional overwrite flag. Initialization fails if the AppImage file does not exist. ```cpp #include "appimage/update.h" #include int main() { try { // Create updater for an AppImage (throws std::invalid_argument if file doesn't exist) appimage::update::Updater updater("/path/to/MyApp.AppImage", false); // With overwrite flag - replaces original file after update appimage::update::Updater updaterOverwrite("/path/to/MyApp.AppImage", true); std::cout << "Updater initialized successfully" << std::endl; } catch (const std::invalid_argument& e) { std::cerr << "Failed to initialize updater: " << e.what() << std::endl; return 1; } return 0; } ``` -------------------------------- ### Include Subdirectories and Packaging (CMake) Source: https://github.com/appimage/appimageupdate/blob/main/CMakeLists.txt Includes the 'src' subdirectory, which contains its own CMakeLists.txt for core source compilation. It also includes CMake scripts for packaging (cpack-deb.cmake) and configuring exported targets, setting up the project for distribution. ```cmake # core source directory, contains its own CMakeLists.txt add_subdirectory(src) # packaging include(${PROJECT_SOURCE_DIR}/cmake/cpack-deb.cmake) # also, configure exported targets include(cmake/export.cmake) ``` -------------------------------- ### Self-Update from Environment using QtUpdater Source: https://context7.com/appimage/appimageupdate/llms.txt Enables self-updating for an AppImage by reading the APPIMAGE environment variable. Returns nullptr if not running as an AppImage. Handles update checks and displays dialogs. ```cpp #include "appimage/update/qt-ui.h" #include #include #include int main(int argc, char* argv[]) { QApplication app(argc, argv); // Create updater from APPIMAGE environment variable // Returns nullptr if not running as AppImage auto* updater = appimage::update::qt::QtUpdater::fromEnv(); if (updater == nullptr) { std::cerr << "Not running as AppImage, self-update unavailable" << std::endl; return 1; } // Check if update is available before showing dialog int checkResult = updater->checkForUpdates(true); // true = write to stderr switch (checkResult) { case 0: QMessageBox::information(nullptr, "Update Check", "Already up to date!"); break; case 1: // Update available - show updater dialog updater->enableRunUpdatedAppImageButton(true); updater->exec(); break; case -1: QMessageBox::warning(nullptr, "Update Check", "No update information found in this AppImage"); break; default: QMessageBox::critical(nullptr, "Update Check", "Update check failed!"); } delete updater; return 0; } // checkForUpdates return codes: // 0 = No update available // 1 = Update available // -1 = No update information in AppImage // 2 = Error during check ``` -------------------------------- ### Manage zsync2 Dependency (CMake) Source: https://github.com/appimage/appimageupdate/blob/main/CMakeLists.txt Configures the zsync2 dependency. It can either use a system-installed zsync2 (if USE_SYSTEM_ZSYNC2 is ON) or fetch it from a Git repository using FetchContent. It also handles the cpr library dependency when using system zsync2. ```cmake option(USE_SYSTEM_ZSYNC2 "Use existing libzsync2 installed on system (or inside CMAKE_PREFIX_PATH)" OFF) if(USE_SYSTEM_ZSYNC2) set(USE_SYSTEM_CPR ON) # we use cpr in AppImageUpdate, too find_package(cpr REQUIRED) add_library(cpr ALIAS cpr::cpr) # note: find_package calls must be made in the same or a parent scope find_package(zsync2 REQUIRED) else() function(import_zsync2) FetchContent_Declare(zsync2 GIT_REPOSITORY https://github.com/AppImageCommunity/zsync2 GIT_TAG 2.0.0-alpha-1-20250926 ) FetchContent_MakeAvailable(zsync2) endfunction() import_zsync2() endif() ``` -------------------------------- ### Manage libappimage Dependency (CMake) Source: https://github.com/appimage/appimageupdate/blob/main/CMakeLists.txt Configures the libappimage dependency. It allows using a system-installed libappimage (if USE_SYSTEM_LIBAPPIMAGE is ON) or fetching it from a Git repository using FetchContent. This ensures the project has the necessary library for its operations. ```cmake option(USE_SYSTEM_LIBAPPIMAGE OFF "Use existing libappimage installed on system (or inside CMAKE_PREFIX_PATH)") if(USE_SYSTEM_LIBAPPIMAGE) # note: find_package calls must be made in the same or a parent scope find_package(libappimage REQUIRED) else() function(import_libappimage) FetchContent_Declare(libappimage GIT_REPOSITORY https://github.com/AppImageCommunity/libappimage GIT_TAG d326d15c8a9299d3f135be8282f6545b32805996 ) FetchContent_MakeAvailable(libappimage) endfunction() import_libappimage() endif() ``` -------------------------------- ### Updater Class Constructor Source: https://context7.com/appimage/appimageupdate/llms.txt Initializes the Updater instance for a specific AppImage file path. ```APIDOC ## Constructor: appimage::update::Updater ### Description Initializes the update handler for a given AppImage file. It validates the file path and sets the overwrite behavior. ### Parameters - **path** (string) - Required - Absolute path to the AppImage file. - **overwrite** (bool) - Optional - If true, replaces the original file after update; otherwise, creates a new file. ### Request Example ```cpp appimage::update::Updater updater("/path/to/MyApp.AppImage", false); ``` ``` -------------------------------- ### Configure GPGME dependency and signing library in CMake Source: https://github.com/appimage/appimageupdate/blob/main/src/signing/CMakeLists.txt This snippet uses PkgConfig to locate the GPGME library and defines a static library target 'signing'. It includes necessary source directories and applies specific compile definitions to ensure large file support compatibility. ```cmake find_package(PkgConfig) pkg_check_modules(gpgme gpgme>=1.10.0 REQUIRED IMPORTED_TARGET) add_library(signing STATIC signaturevalidator.cpp) target_link_libraries(signing PRIVATE PkgConfig::gpgme PRIVATE util ) target_include_directories(signing PUBLIC $/src ) message(STATUS "Enabling largefile support for signing library") target_compile_definitions(signing PRIVATE -D_FILE_OFFSET_BITS=64 -DLARGEFILE_SOURCE ) ``` -------------------------------- ### Configure Qt Libraries and Executables in CMake Source: https://github.com/appimage/appimageupdate/blob/main/src/qt-ui/CMakeLists.txt Defines shared and static library targets for the Qt UI components and configures the main AppImageUpdate executable. It includes automatic MOC processing and links necessary dependencies like libappimageupdate and Qt5 modules. ```cmake find_package(Qt5 REQUIRED COMPONENTS Core Widgets) set(CMAKE_AUTOMOC ON) add_library(libappimageupdate-qt SHARED qt-updater.cpp spoiler.cpp ${PROJECT_SOURCE_DIR}/include/appimage/update/qt-ui.h) target_link_libraries(libappimageupdate-qt PUBLIC libappimageupdate Qt5::Core Qt5::Widgets PRIVATE util) add_executable(AppImageUpdate main.cpp) target_link_libraries(AppImageUpdate libappimageupdate libappimageupdate-qt util) ``` -------------------------------- ### Set Project Version and Build Number (CMake) Source: https://github.com/appimage/appimageupdate/blob/main/CMakeLists.txt Sets the project version and determines the build number. It checks for the GITHUB_RUN_NUMBER environment variable for CI builds, otherwise uses a local development indicator. The date is also fetched and formatted. ```cmake set(VERSION 2.0.0-alpha-1-20251018) if("$ENV{GITHUB_RUN_NUMBER}" STREQUAL "") set(BUILD_NUMBER "") else() set(BUILD_NUMBER "$ENV{GITHUB_RUN_NUMBER}") endif() execute_process( COMMAND env LC_ALL=C date -u "+%Y-%m-%d %H:%M:%S %Z" OUTPUT_VARIABLE DATE OUTPUT_STRIP_TRAILING_WHITESPACE ) ``` -------------------------------- ### Configure AppImageUpdate Library Build with CMake Source: https://github.com/appimage/appimageupdate/blob/main/src/util/CMakeLists.txt This snippet configures the CMake build for the AppImageUpdate library. It sets the minimum required CMake version, defines a static library target 'util' with its source files, specifies include directories for the build interface, and links necessary libraries. Dependencies include libappimage_shared, ZSYNC2, and cpr. ```cmake cmake_minimum_required(VERSION 3.19) add_library(util STATIC util.cpp updatableappimage.cpp ) target_include_directories(util PUBLIC $/src ) target_link_libraries(util PRIVATE libappimage_shared ${ZSYNC2_LIBRARY_NAME} cpr) ``` -------------------------------- ### Integrate libappimageupdate with CMake Source: https://context7.com/appimage/appimageupdate/llms.txt Shows how to include libappimageupdate as a submodule in a CMake project and link the library to an executable. ```cmake # CMakeLists.txt cmake_minimum_required(VERSION 3.5) project(MyApp) # Add AppImageUpdate as subdirectory add_subdirectory(extern/AppImageUpdate) # Your application add_executable(myapp main.cpp) # Link against libappimageupdate target_link_libraries(myapp PRIVATE libappimageupdate) # For Qt UI support (optional) # target_link_libraries(myapp PRIVATE libappimageupdate-qt) ``` -------------------------------- ### QtUpdater Dialog for AppImage Updates Source: https://context7.com/appimage/appimageupdate/llms.txt Provides a Qt dialog for updating AppImages with progress, status, and user interaction. Embeddable in Qt applications. Requires Qt framework. ```cpp #include "appimage/update/qt-ui.h" #include #include int main(int argc, char* argv[]) { QApplication app(argc, argv); // Create updater dialog for specific AppImage appimage::update::qt::QtUpdater updater("/path/to/MyApp.AppImage"); // Optional: Enable "Run updated AppImage" button after successful update updater.enableRunUpdatedAppImageButton(true); // Connect signals for custom handling QObject::connect(&updater, &appimage::update::qt::QtUpdater::canceled, []() { std::cout << "Update was canceled by user" << std::endl; }); QObject::connect(&updater, &appimage::update::qt::QtUpdater::runUpdatedAppImageClicked, []() { std::cout << "User clicked to run updated AppImage" << std::endl; }); // Show dialog (update starts automatically when shown) updater.exec(); // Get path to new file after update QString newPath; if (updater.pathToNewFile(newPath)) { std::cout << "Updated AppImage: " << newPath.toStdString() << std::endl; } return 0; } ``` -------------------------------- ### Check for AppImage Updates (C++) Source: https://context7.com/appimage/appimageupdate/llms.txt Shows how to use the `checkForChanges` method of the Updater class to check for available updates without downloading them. It returns a boolean indicating success and updates an `updateAvailable` flag. Status messages are also retrieved. ```cpp #include "appimage/update.h" #include int main() { appimage::update::Updater updater("/path/to/MyApp.AppImage"); bool updateAvailable = false; bool success = updater.checkForChanges(updateAvailable); // Print any status messages from the check std::string message; while (updater.nextStatusMessage(message)) { std::cerr << message << std::endl; } if (!success) { std::cerr << "Update check failed!" << std::endl; return 2; } if (updateAvailable) { std::cout << "Update is available!" << std::endl; return 1; // Convention: exit code 1 means update available } else { std::cout << "Already up to date." << std::endl; return 0; } } ``` -------------------------------- ### Override Update Information via CLI Source: https://context7.com/appimage/appimageupdate/llms.txt Demonstrates how to use the --update-info flag with the appimageupdatetool to specify custom update sources, overriding embedded information in an AppImage. ```bash # Use custom GitHub releases URL appimageupdatetool --update-info "gh-releases-zsync|MyOrg|MyApp|latest|MyApp-*.AppImage.zsync" /path/to/MyApp.AppImage # Use custom zsync URL appimageupdatetool --update-info "zsync|https://myserver.com/MyApp.AppImage.zsync" /path/to/MyApp.AppImage # Check with custom update info appimageupdatetool --check-for-update --update-info "gh-releases-zsync|owner|repo|latest|*.zsync" /path/to/app.AppImage ``` -------------------------------- ### Describe AppImage Metadata using C++ Source: https://context7.com/appimage/appimageupdate/llms.txt Parses an AppImage file to retrieve its type, update information, and the resolved ZSync URL. This is primarily used for debugging purposes and displaying update details to the end user. ```cpp #include "appimage/update.h" #include int main() { appimage::update::Updater updater("/path/to/MyApp.AppImage"); std::string description; if (updater.describeAppImage(description)) { std::cout << description << std::endl; } else { std::cerr << "Failed to parse AppImage" << std::endl; std::cerr << description << std::endl; return 1; } return 0; } ``` -------------------------------- ### Basic AppImage Update using appimageupdatetool Source: https://context7.com/appimage/appimageupdate/llms.txt Updates an AppImage to the latest version using delta updates. Can create a new file, overwrite the original, or remove the old file after a successful update. Requires the appimageupdatetool binary. ```bash # Update an AppImage (creates new file alongside original) appimageupdatetool /path/to/MyApp.AppImage # Update and overwrite original file appimageupdatetool --overwrite /path/to/MyApp.AppImage # Update and remove old file after successful update appimageupdatetool --remove-old /path/to/MyApp.AppImage # Self-update (when running as AppImage) appimageupdatetool --self-update ``` -------------------------------- ### Describe AppImage Update Information using appimageupdatetool Source: https://context7.com/appimage/appimageupdate/llms.txt Displays detailed information about an AppImage's update configuration, such as the update URL and type, without performing any update. Useful for debugging update mechanisms. ```bash # Show AppImage update information appimageupdatetool --describe /path/to/MyApp.AppImage # Example output: # Parsing file: /path/to/MyApp.AppImage # AppImage type: 2 # Raw update information: gh-releases-zsync|AppImage|AppImageUpdate|latest|appimageupdatetool-*-x86_64.AppImage.zsync # Update information type: ZSync via GitHub Releases # Assembled ZSync URL: https://github.com/AppImage/AppImageUpdate/releases/download/continuous/appimageupdatetool-continuous-x86_64.AppImage.zsync ``` -------------------------------- ### Validate AppImage Signatures using C++ Source: https://context7.com/appimage/appimageupdate/llms.txt Verifies that the old and new AppImages are signed by the same GPG key to prevent supply chain attacks. It handles various validation states including success, warnings for unsigned files, and critical errors like key mismatches or invalid signatures. ```cpp #include "appimage/update.h" #include int main() { appimage::update::Updater updater("/path/to/MyApp.AppImage"); // After update completes, validate signatures auto validationResult = updater.validateSignature(); // Print validation messages std::string message; while (updater.nextStatusMessage(message)) { std::cout << message << std::endl; } // Check validation result if (validationResult >= appimage::update::Updater::VALIDATION_FAILED) { std::cerr << "Validation error: " << appimage::update::Updater::signatureValidationMessage(validationResult) << std::endl; updater.restoreOriginalFile(); return 1; } if (validationResult >= appimage::update::Updater::VALIDATION_WARNING) { std::cerr << "Validation warning: " << appimage::update::Updater::signatureValidationMessage(validationResult) << std::endl; } if (validationResult == appimage::update::Updater::VALIDATION_PASSED) { std::cout << "Signature validation passed!" << std::endl; updater.copyPermissionsToNewFile(); } return 0; } ``` -------------------------------- ### Check for AppImage Updates using appimageupdatetool Source: https://context7.com/appimage/appimageupdate/llms.txt Checks if an update is available for an AppImage without downloading. The exit code indicates the result: 0 for no update, 1 for update available, and 2 for an error. Useful for scripting. ```bash # Check for update availability appimageupdatetool --check-for-update /path/to/MyApp.AppImage echo $? # 0 = up to date, 1 = update available, 2 = error # Scripting example if appimageupdatetool --check-for-update /path/to/MyApp.AppImage; then echo "Already up to date" else if [ $? -eq 1 ]; then echo "Update available, downloading..." appimageupdatetool --overwrite /path/to/MyApp.AppImage else echo "Error checking for updates" fi fi ``` -------------------------------- ### checkForChanges Source: https://context7.com/appimage/appimageupdate/llms.txt Queries the update server to determine if a newer version of the AppImage is available. ```APIDOC ## Method: checkForChanges ### Description Queries the update information embedded in the AppImage to check for newer versions. Does not perform the actual download. ### Parameters - **updateAvailable** (bool&) - Required - Output parameter that will be set to true if an update is found. ### Response - **Success Response (200)** - **return** (bool) - Returns true if the check was successful. ### Response Example ```cpp bool updateAvailable = false; bool success = updater.checkForChanges(updateAvailable); ``` ``` -------------------------------- ### Configure Custom Update Information using C++ Source: https://context7.com/appimage/appimageupdate/llms.txt Allows overriding the embedded update information within an AppImage. This is useful for implementing custom update channels, pointing to alternative servers, or testing update configurations before final deployment. ```cpp #include "appimage/update.h" #include int main() { appimage::update::Updater updater("/path/to/MyApp.AppImage"); // Override with custom GitHub releases update info updater.setUpdateInformation( "gh-releases-zsync|MyOrg|MyApp|latest|MyApp-*-x86_64.AppImage.zsync" ); // Or use a generic zsync URL updater.setUpdateInformation( "zsync|https://myserver.com/releases/MyApp-latest-x86_64.AppImage.zsync" ); // Or use Pling v1 (OCS) update info updater.setUpdateInformation( "pling-v1-zsync|https://api.opendesktop.org/ocs/v1|1234567|MyApp-*-x86_64.AppImage.zsync" ); // Get current update information std::cout << "Update info: " << updater.updateInformation() << std::endl; bool updateAvailable = false; updater.checkForChanges(updateAvailable); return 0; } ``` -------------------------------- ### Remove existing AppImage file Source: https://github.com/appimage/appimageupdate/wiki/Example:-Step-by-step-walkthrough-with-`appimageupdatetool` Removes a specific AppImage file from the local directory to force a fresh update process during the next execution of the update tool. ```bash rm -rf zsync2-106-817978a-x86_64.AppImage ``` -------------------------------- ### Read Git Commit Hash (CMake) Source: https://github.com/appimage/appimageupdate/blob/main/CMakeLists.txt Reads the short Git commit hash using the 'git rev-parse' command and stores it in a CMake variable. This is useful for versioning and debugging. The value is cached and requires cache reset to update. ```cmake execute_process( COMMAND git rev-parse --short HEAD WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} OUTPUT_VARIABLE GIT_COMMIT OUTPUT_STRIP_TRAILING_WHITESPACE ) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.