fix: make RPM runtime portable on Tumbleweed
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
SHELL := /bin/bash
|
||||
PYTHON := python3
|
||||
VENV_DIR := /opt/fenris
|
||||
VENDOR_DIR := $(VENV_DIR)/vendor
|
||||
BIN_DIR := /usr/local/bin
|
||||
LIBEXEC_DIR := /usr/libexec/fenris
|
||||
UNIT_DIR := /etc/systemd/system
|
||||
@@ -57,7 +58,7 @@ check-smartctl:
|
||||
|
||||
dist/fenris-*.whl: pyproject.toml src/fenris/*.py
|
||||
@mkdir -p dist
|
||||
$(PYTHON) -m build --wheel -o dist
|
||||
$(PYTHON) -m pip wheel --no-deps --wheel-dir dist .
|
||||
|
||||
# ─── Install ────────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -71,11 +72,10 @@ install: check-python check-smartctl dist/fenris-*.whl
|
||||
@sudo groupadd -f fenris
|
||||
@sudo install -d -o root -g fenris -m 2750 $(DATA_DIR)
|
||||
|
||||
@echo "=== Installing venv with pinned dependencies ==="
|
||||
@echo "=== Installing version-neutral runtime packages ==="
|
||||
@sudo rm -rf $(VENV_DIR)
|
||||
@sudo $(PYTHON) -m venv $(VENV_DIR)
|
||||
@sudo $(VENV_DIR)/bin/pip install --upgrade pip --quiet
|
||||
@sudo $(VENV_DIR)/bin/pip install dist/fenris-*.whl --quiet
|
||||
@sudo install -d -m 0755 $(VENDOR_DIR)
|
||||
@sudo $(PYTHON) -m pip install --disable-pip-version-check --no-compile --target $(VENDOR_DIR) -r requirements.txt dist/fenris-*.whl --quiet
|
||||
|
||||
@echo "=== Installing wrapper ==="
|
||||
@sudo install -m 0755 scripts/fenris $(BIN_DIR)/fenris
|
||||
@@ -119,7 +119,7 @@ import-legacy:
|
||||
@if [ -f "$(LEGACY_HISTORY)" ]; then \
|
||||
echo "=== Detected legacy history: $(LEGACY_HISTORY) ==="; \
|
||||
echo "Running idempotent import..."; \
|
||||
$(VENV_DIR)/bin/python3 -c "import sys; sys.path.insert(0, 'src'); from fenris.legacy import import_legacy_history; from fenris.store import init_store; from pathlib import Path; conn = init_store(Path('$(DATA_DIR)/observations.db')); r = import_legacy_history(conn, Path('$(LEGACY_HISTORY)')); conn.close(); print(f' Samples imported: {r.get(\"samples_imported\", 0)}'); print(f' Hours imported: {r.get(\"hours_imported\", 0)}'); print(f' Malformed lines: {r.get(\"malformed_lines\", 0)}') if not r.get('skipped') else print(' Skipped: already imported')" || echo " Warning: import failed (non-fatal)"; \
|
||||
PYTHONPATH=$(VENDOR_DIR) $(PYTHON) -c "from fenris.legacy import import_legacy_history; from fenris.store import init_store; from pathlib import Path; conn = init_store(Path('$(DATA_DIR)/observations.db')); r = import_legacy_history(conn, Path('$(LEGACY_HISTORY)')); conn.close(); print(f' Samples imported: {r.get(\"samples_imported\", 0)}'); print(f' Hours imported: {r.get(\"hours_imported\", 0)}'); print(f' Malformed lines: {r.get(\"malformed_lines\", 0)}') if not r.get('skipped') else print(' Skipped: already imported')" || echo " Warning: import failed (non-fatal)"; \
|
||||
else \
|
||||
echo "=== No legacy history found at $(LEGACY_HISTORY) ==="; \
|
||||
fi
|
||||
@@ -131,8 +131,10 @@ upgrade: dist/fenris-*.whl
|
||||
@echo "=== Snapshotting database (IN-6) ==="
|
||||
@sudo cp $(DATA_DIR)/observations.db $(DATA_DIR)/observations.db.bak 2>/dev/null || true
|
||||
|
||||
@echo "=== Installing new wheel with pinned dependencies ==="
|
||||
@sudo $(VENV_DIR)/bin/pip install dist/fenris-*.whl --quiet
|
||||
@echo "=== Installing new version-neutral runtime packages ==="
|
||||
@sudo rm -rf $(VENDOR_DIR)
|
||||
@sudo install -d -m 0755 $(VENDOR_DIR)
|
||||
@sudo $(PYTHON) -m pip install --disable-pip-version-check --no-compile --target $(VENDOR_DIR) -r requirements.txt dist/fenris-*.whl --quiet
|
||||
|
||||
@echo "=== Syncing units against manifest ==="
|
||||
@sudo install -m 0644 units/fenris-collect.timer $(UNIT_DIR)/
|
||||
@@ -172,7 +174,7 @@ upgrade: dist/fenris-*.whl
|
||||
done
|
||||
|
||||
@echo "=== Applying forward-only schema migrations (IN-5, IN-6) ==="
|
||||
@sudo $(VENV_DIR)/bin/python3 -c "from fenris.store import migrate_to_latest; from pathlib import Path; n = migrate_to_latest(Path('$(DATA_DIR)/observations.db')); print(f' Migration steps applied: {n}') if n else print(' Schema already current')"
|
||||
@sudo env PYTHONPATH=$(VENDOR_DIR) $(PYTHON) -c "from fenris.store import migrate_to_latest; from pathlib import Path; n = migrate_to_latest(Path('$(DATA_DIR)/observations.db')); print(f' Migration steps applied: {n}') if n else print(' Schema already current')"
|
||||
|
||||
@echo "=== Upgrade complete ==="
|
||||
|
||||
@@ -237,8 +239,9 @@ FENRIS_VERSION := $(shell sed -n 's/^version = "\(.*\)"/\1/p' pyproject.toml)
|
||||
# GPG signing — packaging key UID (spec §4)
|
||||
PACKAGING_KEY ?= packaging@bongbetic.com
|
||||
|
||||
stage: dist/fenris-*.whl
|
||||
stage:
|
||||
@echo "=== Staging packaging tree (v$(FENRIS_VERSION)) ==="
|
||||
$(PYTHON) -m pip wheel --no-deps --wheel-dir dist .
|
||||
bash packaging/stage.sh "$(FENRIS_VERSION)"
|
||||
|
||||
package-deb: stage
|
||||
|
||||
Reference in New Issue
Block a user