Skip to content

Commit

Permalink
Sort repos by priority and not by name
Browse files Browse the repository at this point in the history
Use the order of the repos in the config as the order for everything else.
selection inputs, package groupes etc
  • Loading branch information
lazka committed Sep 15, 2024
1 parent 2b03c69 commit 1178edd
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 25 deletions.
7 changes: 3 additions & 4 deletions app/appconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@
REPO_URL = "https://repo.msys2.org"
DOWNLOAD_URL = "https://mirror.msys2.org"
REPOSITORIES = [
("mingw32", "", "mingw-w64-i686-", "mingw-w64-", REPO_URL + "/mingw/mingw32", DOWNLOAD_URL + "/mingw/mingw32", "https://github.com/msys2/MINGW-packages"),
("mingw64", "", "mingw-w64-x86_64-", "mingw-w64-", REPO_URL + "/mingw/mingw64", DOWNLOAD_URL + "/mingw/mingw64", "https://github.com/msys2/MINGW-packages"),
("ucrt64", "", "mingw-w64-ucrt-x86_64-", "mingw-w64-", REPO_URL + "/mingw/ucrt64", DOWNLOAD_URL + "/mingw/ucrt64", "https://github.com/msys2/MINGW-packages"),
("clang64", "", "mingw-w64-clang-x86_64-", "mingw-w64-", REPO_URL + "/mingw/clang64", DOWNLOAD_URL + "/mingw/clang64", "https://github.com/msys2/MINGW-packages"),
("clang32", "", "mingw-w64-clang-i686-", "mingw-w64-", REPO_URL + "/mingw/clang32", DOWNLOAD_URL + "/mingw/clang32", "https://github.com/msys2/MINGW-packages"),
("clangarm64", "", "mingw-w64-clang-aarch64-", "mingw-w64-", REPO_URL + "/mingw/clangarm64", DOWNLOAD_URL + "/mingw/clangarm64", "https://github.com/msys2/MINGW-packages"),
("msys", "x86_64", "", "", REPO_URL + "/msys/x86_64", DOWNLOAD_URL + "/msys/x86_64", "https://github.com/msys2/MSYS2-packages"),
("mingw64", "", "mingw-w64-x86_64-", "mingw-w64-", REPO_URL + "/mingw/mingw64", DOWNLOAD_URL + "/mingw/mingw64", "https://github.com/msys2/MINGW-packages"),
("mingw32", "", "mingw-w64-i686-", "mingw-w64-", REPO_URL + "/mingw/mingw32", DOWNLOAD_URL + "/mingw/mingw32", "https://github.com/msys2/MINGW-packages"),
("clang32", "", "mingw-w64-clang-i686-", "mingw-w64-", REPO_URL + "/mingw/clang32", DOWNLOAD_URL + "/mingw/clang32", "https://github.com/msys2/MINGW-packages"),
]
DEFAULT_REPO = "ucrt64"

