feat: Versionsnummer auf 1.0.5 erhöht und Installationsskript aktualisiert

This commit is contained in:
2026-05-09 02:23:02 +02:00
parent 20a1a0e01a
commit b24c08ec5a
4 changed files with 33 additions and 10 deletions

View File

@@ -274,12 +274,7 @@ sudo systemctl stop picopy
So wird ein neues Release erstellt, das alle Nutzer automatisch als Update angezeigt bekommen:
**1. Versionen erhöhen**
In `app.py`:
```python
VERSION = '1.1.0' # ← neue Versionsnummer
```
**1. Version erhöhen**
In `version.txt`:
```
@@ -289,7 +284,7 @@ In `version.txt`:
**2. Committen & pushen**
```bash
git add app.py version.txt
git add version.txt
git commit -m "Release v1.1.0"
git push
```
@@ -300,7 +295,7 @@ Unter [git.leuschner.dev/Tobias/PiCopy/releases](https://git.leuschner.dev/Tobia
**Das war's.** Alle laufenden PiCopy-Instanzen erkennen das Update innerhalb von 6 Stunden automatisch und zeigen das Badge im Web-Interface an.
> **Hinweis:** `version.txt` und `app.py` müssen immer dieselbe Versionsnummer haben. Die `version.txt` ist der einzige Vergleichspunkt der Inhalt der `app.py` wird erst beim tatsächlichen Update-Install heruntergeladen.
> **Hinweis:** `version.txt` ist die Quelle der Wahrheit. `app.py` liest diese Datei beim Start und der Installer/Updater legt sie neben der App unter `/opt/picopy/version.txt` ab.
---

19
app.py
View File

@@ -18,8 +18,18 @@ from flask import Flask, jsonify, request
app = Flask(__name__)
VERSION = '1.0.3'
RAW_BASE = 'https://git.leuschner.dev/Tobias/PiCopy/raw/branch/main'
VERSION_FILE = Path(__file__).with_name('version.txt')
def load_installed_version():
try:
return VERSION_FILE.read_text(encoding='utf-8').strip() or '1.0.4'
except Exception:
return 'X.X.X'
VERSION = load_installed_version()
BASE_DIR = Path('/opt/picopy')
CONFIG_FILE = BASE_DIR / 'config.json'
@@ -1091,6 +1101,8 @@ def r_update_install():
log.info('Update wird heruntergeladen…')
req = _urlreq.urlopen(f'{RAW_BASE}/app.py', timeout=60)
new_code = req.read().decode()
vreq = _urlreq.urlopen(f'{RAW_BASE}/version.txt', timeout=10)
new_version = vreq.read().decode().strip()
# Syntax-Check bevor wir irgendetwas überschreiben
compile(new_code, 'app.py', 'exec')
@@ -1100,6 +1112,11 @@ def r_update_install():
with open(tmp, 'rb') as fh:
os.fsync(fh.fileno()) # Sicherstellen dass Daten auf der Platte sind
os.replace(str(tmp), '/opt/picopy/app.py') # Atomares Umbenennen
vtmp = Path('/opt/picopy/version.txt.tmp')
vtmp.write_text(new_version + '\n', encoding='utf-8')
with open(vtmp, 'rb') as fh:
os.fsync(fh.fileno())
os.replace(str(vtmp), '/opt/picopy/version.txt')
log.info('Update installiert starte Dienst neu…')
# Systemd startet den Dienst automatisch neu

View File

@@ -53,6 +53,17 @@ else
fi
ok "app.py installiert"
# ── Versionsdatei kopieren oder herunterladen ────────────────────────────────
if [ -f "./version.txt" ]; then
info "Lokale version.txt wird verwendet..."
cp version.txt "$INSTALL_DIR/version.txt"
else
info "version.txt wird heruntergeladen..."
curl -sSfL "$REPO_RAW/version.txt" -o "$INSTALL_DIR/version.txt" \
|| fail "Download der version.txt fehlgeschlagen. Prüfe die Internet-Verbindung."
fi
ok "version.txt installiert"
# ── Python-Umgebung ───────────────────────────────────────────────────────────
info "Python venv wird erstellt..."
python3 -m venv "$INSTALL_DIR/venv"

View File

@@ -1 +1 @@
1.0.4
1.0.5