diff options
author | Jon Turney <jon.turney@dronecode.org.uk> | 2019-06-07 19:36:20 +0300 |
---|---|---|
committer | Jon Turney <jon.turney@dronecode.org.uk> | 2019-07-04 14:44:26 +0300 |
commit | f0cf563288d3b0e17bb53b570395a4fd23b13f19 (patch) | |
tree | f570a4c650a1d6ca856a02750052050bfa124d8c /calm/pkg2html.py | |
parent | dec704d7feb89f1a173c03f82369adc0256d72c8 (diff) |
Create a separate package object for the source package
Create separate package objects for the binary and source packages. This
is generally a simplification to the data model.
One slight wrinkle is that stale file detection needs to be aware that
.hint files may now be used by both a binary and source packages, and so
should only be removed if both packages are stale. (Since the source
package cannot be stale if the binary package isn't, we solve this by
making the source package control the staleness of the hint, in that
case [except for archives which are sourceless for permitted reasons,
which we now explicitly annotate as such]).
'external-source' is now always followed, rather than checking for the
source for a given version in the current package first. This exposes a
handful of (migrated) hints which contain an unnecessary
external-source.
Write separate package summary pages for source packages
Always create binary packages when uploading to allow replacement hints,
otherwise, only create a package if there's archives for it to contain
to avoid creating empty packages from the relarea.
Note: since we don't put source packages into a separate namespace,
there is a potential collision if both 'foo' (source package 'foo-src'),
and 'foo-src' (source package 'foo-src-src') exist. That would be daft,
and there aren't currently any examples of this. Forbid package names
ending in '-src' to avoid such problems.
Diffstat (limited to 'calm/pkg2html.py')
-rwxr-xr-x | calm/pkg2html.py | 76 |
1 files changed, 60 insertions, 16 deletions
diff --git a/calm/pkg2html.py b/calm/pkg2html.py index 35043dd..9216139 100755 --- a/calm/pkg2html.py +++ b/calm/pkg2html.py @@ -129,7 +129,8 @@ def update_package_listings(args, packages): def linkify_package(p): if p in package_list: - return '<a href="%s.html">%s</a>' % (p, p) + pn = arch_package(packages, p).orig_name + return '<a href="%s.html">%s</a>' % (p, pn) logging.debug('package linkification failed for %s' % p) return p @@ -159,7 +160,15 @@ def update_package_listings(args, packages): continue bv = po.best_version - title = "Cygwin Package Summary for %s" % p + + if po.kind == package.Kind.source: + pn = po.orig_name + title = "Cygwin Package Summary for %s (source)" % pn + kind = "Source Package" + else: + pn = p + title = "Cygwin Package Summary for %s" % p + kind = "Package" print(textwrap.dedent('''\ <!DOCTYPE html> @@ -173,31 +182,41 @@ def update_package_listings(args, packages): <!--#include virtual="/navbar.html" --> <div id="main"> <!--#include virtual="/top.html" --> - <h1>Package: %s</h1>''' % (title, p)), file=f) + <h1>%s: %s</h1>''' % (title, kind, pn)), file=f) print('<span class="detail">summary</span>: %s<br><br>' % sdesc(po, bv), file=f) print('<span class="detail">description</span>: %s<br><br>' % ldesc(po, bv), file=f) print('<span class="detail">categories</span>: %s<br><br>' % po.version_hints[bv].get('category', ''), file=f) - for key in ['depends', 'obsoletes', 'provides', 'conflicts', 'build-depends']: + if po.kind == package.Kind.source: + details = ['build-depends'] + else: + details = ['depends', 'obsoletes', 'provides', 'conflicts'] + + for key in details: value = po.version_hints[bv].get(key, None) if value: print('<span class="detail">%s</span>: %s<br><br>' % (key, ', '.join([linkify_package(p) for p in value.split(', ')])), file=f) - es = po.version_hints[bv].get('external-source', None) - if es: - print('<span class="detail">source</span>: %s<br><br>' % linkify_package(es), file=f) - else: - print('<span class="detail">binaries</span>: %s<br><br>' % ', '.join([linkify_package(p) for p in sorted(po.is_used_by)]), file=f) + if po.kind == package.Kind.source: es = p - - if 'ORPHANED' in pkg_maintainers[es]: + print('<span class="detail">install package(s)</span>: %s<br><br>' % ', '.join([linkify_package(p) for p in sorted(po.is_used_by)]), file=f) + else: + es = po.version_hints[bv].get('external-source', p + '-src') + print('<span class="detail">source package</span>: %s<br><br>' % linkify_package(es), file=f) + + es_po = arch_package(packages, es) + if not es_po: + es_po = po + m_pn = es_po.orig_name + if 'ORPHANED' in pkg_maintainers[m_pn]: m = 'ORPHANED' else: - m = ', '.join(sorted(pkg_maintainers[es])) + m = ', '.join(sorted(pkg_maintainers[m_pn])) if m: print('<span class="detail">maintainer(s)</span>: %s ' % m, file=f) + print(textwrap.dedent('''\ <span class="smaller">(Use <a href="/lists.html#cygwin">the mailing list</a> to report bugs or ask questions. <a href="/problems.html#personal-email">Do not contact the maintainer(s) directly</a>.)</span>'''), file=f) @@ -218,7 +237,7 @@ def update_package_listings(args, packages): t = p.vermap[v][category] size = int(math.ceil(p.tar(v, category).size / 1024)) name = v if category == 'install' else v + ' (source)' - target = "%s-%s" % (pn, v) + ('' if category == 'install' else '-src') + target = "%s-%s" % (p.orig_name, v) + ('' if category == 'install' else '-src') test = 'test' if 'test' in p.version_hints[v] else 'stable' print('<tr><td>%s</td><td class="right">%d kB</td><td>[<a href="../%s/%s/%s">list of files</a>]</td><td>%s</td></tr>' % (name, size, arch, pn, target, test), file=f) @@ -261,9 +280,27 @@ def update_package_listings(args, packages): print('<table class="pkglist">', file=index) + # This list contains all packages in any arch, but in the interests + # of keeping the size down, we only list (i) all install packages, + # and (ii) source package where there isn't an install package of + # the same name. Source packages sort by their original package + # name. + package_list = {} + for arch in packages: + for p in packages[arch]: + if packages[arch][p].kind == package.Kind.binary: + package_list[p] = p + + for arch in packages: + for p in packages[arch]: + if packages[arch][p].kind == package.Kind.source and packages[arch][p].orig_name not in package_list: + package_list[packages[arch][p].orig_name] = p + first = ' class="pkgname"' jump = '' - for p in sorted(package_list, key=package.sort_key): + for k in sorted(package_list, key=package.sort_key): + p = package_list[k] + if p.endswith('-debuginfo'): continue @@ -274,6 +311,13 @@ def update_package_listings(args, packages): bv = po.best_version header = sdesc(po, bv) + if po.kind == package.Kind.source: + pn = po.orig_name + if 'source' not in header: + header += ' (source)' + else: + pn = p + anchor = '' if jump != p[0].lower(): jump = p[0].lower() @@ -281,7 +325,7 @@ def update_package_listings(args, packages): anchor = ' id="%s"' % (jump) print('<tr%s><td%s><a href="summary/%s.html">%s</a></td><td>%s</td></tr>' % - (anchor, first, p, p, header), + (anchor, first, p, pn, header), file=index) first = '' @@ -371,7 +415,7 @@ def write_arch_listing(args, packages, arch): header = p + ": " + sdesc(packages[p], bv) if fver.endswith('-src'): - header = header + " (source code)" + header = header + " (source)" print(textwrap.dedent('''\ <!DOCTYPE html> |