def backport_distribution(release): distro_info = DebianDistroInfo() if distro_info.codename("stable") == release: return "%s-backports" % release elif distro_info.codename("oldstable") == release: return "%s-backports-sloppy" % release else: raise Exception("unable to determine target suite for %s" % release)
def get_debian_srcpkg(name, release): debian = Distribution('debian') debian_archive = debian.getArchive() try: release = DebianDistroInfo().codename(release, None, release) except DistroDataOutdated as e: Logger.warn(e) return debian_archive.getSourcePackage(name, release)
def test_compat_release(self): debian = DebianDistroInfo() self.build_tree_contents([ ("debian/", ), ( "debian/lintian-brush.conf", """\ compat-release = testing """, ), ]) cfg = Config("debian/lintian-brush.conf") self.assertEqual(debian.testing(), cfg.compat_release())
def _get_release_names(): global _DEBIAN_RELEASES, _UBUNTU_RELEASES try: from distro_info import DebianDistroInfo, UbuntuDistroInfo except ImportError: warning("distro_info not available. Unable to retrieve current " "list of releases.") _DEBIAN_RELEASES = [] _UBUNTU_RELEASES = [] else: # distro info is not available _DEBIAN_RELEASES = DebianDistroInfo().all _UBUNTU_RELEASES = UbuntuDistroInfo().all _DEBIAN_RELEASES.extend(['stable', 'testing', 'unstable', 'frozen'])
def setup_parser(cls, parser): distro_info = DebianDistroInfo() parser.add_argument( "--target-release", type=str, help="Target release", default=distro_info.stable(), ) parser.add_argument("--dry-run", action="store_true", help="Do a dry run.") parser.add_argument( "--builder", type=str, help="Build command", default=( DEFAULT_BUILDER + " --source --source-only-changes " "--debbuildopt=-v${LAST_VERSION}" ), )
def get_ubuntu_delta_changelog(srcpkg): ''' Download the Ubuntu changelog and extract the entries since the last sync from Debian. ''' archive = Distribution('ubuntu').getArchive() spph = archive.getPublishedSources(source_name=srcpkg.getPackageName(), exact_match=True, pocket='Release') debian_info = DebianDistroInfo() topline = re.compile(r'^(\w%(name_chars)s*) \(([^\(\) \t]+)\)' r'((\s+%(name_chars)s+)+)\;' % {'name_chars': '[-+0-9a-z.]'}, re.IGNORECASE) delta = [] for record in spph: changes_url = record.changesFileUrl() if changes_url is None: # Native sync break try: response, body = Http().request(changes_url) except HttpLib2Error as e: Logger.error(str(e)) break if response.status != 200: Logger.error("%s: %s %s", changes_url, response.status, response.reason) break changes = Changes(Http().request(changes_url)[1]) for line in changes['Changes'].splitlines(): line = line[1:] m = topline.match(line) if m: distribution = m.group(3).split()[0].split('-')[0] if debian_info.valid(distribution): break if line.startswith(u' '): delta.append(line) else: continue break return '\n'.join(delta)
def _get_srcpkg(distro, name, release): if distro == 'debian': # Canonicalise release: debian_info = DebianDistroInfo() try: codename = debian_info.codename(release, default=release) except DistroDataOutdated as e: Logger.warn(e) lines = list(rmadison(distro, name, suite=codename, arch='source')) if not lines: lines = list(rmadison(distro, name, suite=release, arch='source')) if not lines: raise PackageNotFoundException( "'%s' doesn't appear to exist in %s '%s'" % (name, distro.capitalize(), release)) pkg = max(lines, key=lambda x: Version(x['version'])) return FakeSPPH(pkg['source'], pkg['version'], pkg['component'], distro)
def get_ubuntu_delta_changelog(srcpkg): ''' Download the Ubuntu changelog and extract the entries since the last sync from Debian. ''' changelog = Changelog(srcpkg.getChangelog()) if changelog is None: return u'' delta = [] debian_info = DebianDistroInfo() for block in changelog: distribution = block.distributions.split()[0].split('-')[0] if debian_info.valid(distribution): break delta += [ unicode(change) for change in block.changes() if change.strip() ] return u'\n'.join(delta)
def main(): args = parse_args() if args.all: for distro in DebianDistroInfo().all: sys.stdout.write(distro + "\n") elif args.devel: sys.stdout.write(DebianDistroInfo().devel(args.date) + "\n") elif args.old: sys.stdout.write(DebianDistroInfo().old(args.date) + "\n") elif args.stable: sys.stdout.write(DebianDistroInfo().stable(args.date) + "\n") elif args.supported: for distro in DebianDistroInfo().supported(args.date): sys.stdout.write(distro + "\n") elif args.testing: sys.stdout.write(DebianDistroInfo().testing(args.date) + "\n") elif args.unsupported: for distro in DebianDistroInfo().unsupported(args.date): sys.stdout.write(distro + "\n")
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import os, re from flask import Flask, Response, Markup, request, render_template, make_response from distro_info import DebianDistroInfo, UbuntuDistroInfo debian = DebianDistroInfo() ubuntu = UbuntuDistroInfo() supported = list(reversed(debian.supported())) + list( reversed(ubuntu.supported())) app = Flask(__name__) _pattern = re.compile("^([0-9a-f]{8})$") def get_file_path(remote_addr, file_name, series=None, code=None): if code and code == "default": return os.path.join(app.root_path, file_name) ip_addr = '' if code and _pattern.match(code): for i in (0, 2, 4, 6): ip_addr = ip_addr + str(int("0x" + code[i:i + 2], 16)) + '.' else: ip_addr = ip_addr[:-1] if series and series in supported: if ip_addr:
def setUp(self): self._distro_info = DebianDistroInfo() self._date = datetime.date(2011, 1, 10)
def setUp(self): # pylint: disable=invalid-name self._distro_info = DebianDistroInfo() self._date = datetime.date(2011, 1, 10)
def __init__(self): super(Codenames, self).__init__() self.debian_info = DebianDistroInfo() self.ubuntu_info = UbuntuDistroInfo() self.settings = None
DEFAULT_AGE_THRESHOLD_DAYS = 5 * 365 maintscripts = [] for entry in os.scandir('debian'): if not (entry.name == "maintscript" or entry.name.endswith(".maintscript")): continue maintscripts.append(entry.name) # Determine the date for which versions created then should still be supported. # This is a little bit tricky since versions uploaded at a particular date # may not have made it into the release then. from distro_info import DebianDistroInfo # noqa: E402 try: [release] = [ r for r in DebianDistroInfo().get_all('object') if r.codename.lower() == upgrade_release() ] except ValueError: date_threshold = None else: date_threshold = release.release if date_threshold is None: # Release has not yet or will never be released # Default to 5 years date_threshold = (datetime.now() - timedelta(days=DEFAULT_AGE_THRESHOLD_DAYS)).date() cl_dates = [] with ChangelogEditor() as cl:
def backport_suffix(release): distro_info = DebianDistroInfo() version = distro_info.version(release) return "bpo%s" % version