Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e5af8ea27d | ||
|
|
c2ed18a8ed | ||
|
|
9a24c2eb61 | ||
|
|
962343f220 | ||
|
|
b2ca454d44 | ||
|
|
114976b912 | ||
|
|
1c1ccd631a | ||
|
|
32412fe6be | ||
|
|
7d0cb8c4a8 | ||
|
|
323c36ba3c | ||
|
|
82f968dbec | ||
|
|
2ce6ddde46 | ||
|
|
384aaf78c6 |
No files matched your search
@@ -20,4 +20,7 @@ Checks: >
|
||||
WarningsAsErrors: ''
|
||||
HeaderFilterRegex: '.*/src/.*'
|
||||
FormatStyle: none
|
||||
CheckOptions:
|
||||
# A dialog dismissed by the user ends in an intentionally empty catch marked with this word.
|
||||
bugprone-empty-catch.IgnoreCatchWithKeywords: '@TODO;@FIXME;dismissed'
|
||||
...
|
||||
@@ -0,0 +1,67 @@
|
||||
# SPDX-License-Identifier: MIT
|
||||
# Build and test on Linux x86_64 and arm64 (native GitHub runners) for every push and pull request.
|
||||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
tags: ["v*"]
|
||||
pull_request:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
linux:
|
||||
name: Linux ${{ matrix.arch }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- arch: x86_64
|
||||
runner: ubuntu-24.04
|
||||
- arch: arm64
|
||||
runner: ubuntu-24.04-arm
|
||||
runs-on: ${{ matrix.runner }}
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
with:
|
||||
fetch-depth: 0 # tags are needed for the version description
|
||||
|
||||
- name: Dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y --no-install-recommends \
|
||||
build-essential cmake ninja-build pkg-config gettext \
|
||||
libcurl4-openssl-dev libarchive-dev nlohmann-json3-dev doctest-dev \
|
||||
libglib2.0-dev libgtkmm-4.0-dev
|
||||
|
||||
- name: Configure
|
||||
run: cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DOPENPU_WERROR=ON -DOPENPU_UI_GTK=ON
|
||||
|
||||
- name: Build
|
||||
run: cmake --build build
|
||||
|
||||
- name: Unit tests
|
||||
run: ctest --test-dir build --output-on-failure
|
||||
|
||||
- name: Smoke test
|
||||
run: |
|
||||
build/src/cli/openpu-cli --version
|
||||
test -f build/locale/fr/LC_MESSAGES/openpu.mo
|
||||
|
||||
sanitizers:
|
||||
name: ASan + UBSan
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
- name: Dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y --no-install-recommends build-essential cmake ninja-build pkg-config \
|
||||
libcurl4-openssl-dev libarchive-dev nlohmann-json3-dev doctest-dev libglib2.0-dev
|
||||
- name: Build and test
|
||||
run: |
|
||||
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug -DOPENPU_SANITIZE=ON
|
||||
cmake --build build
|
||||
UBSAN_OPTIONS=halt_on_error=1:print_stacktrace=1 ctest --test-dir build --output-on-failure
|
||||
@@ -0,0 +1,60 @@
|
||||
# Changelog
|
||||
|
||||
Format: [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). Versions follow
|
||||
[Semantic Versioning](https://semver.org/): `0.x` until the Linux and Haiku applications are
|
||||
complete; every release is an annotated git tag `vX.Y.Z` (see `tools/release.sh`).
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Added
|
||||
- Haiku development VM tooling: `tools/haiku-vm.sh` (Haiku R1/beta6 x86_64 under QEMU/KVM, with a
|
||||
virtual USB stick) and `tools/qmp.py` (headless screenshots, clicks and typing through QMP).
|
||||
- Haiku USB backend (Storage Kit disk device API): lists USB drives, writes an MBR with one FAT32
|
||||
partition at 1 MiB, mounts, unmounts and ejects. Validated end to end in the VM.
|
||||
- The core library and `openpu-cli` build and pass all unit tests on Haiku R1/beta6 x86_64.
|
||||
|
||||
### Fixed
|
||||
- Archive extraction failed when the destination path contained a symbolic link (e.g. `/tmp` on
|
||||
Haiku).
|
||||
- `tools/release.sh` produced empty release notes.
|
||||
|
||||
## [0.2.0] - 2026-11-28
|
||||
|
||||
### Added
|
||||
- GTK4 (gtkmm) graphical interface: vehicles, adding a vehicle by VIN, available updates, download
|
||||
folder, resumable download, USB stick selection, writing, installation guide.
|
||||
- Versioning: CMake version + `git describe` on every build, `openpu-cli --version`, About dialog,
|
||||
`OpenPU/<version>` User-Agent, `tools/release.sh`.
|
||||
- gettext translation infrastructure (English source strings, French translation).
|
||||
- Links to the official installation guides (PDF) in French and English.
|
||||
- Preferences: download folder, language (system language by default), automatic check for a new
|
||||
OpenPU version at startup.
|
||||
- New OpenPU version check (GitHub releases), offering to open the download page in the browser;
|
||||
`openpu-cli app-update`.
|
||||
- MIT license (`LICENSE`, SPDX headers).
|
||||
- GitHub Actions continuous integration: build and tests on Linux x86_64 and arm64, ASan/UBSan.
|
||||
|
||||
### Changed
|
||||
- The main repository is now https://github.com/yann64/openpu.
|
||||
- `vehicles.json` keeps the order in which vehicles were added.
|
||||
|
||||
### Planned
|
||||
- Linux `.deb`, Flatpak and AppImage packages; Haiku `.hpkg` package.
|
||||
- From 1.0.0 on, binaries attached to every release, for x86_64 and arm64.
|
||||
|
||||
## [0.1.0] - 2026-11-28
|
||||
|
||||
### Added
|
||||
- Analysis of "Peugeot Update" 1.6.1 (`docs/analysis/`).
|
||||
- `libopenpu`: Majestic API client (VIN, head units, updates), resumable downloads (HTTP Range),
|
||||
license download (including the empty placeholder Majestic returns while generating it), tar
|
||||
archives (integrity check, safe extraction skipping `UpdateInfo.xml`), settings and vehicles
|
||||
compatible with the official application, Linux USB support through UDisks2 (MBR + FAT32,
|
||||
mounting, ejecting).
|
||||
- `openpu-cli`: `check`, `download`, `verify`, `extract`, `usb-list`, `write-usb`, `write-dir`.
|
||||
- Quality: doctest unit tests, ASan/UBSan, valgrind, clang-tidy, cppcheck (`tools/check.sh`),
|
||||
end-to-end USB test on a loop image (`tools/e2e-usb.sh`).
|
||||
|
||||
[Unreleased]: https://github.com/yann64/openpu/compare/v0.2.0...HEAD
|
||||
[0.2.0]: https://github.com/yann64/openpu/releases/tag/v0.2.0
|
||||
[0.1.0]: https://github.com/yann64/openpu/releases/tag/v0.1.0
|
||||
+6
-1
@@ -1,5 +1,5 @@
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
project(openpu VERSION 0.1.0 LANGUAGES CXX)
|
||||
project(openpu VERSION 0.2.0 LANGUAGES CXX)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
@@ -40,6 +40,11 @@ if(OPENPU_BUILD_CLI)
|
||||
add_subdirectory(src/cli)
|
||||
endif()
|
||||
|
||||
if(OPENPU_UI_GTK)
|
||||
add_subdirectory(src/ui-gtk)
|
||||
add_subdirectory(po)
|
||||
endif()
|
||||
|
||||
if(OPENPU_BUILD_TESTS)
|
||||
enable_testing()
|
||||
add_subdirectory(tests)
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2026 yann64 and the OpenPU contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -1,44 +1,73 @@
|
||||
# OpenPU
|
||||
|
||||
Client libre et natif pour télécharger les mises à jour des autoradios Peugeot
|
||||
(firmware NAC / RCC / AIO / Crony, et cartographie) et préparer la clé USB d'installation.
|
||||
C'est une alternative à l'application officielle « Peugeot Update » (Windows/macOS uniquement), pour
|
||||
**Linux** (GTK4) et **Haiku** (Interface Kit).
|
||||
A free and native client to download updates for Peugeot head units
|
||||
(NAC / RCC / AIO / Crony firmware, and navigation maps) and prepare the installation USB stick.
|
||||
It is an alternative to the official "Peugeot Update" application (Windows/macOS only), for
|
||||
**Linux** (GTK4) and **Haiku** (Interface Kit).
|
||||
|
||||
> Projet indépendant, sans lien avec Stellantis ni Peugeot. Les noms cités sont des marques
|
||||
> de leurs propriétaires respectifs.
|
||||
> Independent project, not affiliated with Stellantis or Peugeot. The names mentioned are
|
||||
> trademarks of their respective owners.
|
||||
|
||||
## État
|
||||
- [x] Analyse de l'application existante : voir [`docs/analysis/`](docs/analysis/)
|
||||
- [x] Cœur C++ : VIN, API Majestic, modèles, CLI `check`
|
||||
- [x] Cœur C++ : téléchargement avec reprise, licence, tar (vérif + extraction), réglages et véhicules
|
||||
- [x] USB Linux (UDisks2 : liste, MBR + FAT32, montage, éjection) + écriture de la mise à jour
|
||||
- [ ] USB Haiku (Storage Kit)
|
||||
- [ ] UI GTK4 (Linux)
|
||||
- [ ] UI Haiku
|
||||
- [ ] Paquets `.deb`, Flatpak et `.hpkg`
|
||||
- Repository: https://github.com/yann64/openpu
|
||||
- License: [MIT](LICENSE)
|
||||
- Release history: [CHANGELOG.md](CHANGELOG.md)
|
||||
|
||||
## Status
|
||||
- [x] Analysis of the existing application: see [`docs/analysis/`](docs/analysis/)
|
||||
- [x] C++ core: VIN, Majestic API, resumable downloads, license, tar, settings, vehicles
|
||||
- [x] Linux USB support (UDisks2: listing, MBR + FAT32, mounting, ejecting) and writing the update
|
||||
- [x] `openpu-cli` command-line tool
|
||||
- [x] GTK4 UI (Linux): complete workflow, preferences, new-version check
|
||||
- [x] Versioning (`--version`, About dialog, `vX.Y.Z` tags, GitHub releases)
|
||||
- [x] gettext translations (English, French)
|
||||
- [x] Haiku: core library, CLI and USB support (Storage Kit), validated in a Haiku R1/beta6 VM
|
||||
- [ ] Haiku UI
|
||||
- [x] GitHub Actions continuous integration (Linux x86_64 + arm64)
|
||||
- [ ] Linux packages: `.deb`, Flatpak and AppImage; Haiku: `.hpkg`
|
||||
- [ ] x86_64 + arm64 binaries attached to every release (from 1.0.0 on)
|
||||
|
||||
## Architecture
|
||||
```
|
||||
src/core libopenpu : API Majestic, téléchargement avec reprise, tar, USB (UDisks2 / Haiku Storage Kit)
|
||||
src/core libopenpu: Majestic API, resumable downloads, tar, USB (UDisks2 / Haiku Storage Kit)
|
||||
src/cli openpu-cli
|
||||
src/ui-gtk interface gtkmm-4
|
||||
src/ui-haiku interface BeAPI
|
||||
src/ui-gtk gtkmm-4 user interface
|
||||
src/ui-haiku BeAPI user interface
|
||||
po/ translations (gettext)
|
||||
```
|
||||
|
||||
## Outils
|
||||
- `tools/asar_extract.py` : extracteur asar minimal, en lecture seule, pour étudier l'app de référence.
|
||||
Les sources extraites restent **hors du dépôt**.
|
||||
|
||||
## Compiler (Linux / WSL)
|
||||
## Building (Linux / WSL)
|
||||
```sh
|
||||
sudo apt install build-essential cmake ninja-build pkg-config libcurl4-openssl-dev \
|
||||
libarchive-dev nlohmann-json3-dev doctest-dev libglib2.0-dev valgrind clang-tidy cppcheck
|
||||
cmake --preset debug && cmake --build --preset debug && ctest --preset debug
|
||||
../build-openpu/debug/src/cli/openpu-cli check VF3XXXXXXXXXXXXXX
|
||||
libarchive-dev nlohmann-json3-dev doctest-dev libglib2.0-dev libgtkmm-4.0-dev gettext \
|
||||
valgrind clang-tidy cppcheck
|
||||
cmake --preset debug -DOPENPU_UI_GTK=ON && cmake --build --preset debug && ctest --preset debug
|
||||
../build-openpu/debug/src/ui-gtk/openpu # graphical interface
|
||||
../build-openpu/debug/src/cli/openpu-cli --version
|
||||
tools/check.sh # tests + ASan/UBSan + valgrind + clang-tidy + cppcheck
|
||||
|
||||
# test USB de bout en bout sur une image loop (paquets udisks2 dosfstools mtools)
|
||||
sudo tools/dev-polkit.sh install # WSL/CI uniquement : polkit sans agent
|
||||
# end-to-end USB test on a loop image (packages udisks2 dosfstools mtools)
|
||||
sudo tools/dev-polkit.sh install # WSL/CI only: polkit without an agent
|
||||
tools/e2e-usb.sh ../build-openpu/debug/src/cli/openpu-cli --license X.key update.tar
|
||||
```
|
||||
When running from the build tree, `OPENPU_LOCALEDIR=../build-openpu/debug/locale` lets the
|
||||
interface find its translations.
|
||||
|
||||
## Versioning
|
||||
- The reference version is `project(openpu VERSION x.y.z)` in `CMakeLists.txt`. On every build,
|
||||
`git describe` produces the displayed description (for example `0.2.0+3.g1a2b3c4.dirty`).
|
||||
- A published version is an annotated `vX.Y.Z` tag with a GitHub release, which the application
|
||||
checks to offer new versions. `tools/release.sh X.Y.Z` bumps the version, dates the CHANGELOG,
|
||||
commits, tags, pushes to every remote and creates the release.
|
||||
|
||||
## Translations
|
||||
Source strings are in English and translations use gettext (`po/<language>.po`). To add a
|
||||
language:
|
||||
1. update the template with `cmake --build <build> --target pot`, or with
|
||||
`python3 tools/extract_strings.py po/openpu.pot src/ui-gtk/main_window.cpp` if gettext is not
|
||||
installed;
|
||||
2. copy `po/openpu.pot` to `po/<language>.po` and translate it;
|
||||
3. add the language to `po/LINGUAS` and to the list in the Preferences dialog.
|
||||
|
||||
## Tools
|
||||
- `tools/asar_extract.py`: minimal, read-only asar extractor used to study the reference
|
||||
application. Extracted sources stay **outside the repository**.
|
||||
@@ -0,0 +1,66 @@
|
||||
# SPDX-License-Identifier: MIT
|
||||
# Run at build time (cmake -P): writes ${OUTPUT} with the release version (from project()) and the
|
||||
# build description from `git describe`, rewriting the file only when it changes.
|
||||
#
|
||||
# Inputs: SOURCE_DIR, OUTPUT, VERSION (x.y.z), GIT_EXECUTABLE (may be empty)
|
||||
#
|
||||
# Description examples:
|
||||
# 0.2.0 built exactly from tag v0.2.0, clean tree
|
||||
# 0.2.0+3.g1a2b3c4 3 commits after v0.2.0
|
||||
# 0.2.0+3.g1a2b3c4.dirty ... with uncommitted changes
|
||||
# 0.2.0 no git (release tarball, HaikuPorts recipe)
|
||||
|
||||
set(description "${VERSION}")
|
||||
if(GIT_EXECUTABLE AND EXISTS "${SOURCE_DIR}/.git")
|
||||
execute_process(
|
||||
COMMAND "${GIT_EXECUTABLE}" describe --tags --long --dirty --match "v[0-9]*"
|
||||
WORKING_DIRECTORY "${SOURCE_DIR}"
|
||||
OUTPUT_VARIABLE describe
|
||||
RESULT_VARIABLE rc
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET)
|
||||
# v0.2.0-3-g1a2b3c4[-dirty]
|
||||
if(rc EQUAL 0 AND describe MATCHES "^v([0-9]+\\.[0-9]+\\.[0-9]+)-([0-9]+)-(g[0-9a-f]+)(-dirty)?$")
|
||||
set(tag_version "${CMAKE_MATCH_1}")
|
||||
set(distance "${CMAKE_MATCH_2}")
|
||||
set(hash "${CMAKE_MATCH_3}")
|
||||
set(dirty "${CMAKE_MATCH_4}")
|
||||
if(NOT tag_version VERSION_EQUAL VERSION AND distance EQUAL 0)
|
||||
message(WARNING "tag v${tag_version} does not match project(VERSION ${VERSION})")
|
||||
endif()
|
||||
if(NOT distance EQUAL 0)
|
||||
string(APPEND description "+${distance}.${hash}")
|
||||
endif()
|
||||
if(dirty)
|
||||
if(distance EQUAL 0)
|
||||
string(APPEND description "+${hash}")
|
||||
endif()
|
||||
string(APPEND description ".dirty")
|
||||
endif()
|
||||
else()
|
||||
# No tag yet: use the commit hash only.
|
||||
execute_process(
|
||||
COMMAND "${GIT_EXECUTABLE}" rev-parse --short HEAD
|
||||
WORKING_DIRECTORY "${SOURCE_DIR}"
|
||||
OUTPUT_VARIABLE hash RESULT_VARIABLE rc
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET)
|
||||
if(rc EQUAL 0)
|
||||
string(APPEND description "+g${hash}")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(content "// Generated by cmake/GitVersion.cmake — do not edit.
|
||||
#include \"openpu/version.hpp\"
|
||||
|
||||
namespace openpu {
|
||||
const char* version() noexcept { return \"${VERSION}\"; }
|
||||
const char* versionDescription() noexcept { return \"${description}\"; }
|
||||
} // namespace openpu
|
||||
")
|
||||
|
||||
if(EXISTS "${OUTPUT}")
|
||||
file(READ "${OUTPUT}" previous)
|
||||
endif()
|
||||
if(NOT previous STREQUAL content)
|
||||
file(WRITE "${OUTPUT}" "${content}")
|
||||
endif()
|
||||
+87
-87
@@ -1,50 +1,49 @@
|
||||
# API Majestic (PSA / Stellantis) — utilisée par « Peugeot Update » 1.6.1
|
||||
# Majestic API (PSA / Stellantis) as used by "Peugeot Update" 1.6.1
|
||||
|
||||
Source : sources TypeScript embarquées dans `resources/app.asar` (`src/environments`,
|
||||
Sources: the TypeScript sources shipped in `resources/app.asar` (`src/environments`,
|
||||
`src/app/services/{vehicle,update}.service.ts`, `electron/{rangeDownload,downloadManagement}.ts`)
|
||||
et journal `%APPDATA%\Peugeot Update\log.log`.
|
||||
and the log file `%APPDATA%\Peugeot Update\log.log`.
|
||||
|
||||
Aucune authentification utilisateur : pas d'OAuth, pas de cookie, pas de jeton.
|
||||
Seul un `client_id` applicatif, fixe, est passé en query string.
|
||||
There is no user authentication: no OAuth, no cookie, no token. Only a fixed application
|
||||
`client_id` is passed in the query string.
|
||||
|
||||
| Constante | Valeur (marque Peugeot) |
|
||||
| Constant | Value (Peugeot build) |
|
||||
|---|---|
|
||||
| `apiAvailableUpdates` | `https://api.groupe-psa.com/applications/majesticf/v1/getAvailableUpdate` |
|
||||
| `apiDevices` | `https://api.groupe-psa.com/applications/majesticf/v1/devices/` |
|
||||
| `clientId` | `?client_id=20a4cf7c-f5fb-41d5-9175-a6e23b9880e5` |
|
||||
| `regExpVin` | `^V[FR]{1}3[A-Z0-9]{14}$` |
|
||||
|
||||
Les autres marques du groupe (Citroën, DS, Opel…) utilisent probablement le même backend
|
||||
avec un `client_id` différent : OpenPU rend ces valeurs configurables.
|
||||
The group's other brands (Citroën, DS, Opel…) probably use the same backend with a different
|
||||
`client_id`, so OpenPU makes these values configurable.
|
||||
|
||||
## 1. Liste des calculateurs : `GET devices/{VIN}`
|
||||
## 1. Head units of a vehicle: `GET devices/{VIN}`
|
||||
|
||||
```
|
||||
GET https://api.groupe-psa.com/applications/majesticf/v1/devices/{VIN}?client_id=…
|
||||
```
|
||||
|
||||
Réponse 200 :
|
||||
200 response:
|
||||
```json
|
||||
{ "vin": "VR3XXXXXXXXXXXXXX", "requestDate": "…", "devices": [ { "ecuType": "RCC_EU_…" } ] }
|
||||
```
|
||||
- **404** ⇒ VIN inconnu (traité comme « véhicule inexistant », pas comme une erreur réseau).
|
||||
- Autre erreur HTTP ⇒ erreur serveur ; statut 0 ⇒ erreur réseau.
|
||||
- **404** means the VIN is unknown (treated as "no such vehicle", not as a network error).
|
||||
- Any other HTTP error is a server error; status 0 is a network error.
|
||||
|
||||
### Classification `ecuType`
|
||||
`prefix = ecuType.split('_')[0]`, comparaison insensible à la casse :
|
||||
### `ecuType` classification
|
||||
`prefix = ecuType.split('_')[0]`, compared case-insensitively:
|
||||
|
||||
| Préfixe | Type | Lien guide (`wave`) |
|
||||
| Prefix | Type | Guide link (`wave`) |
|
||||
|---|---|---|
|
||||
| `RCC` | `rcc` | `path_guide_rcc` |
|
||||
| `AIO` | `aio` | `path_guide_aio` |
|
||||
| `NAC` | `nac` | dernier segment `WAVE1..4` → `path_guide_wave_1..4`, sinon `path_guide_wave_default` |
|
||||
| `CRONY…` (5 premiers caractères) | `crony_nav` / `crony_nonav` | `CRONY2_EU_VAR{1..4}_WAVE1` → `path_guide_crony_{1..4}` |
|
||||
| `NAC` | `nac` | last segment `WAVE1..4` → `path_guide_wave_1..4`, otherwise `path_guide_wave_default` |
|
||||
| `CRONY…` (first 5 characters) | `crony_nav` / `crony_nonav` | `CRONY2_EU_VAR{1..4}_WAVE1` → `path_guide_crony_{1..4}` |
|
||||
|
||||
Seuls les devices dont le préfixe est reconnu sont retenus. Il faut **exactement un**
|
||||
device valide pour obtenir un lien de guide. S'il y a au moins un device valide mais pas de lien,
|
||||
le véhicule « existe » avec un type vide.
|
||||
Only devices with a known prefix are kept. A guide link requires **exactly one** valid device. With
|
||||
at least one valid device but no link, the vehicle "exists" with an empty type.
|
||||
|
||||
## 2. Mises à jour disponibles : `POST getAvailableUpdate`
|
||||
## 2. Available updates: `POST getAvailableUpdate`
|
||||
|
||||
```
|
||||
POST https://api.groupe-psa.com/applications/majesticf/v1/getAvailableUpdate?client_id=…
|
||||
@@ -53,8 +52,8 @@ Content-Type: application/json
|
||||
{ "vin": "VF3…", "softwareTypes": [ { "softwareType": "rcc-firmware" }, { "softwareType": "map-eur" } ] }
|
||||
```
|
||||
|
||||
### Types de logiciel
|
||||
| Constante | `softwareType` |
|
||||
### Software types
|
||||
| Constant | `softwareType` |
|
||||
|---|---|
|
||||
| SOFT_FW_OVIP (NAC) | `ovip-int-firmware-version` |
|
||||
| SOFT_FW_RCC | `rcc-firmware` |
|
||||
@@ -64,21 +63,21 @@ Content-Type: application/json
|
||||
| SOFT_CARTO | `map-eur` |
|
||||
| SOFT_CARTO_CRONY | `crony2-map-western_europe` |
|
||||
|
||||
**Ajout d'un véhicule** (`checkVehicle`) : les 7 types sont envoyés, en parallèle de `devices/{VIN}`.
|
||||
Pour Crony, si la réponse contient une entrée `crony2-software-nonav` avec un `update[0].updateId`,
|
||||
le type est `crony_nonav`, sinon `crony_nav`.
|
||||
**Adding a vehicle** (`checkVehicle`): all 7 types are requested, in parallel with `devices/{VIN}`.
|
||||
For Crony, the type is `crony_nonav` when the answer has a `crony2-software-nonav` entry with an
|
||||
`update[0].updateId`, `crony_nav` otherwise.
|
||||
|
||||
**Recherche de mises à jour** (`getUpdates`) : 2 types selon le type de véhicule.
|
||||
**Looking for updates** (`getUpdates`): 2 types depending on the vehicle type.
|
||||
|
||||
| Type véhicule | Firmware | Cartographie |
|
||||
| Vehicle type | Firmware | Map |
|
||||
|---|---|---|
|
||||
| `nac` | `ovip-int-firmware-version` | `map-eur` |
|
||||
| `rcc` | `rcc-firmware` | `map-eur` |
|
||||
| `aio` (et défaut) | `aio-firmware` | `map-eur` |
|
||||
| `aio` (and default) | `aio-firmware` | `map-eur` |
|
||||
| `crony_nav` | `crony2-software-nav` | `crony2-map-western_europe` |
|
||||
| `crony_nonav` | `crony2-software-nonav` | — (`null` envoyé) |
|
||||
| `crony_nonav` | `crony2-software-nonav` | — (`null` sent) |
|
||||
|
||||
### Réponse
|
||||
### Response
|
||||
```json
|
||||
{
|
||||
"requestResult": "OK",
|
||||
@@ -91,8 +90,8 @@ le type est `crony_nonav`, sinon `crony_nav`.
|
||||
"currentSoftwareVersion": "…",
|
||||
"update": [
|
||||
{
|
||||
"updateId": "005…", // 18 chiffres, chaîne
|
||||
"updateSize": "8390000000", // chaîne, octets
|
||||
"updateId": "005…", // 18 digits, as a string
|
||||
"updateSize": "8390000000", // string, bytes
|
||||
"updateVersion": "…",
|
||||
"updateDate": "…",
|
||||
"updateURL": "https://majestic-web.mpsa.com/mjf00-web/rest/UpdateDownload?updateId=…&uin=…&type=fw",
|
||||
@@ -103,69 +102,70 @@ le type est `crony_nonav`, sinon `crony_nav`.
|
||||
]
|
||||
}
|
||||
```
|
||||
Une mise à jour n'est retenue que si `requestResult == "OK"`, `updateRequestResult == "OK"`,
|
||||
`update` est non vide et `updateURL` est une URL valide.
|
||||
An update is used only if `requestResult == "OK"`, `updateRequestResult == "OK"`, `update` is not
|
||||
empty and `updateURL` is a valid URL.
|
||||
|
||||
> Note : l'app d'origine trie `update[]` avec `a.updateDate - b.updateDate` sur des chaînes, ce qui
|
||||
> donne `NaN` : le tri n'a donc aucun effet et c'est `update[0]` qui est pris. OpenPU prend aussi
|
||||
> `update[0]`, sauf si plusieurs entrées ont des dates ISO comparables, auquel cas il prend la plus récente.
|
||||
> Note: the original application sorts `update[]` with `a.updateDate - b.updateDate` on strings,
|
||||
> which yields `NaN`: the sort has no effect and `update[0]` is used. OpenPU also uses `update[0]`,
|
||||
> unless several entries have comparable ISO dates, in which case it takes the most recent one.
|
||||
|
||||
`uin` est l'identifiant du calculateur (20 caractères hexadécimaux). Il est encodé dans les URLs
|
||||
renvoyées, et le client n'a jamais à le connaître.
|
||||
`uin` is the head unit identifier (20 hexadecimal characters). It is embedded in the returned URLs;
|
||||
the client never needs to know it.
|
||||
|
||||
## 3. Téléchargements (`majestic-web.mpsa.com`)
|
||||
## 3. Downloads (`majestic-web.mpsa.com`)
|
||||
|
||||
| URL | Rôle |
|
||||
| URL | Role |
|
||||
|---|---|
|
||||
| `…/mjf00-web/rest/UpdateDownload?updateId=&uin=&type=fw` | redirige (3xx) vers le CDN `https://ds4emloty3shq.cloudfront.net/<FOURNISSEUR>/<HU_REGION>/<softwareType>/<fichier>.tar` |
|
||||
| `…/mjf00-web/rest/LicenseDownload?mediaVersion=&uin=` | fichier licence, nom donné par `Content-Disposition: …filename=<nom>` (`license_<UIN>.key` ou `licenses_<updateId>_<yyyyMMddHHmmss>.tar`) |
|
||||
| `…/mjf00-web/rest/UpdateDownload?updateId=&uin=&type=fw` | redirects (3xx) to the CDN `https://ds4emloty3shq.cloudfront.net/<SUPPLIER>/<HU_REGION>/<softwareType>/<file>.tar` |
|
||||
| `…/mjf00-web/rest/LicenseDownload?mediaVersion=&uin=` | license file, named by `Content-Disposition: …filename=<name>` (`license_<UIN>.key` or `licenses_<updateId>_<yyyyMMddHHmmss>.tar`) |
|
||||
|
||||
### Nom de fichier
|
||||
- Firmware/carte : dernier segment du chemin de l'**URL finale** (après redirections), sans query.
|
||||
- Licence : HEAD, puis `Content-Disposition` découpé sur `filename=`. À défaut, dernier segment de l'URL.
|
||||
- Les noms sont résolus **séquentiellement**. Commentaire d'origine : deux requêtes simultanées
|
||||
vers Majestic échouent parfois toutes les deux.
|
||||
### File names
|
||||
- Firmware/map: last path segment of the **final URL** (after redirects), without the query.
|
||||
- License: HEAD, then `Content-Disposition` split on `filename=`; otherwise the last URL segment.
|
||||
- Names are resolved **sequentially**. Comment in the original code: two simultaneous requests to
|
||||
Majestic sometimes both fail.
|
||||
|
||||
### Téléchargement avec reprise (`rangeDownload.ts`)
|
||||
1. `HEAD updateURL` (`Connection: keep-alive`), timeout 5 s, redirections suivies.
|
||||
La réponse doit être un 200 avec un `content-length` non nul, qui donne la taille totale.
|
||||
2. Si `<dossier>/<fichier>` existe déjà, sa taille donne `have`. Si `have >= total`, le fichier est complet.
|
||||
3. `GET urlFinale` avec `Range: bytes=<have>-<total-1>`. On attend un **206** avec
|
||||
`content-length == total-have` ; les données sont ajoutées en fin de fichier.
|
||||
- Un 200 (pas de support Range) ou une longueur incorrecte ⇒ le fichier partiel est supprimé, on passe en
|
||||
mode sans Range et on réessaie.
|
||||
4. Watchdog : 10 s sans données ⇒ abandon de la connexion, puis réessai.
|
||||
5. 5 réessais au maximum (cache de session vidé entre deux). Une erreur disque est fatale tout de suite.
|
||||
6. Pause et reprise : arrêt de la requête, puis on recommence à l'étape 1 (le fichier partiel est conservé).
|
||||
### Resumable download (`rangeDownload.ts`)
|
||||
1. `HEAD updateURL` (`Connection: keep-alive`), 5 s timeout, redirects followed. The answer must be
|
||||
a 200 with a non-zero `content-length`, which gives the total size.
|
||||
2. If `<folder>/<file>` already exists, its size gives `have`. If `have >= total`, the file is complete.
|
||||
3. `GET finalUrl` with `Range: bytes=<have>-<total-1>`. A **206** with `content-length == total-have`
|
||||
is expected; data is appended to the file.
|
||||
- A 200 (no Range support) or a wrong length deletes the partial file, switches to non-Range mode
|
||||
and retries.
|
||||
4. Watchdog: 10 s without data drops the connection, then retries.
|
||||
5. At most 5 retries (session cache cleared in between). A disk error is fatal immediately.
|
||||
6. Pause and resume: the request is stopped, then step 1 starts again (the partial file is kept).
|
||||
|
||||
La licence est téléchargée **sans reprise** (`electron-dl`). Si le fichier existe déjà, il n'est pas retéléchargé.
|
||||
The license is downloaded **without resume** (`electron-dl`). An existing file is not downloaded again.
|
||||
|
||||
### Proxy
|
||||
`<install>/proxy.json` : `{http_proxy, https_proxy, no_proxy}`. OpenPU utilise les variables
|
||||
d'environnement standard (libcurl les gère nativement).
|
||||
`<install>/proxy.json`: `{http_proxy, https_proxy, no_proxy}`. OpenPU uses the standard environment
|
||||
variables (natively supported by libcurl).
|
||||
|
||||
## 4. Observations sur l'API réelle (capture du 2026-11-28)
|
||||
- **Passerelle** (`X-Global-Transaction-ID`, de type IBM DataPower) : les réponses n'ont **pas de
|
||||
`Content-Length`**, et la passerelle ferme la connexion TLS **sans `close_notify`**. OpenSSL 3
|
||||
signale alors `unexpected eof while reading` (curl : code 56), alors que le corps est complet. Chromium
|
||||
tolère ce cas, et OpenPU aussi, mais uniquement pour un corps délimité par la fermeture de la connexion.
|
||||
- Le JSON échappe `=` et `&` en `=` / `&` dans les URL. Il faut donc toujours décoder avant d'analyser.
|
||||
- `ecuType` réels : `NAC_EUR_WAVE2`, `NAC_EUR_WAVE4`, RCC (voir les fixtures).
|
||||
- `updateDate` est au format `yyyy-MM-dd HH:mm:ss.S`. `updateSize` est une chaîne.
|
||||
- **Cartographie NAC** : `updateURL` pointe directement vers le CDN TomTom
|
||||
(`https://download-cde.tomtom.com/OEM/PSA/MAP/PSA_map-eur_<ver>-NAC_EUR_WAVE2.tar`), et `licenseURL` est vide.
|
||||
- `installerURL` est présent au niveau racine (une URL `UpdateDownload` sur `majestic.mpsa.com`). Son rôle est inconnu
|
||||
et l'app d'origine ne l'utilise pas.
|
||||
- Un VIN inexistant renvoie **404** avec un corps HTML.
|
||||
- **Licence générée de façon asynchrone** : le premier `LicenseDownload` d'une mise à jour a renvoyé un 200
|
||||
avec `Content-Disposition: filename=licenses_<updateId>_<yyyyMMddHHmmss>.tar` et un **corps vide**.
|
||||
Un appel suivant renvoie le vrai `license_<UIN>.key` (environ 10 Ko). L'app officielle garde le fichier vide,
|
||||
d'où les ENOENT et le « redémarrer l'app » de son journal. OpenPU supprime la réponse vide et réessaie
|
||||
en allongeant progressivement le délai.
|
||||
- CDN firmware RCC (CloudFront) : `HEAD` → 200 + `Content-Length`, et `Range` → 206. La reprise a été vérifiée
|
||||
(interruption à 1,59 Go puis reprise, environ 80 Mo/s).
|
||||
- Aucun en-tête particulier n'est requis : le User-Agent est libre, et HTTP/1.1 suffit (pas de négociation h2).
|
||||
## 4. Observations on the real API (capture of 2026-11-28)
|
||||
- **Gateway** (`X-Global-Transaction-ID`, IBM DataPower-like): responses have **no
|
||||
`Content-Length`**, and the gateway closes the TLS connection **without `close_notify`**. OpenSSL 3
|
||||
then reports `unexpected eof while reading` (curl error 56) although the body is complete. Chromium
|
||||
tolerates it; so does OpenPU, but only for bodies delimited by the connection close.
|
||||
- The JSON escapes `=` and `&` as `\u003d` / `\u0026` in URLs: always decode before parsing.
|
||||
- Real `ecuType` values: `NAC_EUR_WAVE2`, `NAC_EUR_WAVE4`, RCC (see the test fixtures).
|
||||
- `updateDate` uses the `yyyy-MM-dd HH:mm:ss.S` format. `updateSize` is a string.
|
||||
- **NAC maps**: `updateURL` points directly to the TomTom CDN
|
||||
(`https://download-cde.tomtom.com/OEM/PSA/MAP/PSA_map-eur_<ver>-NAC_EUR_WAVE2.tar`), and
|
||||
`licenseURL` is empty.
|
||||
- `installerURL` is present at the root (an `UpdateDownload` URL on `majestic.mpsa.com`). Its role is
|
||||
unknown and the original application does not use it.
|
||||
- An unknown VIN returns **404** with an HTML body.
|
||||
- **The license is generated asynchronously**: the first `LicenseDownload` of an update returned a
|
||||
200 with `Content-Disposition: filename=licenses_<updateId>_<yyyyMMddHHmmss>.tar` and an **empty
|
||||
body**. A later call returns the real `license_<UIN>.key` (about 10 KB). The official application
|
||||
keeps the empty file, hence the ENOENT errors and "restart the app" in its log. OpenPU deletes the
|
||||
empty answer and retries with an increasing delay.
|
||||
- RCC firmware CDN (CloudFront): `HEAD` → 200 + `Content-Length`, and `Range` → 206. Resuming was
|
||||
verified (interrupted at 1.59 GB then resumed, about 80 MB/s).
|
||||
- No special header is required: any User-Agent works, and HTTP/1.1 is enough (no h2 negotiation).
|
||||
|
||||
## 5. Mise à jour de l'application elle-même
|
||||
electron-updater, fournisseur générique `https://d1tik0o5ahgjm.cloudfront.net/peugeot/latest.yml`.
|
||||
Hors périmètre pour OpenPU.
|
||||
## 5. Updating the application itself
|
||||
electron-updater, generic provider `https://d1tik0o5ahgjm.cloudfront.net/peugeot/latest.yml`.
|
||||
Out of scope for OpenPU.
|
||||
+39
-32
@@ -1,43 +1,50 @@
|
||||
# Préparation de la clé USB
|
||||
# Preparing the USB stick
|
||||
|
||||
## Formatage
|
||||
- Système de fichiers : **FAT32**, table de partitions MBR (macOS : `diskutil eraseDisk FAT32 <LABEL> MBR`).
|
||||
- Label : le label actuel de la clé, assaini avec `replace(/[^a-zA-Z0-9_]+/g,'')`, tronqué à 11 caractères
|
||||
et mis en majuscules. Valeur par défaut : `NEW`.
|
||||
- Windows :
|
||||
- ≤ 32 GiB : `format X: /q /fs:FAT32 /v:LABEL` ;
|
||||
- au-delà, ou en cas d'échec : `chkdsk X: & timeout 20 & echo y | fat32format X: & label X: LABEL`,
|
||||
avec élévation de privilèges.
|
||||
- Linux (code présent dans l'app mais jamais livré) : `umount <mnt> && mkfs.vfat -n LABEL /dev/disk/by-uuid/<uuid>`.
|
||||
Seul le volume est reformaté, pas la table de partitions.
|
||||
## Formatting
|
||||
- File system: **FAT32**, MBR partition table (macOS: `diskutil eraseDisk FAT32 <LABEL> MBR`).
|
||||
- Label: the stick's current label, sanitised with `replace(/[^a-zA-Z0-9_]+/g,'')`, truncated to 11
|
||||
characters and upper-cased. Default: `NEW`.
|
||||
- Windows:
|
||||
- up to 32 GiB: `format X: /q /fs:FAT32 /v:LABEL`;
|
||||
- above, or on failure: `chkdsk X: & timeout 20 & echo y | fat32format X: & label X: LABEL`, with
|
||||
elevated privileges.
|
||||
- Linux (code present in the app but never shipped): `umount <mnt> && mkfs.vfat -n LABEL
|
||||
/dev/disk/by-uuid/<uuid>`. Only the volume is reformatted, not the partition table.
|
||||
|
||||
Équivalents OpenPU :
|
||||
- Linux : UDisks2 `org.freedesktop.UDisks2.Block.Format("vfat", {label, erase?})` sur le
|
||||
périphérique bloc entier (création d'une table MBR et d'une partition FAT32), via polkit, sans root.
|
||||
- Haiku : `BDiskDevice` → `BPartition::Initialize("fat", label, "fat 32")` (add-on DriveSetup FAT).
|
||||
OpenPU equivalents:
|
||||
- Linux: UDisks2 `org.freedesktop.UDisks2.Block.Format("dos")` on the whole block device, then
|
||||
`PartitionTable.CreatePartitionAndFormat` (type `0x0c` at 1 MiB, `vfat` with the label), through
|
||||
polkit, without root.
|
||||
- Haiku: Storage Kit disk device API (`BDiskDevice` / `BPartition`, as DriveSetup), MBR ("intel")
|
||||
with one "FAT 32-bit, LBA-mapped" partition at 1 MiB, formatted with the "fat" disk system.
|
||||
On Haiku R1/beta6 each step must be its own transaction (erase foreign content, delete old
|
||||
partitions, create the partition, format): combined transactions fail or hang, and
|
||||
`Uninitialize()` on an existing MBR hangs the disk device manager.
|
||||
|
||||
## Taille minimale
|
||||
## Minimum size
|
||||
```
|
||||
besoin = (taille fw + taille licence + taille carto) × 1.1
|
||||
usbMin = 2 Go ; tant que usbMin × 10^9 < besoin : usbMin ×= 2
|
||||
liste = disques USB montés dont la taille > besoin
|
||||
needed = (firmware size + license size + map size) × 1.1
|
||||
usbMin = 2 GB; while usbMin × 10^9 < needed: usbMin ×= 2
|
||||
choices = mounted USB drives larger than needed
|
||||
```
|
||||
|
||||
## Arborescence produite
|
||||
## Resulting tree
|
||||
```
|
||||
<USB>/
|
||||
├── license/
|
||||
│ └── <nom licence> # license_<UIN>.key ou licenses_<id>_<ts>.tar, copié tel quel
|
||||
├── rcc_update/… # contenu du tar firmware RCC (le nom dépend du calculateur)
|
||||
└── … # contenu du tar cartographie, extrait à la racine
|
||||
│ └── <license name> # license_<UIN>.key or licenses_<id>_<ts>.tar, copied as is
|
||||
├── rcc_update/… # content of the RCC firmware tar (the name depends on the head unit)
|
||||
└── … # content of the map tar, extracted at the root
|
||||
```
|
||||
### Archive firmware RCC réelle (6_0432_23-2I44-1, 8 391 587 840 octets)
|
||||
- Format **ustar** standard (magic `ustar\000`), 16 entrées, uniquement des fichiers réguliers et des dossiers.
|
||||
- Premier membre : `UpdateInfo.xml` (racine), puis `rcc_update/…`.
|
||||
- Plus gros fichiers : `rcc_update/stc.A2.bsh.tar.bin` (2,70 Go), `stc.A1…` (2,68 Go) et `rfs.A2.wml.fp.tar.bin` (1,0 Go).
|
||||
Tout tient sous la limite FAT32 de 4 Gio par fichier. Pour les cartes NAC (10,5 Go), c'est à vérifier.
|
||||
|
||||
- Tout fichier dont le *basename* est `UpdateInfo.xml` est ignoré lors de l'extraction.
|
||||
- Le tar peut être sans « magic number » (`allowUnknownFormat`), donc il faut un lecteur tar tolérant
|
||||
(libarchive : `archive_read_support_format_tar` + `archive_read_support_format_raw` désactivé).
|
||||
- Une extraction « à blanc » (dry-run) préalable vérifie l'intégrité du tar.
|
||||
### Real RCC firmware archive (6_0432_23-2I44-1, 8,391,587,840 bytes)
|
||||
- Standard **ustar** format (magic `ustar\000`), 16 entries, only regular files and directories.
|
||||
- First member: `UpdateInfo.xml` (root), then `rcc_update/…`.
|
||||
- Largest files: `rcc_update/stc.A2.bsh.tar.bin` (2.70 GB), `stc.A1…` (2.68 GB) and
|
||||
`rfs.A2.wml.fp.tar.bin` (1.0 GB). Everything fits under the 4 GiB FAT32 per-file limit. To be
|
||||
checked for NAC maps (10.5 GB).
|
||||
|
||||
- Any file whose *basename* is `UpdateInfo.xml` is skipped during extraction.
|
||||
- The tar may lack the "magic number" (`allowUnknownFormat` in the original app), so a tolerant tar
|
||||
reader is needed (libarchive's tar reader accepts V7 archives without magic).
|
||||
- A preliminary "dry-run" extraction checks the integrity of the tar.
|
||||
+38
-38
@@ -1,56 +1,56 @@
|
||||
# Déroulé fonctionnel de « Peugeot Update »
|
||||
# Functional workflow of "Peugeot Update"
|
||||
|
||||
## Écrans (Angular)
|
||||
1. **Bienvenue** (`welcome`), qu'on peut masquer (`hideWelcome`).
|
||||
2. **Véhicules** (`vehicles`, `vehicle-editor`) : liste, ajout (VIN + nom), suppression,
|
||||
lien vers le guide PDF (`wave` → clé i18n → URL PDF localisée).
|
||||
3. **Mises à jour** (`available-updates`) : firmware et/ou cartographie, cases à cocher.
|
||||
4. **Dossier de téléchargement** (`path-selector`) : refusé s'il est sur une clé USB,
|
||||
ou si l'espace libre est inférieur à (taille restante × 1.1).
|
||||
5. **Téléchargement** (`download-file`) : barre de progression, pause/reprise/annulation, temps estimé.
|
||||
6. **Clé USB** (`usb-selector`) : seuls les disques USB montés de taille > besoin sont listés ;
|
||||
confirmation du formatage.
|
||||
7. **Copie** (`copy-progress`) puis **Fin**, avec les instructions d'installation dans le véhicule.
|
||||
## Screens (Angular)
|
||||
1. **Welcome** (`welcome`), can be hidden (`hideWelcome`).
|
||||
2. **Vehicles** (`vehicles`, `vehicle-editor`): list, add (VIN + name), delete, link to the PDF guide
|
||||
(`wave` → i18n key → localised PDF URL).
|
||||
3. **Updates** (`available-updates`): firmware and/or map, check boxes.
|
||||
4. **Download folder** (`path-selector`): refused when it is on a USB stick, or when the free space
|
||||
is below (remaining size × 1.1).
|
||||
5. **Download** (`download-file`): progress bar, pause/resume/cancel, estimated time.
|
||||
6. **USB stick** (`usb-selector`): only mounted USB drives larger than needed are listed;
|
||||
formatting must be confirmed.
|
||||
7. **Copy** (`copy-progress`), then **Finish**, with installation instructions for the vehicle.
|
||||
|
||||
## Machine à états (download-manager)
|
||||
## State machine (download-manager)
|
||||
|
||||
```
|
||||
SelectUpdates
|
||||
└─ résolution séquentielle des noms : fw → licence (si fw) → carto
|
||||
→ lastDownload = {state: download, vin, fw/cartoUpdateSelected, versions, noms}
|
||||
└─ names resolved sequentially: fw → license (if fw) → map
|
||||
→ lastDownload = {state: download, vin, fw/cartoUpdateSelected, versions, names}
|
||||
ChooseFolder
|
||||
└─ vérifications : dossier pas sur USB, espace libre > besoin×1.1
|
||||
└─ checks: folder not on USB, free space > needed × 1.1
|
||||
Download
|
||||
├─ si fw : licence (simple) → firmware (Range)
|
||||
└─ puis carto (Range)
|
||||
├─ if fw: license (simple) → firmware (Range)
|
||||
└─ then map (Range)
|
||||
→ lastDownload.state = usb
|
||||
PrepareUsb
|
||||
├─ taille = Σ(tailles fw + licence + carto) × 1.1 ; taille USB min = 2 Go × 2^n ≥ besoin (base 10^9)
|
||||
├─ confirmation → formatage FAT32 (label = label actuel de la clé assaini, défaut NEW)
|
||||
├─ si fw : copie licence → <usb>/license/<nomLicence>
|
||||
├─ extraction du tar fw → <usb>/ (en ignorant tout fichier nommé UpdateInfo.xml)
|
||||
├─ extraction du tar carto → <usb>/
|
||||
├─ suppression des fichiers téléchargés ; lastDownload remis à zéro
|
||||
└─ éjection (Windows)
|
||||
├─ size = Σ(fw + license + map sizes) × 1.1; minimum stick = 2 GB × 2^n ≥ needed (base 10^9)
|
||||
├─ confirmation → FAT32 formatting (label = the stick's current label, sanitised, default NEW)
|
||||
├─ if fw: copy license → <usb>/license/<licenseName>
|
||||
├─ extract the fw tar → <usb>/ (skipping any file named UpdateInfo.xml)
|
||||
├─ extract the map tar → <usb>/
|
||||
├─ delete the downloaded files; lastDownload reset
|
||||
└─ eject (Windows)
|
||||
Finish
|
||||
```
|
||||
|
||||
En cas de tar invalide (`Invalid tar header` / `unsupported type`), le tar est supprimé et
|
||||
l'utilisateur revient à la liste des véhicules (il faut retélécharger).
|
||||
On an invalid tar (`Invalid tar header` / `unsupported type`), the tar is deleted and the user goes
|
||||
back to the vehicle list (the file has to be downloaded again).
|
||||
|
||||
## Persistance (`%APPDATA%\Peugeot Update`)
|
||||
- `config.json` : `language`, `hideWelcome`, `downloadPath`,
|
||||
## Persistence (`%APPDATA%\Peugeot Update`)
|
||||
- `config.json`: `language`, `hideWelcome`, `downloadPath`,
|
||||
`lastDownload{state(0=none,…), vin, fwUpdateSelected, cartoUpdateSelected, fwLastVersion,
|
||||
cartoLastVersion, fwFileName, cartoFileName, licenseFileName}`
|
||||
- `vehicles.json` : `{ "<VIN>": {name, type, wave, undeletedFiles?{fw,carto,license}} }`
|
||||
- `vehicles.json`: `{ "<VIN>": {name, type, wave, undeletedFiles?{fw,carto,license}} }`
|
||||
- `downloadPath.txt`, `log.log` (electron-log)
|
||||
|
||||
Au démarrage, si `lastDownload.state != none`, l'app propose de reprendre le téléchargement
|
||||
ou de supprimer les fichiers.
|
||||
At startup, when `lastDownload.state != none`, the application offers to resume the download or
|
||||
to delete the files.
|
||||
|
||||
## Particularités et défauts observés (à ne pas reproduire)
|
||||
- `wmic` est utilisé pour lire le label de la clé, mais il a été retiré de Windows 11.
|
||||
- `xcopy` échoue vers la racine du lecteur, avec repli sur `robocopy`.
|
||||
- Une licence au nom déjà vu, puis supprimée, est réutilisée : ENOENT jusqu'au redémarrage de l'app.
|
||||
- Le dossier temporaire `toUsbContent` n'est pas toujours supprimé (ENOTEMPTY).
|
||||
- Le tri des mises à jour par date est sans effet (voir API.md).
|
||||
## Quirks and defects observed (not to reproduce)
|
||||
- `wmic` is used to read the stick label, but it was removed from Windows 11.
|
||||
- `xcopy` fails when the target is a drive root; it falls back to `robocopy`.
|
||||
- A license name seen before and then deleted is reused: ENOENT until the application restarts.
|
||||
- The temporary `toUsbContent` folder is not always deleted (ENOTEMPTY).
|
||||
- Sorting updates by date has no effect (see API.md).
|
||||
@@ -0,0 +1,28 @@
|
||||
# Translations (gettext). Source strings are English; add a language by adding <lang>.po and
|
||||
# listing it in LINGUAS.
|
||||
find_package(Gettext)
|
||||
if(NOT GETTEXT_FOUND)
|
||||
message(WARNING "gettext (msgfmt) not found: translations are not built")
|
||||
return()
|
||||
endif()
|
||||
file(STRINGS LINGUAS OPENPU_LINGUAS REGEX "^[^#]")
|
||||
foreach(lang IN LISTS OPENPU_LINGUAS)
|
||||
set(mo ${CMAKE_BINARY_DIR}/locale/${lang}/LC_MESSAGES/openpu.mo)
|
||||
add_custom_command(OUTPUT ${mo}
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/locale/${lang}/LC_MESSAGES
|
||||
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)
|
||||
endforeach()
|
||||
add_custom_target(translations ALL DEPENDS ${OPENPU_MO_FILES})
|
||||
|
||||
# `cmake --build . --target pot` refreshes the template from the sources.
|
||||
find_program(XGETTEXT xgettext)
|
||||
if(XGETTEXT)
|
||||
add_custom_target(pot
|
||||
COMMAND ${XGETTEXT} --keyword=_ --keyword=N_ --from-code=UTF-8 --package-name=openpu
|
||||
--add-comments=TRANSLATORS -o ${CMAKE_CURRENT_SOURCE_DIR}/openpu.pot
|
||||
${PROJECT_SOURCE_DIR}/src/ui-gtk/main_window.cpp
|
||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
|
||||
endif()
|
||||
@@ -0,0 +1 @@
|
||||
fr
|
||||
@@ -0,0 +1,320 @@
|
||||
# French translation of OpenPU.
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: openpu\n"
|
||||
"PO-Revision-Date: 2026-11-28 20:00+0100\n"
|
||||
"Last-Translator: OpenPU contributors\n"
|
||||
"Language-Team: French\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Language: fr\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
|
||||
|
||||
msgid "Crony (navigation)"
|
||||
msgstr "Crony (avec navigation)"
|
||||
|
||||
msgid "Crony (no navigation)"
|
||||
msgstr "Crony (sans navigation)"
|
||||
|
||||
msgid "unknown head unit"
|
||||
msgstr "autoradio inconnu"
|
||||
|
||||
msgid "version %1, %2"
|
||||
msgstr "version %1, %2"
|
||||
|
||||
msgid "The update server cannot be reached. Check your Internet connection."
|
||||
msgstr "Le serveur de mises à jour est injoignable. Vérifiez votre connexion Internet."
|
||||
|
||||
msgid "The update server returned an error. Try again later."
|
||||
msgstr "Le serveur de mises à jour a renvoyé une erreur. Réessayez plus tard."
|
||||
|
||||
msgid "This VIN is not valid."
|
||||
msgstr "Ce VIN n'est pas valide."
|
||||
|
||||
msgid "Your saved data cannot be read"
|
||||
msgstr "Vos données enregistrées sont illisibles"
|
||||
|
||||
msgid "Back"
|
||||
msgstr "Retour"
|
||||
|
||||
msgid "About OpenPU"
|
||||
msgstr "À propos d'OpenPU"
|
||||
|
||||
msgid ""
|
||||
"Download Peugeot head unit updates (system and navigation map) and prepare the USB stick, on "
|
||||
"Linux and Haiku.\n"
|
||||
"\n"
|
||||
"Independent project, not affiliated with Stellantis or Peugeot."
|
||||
msgstr ""
|
||||
"Téléchargez les mises à jour de l'autoradio Peugeot (système et cartographie) et préparez la "
|
||||
"clé USB, sous Linux et Haiku.\n"
|
||||
"\n"
|
||||
"Projet indépendant, sans lien avec Stellantis ni Peugeot."
|
||||
|
||||
msgid "Source code"
|
||||
msgstr "Code source"
|
||||
|
||||
msgid "Cannot save the vehicle list"
|
||||
msgstr "Impossible d'enregistrer la liste des véhicules"
|
||||
|
||||
msgid "My vehicles"
|
||||
msgstr "Mes véhicules"
|
||||
|
||||
msgid "Add your vehicle with its VIN (17 characters, on the registration document, field E)."
|
||||
msgstr "Ajoutez votre véhicule avec son VIN (17 caractères, sur le certificat d'immatriculation, champ E)."
|
||||
|
||||
msgid "Add a vehicle"
|
||||
msgstr "Ajouter un véhicule"
|
||||
|
||||
msgid "Remove"
|
||||
msgstr "Supprimer"
|
||||
|
||||
msgid "Check for updates"
|
||||
msgstr "Rechercher les mises à jour"
|
||||
|
||||
msgid "download not finished"
|
||||
msgstr "téléchargement inachevé"
|
||||
|
||||
msgid "Remove %1?"
|
||||
msgstr "Supprimer %1 ?"
|
||||
|
||||
msgid "Downloaded files that were not written to a USB stick yet are deleted too."
|
||||
msgstr "Les fichiers téléchargés qui n'ont pas encore été copiés sur une clé USB seront aussi supprimés."
|
||||
|
||||
msgid "Cancel"
|
||||
msgstr "Annuler"
|
||||
|
||||
msgid ""
|
||||
"The VIN (vehicle identification number) is written in field E of the registration document and "
|
||||
"at the bottom of the windscreen."
|
||||
msgstr ""
|
||||
"Le VIN (numéro d'identification du véhicule) figure au champ E du certificat d'immatriculation "
|
||||
"et en bas du pare-brise."
|
||||
|
||||
msgid "VIN"
|
||||
msgstr "VIN"
|
||||
|
||||
msgid "Name"
|
||||
msgstr "Nom"
|
||||
|
||||
msgid "e.g. 208 or Family car"
|
||||
msgstr "par ex. 208 ou Voiture familiale"
|
||||
|
||||
msgid "Add"
|
||||
msgstr "Ajouter"
|
||||
|
||||
msgid "A VIN has 17 characters and starts with VF3 or VR3."
|
||||
msgstr "Un VIN comporte 17 caractères et commence par VF3 ou VR3."
|
||||
|
||||
msgid "Checking the vehicle…"
|
||||
msgstr "Vérification du véhicule…"
|
||||
|
||||
msgid "This vehicle is unknown to the update service."
|
||||
msgstr "Ce véhicule est inconnu du service de mises à jour."
|
||||
|
||||
msgid "This vehicle has no head unit that can be updated with a USB stick."
|
||||
msgstr "Ce véhicule n'a pas d'autoradio pouvant être mis à jour par clé USB."
|
||||
|
||||
msgid "Download folder:"
|
||||
msgstr "Dossier de téléchargement :"
|
||||
|
||||
msgid "Change…"
|
||||
msgstr "Modifier…"
|
||||
|
||||
msgid "Installation guide"
|
||||
msgstr "Guide d'installation"
|
||||
|
||||
msgid "Download"
|
||||
msgstr "Télécharger"
|
||||
|
||||
msgid "Looking for updates…"
|
||||
msgstr "Recherche des mises à jour…"
|
||||
|
||||
msgid "No update is available: your head unit is up to date."
|
||||
msgstr "Aucune mise à jour disponible : votre autoradio est à jour."
|
||||
|
||||
msgid "Select the updates to download:"
|
||||
msgstr "Sélectionnez les mises à jour à télécharger :"
|
||||
|
||||
msgid "System (firmware)"
|
||||
msgstr "Système (firmware)"
|
||||
|
||||
msgid "Navigation map"
|
||||
msgstr "Cartographie"
|
||||
|
||||
msgid "Download folder"
|
||||
msgstr "Dossier de téléchargement"
|
||||
|
||||
msgid "Cannot save the settings"
|
||||
msgstr "Impossible d'enregistrer les réglages"
|
||||
|
||||
msgid "Not enough free space"
|
||||
msgstr "Espace libre insuffisant"
|
||||
|
||||
msgid ""
|
||||
"%1 are needed in %2 but only %3 are free. If a previous download of these files is already in "
|
||||
"this folder, it will be resumed and may fit."
|
||||
msgstr ""
|
||||
"%1 sont nécessaires dans %2 mais seuls %3 sont libres. Si un téléchargement précédent de ces "
|
||||
"fichiers se trouve déjà dans ce dossier, il sera repris et pourra tenir."
|
||||
|
||||
msgid "Download anyway"
|
||||
msgstr "Télécharger quand même"
|
||||
|
||||
msgid "Downloading"
|
||||
msgstr "Téléchargement"
|
||||
|
||||
msgid "You can close the application: the download will resume where it stopped next time."
|
||||
msgstr "Vous pouvez fermer l'application : le téléchargement reprendra là où il s'est arrêté."
|
||||
|
||||
msgid "Stop"
|
||||
msgstr "Arrêter"
|
||||
|
||||
msgid "License"
|
||||
msgstr "Licence"
|
||||
|
||||
msgid "waiting"
|
||||
msgstr "en attente"
|
||||
|
||||
msgid "Connecting…"
|
||||
msgstr "Connexion…"
|
||||
|
||||
msgid "Cannot write the file: %1"
|
||||
msgstr "Impossible d'écrire le fichier : %1"
|
||||
|
||||
msgid "The download failed: %1"
|
||||
msgstr "Le téléchargement a échoué : %1"
|
||||
|
||||
msgid "Download interrupted"
|
||||
msgstr "Téléchargement interrompu"
|
||||
|
||||
msgid "The files already downloaded are kept; start again to resume."
|
||||
msgstr "Les fichiers déjà téléchargés sont conservés ; relancez pour reprendre."
|
||||
|
||||
msgid "done"
|
||||
msgstr "terminé"
|
||||
|
||||
msgid "Time left: %1"
|
||||
msgstr "Temps restant : %1"
|
||||
|
||||
msgid "(connection lost, attempt %1)"
|
||||
msgstr "(connexion perdue, tentative %1)"
|
||||
|
||||
msgid "Prepare the USB stick"
|
||||
msgstr "Préparer la clé USB"
|
||||
|
||||
msgid "This USB stick is too small."
|
||||
msgstr "Cette clé USB est trop petite."
|
||||
|
||||
msgid "Refresh"
|
||||
msgstr "Actualiser"
|
||||
|
||||
msgid "Erase and write"
|
||||
msgstr "Effacer et écrire"
|
||||
|
||||
msgid "Computing the required size…"
|
||||
msgstr "Calcul de la taille nécessaire…"
|
||||
|
||||
msgid "A downloaded file is damaged"
|
||||
msgstr "Un fichier téléchargé est endommagé"
|
||||
|
||||
msgid "Download the update again."
|
||||
msgstr "Téléchargez à nouveau la mise à jour."
|
||||
|
||||
msgid "Plug in a USB stick of at least %1. It will be completely erased and formatted (FAT32)."
|
||||
msgstr "Branchez une clé USB d'au moins %1. Elle sera entièrement effacée et formatée (FAT32)."
|
||||
|
||||
msgid "USB drives cannot be listed: "
|
||||
msgstr "Impossible de lister les clés USB : "
|
||||
|
||||
msgid "too small"
|
||||
msgstr "trop petite"
|
||||
|
||||
msgid "No USB stick found. Plug one in, then refresh."
|
||||
msgstr "Aucune clé USB trouvée. Branchez-en une, puis actualisez."
|
||||
|
||||
msgid "Erase %1?"
|
||||
msgstr "Effacer %1 ?"
|
||||
|
||||
msgid "Everything on this USB stick will be lost."
|
||||
msgstr "Tout le contenu de cette clé USB sera perdu."
|
||||
|
||||
msgid "Writing the USB stick"
|
||||
msgstr "Écriture de la clé USB"
|
||||
|
||||
msgid "Do not unplug the USB stick."
|
||||
msgstr "Ne débranchez pas la clé USB."
|
||||
|
||||
msgid "Checking the downloaded files…"
|
||||
msgstr "Vérification des fichiers téléchargés…"
|
||||
|
||||
msgid "Permission to format the USB stick was refused."
|
||||
msgstr "L'autorisation de formater la clé USB a été refusée."
|
||||
|
||||
msgid "The USB stick could not be prepared"
|
||||
msgstr "La clé USB n'a pas pu être préparée"
|
||||
|
||||
msgid "Formatting the USB stick…"
|
||||
msgstr "Formatage de la clé USB…"
|
||||
|
||||
msgid "Copying the license…"
|
||||
msgstr "Copie de la licence…"
|
||||
|
||||
msgid "Copying the update…"
|
||||
msgstr "Copie de la mise à jour…"
|
||||
|
||||
msgid "Ejecting the USB stick…"
|
||||
msgstr "Éjection de la clé USB…"
|
||||
|
||||
msgid "The USB stick is ready"
|
||||
msgstr "La clé USB est prête"
|
||||
|
||||
msgid ""
|
||||
"You can unplug the USB stick. With the engine running, plug it into the vehicle and follow the "
|
||||
"instructions on the screen. The installation can take a long time: do not stop the engine."
|
||||
msgstr ""
|
||||
"Vous pouvez débrancher la clé USB. Moteur tournant, branchez-la dans le véhicule et suivez les "
|
||||
"instructions à l'écran. L'installation peut être longue : ne coupez pas le moteur."
|
||||
|
||||
msgid "Finish"
|
||||
msgstr "Terminer"
|
||||
|
||||
msgid "Preferences"
|
||||
msgstr "Préférences"
|
||||
|
||||
msgid "Check for a new version of OpenPU"
|
||||
msgstr "Rechercher une nouvelle version d'OpenPU"
|
||||
|
||||
msgid "Menu"
|
||||
msgstr "Menu"
|
||||
|
||||
msgid "OpenPU is up to date"
|
||||
msgstr "OpenPU est à jour"
|
||||
|
||||
msgid "Version %1 is the latest version."
|
||||
msgstr "La version %1 est la plus récente."
|
||||
|
||||
msgid "Cannot check for a new version"
|
||||
msgstr "Impossible de rechercher une nouvelle version"
|
||||
|
||||
msgid "OpenPU %1 is available"
|
||||
msgstr "OpenPU %1 est disponible"
|
||||
|
||||
msgid "You are using version %1. Do you want to download the new version?"
|
||||
msgstr "Vous utilisez la version %1. Voulez-vous télécharger la nouvelle version ?"
|
||||
|
||||
msgid "Later"
|
||||
msgstr "Plus tard"
|
||||
|
||||
msgid "Language"
|
||||
msgstr "Langue"
|
||||
|
||||
msgid "System language"
|
||||
msgstr "Langue du système"
|
||||
|
||||
msgid "The new language is used the next time OpenPU starts."
|
||||
msgstr "La nouvelle langue sera utilisée au prochain démarrage d'OpenPU."
|
||||
|
||||
msgid "Check for a new version of OpenPU at startup"
|
||||
msgstr "Rechercher une nouvelle version d'OpenPU au démarrage"
|
||||
+401
@@ -0,0 +1,401 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: openpu\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:54
|
||||
msgid "Crony (navigation)"
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:55
|
||||
msgid "Crony (no navigation)"
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:58
|
||||
msgid "unknown head unit"
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:63
|
||||
#, qt-format
|
||||
msgid "version %1, %2"
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:70
|
||||
msgid "The update server cannot be reached. Check your Internet connection."
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:73
|
||||
msgid "The update server returned an error. Try again later."
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:75
|
||||
msgid "This VIN is not valid."
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:104
|
||||
msgid "Your saved data cannot be read"
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:109
|
||||
msgid "Back"
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:113 src\ui-gtk\main_window.cpp:219
|
||||
msgid "Preferences"
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:114
|
||||
msgid "Check for a new version of OpenPU"
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:115
|
||||
msgid "About OpenPU"
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:118
|
||||
msgid "Menu"
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:181
|
||||
msgid "OpenPU is up to date"
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:182
|
||||
#, qt-format
|
||||
msgid "Version %1 is the latest version."
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:185
|
||||
msgid "Cannot check for a new version"
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:195
|
||||
#, qt-format
|
||||
msgid "OpenPU %1 is available"
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:197
|
||||
#, qt-format
|
||||
msgid "You are using version %1. Do you want to download the new version?"
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:201
|
||||
msgid "Later"
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:201 src\ui-gtk\main_window.cpp:625
|
||||
msgid "Download"
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:231 src\ui-gtk\main_window.cpp:705
|
||||
msgid "Download folder"
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:238 src\ui-gtk\main_window.cpp:608
|
||||
msgid "Change…"
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:247
|
||||
msgid "Language"
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:252
|
||||
msgid "System language"
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:258
|
||||
msgid "The new language is used the next time OpenPU starts."
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:271 src\ui-gtk\main_window.cpp:286 src\ui-gtk\main_window.cpp:718
|
||||
msgid "Cannot save the settings"
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:279
|
||||
msgid "Check for a new version of OpenPU at startup"
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:338
|
||||
msgid "Download Peugeot head unit updates (system and navigation map) and prepare the USB stick, on Linux and Haiku.\n\nIndependent project, not affiliated with Stellantis or Peugeot."
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:344
|
||||
msgid "Source code"
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:356
|
||||
msgid "Cannot save the vehicle list"
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:370
|
||||
msgid "My vehicles"
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:372
|
||||
msgid "Add your vehicle with its VIN (17 characters, on the registration document, field E)."
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:392 src\ui-gtk\main_window.cpp:486
|
||||
msgid "Add a vehicle"
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:393 src\ui-gtk\main_window.cpp:457
|
||||
msgid "Remove"
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:394
|
||||
msgid "Check for updates"
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:425
|
||||
msgid "download not finished"
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:455
|
||||
#, qt-format
|
||||
msgid "Remove %1?"
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:456
|
||||
msgid "Downloaded files that were not written to a USB stick yet are deleted too."
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:457 src\ui-gtk\main_window.cpp:741 src\ui-gtk\main_window.cpp:982
|
||||
msgid "Cancel"
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:488
|
||||
msgid "The VIN (vehicle identification number) is written in field E of the registration document and at the bottom of the windscreen."
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:496
|
||||
msgid "VIN"
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:498
|
||||
msgid "Name"
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:503
|
||||
msgid "e.g. 208 or Family car"
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:517
|
||||
msgid "Add"
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:535
|
||||
msgid "A VIN has 17 characters and starts with VF3 or VR3."
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:541
|
||||
msgid "Checking the vehicle…"
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:558
|
||||
msgid "This vehicle is unknown to the update service."
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:562
|
||||
msgid "This vehicle has no head unit that can be updated with a USB stick."
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:604
|
||||
msgid "Download folder:"
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:617 src\ui-gtk\main_window.cpp:1118
|
||||
msgid "Installation guide"
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:651
|
||||
msgid "Looking for updates…"
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:685
|
||||
msgid "No update is available: your head unit is up to date."
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:688
|
||||
msgid "Select the updates to download:"
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:690 src\ui-gtk\main_window.cpp:803
|
||||
msgid "System (firmware)"
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:695 src\ui-gtk\main_window.cpp:807
|
||||
msgid "Navigation map"
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:736
|
||||
msgid "Not enough free space"
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:738
|
||||
#, qt-format
|
||||
msgid "%1 are needed in %2 but only %3 are free. If a previous download of these files is already in this folder, it will be resumed and may fit."
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:741
|
||||
msgid "Download anyway"
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:763
|
||||
msgid "Downloading"
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:765
|
||||
msgid "You can close the application: the download will resume where it stopped next time."
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:786 src\ui-gtk\main_window.cpp:1014
|
||||
msgid "Stop"
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:799 src\ui-gtk\main_window.cpp:849
|
||||
msgid "License"
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:799
|
||||
msgid "waiting"
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:812
|
||||
msgid "Connecting…"
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:829
|
||||
#, qt-format
|
||||
msgid "Cannot write the file: %1"
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:830
|
||||
#, qt-format
|
||||
msgid "The download failed: %1"
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:839
|
||||
msgid "Download interrupted"
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:840
|
||||
msgid "The files already downloaded are kept; start again to resume."
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:849
|
||||
msgid "done"
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:859
|
||||
#, qt-format
|
||||
msgid "Time left: %1"
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:861
|
||||
#, qt-format
|
||||
msgid "(connection lost, attempt %1)"
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:886
|
||||
msgid "Prepare the USB stick"
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:897 src\ui-gtk\main_window.cpp:970
|
||||
msgid "This USB stick is too small."
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:901
|
||||
msgid "Refresh"
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:910 src\ui-gtk\main_window.cpp:982
|
||||
msgid "Erase and write"
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:920
|
||||
msgid "Computing the required size…"
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:934 src\ui-gtk\main_window.cpp:1055
|
||||
msgid "A downloaded file is damaged"
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:934 src\ui-gtk\main_window.cpp:1055
|
||||
msgid "Download the update again."
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:941
|
||||
#, qt-format
|
||||
msgid "Plug in a USB stick of at least %1. It will be completely erased and formatted (FAT32)."
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:956
|
||||
msgid "USB drives cannot be listed: "
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:961
|
||||
msgid "too small"
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:964
|
||||
msgid "No USB stick found. Plug one in, then refresh."
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:980
|
||||
#, qt-format
|
||||
msgid "Erase %1?"
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:981
|
||||
msgid "Everything on this USB stick will be lost."
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:1000
|
||||
msgid "Writing the USB stick"
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:1001
|
||||
msgid "Do not unplug the USB stick."
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:1026 src\ui-gtk\main_window.cpp:1072
|
||||
msgid "Checking the downloaded files…"
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:1046
|
||||
msgid "Permission to format the USB stick was refused."
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:1061
|
||||
msgid "The USB stick could not be prepared"
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:1074
|
||||
msgid "Formatting the USB stick…"
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:1077
|
||||
msgid "Copying the license…"
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:1078
|
||||
msgid "Copying the update…"
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:1080
|
||||
msgid "Ejecting the USB stick…"
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:1111
|
||||
msgid "The USB stick is ready"
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:1113
|
||||
msgid "You can unplug the USB stick. With the engine running, plug it into the vehicle and follow the instructions on the screen. The installation can take a long time: do not stop the engine."
|
||||
msgstr ""
|
||||
|
||||
#: src\ui-gtk\main_window.cpp:1126
|
||||
msgid "Finish"
|
||||
msgstr ""
|
||||
+24
-1
@@ -1,10 +1,13 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// openpu-cli — command-line front-end of libopenpu.
|
||||
|
||||
#include "openpu/api_client.hpp"
|
||||
#include "openpu/app_update.hpp"
|
||||
#include "openpu/archive.hpp"
|
||||
#include "openpu/download.hpp"
|
||||
#include "openpu/storage.hpp"
|
||||
#include "openpu/usb.hpp"
|
||||
#include "openpu/version.hpp"
|
||||
#include "openpu/vin.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
@@ -30,6 +33,7 @@ extern "C" void onSignal(int /*sig*/)
|
||||
void usage()
|
||||
{
|
||||
std::cerr << "usage: openpu-cli [--verbose] <command> [args]\n"
|
||||
" openpu-cli --version\n"
|
||||
"\n"
|
||||
"commands:\n"
|
||||
" check <VIN> identify the head unit and list available updates\n"
|
||||
@@ -43,6 +47,7 @@ void usage()
|
||||
" ERASE <device>, format FAT32 and write the update\n"
|
||||
" write-dir <dir> [--license F] <archive.tar>...\n"
|
||||
" write the update into an existing directory\n"
|
||||
" app-update check for a newer OpenPU (exit status 10 if any)\n"
|
||||
" raw-devices <VIN> print the raw devices/{VIN} response\n"
|
||||
" raw-updates <VIN> print the raw getAvailableUpdate response\n"
|
||||
"\n"
|
||||
@@ -361,6 +366,22 @@ int run(std::vector<std::string> args)
|
||||
curlOptions.verbose = true;
|
||||
args.erase(args.begin());
|
||||
}
|
||||
if (args.size() == 1 && (args[0] == "--version" || args[0] == "version")) {
|
||||
std::cout << "openpu-cli " << openpu::versionDescription() << '\n';
|
||||
return 0;
|
||||
}
|
||||
if (args.size() == 1 && args[0] == "app-update") {
|
||||
auto transport = openpu::makeCurlTransport(curlOptions);
|
||||
const auto release = openpu::checkForNewerRelease(*transport, openpu::AppUpdateConfig::fromEnvironment(),
|
||||
openpu::version());
|
||||
if (!release) {
|
||||
std::cout << "OpenPU " << openpu::version() << " is up to date\n";
|
||||
return 0;
|
||||
}
|
||||
std::cout << "OpenPU " << release->version.toString() << " is available (this is " << openpu::version()
|
||||
<< "): " << release->pageUrl << '\n';
|
||||
return 10;
|
||||
}
|
||||
if (args.size() == 1 && args[0] == "usb-list")
|
||||
return cmdUsbList();
|
||||
if (args.size() < 2) {
|
||||
@@ -418,7 +439,9 @@ int main(int argc, char** argv)
|
||||
<< "): " << e.what() << '\n';
|
||||
} catch (const openpu::UsbError& e) {
|
||||
std::cerr << "\nUSB error: " << e.what() << '\n';
|
||||
} catch (const openpu::StorageError& e) {
|
||||
} catch (const openpu::NetworkError& e) {
|
||||
std::cerr << "network error: " << e.what() << '\n';
|
||||
} catch (const std::runtime_error& e) { // StorageError, ParseError, app-update errors...
|
||||
std::cerr << "error: " << e.what() << '\n';
|
||||
}
|
||||
return 1;
|
||||
|
||||
+21
-1
@@ -13,16 +13,21 @@ add_library(openpu_core STATIC
|
||||
archive.cpp
|
||||
storage.cpp
|
||||
usb.cpp
|
||||
job.cpp
|
||||
app_update.cpp
|
||||
)
|
||||
target_include_directories(openpu_core PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||
target_link_libraries(openpu_core
|
||||
PUBLIC CURL::libcurl Threads::Threads
|
||||
PRIVATE nlohmann_json::nlohmann_json LibArchive::LibArchive openpu_warnings)
|
||||
target_compile_definitions(openpu_core PRIVATE OPENPU_VERSION="${PROJECT_VERSION}")
|
||||
|
||||
# USB backend
|
||||
if(HAIKU)
|
||||
target_sources(openpu_core PRIVATE usb_haiku.cpp)
|
||||
# The disk device API (BDiskDevice, BPartition) lives in the private Storage Kit headers.
|
||||
find_path(HAIKU_PRIVATE_STORAGE DiskDevice.h PATHS /boot/system/develop/headers/private/storage REQUIRED)
|
||||
target_include_directories(openpu_core SYSTEM PRIVATE ${HAIKU_PRIVATE_STORAGE}
|
||||
/boot/system/develop/headers/private/shared)
|
||||
target_link_libraries(openpu_core PUBLIC be)
|
||||
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
find_package(PkgConfig REQUIRED)
|
||||
@@ -32,3 +37,18 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
else()
|
||||
target_sources(openpu_core PRIVATE usb_none.cpp)
|
||||
endif()
|
||||
|
||||
# Version (regenerated at every build from `git describe`, rewritten only when it changes)
|
||||
find_package(Git QUIET)
|
||||
set(OPENPU_VERSION_CPP ${CMAKE_CURRENT_BINARY_DIR}/generated/version.cpp)
|
||||
add_custom_target(openpu_version
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
-DSOURCE_DIR=${PROJECT_SOURCE_DIR}
|
||||
-DOUTPUT=${OPENPU_VERSION_CPP}
|
||||
-DVERSION=${PROJECT_VERSION}
|
||||
-DGIT_EXECUTABLE=${GIT_EXECUTABLE}
|
||||
-P ${PROJECT_SOURCE_DIR}/cmake/GitVersion.cmake
|
||||
BYPRODUCTS ${OPENPU_VERSION_CPP}
|
||||
COMMENT "Computing the build version")
|
||||
target_sources(openpu_core PRIVATE ${OPENPU_VERSION_CPP})
|
||||
add_dependencies(openpu_core openpu_version)
|
||||
@@ -1,3 +1,4 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
#include "openpu/api_client.hpp"
|
||||
|
||||
#include "openpu/vin.hpp"
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
#include "openpu/app_update.hpp"
|
||||
|
||||
#include "openpu/models.hpp"
|
||||
|
||||
#include <cstdlib>
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
namespace openpu {
|
||||
|
||||
namespace {
|
||||
|
||||
std::optional<unsigned> number(std::string_view s)
|
||||
{
|
||||
if (s.empty() || s.size() > 6)
|
||||
return std::nullopt;
|
||||
unsigned v = 0;
|
||||
for (char c : s) {
|
||||
if (c < '0' || c > '9')
|
||||
return std::nullopt;
|
||||
v = v * 10 + static_cast<unsigned>(c - '0');
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
void overrideFromEnv(std::string& field, const char* name)
|
||||
{
|
||||
const char* value = std::getenv(name); // NOLINT(concurrency-mt-unsafe): read once at startup
|
||||
if (value != nullptr && *value != '\0')
|
||||
field = value;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
std::optional<SemVer> SemVer::parse(std::string_view text)
|
||||
{
|
||||
if (!text.empty() && (text.front() == 'v' || text.front() == 'V'))
|
||||
text.remove_prefix(1);
|
||||
text = text.substr(0, text.find('+'));
|
||||
const auto dot1 = text.find('.');
|
||||
const auto dot2 = dot1 == std::string_view::npos ? dot1 : text.find('.', dot1 + 1);
|
||||
if (dot2 == std::string_view::npos)
|
||||
return std::nullopt;
|
||||
const auto major = number(text.substr(0, dot1));
|
||||
const auto minor = number(text.substr(dot1 + 1, dot2 - dot1 - 1));
|
||||
const auto patch = number(text.substr(dot2 + 1)); // "1.2.3-rc1" fails here: no pre-releases
|
||||
if (!major || !minor || !patch)
|
||||
return std::nullopt;
|
||||
return SemVer{*major, *minor, *patch};
|
||||
}
|
||||
|
||||
std::string SemVer::toString() const
|
||||
{
|
||||
return std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(patch);
|
||||
}
|
||||
|
||||
AppUpdateConfig AppUpdateConfig::fromEnvironment()
|
||||
{
|
||||
AppUpdateConfig c;
|
||||
overrideFromEnv(c.releasesUrl, "OPENPU_RELEASES_URL");
|
||||
overrideFromEnv(c.pageUrl, "OPENPU_RELEASE_PAGE_URL");
|
||||
return c;
|
||||
}
|
||||
|
||||
std::optional<AppRelease> latestRelease(std::string_view json, const AppUpdateConfig& config)
|
||||
{
|
||||
const auto doc = nlohmann::json::parse(json, nullptr, false);
|
||||
if (doc.is_discarded() || !doc.is_array())
|
||||
throw ParseError("unexpected release list");
|
||||
const auto text = [](const nlohmann::json& o, const char* key) {
|
||||
auto it = o.find(key);
|
||||
return it != o.end() && it->is_string() ? it->get<std::string>() : std::string();
|
||||
};
|
||||
const auto flag = [](const nlohmann::json& o, const char* key) {
|
||||
auto it = o.find(key);
|
||||
return it != o.end() && it->is_boolean() && it->get<bool>();
|
||||
};
|
||||
std::optional<AppRelease> best;
|
||||
for (const auto& item : doc) {
|
||||
if (!item.is_object() || flag(item, "draft") || flag(item, "prerelease"))
|
||||
continue;
|
||||
// Releases carry "tag_name"; plain tags carry "name".
|
||||
const bool isRelease = item.contains("tag_name");
|
||||
const std::string tag = text(item, isRelease ? "tag_name" : "name");
|
||||
if (tag.empty() || tag.front() != 'v')
|
||||
continue;
|
||||
const auto v = SemVer::parse(tag);
|
||||
if (!v || (best && !(best->version < *v)))
|
||||
continue;
|
||||
AppRelease r;
|
||||
r.version = *v;
|
||||
r.tag = tag;
|
||||
r.pageUrl = text(item, "html_url");
|
||||
if (r.pageUrl.empty()) {
|
||||
r.pageUrl = config.pageUrl;
|
||||
const auto pos = r.pageUrl.find("{tag}");
|
||||
if (pos != std::string::npos)
|
||||
r.pageUrl.replace(pos, 5, tag);
|
||||
}
|
||||
r.notes = text(item, isRelease ? "body" : "message");
|
||||
best = std::move(r);
|
||||
}
|
||||
return best;
|
||||
}
|
||||
|
||||
std::optional<AppRelease> checkForNewerRelease(Transport& transport, const AppUpdateConfig& config,
|
||||
std::string_view currentVersion)
|
||||
{
|
||||
const auto current = SemVer::parse(currentVersion);
|
||||
if (!current)
|
||||
throw std::runtime_error("invalid current version");
|
||||
HttpRequest req;
|
||||
req.url = config.releasesUrl;
|
||||
req.headers.emplace_back("Accept", "application/vnd.github+json, application/json");
|
||||
req.stallTimeout = std::chrono::seconds(20);
|
||||
const HttpResponse r = transport.perform(req);
|
||||
if (r.status != 200)
|
||||
throw std::runtime_error("release server answered HTTP " + std::to_string(r.status));
|
||||
auto latest = latestRelease(r.body, config);
|
||||
if (latest && *current < latest->version)
|
||||
return latest;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
} // namespace openpu
|
||||
+12
-3
@@ -1,3 +1,4 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
#include "openpu/archive.hpp"
|
||||
|
||||
#include <archive.h>
|
||||
@@ -185,13 +186,21 @@ std::uint64_t tarPayloadSize(const fs::path& path)
|
||||
return total;
|
||||
}
|
||||
|
||||
void extractTar(const fs::path& path, const fs::path& destination, const ArchiveProgressCallback& onProgress,
|
||||
void extractTar(const fs::path& path, const fs::path& requestedDestination, const ArchiveProgressCallback& onProgress,
|
||||
const CancelToken* cancel)
|
||||
{
|
||||
std::error_code ec;
|
||||
fs::create_directories(destination, ec);
|
||||
fs::create_directories(requestedDestination, ec);
|
||||
if (ec)
|
||||
throw ArchiveError(ArchiveError::Kind::Io, "cannot create " + destination.string() + ": " + ec.message());
|
||||
throw ArchiveError(ArchiveError::Kind::Io,
|
||||
"cannot create " + requestedDestination.string() + ": " + ec.message());
|
||||
// ARCHIVE_EXTRACT_SECURE_SYMLINKS rejects a symlink anywhere in the target path, including the
|
||||
// destination itself (e.g. /tmp is a symlink on Haiku). Resolve the destination first so that
|
||||
// only links *inside* it are refused.
|
||||
const fs::path destination = fs::canonical(requestedDestination, ec);
|
||||
if (ec)
|
||||
throw ArchiveError(ArchiveError::Kind::Io,
|
||||
"cannot resolve " + requestedDestination.string() + ": " + ec.message());
|
||||
|
||||
ReadPtr a = openTar(path);
|
||||
WritePtr w(archive_write_disk_new());
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
#include "openpu/http.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
@@ -5,9 +6,8 @@
|
||||
#include <curl/curl.h>
|
||||
#include <mutex>
|
||||
|
||||
#ifndef OPENPU_VERSION
|
||||
#define OPENPU_VERSION "dev"
|
||||
#endif
|
||||
#include "openpu/version.hpp"
|
||||
|
||||
|
||||
namespace openpu {
|
||||
|
||||
@@ -123,7 +123,7 @@ public:
|
||||
{
|
||||
globalInit();
|
||||
if (options_.userAgent.empty())
|
||||
options_.userAgent = std::string("OpenPU/") + OPENPU_VERSION;
|
||||
options_.userAgent = std::string("OpenPU/") + version();
|
||||
}
|
||||
|
||||
HttpResponse perform(const HttpRequest& request) override
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
#include "openpu/download.hpp"
|
||||
|
||||
#include <cerrno>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
#include "openpu/http.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
#pragma once
|
||||
|
||||
#include "openpu/http.hpp"
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
#pragma once
|
||||
|
||||
#include "openpu/http.hpp"
|
||||
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
namespace openpu {
|
||||
|
||||
/// MAJOR.MINOR.PATCH, ordered numerically.
|
||||
struct SemVer {
|
||||
unsigned major = 0;
|
||||
unsigned minor = 0;
|
||||
unsigned patch = 0;
|
||||
|
||||
/// Accepts "1.2.3" and "v1.2.3"; build metadata ("+3.gabc") is ignored. Pre-releases are rejected.
|
||||
static std::optional<SemVer> parse(std::string_view text);
|
||||
std::string toString() const;
|
||||
|
||||
friend bool operator<(const SemVer& a, const SemVer& b)
|
||||
{
|
||||
if (a.major != b.major)
|
||||
return a.major < b.major;
|
||||
if (a.minor != b.minor)
|
||||
return a.minor < b.minor;
|
||||
return a.patch < b.patch;
|
||||
}
|
||||
friend bool operator==(const SemVer& a, const SemVer& b)
|
||||
{
|
||||
return a.major == b.major && a.minor == b.minor && a.patch == b.patch;
|
||||
}
|
||||
};
|
||||
|
||||
/// Where new OpenPU versions are published: the GitHub releases of the project.
|
||||
/// A Gitea/GitHub `/tags` list is understood too (OPENPU_RELEASES_URL may point to one).
|
||||
struct AppUpdateConfig {
|
||||
std::string releasesUrl = "https://api.github.com/repos/yann64/openpu/releases";
|
||||
/// Page opened in the browser when the answer gives none; "{tag}" is replaced by the tag name.
|
||||
std::string pageUrl = "https://github.com/yann64/openpu/releases/tag/{tag}";
|
||||
|
||||
/// Defaults overridden by OPENPU_RELEASES_URL and OPENPU_RELEASE_PAGE_URL when set.
|
||||
static AppUpdateConfig fromEnvironment();
|
||||
};
|
||||
|
||||
struct AppRelease {
|
||||
SemVer version;
|
||||
std::string tag;
|
||||
std::string pageUrl;
|
||||
std::string notes; ///< release notes (or annotated tag message)
|
||||
};
|
||||
|
||||
/// Highest vX.Y.Z release of a GitHub/Gitea `/releases` list (drafts and pre-releases skipped) or
|
||||
/// of a `/tags` list (nullopt if none). Throws ParseError.
|
||||
std::optional<AppRelease> latestRelease(std::string_view json, const AppUpdateConfig& config);
|
||||
|
||||
/// Newest published release if it is newer than `currentVersion`, nullopt when up to date.
|
||||
/// Throws NetworkError, or std::runtime_error for an unexpected answer.
|
||||
std::optional<AppRelease> checkForNewerRelease(Transport& transport, const AppUpdateConfig& config,
|
||||
std::string_view currentVersion);
|
||||
|
||||
} // namespace openpu
|
||||
@@ -1,3 +1,4 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
#pragma once
|
||||
|
||||
#include "openpu/cancel.hpp"
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
#pragma once
|
||||
|
||||
#include <atomic>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
#pragma once
|
||||
|
||||
#include "openpu/cancel.hpp"
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
#pragma once
|
||||
|
||||
#include <chrono>
|
||||
#include <cstdint>
|
||||
#include <cstdio>
|
||||
#include <string>
|
||||
|
||||
namespace openpu {
|
||||
|
||||
/// "8.39 GB" (decimal units, as storage vendors and the official app use).
|
||||
inline std::string formatSize(std::uint64_t bytes)
|
||||
{
|
||||
const char* units[] = {"B", "KB", "MB", "GB", "TB"};
|
||||
auto value = static_cast<double>(bytes);
|
||||
std::size_t unit = 0;
|
||||
while (value >= 1000.0 && unit + 1 < sizeof units / sizeof units[0]) {
|
||||
value /= 1000.0;
|
||||
++unit;
|
||||
}
|
||||
char buf[32];
|
||||
(void)std::snprintf(buf, sizeof buf, unit == 0 ? "%.0f %s" : "%.2f %s", value, units[unit]);
|
||||
return buf;
|
||||
}
|
||||
|
||||
/// "1:02:03" or "02:03".
|
||||
inline std::string formatDuration(std::chrono::seconds s)
|
||||
{
|
||||
const auto total = static_cast<long long>(s.count());
|
||||
char buf[32];
|
||||
if (total >= 3600)
|
||||
(void)std::snprintf(buf, sizeof buf, "%lld:%02lld:%02lld", total / 3600, (total / 60) % 60, total % 60);
|
||||
else
|
||||
(void)std::snprintf(buf, sizeof buf, "%02lld:%02lld", total / 60, total % 60);
|
||||
return buf;
|
||||
}
|
||||
|
||||
} // namespace openpu
|
||||
@@ -1,3 +1,4 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
#pragma once
|
||||
|
||||
#include <chrono>
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
#pragma once
|
||||
|
||||
#include "openpu/download.hpp"
|
||||
#include "openpu/models.hpp"
|
||||
#include "openpu/usb.hpp"
|
||||
|
||||
#include <filesystem>
|
||||
#include <functional>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
namespace openpu {
|
||||
|
||||
/// URL of the installation guide (PDF) for a guide key such as "path_guide_rcc".
|
||||
/// `language` is an ISO 639-1 code; French and English are known, anything else gives English.
|
||||
std::string guideUrl(std::string_view guideKey, std::string_view language);
|
||||
|
||||
/// Two-letter language of the user session (LANGUAGE / LC_ALL / LC_MESSAGES / LANG), "en" by default.
|
||||
std::string systemLanguage();
|
||||
|
||||
/// What to download for one vehicle.
|
||||
struct DownloadPlan {
|
||||
std::optional<UpdateInfo> firmware;
|
||||
std::optional<UpdateInfo> map;
|
||||
std::filesystem::path dir;
|
||||
|
||||
/// Bytes still to download (announced sizes minus partial files already in `dir`), +10 %.
|
||||
/// Partial files are matched by name, so this needs the names (see resolveNames()).
|
||||
std::uint64_t requiredSpace() const;
|
||||
/// Total announced size.
|
||||
std::uint64_t totalSize() const;
|
||||
};
|
||||
|
||||
struct DownloadedFiles {
|
||||
std::optional<std::filesystem::path> license;
|
||||
std::optional<std::filesystem::path> firmware;
|
||||
std::optional<std::filesystem::path> map;
|
||||
|
||||
/// Write plan for the stick: license (with firmware only), firmware archive, then map archive.
|
||||
UsbWritePlan writePlan() const;
|
||||
/// Removes every file of the set (after a successful copy, or when the user gives up).
|
||||
void remove() const;
|
||||
};
|
||||
|
||||
enum class DownloadItem { License, Firmware, Map };
|
||||
|
||||
struct JobProgress {
|
||||
DownloadItem item = DownloadItem::Firmware;
|
||||
DownloadProgress progress;
|
||||
};
|
||||
using JobProgressCallback = std::function<void(const JobProgress&)>;
|
||||
|
||||
/// Official order: license (firmware only), firmware, map. Partial files are resumed.
|
||||
DownloadedFiles downloadUpdates(Downloader& downloader, const DownloadPlan& plan, const JobProgressCallback& onProgress = {},
|
||||
const CancelToken* cancel = nullptr);
|
||||
|
||||
} // namespace openpu
|
||||
@@ -1,3 +1,4 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
#pragma once
|
||||
|
||||
#include "openpu/models.hpp"
|
||||
@@ -74,6 +75,7 @@ struct PendingDownload {
|
||||
struct Settings {
|
||||
std::string language; ///< empty: follow the system locale
|
||||
std::filesystem::path downloadDir; ///< empty: paths::defaultDownloadDir()
|
||||
bool checkAppUpdates = true; ///< look for a newer OpenPU at startup
|
||||
std::optional<PendingDownload> pending;
|
||||
|
||||
std::filesystem::path effectiveDownloadDir() const;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
#pragma once
|
||||
|
||||
#include "openpu/cancel.hpp"
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
#pragma once
|
||||
|
||||
namespace openpu {
|
||||
|
||||
/// Release version, "MAJOR.MINOR.PATCH" (CMake project version, tagged vMAJOR.MINOR.PATCH in git).
|
||||
const char* version() noexcept;
|
||||
|
||||
/// Build description: the version, plus "+<commits>.g<hash>[.dirty]" when not built from the tag.
|
||||
const char* versionDescription() noexcept;
|
||||
|
||||
} // namespace openpu
|
||||
@@ -1,3 +1,4 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
@@ -0,0 +1,130 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
#include "openpu/job.hpp"
|
||||
|
||||
#include <cctype>
|
||||
#include <cstdlib>
|
||||
#include <system_error>
|
||||
|
||||
namespace openpu {
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
namespace {
|
||||
|
||||
struct GuideLinks {
|
||||
const char* nac;
|
||||
const char* rcc;
|
||||
const char* aio;
|
||||
};
|
||||
|
||||
// From the official application's translations (dist/ovip-ui/assets/i18n/{fr,en}.json).
|
||||
constexpr GuideLinks kFrench{
|
||||
"https://www.peugeot.fr/content/dam/peugeot/master/media/manual/1/fr/map-software-nac-fr.632350.pdf",
|
||||
"https://www.peugeot.fr/content/dam/peugeot/master/media/manual/1/fr/map-software-rcc-fr.632352.pdf",
|
||||
"https://www.peugeot.fr/content/dam/peugeot/master/media/manual/1/fr/map-software-iao-fr.793298.pdf",
|
||||
};
|
||||
constexpr GuideLinks kEnglish{
|
||||
"https://www.peugeot.co.uk/content/dam/peugeot/master/media/manual/1/en/map-software-nac-en.632380.pdf",
|
||||
"https://www.peugeot.co.uk/content/dam/peugeot/master/media/manual/1/en/map-software-rcc-en.632382.pdf",
|
||||
"https://www.peugeot.co.uk/content/dam/peugeot/master/media/manual/1/en/map-software-iao-es.793301.pdf",
|
||||
};
|
||||
constexpr const char* kCronyGuide = "https://www.stellantis.com/";
|
||||
|
||||
std::uint64_t sizeOf(const fs::path& p)
|
||||
{
|
||||
std::error_code ec;
|
||||
const auto s = fs::file_size(p, ec);
|
||||
return ec ? 0 : static_cast<std::uint64_t>(s);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
std::string guideUrl(std::string_view key, std::string_view language)
|
||||
{
|
||||
const GuideLinks& links = language == "fr" ? kFrench : kEnglish;
|
||||
if (key == "path_guide_rcc")
|
||||
return links.rcc;
|
||||
if (key == "path_guide_aio")
|
||||
return links.aio;
|
||||
if (key.substr(0, 16) == "path_guide_wave_")
|
||||
return links.nac;
|
||||
if (key.substr(0, 17) == "path_guide_crony_")
|
||||
return kCronyGuide;
|
||||
return {};
|
||||
}
|
||||
|
||||
std::string systemLanguage()
|
||||
{
|
||||
for (const char* var : {"LANGUAGE", "LC_ALL", "LC_MESSAGES", "LANG"}) {
|
||||
const char* v = std::getenv(var); // NOLINT(concurrency-mt-unsafe)
|
||||
if (v == nullptr || *v == '\0')
|
||||
continue;
|
||||
std::string s(v);
|
||||
if (s == "C" || s == "POSIX" || s.size() < 2)
|
||||
continue;
|
||||
std::string lang;
|
||||
for (char c : s.substr(0, 2))
|
||||
lang.push_back(static_cast<char>(std::tolower(static_cast<unsigned char>(c))));
|
||||
return lang;
|
||||
}
|
||||
return "en";
|
||||
}
|
||||
|
||||
std::uint64_t DownloadPlan::totalSize() const
|
||||
{
|
||||
return (firmware ? firmware->size : 0) + (map ? map->size : 0);
|
||||
}
|
||||
|
||||
std::uint64_t DownloadPlan::requiredSpace() const
|
||||
{
|
||||
return withMargin(totalSize());
|
||||
}
|
||||
|
||||
UsbWritePlan DownloadedFiles::writePlan() const
|
||||
{
|
||||
UsbWritePlan plan;
|
||||
if (firmware) {
|
||||
plan.license = license;
|
||||
plan.archives.push_back(*firmware);
|
||||
}
|
||||
if (map)
|
||||
plan.archives.push_back(*map);
|
||||
return plan;
|
||||
}
|
||||
|
||||
void DownloadedFiles::remove() const
|
||||
{
|
||||
std::error_code ec;
|
||||
for (const auto& f : {license, firmware, map})
|
||||
if (f)
|
||||
fs::remove(*f, ec);
|
||||
}
|
||||
|
||||
DownloadedFiles downloadUpdates(Downloader& downloader, const DownloadPlan& plan, const JobProgressCallback& onProgress,
|
||||
const CancelToken* cancel)
|
||||
{
|
||||
DownloadedFiles files;
|
||||
auto forward = [&](DownloadItem item) {
|
||||
return [&onProgress, item](const DownloadProgress& p) {
|
||||
if (onProgress)
|
||||
onProgress(JobProgress{item, p});
|
||||
};
|
||||
};
|
||||
if (plan.firmware) {
|
||||
if (!plan.firmware->licenseUrl.empty()) {
|
||||
const auto lic = downloader.downloadSmall(plan.firmware->licenseUrl, plan.dir, std::nullopt, cancel);
|
||||
files.license = lic.file;
|
||||
if (onProgress) {
|
||||
DownloadProgress p;
|
||||
p.total = p.done = sizeOf(lic.file);
|
||||
onProgress(JobProgress{DownloadItem::License, p});
|
||||
}
|
||||
}
|
||||
files.firmware = downloader.downloadResumable(plan.firmware->url, plan.dir, forward(DownloadItem::Firmware), cancel).file;
|
||||
}
|
||||
if (plan.map)
|
||||
files.map = downloader.downloadResumable(plan.map->url, plan.dir, forward(DownloadItem::Map), cancel).file;
|
||||
return files;
|
||||
}
|
||||
|
||||
} // namespace openpu
|
||||
@@ -1,3 +1,4 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
#include "openpu/models.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
#include "openpu/storage.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
@@ -15,7 +16,7 @@
|
||||
namespace openpu {
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
using json = nlohmann::json;
|
||||
using json = nlohmann::ordered_json; // keep the user's vehicle order
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -244,6 +245,8 @@ Settings Settings::load(const fs::path& file)
|
||||
const json doc = parseJson(readFile(file), file.string());
|
||||
s.language = str(doc, "language");
|
||||
s.downloadDir = str(doc, "downloadPath");
|
||||
if (auto it = doc.find("checkAppUpdates"); it != doc.end() && it->is_boolean())
|
||||
s.checkAppUpdates = it->get<bool>();
|
||||
auto p = doc.find("pendingDownload");
|
||||
if (p != doc.end() && p->is_object() && !str(*p, "vin").empty()) {
|
||||
PendingDownload d;
|
||||
@@ -267,6 +270,7 @@ void Settings::save(const fs::path& file) const
|
||||
doc["language"] = language;
|
||||
if (!downloadDir.empty())
|
||||
doc["downloadPath"] = downloadDir.string();
|
||||
doc["checkAppUpdates"] = checkAppUpdates;
|
||||
if (pending) {
|
||||
doc["pendingDownload"] = {
|
||||
{"vin", pending->vin},
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
#include "openpu/usb.hpp"
|
||||
|
||||
#include "openpu/archive.hpp"
|
||||
|
||||
@@ -0,0 +1,266 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Haiku USB backend: enumeration, FAT32 formatting, mounting and ejecting through the Storage Kit
|
||||
// disk device API (BDiskDeviceRoster / BDiskDevice / BPartition), the same API DriveSetup uses.
|
||||
// Haiku is single-user, so no authorisation step is involved.
|
||||
|
||||
#include "openpu/usb.hpp"
|
||||
|
||||
#include <DiskDevice.h>
|
||||
#include <DiskDeviceRoster.h>
|
||||
#include <DiskDeviceTypes.h>
|
||||
#include <Partition.h>
|
||||
#include <Path.h>
|
||||
#include <String.h>
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
|
||||
namespace openpu {
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
namespace {
|
||||
|
||||
constexpr off_t kPartitionOffset = off_t{1024} * 1024; // 1 MiB, like the Linux backend
|
||||
// Partition type as named by the "intel" partitioning add-on (MBR type 0x0c, as on Linux).
|
||||
// Not kPartitionTypeFAT32: that one is the *file system* name ("FAT32 File System").
|
||||
constexpr const char* kMbrTypeFat32Lba = "FAT 32-bit, LBA-mapped";
|
||||
// The intel add-on rejects a NULL parameter string when the job runs; DriveSetup always sends this.
|
||||
constexpr const char* kMbrChildParameters = "active false\n";
|
||||
|
||||
std::string statusText(status_t s)
|
||||
{
|
||||
return std::strerror(s); // NOLINT(concurrency-mt-unsafe): Haiku's strerror is thread-safe
|
||||
}
|
||||
|
||||
[[noreturn]] void fail(const std::string& what, status_t status)
|
||||
{
|
||||
throw UsbError(UsbError::Kind::Failed, what + ": " + statusText(status));
|
||||
}
|
||||
|
||||
/// Step tracing on stderr when OPENPU_DEBUG is set (diagnosing disk device jobs).
|
||||
void trace(const std::string& step)
|
||||
{
|
||||
static const bool enabled = std::getenv("OPENPU_DEBUG") != nullptr; // NOLINT(concurrency-mt-unsafe)
|
||||
if (enabled)
|
||||
(void)std::fprintf(stderr, "[usb_haiku] %s\n", step.c_str());
|
||||
}
|
||||
|
||||
bool startsWith(const char* s, const char* prefix)
|
||||
{
|
||||
return s != nullptr && std::strncmp(s, prefix, std::strlen(prefix)) == 0;
|
||||
}
|
||||
|
||||
/// Calls `fn` for the device itself and every partition below it.
|
||||
template <typename F>
|
||||
void forEachPartition(BPartition* p, F&& fn)
|
||||
{
|
||||
fn(p);
|
||||
for (int32 i = 0; i < p->CountChildren(); ++i)
|
||||
forEachPartition(p->ChildAt(i), fn);
|
||||
}
|
||||
|
||||
bool hostsBootVolume(BDiskDevice& device)
|
||||
{
|
||||
bool boot = false;
|
||||
forEachPartition(&device, [&](BPartition* p) {
|
||||
BPath mp;
|
||||
if (p->IsMounted() && p->GetMountPoint(&mp) == B_OK && std::strcmp(mp.Path(), "/boot") == 0)
|
||||
boot = true;
|
||||
});
|
||||
return boot;
|
||||
}
|
||||
|
||||
partition_id parseId(const std::string& id)
|
||||
{
|
||||
try {
|
||||
return static_cast<partition_id>(std::stoi(id));
|
||||
} catch (const std::exception&) {
|
||||
throw UsbError(UsbError::Kind::Failed, "invalid drive id " + id);
|
||||
}
|
||||
}
|
||||
|
||||
/// Disk systems are looked up by short name on some Haiku versions and by "pretty" name on others.
|
||||
status_t initialize(BPartition* p, const char* shortName, const char* prettyName, const char* name,
|
||||
const char* parameters)
|
||||
{
|
||||
status_t s = p->Initialize(shortName, name, parameters);
|
||||
if (s != B_OK)
|
||||
s = p->Initialize(prettyName, name, parameters);
|
||||
return s;
|
||||
}
|
||||
|
||||
class HaikuUsbBackend final : public UsbBackend {
|
||||
public:
|
||||
std::vector<UsbDrive> list() override
|
||||
{
|
||||
std::vector<UsbDrive> out;
|
||||
BDiskDeviceRoster roster;
|
||||
BDiskDevice device;
|
||||
roster.RewindDevices();
|
||||
while (roster.GetNextDevice(&device) == B_OK) {
|
||||
BPath path;
|
||||
if (device.GetPath(&path) != B_OK || !startsWith(path.Path(), "/dev/disk/usb/"))
|
||||
continue;
|
||||
if (!device.HasMedia() || device.IsReadOnlyMedia() || device.Size() <= 0 || hostsBootVolume(device))
|
||||
continue;
|
||||
UsbDrive d;
|
||||
d.id = std::to_string(device.ID());
|
||||
d.device = path.Path();
|
||||
d.size = static_cast<std::uint64_t>(device.Size());
|
||||
if (device.Name() != nullptr)
|
||||
d.model = device.Name();
|
||||
forEachPartition(&device, [&](BPartition* p) {
|
||||
if (d.label.empty() && p->ContentType() != nullptr)
|
||||
d.label = p->ContentName().String();
|
||||
BPath mp;
|
||||
if (p->IsMounted() && p->GetMountPoint(&mp) == B_OK)
|
||||
d.mountPoints.emplace_back(mp.Path());
|
||||
});
|
||||
out.push_back(std::move(d));
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
fs::path formatFat32(const UsbDrive& drive, const std::string& label) override
|
||||
{
|
||||
const partition_id id = parseId(drive.id);
|
||||
BDiskDeviceRoster roster;
|
||||
BDiskDevice device;
|
||||
status_t s = roster.GetDeviceWithID(id, &device);
|
||||
if (s != B_OK)
|
||||
fail("USB drive " + drive.device + " not found", s);
|
||||
BPath path;
|
||||
if (device.GetPath(&path) != B_OK || !startsWith(path.Path(), "/dev/disk/usb/") || hostsBootVolume(device))
|
||||
throw UsbError(UsbError::Kind::Failed, drive.device + " is not a removable USB drive");
|
||||
|
||||
trace("unmount");
|
||||
unmountAll(device);
|
||||
|
||||
const bool hasMbr = device.ContentType() != nullptr && std::strcmp(device.ContentType(), kPartitionTypeIntel) == 0;
|
||||
trace(std::string("content type: ") + (device.ContentType() != nullptr ? device.ContentType() : "(none)"));
|
||||
if (device.ContentType() != nullptr && !hasMbr) {
|
||||
// Other content (GPT, a file system without partition table...): erase it in its own
|
||||
// transaction. Uninitialize + Initialize in one transaction hangs the disk device
|
||||
// manager on Haiku R1/beta6.
|
||||
if ((s = device.PrepareModifications()) != B_OK)
|
||||
fail("cannot modify " + drive.device, s);
|
||||
if ((s = device.Uninitialize()) != B_OK || (s = device.CommitModifications()) != B_OK) {
|
||||
device.CancelModifications();
|
||||
fail("cannot erase " + drive.device, s);
|
||||
}
|
||||
if ((s = roster.GetDeviceWithID(id, &device)) != B_OK)
|
||||
fail("USB drive " + drive.device + " not found", s);
|
||||
}
|
||||
|
||||
if (hasMbr && device.CountChildren() > 0) {
|
||||
// Keep the existing MBR and drop its partitions (Uninitialize would hang, see above).
|
||||
// Own transaction too: freed space is not reusable within the same transaction.
|
||||
if ((s = device.PrepareModifications()) != B_OK)
|
||||
fail("cannot modify " + drive.device, s);
|
||||
for (int32 i = device.CountChildren() - 1; i >= 0 && s == B_OK; --i) {
|
||||
trace("delete partition " + std::to_string(i));
|
||||
s = device.DeleteChild(i);
|
||||
}
|
||||
if (s != B_OK || (s = device.CommitModifications()) != B_OK) {
|
||||
device.CancelModifications();
|
||||
fail("cannot delete the existing partitions", s);
|
||||
}
|
||||
if ((s = roster.GetDeviceWithID(id, &device)) != B_OK)
|
||||
fail("USB drive " + drive.device + " not found", s);
|
||||
}
|
||||
|
||||
trace("prepare modifications");
|
||||
if ((s = device.PrepareModifications()) != B_OK)
|
||||
fail("cannot modify " + drive.device, s);
|
||||
try {
|
||||
if (!hasMbr) {
|
||||
trace("initialize intel");
|
||||
if ((s = initialize(&device, "intel", kPartitionTypeIntel, nullptr, nullptr)) != B_OK)
|
||||
fail("cannot create the MBR partition table", s);
|
||||
}
|
||||
|
||||
off_t start = kPartitionOffset;
|
||||
off_t size = device.Size() - start;
|
||||
BString name;
|
||||
if ((s = device.ValidateCreateChild(&start, &size, kMbrTypeFat32Lba, &name, kMbrChildParameters)) != B_OK)
|
||||
fail("cannot create the FAT32 partition", s);
|
||||
trace("create child at " + std::to_string(start) + " size " + std::to_string(size));
|
||||
if ((s = device.CreateChild(start, size, kMbrTypeFat32Lba, nullptr, kMbrChildParameters)) != B_OK)
|
||||
fail("cannot create the FAT32 partition", s);
|
||||
trace("commit partition table");
|
||||
if ((s = device.CommitModifications()) != B_OK)
|
||||
fail("cannot write the partition table to " + drive.device, s);
|
||||
} catch (...) {
|
||||
device.CancelModifications();
|
||||
throw;
|
||||
}
|
||||
|
||||
// Format in a separate transaction: initializing a partition created in the same
|
||||
// transaction fails when the job runs ("Invalid Argument").
|
||||
if ((s = roster.GetDeviceWithID(id, &device)) != B_OK || device.CountChildren() == 0)
|
||||
fail("the new partition is not visible", s != B_OK ? s : B_ENTRY_NOT_FOUND);
|
||||
if ((s = device.PrepareModifications()) != B_OK)
|
||||
fail("cannot modify " + drive.device, s);
|
||||
try {
|
||||
trace("initialize fat");
|
||||
// No parameters: the FAT driver picks FAT32 for volumes this size (checked by the e2e test).
|
||||
if ((s = initialize(device.ChildAt(0), "fat", "FAT32 File System", label.c_str(), nullptr)) != B_OK)
|
||||
fail("cannot format the FAT32 partition", s);
|
||||
trace("commit format");
|
||||
if ((s = device.CommitModifications()) != B_OK)
|
||||
fail("cannot format " + drive.device, s);
|
||||
} catch (...) {
|
||||
device.CancelModifications();
|
||||
throw;
|
||||
}
|
||||
|
||||
// Mount the new file system (re-read the device: the committed state is a new snapshot).
|
||||
if ((s = roster.GetDeviceWithID(id, &device)) != B_OK || device.CountChildren() == 0)
|
||||
fail("the new partition is not visible", s != B_OK ? s : B_ENTRY_NOT_FOUND);
|
||||
BPartition* part = device.ChildAt(0);
|
||||
if (!part->IsMounted() && (s = part->Mount()) != B_OK)
|
||||
fail("cannot mount the new file system", s);
|
||||
BPath mountPoint;
|
||||
if ((s = part->GetMountPoint(&mountPoint)) != B_OK)
|
||||
fail("cannot locate the mount point", s);
|
||||
return mountPoint.Path();
|
||||
}
|
||||
|
||||
void eject(const UsbDrive& drive) override
|
||||
{
|
||||
BDiskDeviceRoster roster;
|
||||
BDiskDevice device;
|
||||
if (roster.GetDeviceWithID(parseId(drive.id), &device) != B_OK)
|
||||
return; // already gone
|
||||
unmountAll(device); // flushes the FAT
|
||||
// Not every USB mass-storage device supports the eject command; unmounting is enough then.
|
||||
(void)device.Eject(true);
|
||||
}
|
||||
|
||||
private:
|
||||
static void unmountAll(BDiskDevice& device)
|
||||
{
|
||||
status_t failure = B_OK;
|
||||
forEachPartition(&device, [&](BPartition* p) {
|
||||
if (p->IsMounted()) {
|
||||
const status_t s = p->Unmount();
|
||||
if (s != B_OK)
|
||||
failure = s;
|
||||
}
|
||||
});
|
||||
if (failure != B_OK)
|
||||
throw UsbError(UsbError::Kind::Busy, "cannot unmount the USB drive: " + statusText(failure));
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
std::unique_ptr<UsbBackend> makeUsbBackend()
|
||||
{
|
||||
return std::make_unique<HaikuUsbBackend>();
|
||||
}
|
||||
|
||||
} // namespace openpu
|
||||
@@ -1,3 +1,4 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Fallback for platforms without a USB backend: listing and formatting are unavailable,
|
||||
// but writePayload() still works on an already prepared stick.
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// UDisks2 backend (Linux): enumeration, FAT32 formatting, mounting and ejecting over D-Bus.
|
||||
// Authorisation is delegated to polkit, so no root privileges are needed in a desktop session.
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
#include "openpu/vin.hpp"
|
||||
|
||||
#include <cctype>
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_check_modules(GTKMM REQUIRED IMPORTED_TARGET gtkmm-4.0>=4.10)
|
||||
include(GNUInstallDirs)
|
||||
|
||||
add_executable(openpu
|
||||
main.cpp
|
||||
main_window.cpp
|
||||
)
|
||||
target_link_libraries(openpu PRIVATE openpu_core PkgConfig::GTKMM openpu_warnings)
|
||||
target_compile_definitions(openpu PRIVATE
|
||||
GETTEXT_PACKAGE="openpu"
|
||||
OPENPU_LOCALEDIR="${CMAKE_INSTALL_FULL_LOCALEDIR}")
|
||||
# gtkmm headers trigger -Wshadow/-Wconversion noise we cannot fix.
|
||||
target_compile_options(openpu PRIVATE -Wno-shadow -Wno-conversion)
|
||||
|
||||
install(TARGETS openpu RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
install(FILES io.github.openpu.OpenPU.desktop DESTINATION ${CMAKE_INSTALL_DATADIR}/applications)
|
||||
@@ -0,0 +1,12 @@
|
||||
[Desktop Entry]
|
||||
Type=Application
|
||||
Name=OpenPU
|
||||
GenericName=Head unit updates
|
||||
GenericName[fr]=Mises à jour de l'autoradio
|
||||
Comment=Download firmware and map updates for Peugeot head units and prepare the USB stick
|
||||
Comment[fr]=Télécharger les mises à jour système et cartographie des autoradios Peugeot et préparer la clé USB
|
||||
Exec=openpu
|
||||
Icon=io.github.openpu.OpenPU
|
||||
Terminal=false
|
||||
Categories=Utility;GTK;
|
||||
Keywords=Peugeot;NAC;RCC;GPS;map;firmware;USB;
|
||||
@@ -0,0 +1,30 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
#include "main_window.hpp"
|
||||
|
||||
#include "openpu/storage.hpp"
|
||||
|
||||
#include <clocale>
|
||||
#include <cstdlib>
|
||||
#include <glibmm/i18n.h>
|
||||
#include <gtkmm/application.h>
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
// A language chosen in the settings overrides the session language (gettext reads LANGUAGE).
|
||||
try {
|
||||
const auto settings = openpu::Settings::load(openpu::paths::configDir() / "config.json");
|
||||
if (!settings.language.empty())
|
||||
(void)setenv("LANGUAGE", settings.language.c_str(), 1); // NOLINT(concurrency-mt-unsafe): no thread yet
|
||||
} catch (const openpu::StorageError&) {
|
||||
// dismissed: the window reports unreadable settings itself
|
||||
}
|
||||
(void)std::setlocale(LC_ALL, ""); // NOLINT(concurrency-mt-unsafe): no thread yet
|
||||
// OPENPU_LOCALEDIR lets a build-tree binary find its translations.
|
||||
const char* localeDir = std::getenv("OPENPU_LOCALEDIR"); // NOLINT(concurrency-mt-unsafe)
|
||||
bindtextdomain(GETTEXT_PACKAGE, localeDir != nullptr ? localeDir : OPENPU_LOCALEDIR);
|
||||
bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
|
||||
textdomain(GETTEXT_PACKAGE);
|
||||
|
||||
auto app = Gtk::Application::create("io.github.openpu.OpenPU");
|
||||
return app->make_window_and_run<openpu::gtk::MainWindow>(argc, argv);
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,141 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
#pragma once
|
||||
|
||||
#include "ui_queue.hpp"
|
||||
|
||||
#include "openpu/api_client.hpp"
|
||||
#include "openpu/app_update.hpp"
|
||||
#include "openpu/job.hpp"
|
||||
#include "openpu/storage.hpp"
|
||||
#include "openpu/usb.hpp"
|
||||
|
||||
#include <gtkmm.h>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <thread>
|
||||
|
||||
namespace openpu::gtk {
|
||||
|
||||
class MainWindow : public Gtk::ApplicationWindow {
|
||||
public:
|
||||
MainWindow();
|
||||
~MainWindow() override;
|
||||
MainWindow(const MainWindow&) = delete;
|
||||
MainWindow& operator=(const MainWindow&) = delete;
|
||||
|
||||
private:
|
||||
// pages
|
||||
void buildVehiclesPage();
|
||||
void buildAddPage();
|
||||
void buildUpdatesPage();
|
||||
void buildDownloadPage();
|
||||
void buildUsbPage();
|
||||
void buildWritePage();
|
||||
void buildDonePage();
|
||||
void show(const char* page);
|
||||
|
||||
// vehicles
|
||||
void refreshVehicles();
|
||||
std::optional<Vehicle> selectedVehicle() const;
|
||||
void onAddVehicle();
|
||||
void onRemoveVehicle();
|
||||
void onCheckUpdates();
|
||||
|
||||
// updates / download
|
||||
void showUpdates(const AvailableUpdates& updates);
|
||||
void onChooseFolder();
|
||||
void onStartDownload();
|
||||
void startDownload(const DownloadPlan& plan);
|
||||
void onDownloadProgress(const JobProgress& p);
|
||||
void onDownloaded(const DownloadedFiles& files);
|
||||
|
||||
// usb
|
||||
void enterUsbPage();
|
||||
void refreshDrives();
|
||||
void onPrepareUsb();
|
||||
void startWrite(const UsbDrive& drive);
|
||||
void onWriteProgress(const UsbProgress& p);
|
||||
void onWritten();
|
||||
|
||||
// helpers
|
||||
template <typename F>
|
||||
void runAsync(F&& work);
|
||||
void joinWorker();
|
||||
void showError(const Glib::ustring& title, const Glib::ustring& detail);
|
||||
void showAbout();
|
||||
void showPreferences();
|
||||
void checkAppUpdate(bool manual);
|
||||
void offerAppUpdate(const AppRelease& release);
|
||||
void saveVehicles();
|
||||
void updateDownloadDirLabel();
|
||||
std::string language() const;
|
||||
|
||||
UiQueue ui_;
|
||||
std::unique_ptr<Transport> transport_;
|
||||
std::unique_ptr<ApiClient> api_;
|
||||
std::unique_ptr<UsbBackend> usb_;
|
||||
VehicleStore store_;
|
||||
Settings settings_;
|
||||
std::filesystem::path settingsFile_;
|
||||
std::thread worker_;
|
||||
std::thread updateThread_; // OpenPU new-version check, independent of the main flow
|
||||
bool updateCheckRunning_ = false;
|
||||
CancelToken cancel_;
|
||||
|
||||
// flow state
|
||||
std::optional<Vehicle> current_;
|
||||
AvailableUpdates updates_;
|
||||
DownloadedFiles files_;
|
||||
std::vector<UsbDrive> drives_;
|
||||
std::uint64_t payload_ = 0;
|
||||
|
||||
// widgets
|
||||
Gtk::HeaderBar header_;
|
||||
Gtk::Button back_;
|
||||
Gtk::MenuButton menu_;
|
||||
Gtk::Label* prefsDirLabel_ = nullptr; // download folder shown in the open preferences window
|
||||
Gtk::Stack stack_;
|
||||
|
||||
Gtk::Box vehiclesPage_{Gtk::Orientation::VERTICAL, 12};
|
||||
Gtk::ListBox vehicleList_;
|
||||
Gtk::Label vehiclesEmpty_;
|
||||
Gtk::Button addButton_, removeButton_, checkButton_;
|
||||
|
||||
Gtk::Box addPage_{Gtk::Orientation::VERTICAL, 12};
|
||||
Gtk::Entry vinEntry_, nameEntry_;
|
||||
Gtk::Label addStatus_;
|
||||
Gtk::Spinner addSpinner_;
|
||||
Gtk::Button addConfirm_;
|
||||
|
||||
Gtk::Box updatesPage_{Gtk::Orientation::VERTICAL, 12};
|
||||
Gtk::Label updatesTitle_, updatesStatus_;
|
||||
Gtk::Spinner updatesSpinner_;
|
||||
Gtk::CheckButton firmwareCheck_, mapCheck_;
|
||||
Gtk::Label downloadDirLabel_;
|
||||
Gtk::Button chooseDir_, downloadButton_, guideButton_;
|
||||
|
||||
Gtk::Box downloadPage_{Gtk::Orientation::VERTICAL, 12};
|
||||
Gtk::Label downloadTitle_;
|
||||
Gtk::Label licenseLabel_, firmwareLabel_, mapLabel_;
|
||||
Gtk::ProgressBar firmwareBar_, mapBar_;
|
||||
Gtk::Label etaLabel_;
|
||||
Gtk::Button cancelDownload_;
|
||||
|
||||
Gtk::Box usbPage_{Gtk::Orientation::VERTICAL, 12};
|
||||
Gtk::Label usbInfo_;
|
||||
Gtk::DropDown driveDrop_;
|
||||
Glib::RefPtr<Gtk::StringList> driveModel_;
|
||||
Gtk::Button refreshDrives_, prepareButton_;
|
||||
Gtk::Label usbStatus_;
|
||||
|
||||
Gtk::Box writePage_{Gtk::Orientation::VERTICAL, 12};
|
||||
Gtk::Label writeStep_, writeDetail_;
|
||||
Gtk::ProgressBar writeBar_;
|
||||
Gtk::Button cancelWrite_;
|
||||
|
||||
Gtk::Box donePage_{Gtk::Orientation::VERTICAL, 12};
|
||||
Gtk::Label doneText_;
|
||||
Gtk::Button doneGuide_, doneButton_;
|
||||
};
|
||||
|
||||
} // namespace openpu::gtk
|
||||
@@ -0,0 +1,43 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
#pragma once
|
||||
|
||||
#include <deque>
|
||||
#include <functional>
|
||||
#include <glibmm/dispatcher.h>
|
||||
#include <mutex>
|
||||
|
||||
namespace openpu::gtk {
|
||||
|
||||
/// Runs closures posted from worker threads on the GTK main loop.
|
||||
/// Must be constructed on the main thread (Glib::Dispatcher requirement).
|
||||
class UiQueue {
|
||||
public:
|
||||
UiQueue() { dispatcher_.connect([this] { drain(); }); }
|
||||
|
||||
void post(std::function<void()> fn)
|
||||
{
|
||||
{
|
||||
std::scoped_lock lock(mutex_);
|
||||
queue_.push_back(std::move(fn));
|
||||
}
|
||||
dispatcher_.emit();
|
||||
}
|
||||
|
||||
private:
|
||||
void drain()
|
||||
{
|
||||
std::deque<std::function<void()>> local;
|
||||
{
|
||||
std::scoped_lock lock(mutex_);
|
||||
local.swap(queue_);
|
||||
}
|
||||
for (auto& fn : local)
|
||||
fn();
|
||||
}
|
||||
|
||||
Glib::Dispatcher dispatcher_;
|
||||
std::mutex mutex_;
|
||||
std::deque<std::function<void()>> queue_;
|
||||
};
|
||||
|
||||
} // namespace openpu::gtk
|
||||
@@ -10,11 +10,15 @@ add_executable(openpu_tests
|
||||
test_archive.cpp
|
||||
test_storage.cpp
|
||||
test_usb.cpp
|
||||
test_app_update.cpp
|
||||
)
|
||||
find_package(LibArchive REQUIRED)
|
||||
target_link_libraries(openpu_tests PRIVATE openpu_core openpu_warnings LibArchive::LibArchive)
|
||||
if(TARGET doctest::doctest)
|
||||
target_link_libraries(openpu_tests PRIVATE doctest::doctest)
|
||||
else()
|
||||
# Bundled single header (third_party/doctest, MIT) when the system has no doctest package.
|
||||
target_include_directories(openpu_tests SYSTEM PRIVATE ${PROJECT_SOURCE_DIR}/third_party)
|
||||
endif()
|
||||
target_compile_definitions(openpu_tests PRIVATE OPENPU_FIXTURES_DIR="${CMAKE_CURRENT_SOURCE_DIR}/fixtures")
|
||||
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
|
||||
#include <doctest/doctest.h>
|
||||
@@ -1,3 +1,4 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
#include "openpu/api_client.hpp"
|
||||
|
||||
#include <deque>
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
#include "openpu/app_update.hpp"
|
||||
#include "openpu/models.hpp"
|
||||
#include "openpu/version.hpp"
|
||||
|
||||
#include <doctest/doctest.h>
|
||||
|
||||
using namespace openpu;
|
||||
|
||||
namespace {
|
||||
|
||||
class OneShot final : public Transport {
|
||||
public:
|
||||
HttpResponse response;
|
||||
std::string url;
|
||||
HttpResponse perform(const HttpRequest& req) override
|
||||
{
|
||||
url = req.url;
|
||||
return response;
|
||||
}
|
||||
};
|
||||
|
||||
const char* const kTags = R"([
|
||||
{"name":"v0.1.0","message":"OpenPU 0.1.0\n\nfirst"},
|
||||
{"name":"v0.10.0","message":"OpenPU 0.10.0"},
|
||||
{"name":"v0.2.0","message":"OpenPU 0.2.0"},
|
||||
{"name":"v1.0.0-rc1","message":"pre-release, ignored"},
|
||||
{"name":"experiment","message":"not a version"}
|
||||
])";
|
||||
|
||||
} // namespace
|
||||
|
||||
TEST_CASE("semantic versions")
|
||||
{
|
||||
CHECK(SemVer::parse("1.2.3").value() == SemVer{1, 2, 3});
|
||||
CHECK(SemVer::parse("v0.10.0").value() == SemVer{0, 10, 0});
|
||||
CHECK(SemVer::parse("0.2.0+3.g1a2b3c4.dirty").value() == SemVer{0, 2, 0});
|
||||
CHECK_FALSE(SemVer::parse("1.2").has_value());
|
||||
CHECK_FALSE(SemVer::parse("1.2.3-rc1").has_value());
|
||||
CHECK_FALSE(SemVer::parse("a.b.c").has_value());
|
||||
CHECK(SemVer{0, 9, 9} < SemVer{0, 10, 0}); // numeric, not lexical
|
||||
CHECK(SemVer{1, 0, 0}.toString() == "1.0.0");
|
||||
// The build's own version must be valid, or the update check could never work.
|
||||
CHECK(SemVer::parse(version()).has_value());
|
||||
CHECK(SemVer::parse(versionDescription()).has_value());
|
||||
}
|
||||
|
||||
TEST_CASE("latest release is the highest vX.Y.Z tag")
|
||||
{
|
||||
AppUpdateConfig cfg;
|
||||
cfg.pageUrl = "https://example.test/releases/tag/{tag}";
|
||||
const auto r = latestRelease(kTags, cfg);
|
||||
REQUIRE(r.has_value());
|
||||
CHECK(r->tag == "v0.10.0");
|
||||
CHECK(r->pageUrl == "https://example.test/releases/tag/v0.10.0");
|
||||
CHECK(r->notes == "OpenPU 0.10.0");
|
||||
CHECK_FALSE(latestRelease("[]", cfg).has_value());
|
||||
CHECK_THROWS_AS(latestRelease("{}", cfg), ParseError);
|
||||
}
|
||||
|
||||
TEST_CASE("GitHub releases: html_url and body, drafts and pre-releases skipped")
|
||||
{
|
||||
const char* releases = R"([
|
||||
{"tag_name":"v0.3.0","draft":true,"prerelease":false,"html_url":"https://gh/d","body":"draft"},
|
||||
{"tag_name":"v0.2.1","draft":false,"prerelease":true,"html_url":"https://gh/p","body":"pre"},
|
||||
{"tag_name":"v0.2.0","draft":false,"prerelease":false,"html_url":"https://gh/r/v0.2.0","body":"notes"},
|
||||
{"tag_name":"v0.1.0","draft":false,"prerelease":false,"html_url":"https://gh/r/v0.1.0","body":"old"}
|
||||
])";
|
||||
const auto r = latestRelease(releases, AppUpdateConfig{});
|
||||
REQUIRE(r.has_value());
|
||||
CHECK(r->tag == "v0.2.0");
|
||||
CHECK(r->pageUrl == "https://gh/r/v0.2.0");
|
||||
CHECK(r->notes == "notes");
|
||||
}
|
||||
|
||||
TEST_CASE("newer release detection")
|
||||
{
|
||||
OneShot t;
|
||||
t.response.status = 200;
|
||||
t.response.body = kTags;
|
||||
AppUpdateConfig cfg;
|
||||
cfg.releasesUrl = "https://example.test/tags";
|
||||
const auto newer = checkForNewerRelease(t, cfg, "0.2.0");
|
||||
REQUIRE(newer.has_value());
|
||||
CHECK(newer->version == SemVer{0, 10, 0});
|
||||
CHECK(t.url == "https://example.test/tags");
|
||||
CHECK_FALSE(checkForNewerRelease(t, cfg, "0.10.0").has_value());
|
||||
CHECK_FALSE(checkForNewerRelease(t, cfg, "1.0.0").has_value());
|
||||
t.response.status = 404;
|
||||
CHECK_THROWS(checkForNewerRelease(t, cfg, "0.1.0"));
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
#include "openpu/archive.hpp"
|
||||
|
||||
#include "test_util.hpp"
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
#include "openpu/download.hpp"
|
||||
|
||||
#include "test_util.hpp"
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
#include "openpu/http.hpp"
|
||||
|
||||
#include <doctest/doctest.h>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
#include "openpu/models.hpp"
|
||||
|
||||
#include <doctest/doctest.h>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
#include "openpu/storage.hpp"
|
||||
|
||||
#include "test_util.hpp"
|
||||
@@ -91,6 +92,11 @@ TEST_CASE("settings round trip")
|
||||
CHECK(r.pending->firmware);
|
||||
CHECK_FALSE(r.pending->map);
|
||||
CHECK(r.pending->licenseFile == "license_X.key");
|
||||
CHECK(r.checkAppUpdates); // default
|
||||
|
||||
s.checkAppUpdates = false;
|
||||
s.save(file);
|
||||
CHECK_FALSE(Settings::load(file).checkAppUpdates);
|
||||
}
|
||||
|
||||
TEST_CASE("XDG paths")
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
#include "openpu/archive.hpp"
|
||||
#include "openpu/usb.hpp"
|
||||
|
||||
@@ -150,3 +151,31 @@ TEST_CASE("drive description")
|
||||
d.size = 32000000000ULL;
|
||||
CHECK(d.description() == "SanDisk Ultra (/dev/sdb, 32.0 GB)");
|
||||
}
|
||||
|
||||
#include "openpu/job.hpp"
|
||||
|
||||
TEST_CASE("installation guide links")
|
||||
{
|
||||
CHECK(guideUrl("path_guide_rcc", "fr").find("map-software-rcc-fr") != std::string::npos);
|
||||
CHECK(guideUrl("path_guide_wave_4", "fr").find("map-software-nac-fr") != std::string::npos);
|
||||
CHECK(guideUrl("path_guide_wave_default", "de").find("map-software-nac-en") != std::string::npos);
|
||||
CHECK(guideUrl("path_guide_aio", "en").find("map-software-iao") != std::string::npos);
|
||||
CHECK(guideUrl("path_guide_crony_2", "fr") == "https://www.stellantis.com/");
|
||||
CHECK(guideUrl("", "fr").empty());
|
||||
}
|
||||
|
||||
TEST_CASE("downloaded files give the write plan in the official order")
|
||||
{
|
||||
DownloadedFiles f;
|
||||
f.license = fs::path("/dl/license_X.key");
|
||||
f.firmware = fs::path("/dl/fw.tar");
|
||||
f.map = fs::path("/dl/map.tar");
|
||||
auto plan = f.writePlan();
|
||||
REQUIRE(plan.license.has_value());
|
||||
CHECK(plan.archives == std::vector<fs::path>{"/dl/fw.tar", "/dl/map.tar"});
|
||||
|
||||
f.firmware.reset(); // map only: the license is not copied
|
||||
plan = f.writePlan();
|
||||
CHECK_FALSE(plan.license.has_value());
|
||||
CHECK(plan.archives == std::vector<fs::path>{"/dl/map.tar"});
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
#pragma once
|
||||
|
||||
#include <atomic>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
#include "openpu/vin.hpp"
|
||||
|
||||
#include <doctest/doctest.h>
|
||||
|
||||
Vendored
+21
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016-2023 Viktor Kirilov
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
doctest 2.4.12 single header (https://github.com/doctest/doctest), MIT license.
|
||||
Used by the unit tests only when no system doctest package is found (e.g. Haiku).
|
||||
Vendored
+7134
File diff suppressed because it is too large.
Load diff
@@ -1,3 +1,4 @@
|
||||
# SPDX-License-Identifier: MIT
|
||||
"""Minimal read-only asar extractor: copies selected files out of an asar archive.
|
||||
|
||||
usage: python -I asar_extract.py <app.asar> <out_dir> [prefix ...]
|
||||
|
||||
+15
-1
@@ -1,4 +1,5 @@
|
||||
#!/bin/sh
|
||||
# SPDX-License-Identifier: MIT
|
||||
# Full local quality gate: build + tests, ASan/UBSan tests, valgrind, clang-tidy, cppcheck.
|
||||
# usage: tools/check.sh [build-root] (default: ~/build/openpu-check)
|
||||
set -eu
|
||||
@@ -27,10 +28,23 @@ fi
|
||||
if command -v clang-tidy >/dev/null; then
|
||||
step "clang-tidy"
|
||||
# Only our sources; compile_commands.json comes from the debug build.
|
||||
find "$SRC/src" -name '*.cpp' -print0 |
|
||||
# Only files of this build: usb_haiku.cpp / usb_none.cpp are not compiled on Linux.
|
||||
find "$SRC/src" -name '*.cpp' -not -path '*/ui-*' -not -name 'usb_haiku.cpp' -not -name 'usb_none.cpp' -print0 |
|
||||
xargs -0 clang-tidy -p "$OUT/debug" --quiet --warnings-as-errors='*'
|
||||
fi
|
||||
|
||||
if pkg-config --exists gtkmm-4.0; then
|
||||
step "GTK user interface build"
|
||||
cmake -S "$SRC" -B "$OUT/gtk" -G Ninja -DCMAKE_BUILD_TYPE=Debug -DOPENPU_WERROR=ON -DOPENPU_UI_GTK=ON \
|
||||
-DOPENPU_BUILD_TESTS=OFF >/dev/null
|
||||
cmake --build "$OUT/gtk"
|
||||
if command -v clang-tidy >/dev/null; then
|
||||
step "clang-tidy (GTK user interface)"
|
||||
find "$SRC/src/ui-gtk" -name '*.cpp' -print0 |
|
||||
xargs -0 clang-tidy -p "$OUT/gtk" --quiet --warnings-as-errors='*'
|
||||
fi
|
||||
fi
|
||||
|
||||
if command -v cppcheck >/dev/null; then
|
||||
step "cppcheck"
|
||||
cppcheck --quiet --error-exitcode=1 --std=c++17 --enable=warning,performance,portability \
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#!/bin/sh
|
||||
# SPDX-License-Identifier: MIT
|
||||
# DEVELOPMENT ONLY (WSL / test VM): lets the invoking user run UDisks2 operations
|
||||
# (loop-setup, format, mount, power-off) without a polkit agent, so that the end-to-end
|
||||
# USB tests can run headless. Never install this on a real desktop machine.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#!/bin/sh
|
||||
# SPDX-License-Identifier: MIT
|
||||
# End-to-end USB test on Linux without a real stick: a sparse disk image is attached as a loop
|
||||
# device through UDisks2, `openpu-cli write-usb` formats and fills it, then the result is checked
|
||||
# with sfdisk / fsck.fat / mtools. Needs udisks2, dosfstools, mtools and, in a session without a
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
# SPDX-License-Identifier: MIT
|
||||
"""Fallback string extractor when xgettext is not available.
|
||||
|
||||
Collects _("...") calls (with adjacent literal concatenation) from C++ sources and writes a
|
||||
gettext template. Prefer `cmake --build <dir> --target pot` (xgettext) when gettext is installed.
|
||||
|
||||
usage: python3 tools/extract_strings.py po/openpu.pot src/ui-gtk/main_window.cpp ...
|
||||
"""
|
||||
import re
|
||||
import sys
|
||||
|
||||
CALL = re.compile(r'\b_\(\s*((?:"(?:[^"\\]|\\.)*"\s*)+)\)', re.S)
|
||||
LITERAL = re.compile(r'"((?:[^"\\]|\\.)*)"')
|
||||
|
||||
|
||||
def main():
|
||||
out, *sources = sys.argv[1:]
|
||||
seen = {}
|
||||
for path in sources:
|
||||
text = open(path, encoding="utf-8").read()
|
||||
for m in CALL.finditer(text):
|
||||
msgid = "".join(LITERAL.findall(m.group(1)))
|
||||
line = text.count("\n", 0, m.start()) + 1
|
||||
seen.setdefault(msgid, []).append(f"{path}:{line}")
|
||||
with open(out, "w", encoding="utf-8", newline="\n") as f:
|
||||
f.write('msgid ""\nmsgstr ""\n"Project-Id-Version: openpu\\n"\n'
|
||||
'"Content-Type: text/plain; charset=UTF-8\\n"\n"Content-Transfer-Encoding: 8bit\\n"\n')
|
||||
for msgid, refs in seen.items():
|
||||
f.write("\n#: " + " ".join(refs) + "\n")
|
||||
if "%1" in msgid:
|
||||
f.write("#, qt-format\n")
|
||||
f.write(f'msgid "{msgid}"\nmsgstr ""\n')
|
||||
print(f"{len(seen)} strings -> {out}")
|
||||
|
||||
|
||||
main()
|
||||
@@ -0,0 +1,88 @@
|
||||
#!/bin/sh
|
||||
# SPDX-License-Identifier: MIT
|
||||
# Haiku R1/beta6 x86_64 development VM under QEMU (Linux / WSL2, KVM when available).
|
||||
#
|
||||
# tools/haiku-vm.sh fetch download + verify the official anyboot image
|
||||
# tools/haiku-vm.sh install boot the image with an empty 20 GB disk (run the Installer, see docs)
|
||||
# tools/haiku-vm.sh start boot the installed system (headless, VNC on 127.0.0.1:5901)
|
||||
# tools/haiku-vm.sh stop ACPI power-off (hard kill after 60 s)
|
||||
# tools/haiku-vm.sh ssh [cmd] ssh into the VM (port 2222, user "user")
|
||||
# tools/haiku-vm.sh status
|
||||
#
|
||||
# A 16 GB sparse raw image is attached as a USB mass-storage device ("the stick"), so the
|
||||
# Haiku USB backend can be tested end to end; inspect it from Linux with mtools.
|
||||
# The VM is driven with tools/qmp.py (screenshots, clicks, typing) through $VM_DIR/qmp.sock.
|
||||
set -eu
|
||||
|
||||
VM_DIR=${OPENPU_VM_DIR:-$HOME/openpu-vm}
|
||||
RELEASE=r1beta6
|
||||
ISO=$VM_DIR/haiku-$RELEASE-x86_64-anyboot.iso
|
||||
ISO_SHA256=bb7743474fd175aea511be1799764ba054465285bbdf54c4722ca61d1fb4f5c9
|
||||
ISO_URL=https://mirrors.rit.edu/haiku/$RELEASE/haiku-$RELEASE-x86_64-anyboot.iso
|
||||
DISK=$VM_DIR/haiku.qcow2
|
||||
STICK=$VM_DIR/haiku-usb.img
|
||||
QMP=$VM_DIR/qmp.sock
|
||||
PIDFILE=$VM_DIR/qemu.pid
|
||||
SSH_PORT=${OPENPU_VM_SSH_PORT:-2222}
|
||||
|
||||
mkdir -p "$VM_DIR"
|
||||
|
||||
running() { [ -f "$PIDFILE" ] && kill -0 "$(cat "$PIDFILE")" 2>/dev/null; }
|
||||
|
||||
qemu() {
|
||||
accel="-accel tcg"
|
||||
[ -w /dev/kvm ] && accel="-accel kvm -cpu host"
|
||||
[ -f "$STICK" ] || truncate -s 16G "$STICK"
|
||||
# shellcheck disable=SC2086
|
||||
qemu-system-x86_64 $accel -machine q35 -smp 4 -m 4096 \
|
||||
-drive file="$DISK",format=qcow2,if=none,id=hd0 -device ide-hd,drive=hd0,bus=ide.0 \
|
||||
-nic user,model=e1000,hostfwd=tcp:127.0.0.1:"$SSH_PORT"-:22 \
|
||||
-device qemu-xhci,id=xhci -device usb-tablet,bus=xhci.0 \
|
||||
-drive file="$STICK",format=raw,if=none,id=stick \
|
||||
-device usb-storage,bus=xhci.0,drive=stick,removable=on \
|
||||
-display none -vnc 127.0.0.1:1 \
|
||||
-qmp unix:"$QMP",server=on,wait=off \
|
||||
-daemonize -pidfile "$PIDFILE" "$@"
|
||||
}
|
||||
|
||||
case "${1:-}" in
|
||||
fetch)
|
||||
[ -f "$ISO" ] || curl -fL -o "$ISO.part" "$ISO_URL" && { [ -f "$ISO" ] || mv "$ISO.part" "$ISO"; }
|
||||
echo "$ISO_SHA256 $ISO" | sha256sum -c -
|
||||
;;
|
||||
install)
|
||||
running && { echo "VM already running" >&2; exit 1; }
|
||||
[ -f "$DISK" ] || qemu-img create -f qcow2 "$DISK" 20G
|
||||
qemu -drive file="$ISO",media=cdrom,if=none,id=cd -device ide-cd,drive=cd,bus=ide.1 -boot d
|
||||
echo "installer booted (VNC 127.0.0.1:5901, QMP $QMP)"
|
||||
;;
|
||||
start)
|
||||
running && { echo "VM already running"; exit 0; }
|
||||
qemu -boot c
|
||||
echo "VM started (VNC 127.0.0.1:5901, ssh -p $SSH_PORT user@127.0.0.1)"
|
||||
;;
|
||||
stop)
|
||||
running || { echo "VM not running"; exit 0; }
|
||||
python3 "$(dirname "$0")/qmp.py" --socket "$QMP" powerdown || true
|
||||
for _ in $(seq 60); do running || { echo "stopped"; exit 0; }; sleep 1; done
|
||||
kill "$(cat "$PIDFILE")"; echo "killed"
|
||||
;;
|
||||
ssh)
|
||||
shift
|
||||
exec ssh -p "$SSH_PORT" -i "$VM_DIR/id_ed25519" -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=ERROR \
|
||||
user@127.0.0.1 "$@"
|
||||
;;
|
||||
sync)
|
||||
# Copy the working tree (without .git) to ~/openpu in the VM.
|
||||
SRC=$(cd "$(dirname "$0")/.." && pwd)
|
||||
tar -C "$SRC" --exclude=.git -cf - . | "$0" ssh "mkdir -p openpu && tar -xf - -C openpu"
|
||||
echo "synced $SRC -> VM:~/openpu"
|
||||
;;
|
||||
status)
|
||||
running && echo "running (pid $(cat "$PIDFILE"))" || echo "stopped"
|
||||
;;
|
||||
*)
|
||||
sed -n '3,12p' "$0" >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
+174
@@ -0,0 +1,174 @@
|
||||
# SPDX-License-Identifier: MIT
|
||||
"""Drive a headless QEMU VM through QMP: screenshots, absolute clicks, typing, power-off.
|
||||
|
||||
usage: python3 tools/qmp.py [--socket PATH] COMMAND...
|
||||
shot OUT.png screenshot (PNG, no external dependency)
|
||||
click X Y [right|double] click at screen pixel X,Y (needs a usb-tablet device)
|
||||
move X Y move the pointer
|
||||
type TEXT type text with a US keyboard layout
|
||||
typefile FILE type the content of FILE (newlines press Return)
|
||||
key COMBO... press key combos, e.g. ret, tab, ctrl-alt-delete, alt-f4
|
||||
powerdown ACPI power button
|
||||
hmp COMMAND human monitor command (prints the answer)
|
||||
"""
|
||||
import json
|
||||
import os
|
||||
import socket
|
||||
import struct
|
||||
import sys
|
||||
import time
|
||||
import zlib
|
||||
|
||||
|
||||
class Qmp:
|
||||
def __init__(self, path):
|
||||
self.sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
||||
self.sock.connect(path)
|
||||
self.buf = b""
|
||||
self._read() # greeting
|
||||
self.cmd("qmp_capabilities")
|
||||
|
||||
def _read(self):
|
||||
while b"\n" not in self.buf:
|
||||
chunk = self.sock.recv(65536)
|
||||
if not chunk:
|
||||
raise RuntimeError("QMP connection closed")
|
||||
self.buf += chunk
|
||||
line, self.buf = self.buf.split(b"\n", 1)
|
||||
return json.loads(line)
|
||||
|
||||
def cmd(self, name, **args):
|
||||
self.sock.sendall(json.dumps({"execute": name, "arguments": args}).encode() + b"\n")
|
||||
while True:
|
||||
msg = self._read()
|
||||
if "return" in msg:
|
||||
return msg["return"]
|
||||
if "error" in msg:
|
||||
raise RuntimeError(f"{name}: {msg['error'].get('desc')}")
|
||||
# asynchronous events are ignored
|
||||
|
||||
|
||||
def ppm_to_png(ppm, png):
|
||||
data = open(ppm, "rb").read()
|
||||
fields, pos = [], 0
|
||||
while len(fields) < 4: # P6, width, height, maxval
|
||||
while data[pos:pos + 1].isspace():
|
||||
pos += 1
|
||||
if data[pos:pos + 1] == b"#":
|
||||
pos = data.index(b"\n", pos) + 1
|
||||
continue
|
||||
end = pos
|
||||
while not data[end:end + 1].isspace():
|
||||
end += 1
|
||||
fields.append(data[pos:end])
|
||||
pos = end
|
||||
width, height = int(fields[1]), int(fields[2])
|
||||
pixels = data[pos + 1:]
|
||||
stride = width * 3
|
||||
raw = b"".join(b"\x00" + pixels[y * stride:(y + 1) * stride] for y in range(height))
|
||||
|
||||
def chunk(kind, payload):
|
||||
body = kind + payload
|
||||
return struct.pack(">I", len(payload)) + body + struct.pack(">I", zlib.crc32(body) & 0xFFFFFFFF)
|
||||
|
||||
with open(png, "wb") as f:
|
||||
f.write(b"\x89PNG\r\n\x1a\n")
|
||||
f.write(chunk(b"IHDR", struct.pack(">IIBBBBB", width, height, 8, 2, 0, 0, 0)))
|
||||
f.write(chunk(b"IDAT", zlib.compress(raw, 6)))
|
||||
f.write(chunk(b"IEND", b""))
|
||||
return width, height
|
||||
|
||||
|
||||
def screen_size(q):
|
||||
tmp = f"/tmp/qmp-size-{os.getpid()}.ppm"
|
||||
q.cmd("screendump", filename=tmp)
|
||||
with open(tmp, "rb") as f:
|
||||
head = f.read(64).split()
|
||||
os.unlink(tmp)
|
||||
return int(head[1]), int(head[2])
|
||||
|
||||
|
||||
def move(q, x, y):
|
||||
w, h = screen_size(q)
|
||||
q.cmd("input-send-event", events=[
|
||||
{"type": "abs", "data": {"axis": "x", "value": int(x * 32767 / max(1, w - 1))}},
|
||||
{"type": "abs", "data": {"axis": "y", "value": int(y * 32767 / max(1, h - 1))}},
|
||||
])
|
||||
|
||||
|
||||
def click(q, x, y, mode="left"):
|
||||
move(q, x, y)
|
||||
button = "right" if mode == "right" else "left"
|
||||
for _ in range(2 if mode == "double" else 1):
|
||||
for down in (True, False):
|
||||
q.cmd("input-send-event", events=[{"type": "btn", "data": {"down": down, "button": button}}])
|
||||
time.sleep(0.05)
|
||||
|
||||
|
||||
SHIFTED = {"_": "minus", ":": "semicolon", "\"": "apostrophe", "<": "comma", ">": "dot", "?": "slash",
|
||||
"!": "1", "@": "2", "#": "3", "$": "4", "%": "5", "^": "6", "&": "7", "*": "8", "(": "9",
|
||||
")": "0", "+": "equal", "{": "bracket_left", "}": "bracket_right", "|": "backslash", "~": "grave_accent"}
|
||||
PLAIN = {" ": "spc", "-": "minus", ".": "dot", "/": "slash", ",": "comma", ";": "semicolon", "'": "apostrophe",
|
||||
"=": "equal", "[": "bracket_left", "]": "bracket_right", "\\": "backslash", "`": "grave_accent",
|
||||
"\n": "ret", "\t": "tab"}
|
||||
|
||||
|
||||
def keys_for(ch):
|
||||
if ch.isalpha() and ch.isascii():
|
||||
return (["shift"] if ch.isupper() else []) + [ch.lower()]
|
||||
if ch.isdigit():
|
||||
return [ch]
|
||||
if ch in PLAIN:
|
||||
return [PLAIN[ch]]
|
||||
if ch in SHIFTED:
|
||||
return ["shift", SHIFTED[ch]]
|
||||
raise ValueError(f"cannot type {ch!r}")
|
||||
|
||||
|
||||
def press(q, names):
|
||||
# send-key returns before QEMU replays the keys: wait longer than the hold time, or
|
||||
# consecutive keys overlap (and a held shift leaks into the next characters).
|
||||
q.cmd("send-key", keys=[{"type": "qcode", "data": n} for n in names], **{"hold-time": 30})
|
||||
time.sleep(0.08)
|
||||
|
||||
|
||||
def main():
|
||||
args = sys.argv[1:]
|
||||
path = os.path.expanduser("~/openpu-vm/qmp.sock")
|
||||
if args[:1] == ["--socket"]:
|
||||
path, args = args[1], args[2:]
|
||||
if not args:
|
||||
print(__doc__, file=sys.stderr)
|
||||
sys.exit(2)
|
||||
q = Qmp(path)
|
||||
cmd, rest = args[0], args[1:]
|
||||
if cmd == "shot":
|
||||
tmp = os.path.abspath(rest[0]) + ".ppm"
|
||||
q.cmd("screendump", filename=tmp)
|
||||
w, h = ppm_to_png(tmp, rest[0])
|
||||
os.unlink(tmp)
|
||||
print(f"{rest[0]} {w}x{h}")
|
||||
elif cmd == "click":
|
||||
click(q, int(rest[0]), int(rest[1]), rest[2] if len(rest) > 2 else "left")
|
||||
elif cmd == "move":
|
||||
move(q, int(rest[0]), int(rest[1]))
|
||||
elif cmd == "type":
|
||||
for ch in " ".join(rest):
|
||||
press(q, keys_for(ch))
|
||||
elif cmd == "typefile":
|
||||
with open(rest[0], encoding="utf-8") as f:
|
||||
for ch in f.read():
|
||||
press(q, keys_for(ch))
|
||||
elif cmd == "key":
|
||||
for combo in rest:
|
||||
press(q, combo.split("-"))
|
||||
elif cmd == "powerdown":
|
||||
q.cmd("system_powerdown")
|
||||
elif cmd == "hmp":
|
||||
print(q.cmd("human-monitor-command", **{"command-line": " ".join(rest)}))
|
||||
else:
|
||||
print(__doc__, file=sys.stderr)
|
||||
sys.exit(2)
|
||||
|
||||
|
||||
main()
|
||||
@@ -0,0 +1,49 @@
|
||||
#!/bin/sh
|
||||
# SPDX-License-Identifier: MIT
|
||||
# Cut a release: set project(VERSION) in CMakeLists.txt, date the "Unreleased" section of
|
||||
# CHANGELOG.md, commit, create the annotated tag vX.Y.Z, push to every remote (GitHub origin and
|
||||
# the Gitea mirror) and publish the GitHub release that the in-app update check reads.
|
||||
#
|
||||
# usage: tools/release.sh X.Y.Z [--no-push]
|
||||
set -eu
|
||||
|
||||
VERSION=${1:-}
|
||||
PUSH=1
|
||||
[ "${2:-}" = "--no-push" ] && PUSH=0
|
||||
echo "$VERSION" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+$' || { echo "usage: $0 X.Y.Z [--no-push]" >&2; exit 2; }
|
||||
|
||||
cd "$(dirname "$0")/.."
|
||||
[ -z "$(git status --porcelain)" ] || { echo "the working tree is not clean" >&2; exit 1; }
|
||||
git rev-parse -q --verify "refs/tags/v$VERSION" >/dev/null && { echo "tag v$VERSION already exists" >&2; exit 1; }
|
||||
grep -q '^## \[Unreleased\]' CHANGELOG.md || { echo "CHANGELOG.md has no [Unreleased] section" >&2; exit 1; }
|
||||
PREVIOUS=$(git describe --tags --abbrev=0 --match 'v[0-9]*' 2>/dev/null || true)
|
||||
|
||||
TODAY=$(date +%Y-%m-%d)
|
||||
sed -i "s/^project(openpu VERSION [0-9.]* /project(openpu VERSION $VERSION /" CMakeLists.txt
|
||||
grep -q "^project(openpu VERSION $VERSION " CMakeLists.txt || { echo "cannot update CMakeLists.txt" >&2; exit 1; }
|
||||
# New release section under an empty Unreleased one, and comparison links at the bottom.
|
||||
sed -i "s/^## \[Unreleased\]$/## [Unreleased]\n\n## [$VERSION] - $TODAY/" CHANGELOG.md
|
||||
sed -i "s|^\[Unreleased\]: \(.*\)/compare/v[0-9.]*\.\.\.HEAD$|[Unreleased]: \1/compare/v$VERSION...HEAD\n[$VERSION]: \1/releases/tag/v$VERSION|" CHANGELOG.md
|
||||
|
||||
git add CMakeLists.txt CHANGELOG.md
|
||||
# RELEASE_TRAILER: optional trailer lines appended to the release commit message (e.g. co-authors).
|
||||
git commit -q -m "release: v$VERSION" ${RELEASE_TRAILER:+-m "$RELEASE_TRAILER"}
|
||||
# Plain string comparison (not a regex: "[" and "." in the heading would be special).
|
||||
NOTES=$(awk -v v="$VERSION" 'index($0, "## [" v "]") == 1 {on=1; next}
|
||||
on && (index($0, "## ") == 1 || index($0, "[") == 1) {exit}
|
||||
on {print}' CHANGELOG.md | sed -e '/./,$!d')
|
||||
[ -n "$NOTES" ] || { echo "no release notes found for $VERSION in CHANGELOG.md" >&2; exit 1; }
|
||||
git tag -a "v$VERSION" -m "OpenPU $VERSION" -m "$NOTES"
|
||||
echo "tagged v$VERSION (previous: ${PREVIOUS:-none})"
|
||||
|
||||
[ "$PUSH" = 1 ] || exit 0
|
||||
for remote in $(git remote); do
|
||||
git push --follow-tags "$remote" HEAD
|
||||
done
|
||||
GH=$(command -v gh || command -v gh.exe || true)
|
||||
[ -z "$GH" ] && [ -x "/c/Program Files/GitHub CLI/gh.exe" ] && GH="/c/Program Files/GitHub CLI/gh.exe"
|
||||
if [ -n "$GH" ]; then
|
||||
printf '%s\n' "$NOTES" | "$GH" release create "v$VERSION" --verify-tag --title "OpenPU $VERSION" --notes-file -
|
||||
else
|
||||
echo "gh not found: create the GitHub release for v$VERSION by hand" >&2
|
||||
fi
|
||||
Reference in new issue
Block a user