public inbox for cygwin-apps-cvs@sourceware.org help / color / mirror / Atom feed
From: jturney@sourceware.org To: cygwin-apps-cvs@sourceware.org Subject: [calm - Cygwin server-side packaging maintenance script] branch master, updated. 20181020-16-g9d099cf Date: Sun, 26 May 2019 19:19:00 -0000 [thread overview] Message-ID: <20190526191943.61613.qmail@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/calm.git;h=9d099cf0816fd73758593c958d9aff804b534b2b commit 9d099cf0816fd73758593c958d9aff804b534b2b Author: Jon Turney <jon.turney@dronecode.org.uk> Date: Sun May 26 12:03:19 2019 +0100 Write package metadata summary Write a summary of package metadata in json format. Diff: --- calm/calm.py | 10 ++++++++++ calm/package.py | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 0 deletions(-) diff --git a/calm/calm.py b/calm/calm.py index 3b7ea79..76ffd39 100755 --- a/calm/calm.py +++ b/calm/calm.py @@ -56,6 +56,7 @@ from collections import defaultdict from contextlib import ExitStack import argparse import logging +import lzma import os import shutil import signal @@ -452,6 +453,15 @@ def do_output(args, state): logging.debug("removing %s, unchanged %s" % (tmpfile.name, inifile)) os.remove(tmpfile.name) + # write packages.json + jsonfile = os.path.join(args.htdocs, 'packages.json.xz') + with tempfile.NamedTemporaryFile(mode='wb', delete=False) as tmpfile: + logging.debug('writing %s' % (tmpfile.name)) + with lzma.open(tmpfile, 'wt') as lzf: + package.write_repo_json(args, state.packages, lzf) + logging.info("moving %s to %s" % (tmpfile.name, jsonfile)) + shutil.move(tmpfile.name, jsonfile) + # # daemonization loop diff --git a/calm/package.py b/calm/package.py index c90d955..5710185 100755 --- a/calm/package.py +++ b/calm/package.py @@ -29,6 +29,7 @@ from collections import defaultdict import copy import difflib import hashlib +import json import logging import os import pprint @@ -1024,6 +1025,59 @@ def upper_first_character(s): # +# write a json summary of packages +# +def write_repo_json(args, packages, f): + package_list = set() + for arch in packages: + package_list.update(packages[arch]) + + mlist = maintainers.Maintainer.read(args, None) + pkg_maintainers = maintainers.Maintainer.invert(mlist) + + pl = [] + for pn in sorted(package_list): + po = None + arches = [] + for arch in common_constants.ARCHES: + if pn in packages[arch]: + po = packages[arch][pn] + arches.append(arch) + + bv = po.best_version + + if po.version_hints[bv].get('external-source', None): + continue + + versions = {} + for vr in sorted(po.version_hints.keys(), key=lambda v: SetupVersion(v)): + key = 'test' if 'test' in po.version_hints[vr] else 'stable' + versions[key] = versions.get(key, []) + [vr] + + d = { + 'name': pn, + 'versions': versions, + 'summary': po.version_hints[bv].get('sdesc', '').strip('"'), + 'categories': po.version_hints[bv].get('category', '').split(), + 'subpackages': [{'name': sp} for sp in po.is_used_by], + 'arches': arches, + } + + if pkg_maintainers[pn] and ('ORPHANED' not in pkg_maintainers[pn]): + d['maintainers'] = pkg_maintainers[pn] + + pl.append(d) + + j = { + 'repository_name': args.release, + 'timestamp': int(time.time()), + 'num_packages': len(pl), + 'packages': pl, + } + json.dump(j, f) + + +# # merge sets of packages # # for each package which exist in both a and b:
reply other threads:[~2019-05-26 19:19 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20190526191943.61613.qmail@sourceware.org \ --to=jturney@sourceware.org \ --cc=cygwin-apps-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).