diff --git a/CHANGELOG.md b/CHANGELOG.md index 02247d1..450215e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,14 +24,21 @@ complete; every release is an annotated git tag `vX.Y.Z` (see `tools/release.sh` - `tools/appimage.sh`: AppImage of the GTK interface and `openpu-cli` (linuxdeploy + GTK plugin). - `Release` GitHub workflow: Debian package, AppImage and `openpu-cli` tarball for Linux x86_64 and arm64, attached to the release of every `vX.Y.Z` tag. +- Haiku package: `tools/haiku-package.sh` builds an `.hpkg` (application, `openpu-cli`, + translations, Deskbar entry), and `packaging/haiku/openpu.recipe` is a HaikuPorts recipe + template. ### Changed +- The Haiku application is installed in `apps/` and finds its translations in the `data/locale` + directory of its installation location. - The GTK interface looks for its translations in `../share/locale` next to the executable first, so that relocatable installs (AppImage) are translated. - `tools/release.sh` adds the release to the AppStream metadata and updates a GitHub release that the release workflow created first. ### Fixed +- `cmake --install --strip` dropped the resources of the Haiku application (icon, signature, + version): they are attached again to the installed file. - Translations were installed in `//LC_MESSAGES` instead of the locale directory. - Archive extraction failed when the destination path contained a symbolic link (e.g. `/tmp` on Haiku). diff --git a/README.md b/README.md index 883487d..dd8eb2f 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,8 @@ It is an alternative to the official "Peugeot Update" application (Windows/macOS - [x] GitHub Actions continuous integration (Linux x86_64 + arm64) - [x] Linux packages: Debian package (`cpack -G DEB`) and AppImage (`tools/appimage.sh`) - [x] `Release` workflow: `.deb`, AppImage and `openpu-cli` tarball for x86_64 and arm64 -- [ ] Flatpak; Haiku `.hpkg` +- [x] Haiku package (`tools/haiku-package.sh`) and HaikuPorts recipe template +- [ ] Flatpak - [ ] x86_64 + arm64 binaries attached to every release (from 1.0.0 on) ## Architecture @@ -77,6 +78,12 @@ cmake -S . -B build -G Ninja && cmake --build build && build/tests/openpu_tests OPENPU_LOCALEDIR=build/locale build/src/ui-haiku/OpenPU # graphical interface build/src/cli/openpu-cli usb-list ``` +Package: `tools/haiku-package.sh` builds `openpu--1-x86_64.hpkg` in the current +directory (application in `apps/`, `openpu-cli` in `bin/`, translations, Deskbar entry); install +it with `pkgman install ./openpu-*.hpkg`. GitHub has no Haiku runners, so the package is built in +the VM and attached to the release by hand. `packaging/haiku/openpu.recipe` is the template of the +HaikuPorts recipe, to fill in with the released version and its checksum. + `tools/haiku-vm.sh` installs and runs a Haiku R1/beta6 VM under QEMU/KVM (from WSL or Linux), with a virtual USB stick; `sync` copies the working tree into it and `ssh` runs commands there. diff --git a/packaging/haiku/openpu.recipe b/packaging/haiku/openpu.recipe new file mode 100644 index 0000000..b2a0747 --- /dev/null +++ b/packaging/haiku/openpu.recipe @@ -0,0 +1,65 @@ +SUMMARY="Download Peugeot head unit updates and prepare the USB stick" +DESCRIPTION="OpenPU downloads the firmware and navigation map updates of Peugeot head \ +units (NAC, RCC, AIO, Crony) and prepares the installation USB stick: FAT32 formatting, \ +license and update files. Downloads resume where they stopped. + +It provides a native graphical application and a command-line tool (openpu-cli). \ +Independent project, not affiliated with Stellantis or Peugeot." +HOMEPAGE="https://github.com/yann64/openpu" +COPYRIGHT="2026 yann64 and the OpenPU contributors" +LICENSE="MIT" +REVISION="1" +# Template for HaikuPorts (app-misc/openpu/openpu-.recipe): set the file name to the +# released version and CHECKSUM_SHA256 to the sha256sum of the tag archive below. +SOURCE_URI="https://github.com/yann64/openpu/archive/refs/tags/v$portVersion.tar.gz" +CHECKSUM_SHA256="0000000000000000000000000000000000000000000000000000000000000000" +SOURCE_DIR="openpu-$portVersion" + +ARCHITECTURES="all !x86_gcc2" + +PROVIDES=" + openpu$secondaryArchSuffix = $portVersion + app:OpenPU = $portVersion + cmd:openpu_cli = $portVersion + " +REQUIRES=" + haiku$secondaryArchSuffix + lib:libarchive$secondaryArchSuffix + lib:libcurl$secondaryArchSuffix + lib:libintl$secondaryArchSuffix + " + +BUILD_REQUIRES=" + haiku${secondaryArchSuffix}_devel + devel:libarchive$secondaryArchSuffix + devel:libcurl$secondaryArchSuffix + devel:libintl$secondaryArchSuffix + devel:nlohmann_json + " +BUILD_PREREQUIRES=" + cmd:cmake + cmd:g++$secondaryArchSuffix + cmd:mimeset + cmd:msgfmt + cmd:ninja + cmd:rc + cmd:xres + " + +BUILD() +{ + cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_INSTALL_PREFIX="$prefix" -DOPENPU_BUILD_TESTS=ON + cmake --build build $jobArgs +} + +INSTALL() +{ + # apps/OpenPU, bin/openpu-cli, data/locale and the Deskbar link, relative to $prefix. + cmake --install build --strip +} + +TEST() +{ + build/tests/openpu_tests +} diff --git a/po/CMakeLists.txt b/po/CMakeLists.txt index 7e3ef11..273de89 100644 --- a/po/CMakeLists.txt +++ b/po/CMakeLists.txt @@ -1,6 +1,11 @@ # Translations (gettext). Source strings are English; add a language by adding .po and # listing it in LINGUAS. include(GNUInstallDirs) +if(CMAKE_SYSTEM_NAME STREQUAL "Haiku") + set(OPENPU_INSTALL_LOCALEDIR data/locale) # Haiku package layout +else() + set(OPENPU_INSTALL_LOCALEDIR ${CMAKE_INSTALL_LOCALEDIR}) +endif() find_package(Gettext) if(NOT GETTEXT_FOUND) message(WARNING "gettext (msgfmt) not found: translations are not built") @@ -14,7 +19,7 @@ foreach(lang IN LISTS OPENPU_LINGUAS) COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} --check -o ${mo} ${CMAKE_CURRENT_SOURCE_DIR}/${lang}.po DEPENDS ${lang}.po) list(APPEND OPENPU_MO_FILES ${mo}) - install(FILES ${mo} DESTINATION ${CMAKE_INSTALL_LOCALEDIR}/${lang}/LC_MESSAGES) + install(FILES ${mo} DESTINATION ${OPENPU_INSTALL_LOCALEDIR}/${lang}/LC_MESSAGES) endforeach() add_custom_target(translations ALL DEPENDS ${OPENPU_MO_FILES}) diff --git a/src/ui-haiku/CMakeLists.txt b/src/ui-haiku/CMakeLists.txt index ad860dd..2b3b850 100644 --- a/src/ui-haiku/CMakeLists.txt +++ b/src/ui-haiku/CMakeLists.txt @@ -9,7 +9,7 @@ target_link_libraries(OpenPU PRIVATE openpu_core openpu_warnings be tracker shar $<$:${INTL_LIBRARY}>) target_compile_definitions(OpenPU PRIVATE GETTEXT_PACKAGE="openpu" - OPENPU_LOCALEDIR="${CMAKE_INSTALL_FULL_LOCALEDIR}") + OPENPU_LOCALEDIR="${CMAKE_INSTALL_PREFIX}/data/locale") # BeAPI headers trigger -Wshadow/-Wconversion noise we cannot fix. target_compile_options(OpenPU PRIVATE -Wno-shadow -Wno-conversion) @@ -35,4 +35,20 @@ if(HAIKU_RC AND HAIKU_XRES) COMMAND ${HAIKU_MIMESET} -f $) endif() -install(TARGETS OpenPU RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) +# Haiku package layout: the application in apps/, a link in the Deskbar's Applications menu. +install(TARGETS OpenPU RUNTIME DESTINATION apps) +if(HAIKU_RC AND HAIKU_XRES) + # `cmake --install --strip` rewrites the ELF file and drops the appended resources (icon, + # signature, version): attach them again to the installed copy. + install(CODE " + set(app \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/apps/OpenPU\") + execute_process(COMMAND ${HAIKU_XRES} -o \"\${app}\" ${CMAKE_CURRENT_BINARY_DIR}/OpenPU.rsrc + COMMAND_ERROR_IS_FATAL ANY) + execute_process(COMMAND ${HAIKU_MIMESET} -f \"\${app}\") + ") +endif() +install(CODE " + set(menu \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/data/deskbar/menu/Applications\") + file(MAKE_DIRECTORY \"\${menu}\") + file(CREATE_LINK ../../../../apps/OpenPU \"\${menu}/OpenPU\" SYMBOLIC) +") diff --git a/src/ui-haiku/main.cpp b/src/ui-haiku/main.cpp index 53a75e9..5a2c6cf 100644 --- a/src/ui-haiku/main.cpp +++ b/src/ui-haiku/main.cpp @@ -6,6 +6,8 @@ #include #include #include +#include +#include #include "i18n.hpp" @@ -30,6 +32,18 @@ std::string preferredLanguage() return language; } +/// Translations directory: OPENPU_LOCALEDIR (build tree), else data/locale of the installation +/// location holding the application (system or user packages), else the configured one. +std::string localeDir() +{ + if (const char* dir = std::getenv("OPENPU_LOCALEDIR")) // NOLINT(concurrency-mt-unsafe): no thread yet + return dir; + BPath path; + if (BPathFinder().FindPath(B_FIND_PATH_DATA_DIRECTORY, "locale", B_FIND_PATH_EXISTING_ONLY, path) == B_OK) + return path.Path(); + return OPENPU_LOCALEDIR; +} + class App : public BApplication { public: explicit App(std::string language) : BApplication(kSignature), language_(std::move(language)) {} @@ -60,8 +74,7 @@ int main() (void)setenv("LANGUAGE", language.c_str(), 1); // NOLINT(concurrency-mt-unsafe): no thread yet (void)setenv("LC_MESSAGES", "en_US.UTF-8", 0); // NOLINT(concurrency-mt-unsafe) (void)std::setlocale(LC_ALL, ""); // NOLINT(concurrency-mt-unsafe) - const char* localeDir = std::getenv("OPENPU_LOCALEDIR"); // NOLINT(concurrency-mt-unsafe): build tree - bindtextdomain(GETTEXT_PACKAGE, localeDir != nullptr ? localeDir : OPENPU_LOCALEDIR); + bindtextdomain(GETTEXT_PACKAGE, localeDir().c_str()); bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); textdomain(GETTEXT_PACKAGE); diff --git a/tools/haiku-package.sh b/tools/haiku-package.sh new file mode 100755 index 0000000..c43790e --- /dev/null +++ b/tools/haiku-package.sh @@ -0,0 +1,61 @@ +#!/bin/sh +# SPDX-License-Identifier: MIT +# Builds openpu--1-x86_64.hpkg on Haiku from the working tree: release build, staged +# install (apps/OpenPU, bin/openpu-cli, data/locale, Deskbar link), .PackageInfo, `package create`. +# The HaikuPorts recipe (packaging/haiku) is the way to publish; this script is for testing and +# for attaching a package to a GitHub release. +# +# usage: tools/haiku-package.sh [build-dir] (output in the current directory) +set -eu + +SRC=$(cd "$(dirname "$0")/.." && pwd) +BUILD=${1:-$SRC/../build-openpu/hpkg} +OUT=$(pwd) +ARCH=$(getarch) +STAGE=$BUILD/stage + +cmake -S "$SRC" -B "$BUILD" -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/boot/system \ + -DOPENPU_BUILD_TESTS=OFF +cmake --build "$BUILD" +rm -rf "$STAGE" +# Files are staged relative to the installation location (the package's root). +cmake --install "$BUILD" --strip --prefix "$STAGE" + +# Package versions cannot contain '+' or '.' after the micro number: a development build +# 0.2.0+3.gabc1234.dirty becomes 0.2.0_git3_gabc1234_dirty; a tagged build stays 0.2.0. +DESCRIPTION=$("$STAGE/bin/openpu-cli" --version | awk '{print $2}') +VERSION=$(echo "$DESCRIPTION" | sed -e 's/+/_git/' -e 's/\./_/3g') + +cat > "$STAGE/.PackageInfo" <" +vendor "OpenPU contributors" +licenses { "MIT" } +copyrights { "2026 yann64 and the OpenPU contributors" } +urls { "https://github.com/yann64/openpu" } +provides { + openpu = $VERSION + app:OpenPU = $VERSION + cmd:openpu_cli = $VERSION +} +requires { + haiku >= r1~beta6 + lib:libarchive >= 13 + lib:libcurl >= 4 + lib:libgcc_s >= 1 + lib:libintl >= 8 + lib:libstdc++ +} +EOF + +PACKAGE=$OUT/openpu-$VERSION-1-$ARCH.hpkg +rm -f "$PACKAGE" +package create -C "$STAGE" "$PACKAGE" +package list "$PACKAGE"