Android: a RuStore build, without the app's own updates and the counted check
Some checks are pending
CI / check (push) Waiting to run
CI / windows-build (push) Waiting to run
CI / macos-build (push) Waiting to run

The owner puts the app in RuStore: the store updates it, and the store's build
must neither update itself nor be counted by the site. A build type «rustore»
on the same branch (not a branch to catch up each time): the release with
SELF_UPDATE off — no check of releases (the check is what the site counts
installations by), no download or install, no updates block in About, a
release kept from the site's build forgotten; its manifest drops the install
permissions and the installer's receiver. The full build only; the same
package and key, so it goes over the site's one and back with the databases.
release.sh builds it into dist-rustore and checks it asks for no install
permission; the release workflow keeps it as the run's «rustore» artifact, not
a file of the release. The site's builds are as they were.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
vrubelroman 2026-10-27 18:49:12 +03:00
parent f31023dcd7
commit dd4572fd8a
9 changed files with 73 additions and 10 deletions

View file

@ -169,6 +169,11 @@ jobs:
with:
name: android
path: androidApp/dist/*.apk
# The RuStore build: uploaded to the store by hand, not a file of the release.
- uses: actions/upload-artifact@v7
with:
name: rustore
path: androidApp/dist-rustore/*.apk
publish:
needs: [version, linux, flatpak, windows, macos, android]
@ -180,6 +185,9 @@ jobs:
with:
path: dist
merge-multiple: true
# The RuStore build stays an artifact of the run (merge-multiple brought it here).
- name: Not the store's build
run: rm -f dist/*-rustore.apk
- name: Stockfish source (GPL-3.0 source offer for the engine bundled in the Flatpak and Android)
run: packaging/stockfish.sh source dist
- name: Checksums

View file

@ -14,4 +14,5 @@
.cxx
local.properties
/dist
/dist-rustore
.env

View file

@ -147,6 +147,9 @@ android {
buildConfigField("String", "NET_NAME", "\"nn-1a298aa575a0.nnue\"")
buildConfigField("String", "NET_SHA256", "\"1a298aa575a085434d29027978dc36867fe9c5bcea9376654b7a8eba1e52dfc2\"")
buildConfigField("long", "NET_SIZE", "98511183L")
// The app checks for its releases and installs them itself (android-ui.md §25);
// the check is what the site counts installations by. Off for stores.
buildConfigField("boolean", "SELF_UPDATE", "true")
buildConfigField(
"String",
"NET_URL",
@ -182,6 +185,14 @@ android {
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
signingConfig = signingConfigs.findByName("release")
}
// RuStore (docs/decisions.md «RuStore»): the release, signed with the same key,
// without the app's own updates and the check the site counts installations by;
// the store updates it. Its manifest (src/rustore) drops the install permissions.
create("rustore") {
initWith(getByName("release"))
buildConfigField("boolean", "SELF_UPDATE", "false")
matchingFallbacks += listOf("release")
}
}
// The languages of the interface; the libraries' other translations stay out.
androidResources {
@ -229,6 +240,11 @@ tasks.named("preBuild") {
dependsOn(uniffiBindings, bundleAssets, stockfish, rodent4)
}
// RuStore gets the full build only (Stockfish inside: nothing to fetch from GitHub).
androidComponents {
beforeVariants(selector().withBuildType("rustore").withFlavor("engine" to "light")) { it.enable = false }
}
dependencies {
val composeBom = platform(libs.androidx.compose.bom)
implementation(composeBom)

View file

@ -186,8 +186,9 @@ class AppUpdates(private val context: Context, private val scope: CoroutineScope
}
val update = known()
when {
// Installed by hand from the site, or never newer than this app.
update == null || !newer(update.version) -> forgetAll()
// Installed by hand from the site, or never newer than this app; or a store's
// build put over the site's (the store updates it, a release kept is dropped).
!BuildConfig.SELF_UPDATE || update == null || !newer(update.version) -> forgetAll()
prefs.getLong(DOWNLOAD, -1L) != -1L -> watch(update, prefs.getLong(DOWNLOAD, -1L))
update.sha256.isEmpty() -> _state.value = UpdateState.Failed(update, UpdateProblem.BadRelease, null)
prefs.getString(READY, null) == update.version && apk(update).exists() -> _state.value = UpdateState.Ready(update, aborted = false)
@ -205,7 +206,7 @@ class AppUpdates(private val context: Context, private val scope: CoroutineScope
/// of the app, as the desktop does (a release out since the last check is offered at
/// once), and on return 6 h after the last answer (1 h after a failed try).
fun checkIfDue() {
if (!_auto.value || busy()) return
if (!BuildConfig.SELF_UPDATE || !_auto.value || busy()) return
val now = System.currentTimeMillis()
if (askedThisRun && (now - _lastCheck.value < RECHECK || now - prefs.getLong(LAST_ATTEMPT, 0L) < HOUR)) return
askedThisRun = true
@ -214,11 +215,13 @@ class AppUpdates(private val context: Context, private val scope: CoroutineScope
/// «Check now» (works with the automatic check off).
fun checkNow() {
if (_check.value == CheckState.Checking) return
if (!BuildConfig.SELF_UPDATE || _check.value == CheckState.Checking) return
scope.launch { runCheck(manual = true) }
}
private suspend fun runCheck(manual: Boolean) {
// A store's build never asks the site (nor counts itself there).
if (!BuildConfig.SELF_UPDATE) return
if (busy()) {
if (manual) _check.value = CheckState.Idle
return

View file

@ -86,9 +86,12 @@ fun AboutScreen(onBack: () -> Unit) {
val build = stringResource(if (BuildConfig.NET_BUILT_IN) R.string.build_full else R.string.build_light)
Text("${BuildConfig.VERSION_NAME} ${stringResource(R.string.alpha)} · $build", color = MaterialTheme.colorScheme.onSurfaceVariant)
Spacer(Modifier.height(24.dp))
// Right under the version (android-ui.md §25.5).
AboutUpdates()
Spacer(Modifier.height(24.dp))
// Right under the version (android-ui.md §25.5); a store's build is updated by
// the store.
if (BuildConfig.SELF_UPDATE) {
AboutUpdates()
Spacer(Modifier.height(24.dp))
}
Text(stringResource(R.string.about_text), style = MaterialTheme.typography.bodyLarge)
TextButton(onClick = { uri.openUri(SITE) }, contentPadding = androidx.compose.foundation.layout.PaddingValues(0.dp)) {
Text(stringResource(R.string.website))

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- The RuStore build (build.gradle.kts, buildType "rustore"): the store installs and
updates the app, so it neither installs packages nor receives the installer's answer. -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" tools:node="remove" />
<uses-permission android:name="android.permission.UPDATE_PACKAGES_WITHOUT_USER_ACTION" tools:node="remove" />
<application>
<receiver android:name=".data.InstallResult" tools:node="remove" />
</application>
</manifest>

View file

@ -2,6 +2,9 @@
# Builds the two signed release APKs into androidApp/dist:
# ChessPenguin-<version>-android.apk Stockfish built in ("full")
# ChessPenguin-<version>-android-noengine.apk Stockfish downloaded in the app ("light")
# and, apart (not a file of the release), into androidApp/dist-rustore:
# ChessPenguin-<version>-rustore.apk the full one for RuStore: no updates of its
# own, no check the site counts
# The key comes from the environment or from ~/.config/chesspenguin/android/.env.
set -euo pipefail
cd "$(dirname "$0")/.."
@ -13,15 +16,22 @@ if [[ -z "${CP_KEYSTORE:-}" && -f "${env_file}" ]]; then
set +a
fi
: "${CP_KEYSTORE:?no release key: set CP_KEYSTORE and the passwords, or CP_SIGNING_ENV}"
./gradlew --console=plain assembleFullRelease assembleLightRelease
./gradlew --console=plain assembleFullRelease assembleLightRelease assembleFullRustore
version="$(sed -n 's/^version = "\(.*\)"/\1/p' ../Cargo.toml | head -n1)"
mkdir -p dist
cp app/build/outputs/apk/full/release/app-full-release.apk "dist/ChessPenguin-${version}-android.apk"
cp app/build/outputs/apk/light/release/app-light-release.apk "dist/ChessPenguin-${version}-android-noengine.apk"
mkdir -p dist-rustore
cp app/build/outputs/apk/full/rustore/app-full-rustore.apk "dist-rustore/ChessPenguin-${version}-rustore.apk"
build_tools="$(ls -d "${ANDROID_HOME:-$HOME/Android/Sdk}"/build-tools/* | sort -V | tail -n1)"
for apk in dist/ChessPenguin-"${version}"-android*.apk; do
for apk in dist/ChessPenguin-"${version}"-android*.apk dist-rustore/ChessPenguin-"${version}"-rustore.apk; do
"${build_tools}/apksigner" verify "${apk}"
"${build_tools}/zipalign" -c -P 16 4 "${apk}"
done
(cd dist && sha256sum ChessPenguin-"${version}"-android*.apk > ChessPenguin-"${version}"-android.sha256)
ls -l dist
# The store's build asks for nothing it would not need.
if "${build_tools}/aapt2" dump permissions "dist-rustore/ChessPenguin-${version}-rustore.apk" | grep -q 'INSTALL_PACKAGES'; then
echo "the RuStore build may install packages" >&2
exit 1
fi
ls -l dist dist-rustore

View file

@ -157,3 +157,12 @@
## Ход назад — только в блице (2026-10-27)
Владелец: «для всех контролей игры с движком кроме блицов убрал кнопку отменить ход»; уточнено: кнопка «↶ Ход назад» (и Ctrl+Z) есть только в блице (3+0, 3+2, 5+0, 5+3); в рапиде, классике и игре без часов её нет (скрыта, не серая). Только компьютер; телефон не меняется.
## Сборка для RuStore (2026-10-27)
Владелец: приложение выкладывается в RuStore; в сборке для магазина не должно быть самообновления и учёта установок, а сборка для сайта остаётся как есть. Решено:
- **Не отдельная ветка**, а тип сборки `rustore` в той же основной ветке (`androidApp/app/build.gradle.kts`): копия `release` с флагом `SELF_UPDATE = false`. Ветку пришлось бы каждый раз догонять до основной; тип сборки всегда собирается из свежего кода. Сборки для сайта (`assembleFullRelease`, `assembleLightRelease`) не меняются.
- В сборке RuStore приложение **не проверяет выпуски и не обращается к сайту** (эта проверка и есть учёт установок: `/api/update` с id установки), не скачивает и не ставит обновления; в «О программе» нет блока обновлений; сохранённое ранее найденное обновление (если её поставили поверх сайтовой) забывается. Манифест `src/rustore/AndroidManifest.xml` убирает `REQUEST_INSTALL_PACKAGES`, `UPDATE_PACKAGES_WITHOUT_USER_ACTION` и приёмник ответа установщика. Обновляет приложение магазин.
- **Только полная сборка** (Stockfish внутри): лёгкая для `rustore` отключена.
- **Тот же пакет и тот же ключ**, что у сайта: одно и то же приложение, ставится поверх с сохранением баз и настроек в обе стороны.
- **Собирается на GitHub при каждом выпуске** (`androidApp/scripts/release.sh` → `androidApp/dist-rustore/ChessPenguin-<версия>-rustore.apk`): артефакт `rustore` прогона «Release», **не файл выпуска** — на сайте и в списке скачиваний его нет; в RuStore загружается вручную. Скрипт проверяет, что разрешения на установку в нём нет.

View file

@ -1844,6 +1844,8 @@
## 25. Обновление приложения (2026-10-23)
> Сборка для RuStore (`decisions.md` «Сборка для RuStore», 2026-10-27) — без всего этого раздела: проверки, карточки, листа, блока в «О программе» и разрешений на установку; обновляет магазин.
Приложение ставится не из магазина, а файлом APK с сайта или со страницы выпуска на GitHub. Чтобы человек не ходил за новой версией сам, приложение узнаёт о ней, скачивает лёгкую сборку, проверяет и передаёт Android на установку. Базы, настройки и движок при этом остаются. Проверка — запрос к сайту, который отвечает сведениями о последнем выпуске и заодно считает установки (§25.6), и сверка с `SHA256SUMS.txt`, как на компьютере (`apps/desktop/src/update.rs`). Слова тоже взяты с компьютера, где они там есть.
Решения: