re-implemented last_stable_version (use our repository)

This commit is contained in:
Emmanuel 2022-03-19 14:58:40 +01:00
parent d90a5ee6fe
commit 12c875f76a

View File

@ -1,4 +1,4 @@
import json, datetime, fcntl, os, re, socket, subprocess, time
import json, datetime, fcntl, glob, os, re, socket, subprocess, time
from flask import request, abort
from flask import Blueprint
@ -9,7 +9,7 @@ bp = Blueprint("routes", __name__)
# --------------------------------------------------------------
DIR = "/opt/installmgr/"
REPOSIT_DIR = "/opt/installmgr/incoming_dumps"
MAX_REPOSIT_SIZE = 200 * 20 * 1024 # kB (here, max 200 dumps of 20MB)
MAX_REPOSIT_SIZE = 300 * 20 * 1024 # kB (here, max 300 dumps of 20MB)
ALERT_MAIL_FROM = "root@scodoc.org"
ALERT_MAIL_TO = "emmanuel.viennet@gmail.com"
@ -18,11 +18,28 @@ LOG_FILENAME = os.path.join(DIR, "upload-dump-errors.log")
UPLOAD_LOG_FILENAME = os.path.join(DIR, "upload-dump-log.json")
DEBUG = False # if false, don't publish error messages
# Les paquets publiés:
DEBIAN_PACKAGES_EXP="/srv/packages/pool/main/s/scodoc9/scodoc9_*.deb"
@bp.route("/scodoc-installmgr/last_stable_version")
def last_stable_version():
"""version du dernier paquet ScoDoc 9 publié.
=> chaine, "9.1.82"
"""
# LAST_RELEASE_TAG=$(curl "$GITEA_RELEASE_URL" | jq ".[].tag_name" | tr -d -c "0-9.\n" | sort --version-sort | tail -1)
return "9.0.51"
debs = glob.glob(DEBIAN_PACKAGES_EXP)
version_tuples = [] # (9,1,81)
for filename in debs:
m = re.match(r".*scodoc9_9\.([0-9]{1,2})\.([0-9]{1,3})-1_amd64.deb", filename)
if m:
version_tuples.append( (9, int(m.group(1)), int(m.group(2))) )
if len(version_tuples) == 0:
return "?.?.?"
version_tuples.sort()
last_package_version = version_tuples[-1]
return ".".join([str(x) for x in last_package_version])
@bp.route("/scodoc-installmgr/upload-dump", methods=["POST"])