refactor(server)!: rename archrepo to repo
The repository, its Python service, its systemd units, its token file and its environment prefix still carried the old name, which matches nothing public any more. Paths, units, user and variables now use repo: REPO_*, /etc/repo/token, /var/lib/repo, repo.service and repo-prune.timer. A server installed before this change keeps the old user, paths and token: run server/install.sh again to recreate them.
This commit is contained in:
1 parent
b689351535
commit
30cb9c9fc2
8 files changed
+80
-77
No files matched your search
+6
-6
@@ -1,4 +1,4 @@
|
||||
# archrepo — dépôt pacman auto-hébergé avec interface de publication
|
||||
# repo — dépôt pacman auto-hébergé avec interface de publication
|
||||
|
||||
Le dépôt **fws** : un dépôt Arch Linux complet (`fws.db` + `fws.files` + paquets)
|
||||
servi par Caddy, avec une petite interface web pour envoyer, lister et supprimer
|
||||
@@ -92,7 +92,7 @@ pacman -F mon-fichier # recherche par fichier (base .files)
|
||||
|
||||
### Interface web
|
||||
|
||||
`/admin/` : coller le jeton (`/etc/archrepo/token`), glisser-déposer des
|
||||
`/admin/` : coller le jeton (`/etc/repo/token`), glisser-déposer des
|
||||
`*.pkg.tar.zst`, suivre la progression, supprimer un paquet, reconstruire la base.
|
||||
Le jeton reste dans le `localStorage` du navigateur.
|
||||
|
||||
@@ -135,7 +135,7 @@ ne correspond pas.
|
||||
2. garde la version la plus récente par nom de paquet (comparaison `vercmp` de
|
||||
pacman : epoch, version, release) ;
|
||||
3. réécrit `fws.db.tar.gz` et `fws.files.tar.gz`, leurs liens `.db` / `.files`,
|
||||
et un index cache dans `/var/lib/archrepo/index.json` (évite de re-hacher tous
|
||||
et un index cache dans `/var/lib/repo/index.json` (évite de re-hacher tous
|
||||
les paquets au redémarrage).
|
||||
|
||||
À la publication, un nouveau fichier ne remplace que la version identique
|
||||
@@ -161,10 +161,10 @@ sortent simplement de la base. C'est `prune.sh` qui les efface (voir ci-dessous)
|
||||
- Les suppressions passent par `DELETE /api/packages/<fichier>`, donc `fws.db` et
|
||||
`fws.files` sont reconstruites et la version restante devient la seule servie
|
||||
aux clients.
|
||||
- `install.sh` met en place `archrepo-prune.timer` : purge au démarrage puis
|
||||
- `install.sh` met en place `repo-prune.timer` : purge au démarrage puis
|
||||
toutes les heures. Forcer une passe :
|
||||
`sudo systemctl start archrepo-prune`. Journal :
|
||||
`journalctl -u archrepo-prune`.
|
||||
`sudo systemctl start repo-prune`. Journal :
|
||||
`journalctl -u repo-prune`.
|
||||
|
||||
Le script est en bash ; la comparaison de versions est un portage de `vercmp` en
|
||||
Perl (la machine n'a ni `pacman` ni `repo-add`). Il utilise l'API, il peut donc
|
||||
|
||||
+1
-1
@@ -253,7 +253,7 @@ def scan_packages(directory: str, cache: dict[str, dict] | None = None) -> dict[
|
||||
try:
|
||||
found[name] = read_package_metadata(path, name)
|
||||
except (OSError, ValueError) as exc:
|
||||
print(f"archrepo: paquet ignoré {name} : {exc}", flush=True)
|
||||
print(f"repo: paquet ignoré {name} : {exc}", flush=True)
|
||||
return found
|
||||
|
||||
|
||||
|
||||
+14
-14
@@ -1,10 +1,10 @@
|
||||
#!/usr/bin/env python3
|
||||
"""archrepo — petit serveur pour un dépôt pacman auto-hébergé.
|
||||
"""repo — petit serveur pour un dépôt pacman auto-hébergé.
|
||||
|
||||
Gère l'interface d'administration (/admin/) et l'API JSON (/api/*) qui permet
|
||||
d'envoyer des paquets, de les supprimer et de reconstruire <repo>.db / .files.
|
||||
Les paquets et les bases eux-mêmes sont servis directement par Caddy depuis
|
||||
$ARCHREPO_ROOT/$ARCHREPO_ARCH, ce processus ne traite que l'administration.
|
||||
$REPO_ROOT/$REPO_ARCH, ce processus ne traite que l'administration.
|
||||
|
||||
Dépendances : Python >= 3.10 et les binaires zstd / xz (selon les formats reçus).
|
||||
"""
|
||||
@@ -68,15 +68,15 @@ def _split_bind(value: str) -> tuple[str, int]:
|
||||
class Config:
|
||||
def __init__(self) -> None:
|
||||
env = os.environ.get
|
||||
self.root = os.path.abspath(env("ARCHREPO_ROOT", "/var/www/fws"))
|
||||
self.arch = env("ARCHREPO_ARCH", "x86_64")
|
||||
self.name = env("ARCHREPO_NAME", "fws")
|
||||
self.root = os.path.abspath(env("REPO_ROOT", "/var/www/fws"))
|
||||
self.arch = env("REPO_ARCH", "x86_64")
|
||||
self.name = env("REPO_NAME", "fws")
|
||||
self.bind_host, self.bind_port = _split_bind(
|
||||
env("ARCHREPO_BIND", "127.0.0.1:8099")
|
||||
env("REPO_BIND", "127.0.0.1:8099")
|
||||
)
|
||||
self.token_file = env("ARCHREPO_TOKEN_FILE", "/etc/archrepo/token")
|
||||
self.state_dir = os.path.abspath(env("ARCHREPO_STATE_DIR", "/var/lib/archrepo"))
|
||||
self.max_upload = _int(env("ARCHREPO_MAX_UPLOAD"), 4 * 1024 ** 3)
|
||||
self.token_file = env("REPO_TOKEN_FILE", "/etc/repo/token")
|
||||
self.state_dir = os.path.abspath(env("REPO_STATE_DIR", "/var/lib/repo"))
|
||||
self.max_upload = _int(env("REPO_MAX_UPLOAD"), 4 * 1024 ** 3)
|
||||
self.static_dir = os.path.join(
|
||||
os.path.dirname(os.path.abspath(__file__)), "static"
|
||||
)
|
||||
@@ -125,7 +125,7 @@ class App:
|
||||
if not os.path.exists(config.db_file):
|
||||
try:
|
||||
self.rebuild()
|
||||
print("archrepo: base initiale créée", flush=True)
|
||||
print("repo: base initiale créée", flush=True)
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
|
||||
@@ -185,7 +185,7 @@ def _public(pkg: dict) -> dict:
|
||||
# --------------------------------------------------------------------------
|
||||
|
||||
class Handler(BaseHTTPRequestHandler):
|
||||
server_version = "archrepo/1.0"
|
||||
server_version = "repo/1.0"
|
||||
protocol_version = "HTTP/1.1"
|
||||
|
||||
@property
|
||||
@@ -475,7 +475,7 @@ def main() -> int:
|
||||
try:
|
||||
app = App(config)
|
||||
except RuntimeError as exc:
|
||||
print(f"archrepo: {exc}", file=sys.stderr, flush=True)
|
||||
print(f"repo: {exc}", file=sys.stderr, flush=True)
|
||||
return 1
|
||||
|
||||
server = ThreadingHTTPServer((config.bind_host, config.bind_port), Handler)
|
||||
@@ -489,7 +489,7 @@ def main() -> int:
|
||||
signal.signal(signal.SIGINT, stop)
|
||||
|
||||
print(
|
||||
f"archrepo: {config.packages_dir} — http://{config.bind_host}:"
|
||||
f"repo: {config.packages_dir} — http://{config.bind_host}:"
|
||||
f"{config.bind_port}/admin/ (dépôt {config.name}/{config.arch})",
|
||||
flush=True,
|
||||
)
|
||||
@@ -497,7 +497,7 @@ def main() -> int:
|
||||
server.serve_forever()
|
||||
finally:
|
||||
server.server_close()
|
||||
print("archrepo: arrêt", flush=True)
|
||||
print("repo: arrêt", flush=True)
|
||||
return 0
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="robots" content="noindex">
|
||||
<title>archrepo — publication de paquets</title>
|
||||
<title>repo — publication de paquets</title>
|
||||
<style>
|
||||
:root {
|
||||
--bg: #0d1117;
|
||||
@@ -110,7 +110,7 @@
|
||||
<div class="brand">
|
||||
<span class="logo">◧</span>
|
||||
<div>
|
||||
<h1 id="repo-name">archrepo</h1>
|
||||
<h1 id="repo-name">repo</h1>
|
||||
<p class="sub" id="repo-sub">dépôt pacman</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -125,7 +125,7 @@
|
||||
<button id="save-token" class="primary">Enregistrer</button>
|
||||
<button id="forget-token" class="ghost">Oublier</button>
|
||||
</div>
|
||||
<p class="hint">Le jeton se trouve sur le serveur dans <code>/etc/archrepo/token</code>. Il n'est conservé que dans ce navigateur.</p>
|
||||
<p class="hint">Le jeton se trouve sur le serveur dans <code>/etc/repo/token</code>. Il n'est conservé que dans ce navigateur.</p>
|
||||
</section>
|
||||
|
||||
<section class="card">
|
||||
@@ -165,11 +165,11 @@
|
||||
</section>
|
||||
</main>
|
||||
|
||||
<footer>archrepo — les paquets et bases sont servis par Caddy, les publications passent par cette interface.</footer>
|
||||
<footer>repo — les paquets et bases sont servis par Caddy, les publications passent par cette interface.</footer>
|
||||
<div id="toast" class="toast"></div>
|
||||
|
||||
<script>
|
||||
const TOKEN_KEY = 'archrepo.token';
|
||||
const TOKEN_KEY = 'repo.token';
|
||||
const state = {
|
||||
token: localStorage.getItem(TOKEN_KEY) || '',
|
||||
health: null,
|
||||
@@ -235,7 +235,7 @@ async function loadHealth() {
|
||||
|
||||
function renderPacmanConf() {
|
||||
const arch = (state.health && state.health.arch) || 'x86_64';
|
||||
const repo = (state.health && state.health.repo) || 'archrepo';
|
||||
const repo = (state.health && state.health.repo) || 'repo';
|
||||
const conf = `[${repo}]\nServer = ${window.location.origin}/${arch}\nSigLevel = Optional TrustAll`;
|
||||
$('pacman-conf').textContent = conf;
|
||||
}
|
||||
|
||||
+34
-31
@@ -1,34 +1,37 @@
|
||||
#!/usr/bin/env bash
|
||||
# Installe (ou met à jour) archrepo sur cette machine. Root requis.
|
||||
# Installe (ou met à jour) repo sur cette machine. Root requis.
|
||||
#
|
||||
# ./install.sh # valeurs par défaut
|
||||
# ARCHREPO_BIND=127.0.0.1:9000 ./install.sh
|
||||
# REPO_BIND=127.0.0.1:9000 ./install.sh
|
||||
#
|
||||
# Variables reconnues : ARCHREPO_ROOT, ARCHREPO_STATE_DIR, ARCHREPO_NAME,
|
||||
# ARCHREPO_ARCH, ARCHREPO_BIND, ARCHREPO_MAX_UPLOAD, ARCHREPO_USER,
|
||||
# ARCHREPO_TOKEN_FILE, ARCHREPO_UNIT, ARCHREPO_KEEP (versions gardées, 3).
|
||||
# Variables reconnues : REPO_ROOT, REPO_STATE_DIR, REPO_NAME,
|
||||
# REPO_ARCH, REPO_BIND, REPO_MAX_UPLOAD, REPO_USER,
|
||||
# REPO_TOKEN_FILE, REPO_UNIT, REPO_KEEP (versions gardées, 3).
|
||||
#
|
||||
# Caddy (Caddyfile) se règle à part, dans SON environnement : REPO_DOMAIN
|
||||
# (repo.fws-linux.org) et REPO_WEBROOT (/var/www/fws).
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
APP_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
REPO_ROOT="${ARCHREPO_ROOT:-/var/www/fws}"
|
||||
STATE_DIR="${ARCHREPO_STATE_DIR:-/var/lib/archrepo}"
|
||||
REPO_NAME="${ARCHREPO_NAME:-fws}"
|
||||
REPO_ARCH="${ARCHREPO_ARCH:-x86_64}"
|
||||
BIND="${ARCHREPO_BIND:-127.0.0.1:8099}"
|
||||
MAX_UPLOAD="${ARCHREPO_MAX_UPLOAD:-4294967296}"
|
||||
SERVICE_USER="${ARCHREPO_USER:-archrepo}"
|
||||
TOKEN_FILE="${ARCHREPO_TOKEN_FILE:-/etc/archrepo/token}"
|
||||
UNIT_FILE="${ARCHREPO_UNIT:-/etc/systemd/system/archrepo.service}"
|
||||
REPO_ROOT="${REPO_ROOT:-/var/www/fws}"
|
||||
STATE_DIR="${REPO_STATE_DIR:-/var/lib/repo}"
|
||||
REPO_NAME="${REPO_NAME:-fws}"
|
||||
REPO_ARCH="${REPO_ARCH:-x86_64}"
|
||||
BIND="${REPO_BIND:-127.0.0.1:8099}"
|
||||
MAX_UPLOAD="${REPO_MAX_UPLOAD:-4294967296}"
|
||||
SERVICE_USER="${REPO_USER:-repo}"
|
||||
TOKEN_FILE="${REPO_TOKEN_FILE:-/etc/repo/token}"
|
||||
UNIT_FILE="${REPO_UNIT:-/etc/systemd/system/repo.service}"
|
||||
SERVICE_NAME="$(basename "$UNIT_FILE" .service)"
|
||||
KEEP="${ARCHREPO_KEEP:-3}"
|
||||
KEEP="${REPO_KEEP:-3}"
|
||||
SERVICE_DIR="$(dirname "$UNIT_FILE")"
|
||||
PRUNE_UNIT="$SERVICE_DIR/$SERVICE_NAME-prune.service"
|
||||
PRUNE_NAME="$(basename "$PRUNE_UNIT" .service)"
|
||||
PRUNE_TIMER="${PRUNE_UNIT%.service}.timer"
|
||||
|
||||
if [[ $EUID -ne 0 ]]; then
|
||||
exec sudo --preserve-env=ARCHREPO_ROOT,ARCHREPO_STATE_DIR,ARCHREPO_NAME,ARCHREPO_ARCH,ARCHREPO_BIND,ARCHREPO_MAX_UPLOAD,ARCHREPO_USER,ARCHREPO_TOKEN_FILE,ARCHREPO_UNIT,ARCHREPO_KEEP \
|
||||
exec sudo --preserve-env=REPO_ROOT,REPO_STATE_DIR,REPO_NAME,REPO_ARCH,REPO_BIND,REPO_MAX_UPLOAD,REPO_USER,REPO_TOKEN_FILE,REPO_UNIT,REPO_KEEP \
|
||||
bash "$0" "$@"
|
||||
fi
|
||||
|
||||
@@ -45,7 +48,7 @@ fi
|
||||
if ! id -u "$SERVICE_USER" >/dev/null 2>&1; then
|
||||
useradd --system --user-group --home-dir "$REPO_ROOT" \
|
||||
--shell "$(command -v nologin || echo /usr/sbin/nologin)" \
|
||||
--comment "archrepo (dépôt pacman)" "$SERVICE_USER"
|
||||
--comment "repo (dépôt pacman)" "$SERVICE_USER"
|
||||
echo "✓ utilisateur système $SERVICE_USER créé"
|
||||
fi
|
||||
|
||||
@@ -70,12 +73,12 @@ fi
|
||||
# --- service systemd --------------------------------------------------------
|
||||
if [[ "$APP_DIR" == /root/* ]]; then
|
||||
echo "⚠ l'application est dans /root : le service (ProtectHome) ne pourra pas la lire." >&2
|
||||
echo " déplacez le dépôt ailleurs (ex. /opt/archrepo) puis relancez install.sh." >&2
|
||||
echo " déplacez le dépôt ailleurs (ex. /opt/repo) puis relancez install.sh." >&2
|
||||
fi
|
||||
|
||||
cat >"$UNIT_FILE" <<EOF
|
||||
[Unit]
|
||||
Description=archrepo — dépôt pacman (publication de paquets + reconstruction de la base)
|
||||
Description=repo — dépôt pacman (publication de paquets + reconstruction de la base)
|
||||
Documentation=file://$APP_DIR/README.md
|
||||
After=network-online.target
|
||||
Wants=network-online.target
|
||||
@@ -85,13 +88,13 @@ Type=simple
|
||||
User=$SERVICE_USER
|
||||
Group=$SERVICE_USER
|
||||
WorkingDirectory=$APP_DIR/app
|
||||
Environment=ARCHREPO_ROOT=$REPO_ROOT
|
||||
Environment=ARCHREPO_STATE_DIR=$STATE_DIR
|
||||
Environment=ARCHREPO_NAME=$REPO_NAME
|
||||
Environment=ARCHREPO_ARCH=$REPO_ARCH
|
||||
Environment=ARCHREPO_BIND=$BIND
|
||||
Environment=ARCHREPO_TOKEN_FILE=$TOKEN_FILE
|
||||
Environment=ARCHREPO_MAX_UPLOAD=$MAX_UPLOAD
|
||||
Environment=REPO_ROOT=$REPO_ROOT
|
||||
Environment=REPO_STATE_DIR=$STATE_DIR
|
||||
Environment=REPO_NAME=$REPO_NAME
|
||||
Environment=REPO_ARCH=$REPO_ARCH
|
||||
Environment=REPO_BIND=$BIND
|
||||
Environment=REPO_TOKEN_FILE=$TOKEN_FILE
|
||||
Environment=REPO_MAX_UPLOAD=$MAX_UPLOAD
|
||||
Environment=PYTHONUNBUFFERED=1
|
||||
ExecStart=$PYTHON $APP_DIR/app/server.py
|
||||
Restart=on-failure
|
||||
@@ -112,7 +115,7 @@ echo "✓ unité systemd écrite dans $UNIT_FILE"
|
||||
# --- rétention des anciennes versions ---------------------------------------
|
||||
cat >"$PRUNE_UNIT" <<EOF
|
||||
[Unit]
|
||||
Description=archrepo — rétention (garde $KEEP versions par paquet)
|
||||
Description=repo — rétention (garde $KEEP versions par paquet)
|
||||
Documentation=file://$APP_DIR/README.md
|
||||
After=$SERVICE_NAME.service
|
||||
|
||||
@@ -121,8 +124,8 @@ Type=oneshot
|
||||
User=$SERVICE_USER
|
||||
Group=$SERVICE_USER
|
||||
Environment=REPO_URL=http://$BIND
|
||||
Environment=ARCHREPO_TOKEN_FILE=$TOKEN_FILE
|
||||
Environment=ARCHREPO_KEEP=$KEEP
|
||||
Environment=REPO_TOKEN_FILE=$TOKEN_FILE
|
||||
Environment=REPO_KEEP=$KEEP
|
||||
ExecStart=$APP_DIR/prune.sh
|
||||
Restart=on-failure
|
||||
RestartSec=30
|
||||
@@ -138,7 +141,7 @@ chmod 0644 "$PRUNE_UNIT"
|
||||
|
||||
cat >"$PRUNE_TIMER" <<EOF
|
||||
[Unit]
|
||||
Description=archrepo — purge périodique des anciennes versions
|
||||
Description=repo — purge périodique des anciennes versions
|
||||
|
||||
[Timer]
|
||||
OnBootSec=5min
|
||||
@@ -169,7 +172,7 @@ done
|
||||
|
||||
echo
|
||||
if [[ $ready -eq 1 ]]; then
|
||||
echo "✓ archrepo écoute sur http://$BIND"
|
||||
echo "✓ repo écoute sur http://$BIND"
|
||||
else
|
||||
echo "⚠ le service ne répond pas encore sur http://$BIND" >&2
|
||||
systemctl status "$SERVICE_NAME" --no-pager --lines=15 || true
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
# archrepo — rétention : ne garde que les N versions les plus récentes de chaque
|
||||
# repo — rétention : ne garde que les N versions les plus récentes de chaque
|
||||
# paquet et supprime les fichiers des versions plus anciennes.
|
||||
#
|
||||
# ./prune.sh # garde 3 versions par paquet
|
||||
@@ -15,9 +15,9 @@
|
||||
set -euo pipefail
|
||||
|
||||
REPO_URL="${REPO_URL:-http://127.0.0.1:30065}"
|
||||
TOKEN_FILE="${ARCHREPO_TOKEN_FILE:-/etc/archrepo/token}"
|
||||
TOKEN_FILE="${REPO_TOKEN_FILE:-/etc/repo/token}"
|
||||
REPO_TOKEN="${REPO_TOKEN:-}"
|
||||
KEEP="${ARCHREPO_KEEP:-3}"
|
||||
KEEP="${REPO_KEEP:-3}"
|
||||
DRY_RUN=0
|
||||
|
||||
usage() {
|
||||
|
||||
+4
-4
@@ -1,17 +1,17 @@
|
||||
#!/usr/bin/env bash
|
||||
# Envoie un ou plusieurs paquets vers le dépôt archrepo.
|
||||
# Envoie un ou plusieurs paquets vers le dépôt repo.
|
||||
#
|
||||
# REPO_URL=http://mc.laxacube.ch:30065 REPO_TOKEN=... ./push.sh *.pkg.tar.zst
|
||||
#
|
||||
# REPO_URL URL du dépôt (défaut : http://127.0.0.1:30065 ; Caddy écoute le port
|
||||
# pour n'importe quel Host, le nom public fonctionne aussi)
|
||||
# REPO_TOKEN jeton d'administration ; à défaut, lu dans $ARCHREPO_TOKEN_FILE
|
||||
# (/etc/archrepo/token par défaut), avec sudo si nécessaire.
|
||||
# REPO_TOKEN jeton d'administration ; à défaut, lu dans $REPO_TOKEN_FILE
|
||||
# (/etc/repo/token par défaut), avec sudo si nécessaire.
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
REPO_URL="${REPO_URL:-http://127.0.0.1:30065}"
|
||||
TOKEN_FILE="${ARCHREPO_TOKEN_FILE:-/etc/archrepo/token}"
|
||||
TOKEN_FILE="${REPO_TOKEN_FILE:-/etc/repo/token}"
|
||||
REPO_TOKEN="${REPO_TOKEN:-}"
|
||||
|
||||
usage() {
|
||||
|
||||
Reference in new issue
Block a user