97
main.py
97
main.py
@@ -40,7 +40,7 @@ import hashlib
|
||||
from itertools import zip_longest
|
||||
from functools import cmp_to_key, wraps
|
||||
from urllib.parse import quote_plus, quote
|
||||
from typing import List, Set, Dict, Tuple, Optional, Generator, Any, Type, Callable, Union
|
||||
from typing import List, Set, Dict, Tuple, Optional, Generator, Any, Type, Callable, Union, NamedTuple, Sequence
|
||||
|
||||
import requests
|
||||
from flask import Flask, render_template, request, url_for, redirect, \
|
||||
@@ -142,6 +142,14 @@ class ArchMapping:
|
||||
|
||||
CygwinVersions = Dict[str, Tuple[str, str, str]]
|
||||
|
||||
ExtInfo = NamedTuple('ExtInfo', [
|
||||
('name', str),
|
||||
('version', str),
|
||||
('date', int),
|
||||
('url', str),
|
||||
('other_urls', List[str]),
|
||||
])
|
||||
|
||||
|
||||
class AppState:
|
||||
|
||||
@@ -152,7 +160,7 @@ class AppState:
|
||||
self._last_update = 0.0
|
||||
self._sources: List[Source] = []
|
||||
self._sourceinfos: Dict[str, SrcInfoPackage] = {}
|
||||
self._versions: Dict[str, Tuple[str, str, int]] = {}
|
||||
self._arch_versions: Dict[str, Tuple[str, str, int]] = {}
|
||||
self._arch_mapping: ArchMapping = ArchMapping()
|
||||
self._cygwin_versions: CygwinVersions = {}
|
||||
self._update_etag()
|
||||
@@ -188,12 +196,12 @@ class AppState:
|
||||
self._update_etag()
|
||||
|
||||
@property
|
||||
def versions(self) -> Dict[str, Tuple[str, str, int]]:
|
||||
return self._versions
|
||||
def arch_versions(self) -> Dict[str, Tuple[str, str, int]]:
|
||||
return self._arch_versions
|
||||
|
||||
@versions.setter
|
||||
def versions(self, versions: Dict[str, Tuple[str, str, int]]) -> None:
|
||||
self._versions = versions
|
||||
@arch_versions.setter
|
||||
def arch_versions(self, versions: Dict[str, Tuple[str, str, int]]) -> None:
|
||||
self._arch_versions = versions
|
||||
self._update_etag()
|
||||
|
||||
@property
|
||||
@@ -429,37 +437,40 @@ class Source:
|
||||
return sorted(licenses)
|
||||
|
||||
@property
|
||||
def cygwin_info(self) -> Optional[Tuple[str, str, str]]:
|
||||
def upstream_version(self) -> str:
|
||||
# Take the newest version of the external versions
|
||||
version = None
|
||||
for info in self.external_infos:
|
||||
if version is None or version_is_newer_than(info.version, version):
|
||||
version = info.version
|
||||
return version or ""
|
||||
|
||||
@property
|
||||
def external_infos(self) -> Sequence[ExtInfo]:
|
||||
global state
|
||||
|
||||
ext = []
|
||||
arch_info = get_arch_info_for_base(self)
|
||||
if arch_info is not None:
|
||||
version = extract_upstream_version(arch_info[0])
|
||||
url = arch_info[1]
|
||||
ext.append(ExtInfo("Arch Linux", version, arch_info[2], url, []))
|
||||
|
||||
cygwin_versions = state.cygwin_versions
|
||||
if self.name in cygwin_versions:
|
||||
return cygwin_versions[self.name]
|
||||
return None
|
||||
info = cygwin_versions[self.name]
|
||||
ext.append(ExtInfo("Cygwin", info[0], 0, info[1], [info[2]]))
|
||||
|
||||
@property
|
||||
def arch_url(self) -> str:
|
||||
arch_info = get_arch_info_for_base(self)
|
||||
if arch_info is not None:
|
||||
return arch_info[1]
|
||||
return ""
|
||||
|
||||
@property
|
||||
def upstream_version(self) -> str:
|
||||
arch_info = get_arch_info_for_base(self)
|
||||
if arch_info is not None:
|
||||
return extract_upstream_version(arch_info[0])
|
||||
return ""
|
||||
return sorted(ext)
|
||||
|
||||
@property
|
||||
def is_outdated(self) -> bool:
|
||||
arch_version = self.upstream_version
|
||||
if not arch_version:
|
||||
return False
|
||||
|
||||
msys_version = extract_upstream_version(self.version)
|
||||
|
||||
return version_is_newer_than(arch_version, msys_version)
|
||||
for info in self.external_infos:
|
||||
if version_is_newer_than(info.version, msys_version):
|
||||
return True
|
||||
return False
|
||||
|
||||
@property
|
||||
def realname(self) -> str:
|
||||
@@ -998,7 +1009,7 @@ def update_versions() -> None:
|
||||
arch_versions[name] = (result["Version"], url, last_modified)
|
||||
print("done")
|
||||
|
||||
state.versions = arch_versions
|
||||
state.arch_versions = arch_versions
|
||||
|
||||
|
||||
def extract_upstream_version(version: str) -> str:
|
||||
@@ -1021,8 +1032,8 @@ def get_arch_info_for_base(s: Source) -> Optional[Tuple[str, str, int]]:
|
||||
|
||||
for realname in variants:
|
||||
for arch_name in get_arch_names(realname):
|
||||
if arch_name in state.versions:
|
||||
return state.versions[arch_name]
|
||||
if arch_name in state.arch_versions:
|
||||
return state.arch_versions[arch_name]
|
||||
return None
|
||||
|
||||
|
||||
@@ -1041,23 +1052,23 @@ def outofdate() -> RouteResponse:
|
||||
|
||||
all_sources.append(s)
|
||||
|
||||
arch_info = get_arch_info_for_base(s)
|
||||
if arch_info is None:
|
||||
if is_skipped(s.name):
|
||||
skipped.append(s)
|
||||
else:
|
||||
missing.append((s, s.realname))
|
||||
continue
|
||||
|
||||
arch_version, url, date = arch_info
|
||||
arch_version = extract_upstream_version(arch_version)
|
||||
msys_version = extract_upstream_version(s.version)
|
||||
git_version = extract_upstream_version(s.git_version)
|
||||
if not version_is_newer_than(git_version, msys_version):
|
||||
git_version = ""
|
||||
|
||||
if version_is_newer_than(arch_version, msys_version):
|
||||
to_update.append((s, msys_version, git_version, arch_version, url, date))
|
||||
external_infos = s.external_infos
|
||||
|
||||
for info in external_infos:
|
||||
if version_is_newer_than(info.version, msys_version):
|
||||
to_update.append((s, msys_version, git_version, info.version, info.url, info.date))
|
||||
break
|
||||
|
||||
if not external_infos:
|
||||
if is_skipped(s.name):
|
||||
skipped.append(s)
|
||||
else:
|
||||
missing.append((s, s.realname))
|
||||
|
||||
# show packages which have recently been build first.
|
||||
# assumes high frequency update packages are more important
|
||||
|
||||
@@ -22,9 +22,9 @@
|
||||
{% if s.is_outdated %}
|
||||
<small><div class="alert alert-secondary" role="alert">
|
||||
A <strong>newer upstream version ({{ s.upstream_version }})</strong>
|
||||
is packaged in Arch Linux.<br>Consider packaging the new version for
|
||||
is available.<br>Consider packaging the new version for
|
||||
MSYS2 as well. See <a
|
||||
href="https://github.com/msys2/msys2/wiki/Creating-packages">the
|
||||
href="https://www.msys2.org/wiki/Creating-Packages/">the
|
||||
packaging guide</a> for how to help.
|
||||
</div></small>
|
||||
{% endif %}
|
||||
@@ -54,27 +54,22 @@
|
||||
<dt class="col-sm-3 text-sm-right">Upstream URL:</dt>
|
||||
<dd class="col-sm-9"><a href="{{ s.url }}">{{ s.url }}</a></dd>
|
||||
|
||||
<dt class="col-sm-3 text-sm-right">Arch Linux Version:</dt>
|
||||
<dd class="col-sm-9">
|
||||
{% if s.upstream_version %}
|
||||
<a href="{{ s.arch_url }}">{{ s.upstream_version }}</a>
|
||||
{% else %}
|
||||
-
|
||||
{% endif%}
|
||||
</dd>
|
||||
|
||||
<dt class="col-sm-3 text-sm-right">Cygwin Info:</dt>
|
||||
<dd class="col-sm-9">
|
||||
{% if s.cygwin_info %}
|
||||
<a href="{{ s.cygwin_info[1] }}">{{ s.cygwin_info[0] }}</a> | <a href="{{ s.cygwin_info[2] }}">{{ s.cygwin_info[2].rsplit("/")[-1] }}</a>
|
||||
{% else %}
|
||||
-
|
||||
{% endif%}
|
||||
</dd>
|
||||
{% for info in s.external_infos %}
|
||||
<dt class="col-sm-3 text-sm-right">{{ info.name }}:</dt>
|
||||
<dd class="col-sm-9"><a href="{{ info.url }}">{{ info.version }}</a>
|
||||
{% for url in info.other_urls %}
|
||||
| <a href="{{ url }}">{{ url.rsplit("/")[-1] }}</a>
|
||||
{% endfor %}
|
||||
</dd>
|
||||
{% endfor %}
|
||||
|
||||
<dt class="col-sm-3 text-sm-right">GIT Version:</dt>
|
||||
<dd class="col-sm-9">
|
||||
{{ s.git_version or "-" }}
|
||||
{% if s.git_version %}
|
||||
<a href="{{ s.source_url }}">{{ s.git_version }}</a>
|
||||
{% else %}
|
||||
-
|
||||
{% endif%}
|
||||
</dd>
|
||||
|
||||
<dt class="col-sm-3 text-sm-right">License(s):</dt>
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<div class="card-body overflow-auto">
|
||||
|
||||
<p class="text-muted">See the <a
|
||||
href="https://github.com/msys2/msys2/wiki/Creating-packages">the packaging
|
||||
href="https://www.msys2.org/wiki/Creating-Packages/">the packaging
|
||||
guide</a> for how to package new upstream versions</p>
|
||||
|
||||
<table class="table table-hover table-sm">
|
||||
@@ -24,8 +24,8 @@
|
||||
<th>Base Package</th>
|
||||
<th>MSYS2 Version</th>
|
||||
<th></th>
|
||||
<th>Arch Linux Version</th>
|
||||
<th>Arch Linux Update Date</th>
|
||||
<th>New Version</th>
|
||||
<th>Update Date</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -35,16 +35,16 @@
|
||||
<td>{{ myver }}{% if gitver %} <span class="text-muted small px-2">({{ gitver }} in git)</span>{% endif %}</td>
|
||||
<td>→</td>
|
||||
<td><a href="{{ url }}">{{ ver }}</a></td>
|
||||
<td>{{ date|timestamp }}</td>
|
||||
<td>{{ date|timestamp if date else '' }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<h6>{{ missing|length }} packages not found in Arch Linux:</h6>
|
||||
{% for (s, arch_name) in missing %}
|
||||
<h6>{{ missing|length }} packages not found in other distros:</h6>
|
||||
{% for (s, short_name) in missing %}
|
||||
<a href="{{ url_for('.base', name=s.name) }}">{{ s.name }}</a>
|
||||
<span class="text-muted">({{ arch_name }})</span>{{ ", " if not loop.last else '' }}
|
||||
<span class="text-muted">({{ short_name }})</span>{{ ", " if not loop.last else '' }}
|
||||
{% endfor %}
|
||||
|
||||
<br>
|
||||
|
||||
Reference in New Issue
Block a user