ARCH_REPO_URL = "https://europe.mirror.pkgbuild.com"
ARCH_REPO_CONFIG = []
Expand Down
2 changes: 1 addition & 1 deletion app/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ <h4 class="card-title">Base Package: <a href="{{ s.name }}">{{ s.name }}</a></h4
<dt class="col-sm-3 text-sm-end mb-2">Binary Packages:</dt>
<dd class="col-sm-9">
<dl class="row mb-0">
{% for repo, packages in s.packages|group_by_repo|dictsort(false) %}
{% for repo, packages in s.packages|group_by_repo %}
<dt class="text-muted small">{{ repo }}</dt>
<dd>
<ul class="list-unstyled mb-0">
Expand Down
2 changes: 1 addition & 1 deletion app/templates/outofdate.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ <h6 class="card-subtitle mb-2 text-muted">
<div class="col-auto">
<select name="repo" class="form-select form-select-sm" onchange="this.form.submit()">
<option {{ "selected" if not repo_filter or "" }} value="">All</option>
{% for r in repos|sort(attribute='name') %}
{% for r in repos %}
<option value="{{ r.name }}" {{ "selected" if repo_filter == r.name or "" }}>{{ r.name }}</option>
{% endfor %}
</select>
Expand Down
2 changes: 1 addition & 1 deletion app/templates/packages.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ <h6 class="card-subtitle mb-2 text-muted">{{ packages|length }} packages {% if r

<div class="col-auto">
<select name="repo" class="form-select form-select-sm" onchange="this.form.submit()">
{% for r in repos|sort(attribute='name') %}
{% for r in repos %}
<option value="{{ r.name }}" {{ "selected" if repo_filter == r.name or "" }}>{{ r.name }}</option>
{% endfor %}
</select>
Expand Down
2 changes: 1 addition & 1 deletion app/templates/queue.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ <h6 class="card-subtitle mb-2 text-muted">
<div class="col-auto">
<select name="build_type" class="form-select form-select-sm" onchange="this.form.submit()">
<option {{ "selected" if not build_filter or "" }} value="">All</option>
{% for bt in build_types|sort %}
{% for bt in build_types %}
<option value="{{ bt }}" {{ "selected" if build_filter == bt or "" }}>{{ bt }}</option>
{% endfor %}
</select>
Expand Down
2 changes: 1 addition & 1 deletion app/templates/updates.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ <h6 class="card-subtitle mb-2 text-muted"> The last {{ packages|length }} repo u
<div class="col-auto">
<select name="repo" class="form-select form-select-sm" onchange="this.form.submit()">
<option {{ "selected" if not repo_filter or "" }} value="">All</option>
{% for r in repos|sort(attribute='name') %}
{% for r in repos %}
<option value="{{ r.name }}" {{ "selected" if repo_filter == r.name or "" }}>{{ r.name }}</option>
{% endfor %}
</select>
Expand Down
42 changes: 26 additions & 16 deletions app/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
from fastapi_etag import add_exception_handler as add_etag_exception_handler

from .appstate import state, get_repositories, Package, Source, DepType, SrcInfoPackage, get_base_group_name, Vulnerability, Severity, PackageKey
from .appconfig import DEFAULT_REPO
from .utils import extract_upstream_version, version_is_newer_than

router = APIRouter(default_response_class=HTMLResponse)
Expand Down Expand Up @@ -198,11 +197,16 @@ def filter_filesize(d: int) -> str:


@template_filter("group_by_repo")
def group_by_repo(packages: dict[PackageKey, Package]) -> dict[str, list[Package]]:
def group_by_repo(packages: dict[PackageKey, Package]) -> list[tuple[str, list[Package]]]:
res: dict[str, list[Package]] = {}
for _, p in sorted(packages.items()):
res.setdefault(p.repo, []).append(p)
return res
sorted_res = []
for repo in get_repositories():
name = repo.name
if name in res:
sorted_res.append((name, res[name]))
return sorted_res


@router.get('/robots.txt')
Expand Down Expand Up @@ -350,7 +354,7 @@ async def basegroups(request: Request, response: Response, group_name: str | Non
async def packages(request: Request, response: Response, repo: str | None = None, variant: str | None = None) -> Response:
global state

repo = repo or DEFAULT_REPO
repo = repo or get_repositories()[0].name

packages = []
for s in state.sources.values():
Expand Down Expand Up @@ -576,13 +580,23 @@ def get_status_priority(key: str) -> tuple[int, str]:
return (-1, key)


def repo_to_builds(repo: str) -> list[str]:
def repo_to_build_type(repo: str) -> list[str]:
if repo == "msys":
return [repo, "msys-src"]
else:
return [repo, "mingw-src"]


def get_build_types() -> list[str]:
build_types: list[str] = []
for r in get_repositories():
for build_type in repo_to_build_type(r.name):
if build_type in build_types:
build_types.remove(build_type)
build_types.append(build_type)
return build_types


def get_build_status(srcinfo: SrcInfoPackage, build_types: set[str] = set()) -> list[PackageBuildStatus]:
build_status = state.build_status

Expand All @@ -606,7 +620,7 @@ def get_build_status(srcinfo: SrcInfoPackage, build_types: set[str] = set()) ->
)

if not results:
for build in sorted(build_types):
for build in build_types:
key = "unknown"
results.append(
PackageBuildStatus(build, get_status_text(key), "", {}, get_status_category(key)))
Expand All @@ -628,18 +642,18 @@ async def queue(request: Request, response: Response, build_type: str = "") -> R
for k, p in sorted(s.packages.items()):
if p.name in state.sourceinfos:
srcinfo = state.sourceinfos[p.name]
if build_filter is not None and build_filter not in repo_to_builds(srcinfo.repo):
if build_filter is not None and build_filter not in repo_to_build_type(srcinfo.repo):
continue
if version_is_newer_than(srcinfo.build_version, p.version):
srcinfo_repos.setdefault(srcinfo.pkgbase, set()).update(repo_to_builds(srcinfo.repo))
srcinfo_repos.setdefault(srcinfo.pkgbase, set()).update(repo_to_build_type(srcinfo.repo))
repo_list = srcinfo_repos[srcinfo.pkgbase] if not build_filter else {build_filter}
new_src = state.sources.get(srcinfo.pkgbase)
grouped[srcinfo.pkgbase] = (srcinfo, new_src, p, get_build_status(srcinfo, repo_list))

# new packages
available: dict[str, list[SrcInfoPackage]] = {}
for srcinfo in state.sourceinfos.values():
if build_filter is not None and build_filter not in repo_to_builds(srcinfo.repo):
if build_filter is not None and build_filter not in repo_to_build_type(srcinfo.repo):
continue
available.setdefault(srcinfo.pkgname, []).append(srcinfo)
for s in state.sources.values():
Expand All @@ -649,7 +663,7 @@ async def queue(request: Request, response: Response, build_type: str = "") -> R
# only one per pkgbase
for srcinfos in available.values():
for srcinfo in srcinfos:
srcinfo_repos.setdefault(srcinfo.pkgbase, set()).update(repo_to_builds(srcinfo.repo))
srcinfo_repos.setdefault(srcinfo.pkgbase, set()).update(repo_to_build_type(srcinfo.repo))
repo_list = srcinfo_repos[srcinfo.pkgbase] if not build_filter else {build_filter}
src, pkg = None, None
if srcinfo.pkgbase in grouped:
Expand All @@ -668,22 +682,18 @@ async def queue(request: Request, response: Response, build_type: str = "") -> R
removals = []
for s in state.sources.values():
for k, p in s.packages.items():
if build_filter is not None and build_filter not in repo_to_builds(p.repo):
if build_filter is not None and build_filter not in repo_to_build_type(p.repo):
continue
if p.name not in state.sourceinfos:
# FIXME: can also break things if it's the only provides and removed,
# and also is ok to remove if there is a replacement
removals.append((p, p.rdepends))

build_types = set()
for r in get_repositories():
build_types.update(repo_to_builds(r.name))

return templates.TemplateResponse("queue.html", {
"request": request,
"updates": updates,
"removals": removals,
"build_types": build_types,
"build_types": get_build_types(),
"build_filter": build_filter,
"cycles": state.build_status.cycles,
}, headers=dict(response.headers))
Expand Down

0 comments on commit 1178edd

Please sign in to comment.