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)
class Codenames(Base): name = 'codenames' def __init__(self): super(Codenames, self).__init__() self.debian_info = DebianDistroInfo() self.ubuntu_info = UbuntuDistroInfo() self.settings = None def define_settings(self, settings): self.settings = settings def suite_to_codename(self, distro): suite = self.debian_info.codename(distro, datetime.date.today()) if not suite: return distro return suite def was_oldstable(self, limit): suite = self.suite_to_codename(self.settings['distribution']) # this check is only for debian if not self.debian_info.valid(suite): return False return suite == self.debian_info.old(limit) def was_stable(self, limit): suite = self.suite_to_codename(self.settings['distribution']) # this check is only for debian if not self.debian_info.valid(suite): return False return suite == self.debian_info.stable(limit) def kernel_package(self): packages = [] if self.settings['no-kernel'] or self.settings['kernel-package']: return packages if self.settings['arch'] == 'i386': # wheezy (which became oldstable on 2015-04-25) used '486' if self.was_oldstable(datetime.date(2015, 4, 26)): kernel_arch = '486' # jessie (which became oldstable on 2017-06-17) used '586' elif self.was_oldstable(datetime.date(2017, 6, 18)): kernel_arch = '586' else: kernel_arch = '686' elif self.settings['arch'] == 'armhf': kernel_arch = 'armmp' elif self.settings['arch'] == 'ppc64el': kernel_arch = 'powerpc64le' else: kernel_arch = self.settings['arch'] packages.append('linux-image-%s' % kernel_arch) return packages
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())
class Codenames(Base): name = 'codenames' def __init__(self): super(Codenames, self).__init__() self.debian_info = DebianDistroInfo() self.ubuntu_info = UbuntuDistroInfo() self.settings = None def define_settings(self, settings): self.settings = settings def suite_to_codename(self, distro): suite = self.debian_info.codename(distro, datetime.date.today()) if not suite: return distro return suite def was_oldstable(self, limit): suite = self.suite_to_codename(self.settings['distribution']) # this check is only for debian if not self.debian_info.valid(suite): return False return suite == self.debian_info.old(limit) def was_stable(self, limit): suite = self.suite_to_codename(self.settings['distribution']) # this check is only for debian if not self.debian_info.valid(suite): return False return suite == self.debian_info.stable(limit) def kernel_package(self): packages = [] if self.settings['no-kernel'] or self.settings['kernel-package']: return packages if self.settings['arch'] == 'i386': # wheezy (which became oldstable on 04/25/2015) used '486' if self.was_oldstable(datetime.date(2015, 4, 26)): kernel_arch = '486' else: kernel_arch = '586' elif self.settings['arch'] == 'armhf': kernel_arch = 'armmp' elif self.settings['arch'] == 'ppc64el': kernel_arch = 'powerpc64le' else: kernel_arch = self.settings['arch'] packages.append('linux-image-%s' % kernel_arch) return packages
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_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 _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")
def __init__(self): super(Codenames, self).__init__() self.debian_info = DebianDistroInfo() self.ubuntu_info = UbuntuDistroInfo() self.settings = None
#!/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)
class DebianDistroInfoTestCase(unittest.TestCase): """TestCase object for distro_info.DebianDistroInfo""" #pylint: disable=C0103 def setUp(self): self._distro_info = DebianDistroInfo() self._date = datetime.date(2011, 1, 10) #pylint: enable=C0103 def test_all(self): """Test: List all known Debian distributions.""" all_distros = set(["buzz", "rex", "bo", "hamm", "slink", "potato", "woody", "sarge", "etch", "lenny", "squeeze", "sid", "experimental"]) self.assertEqual(all_distros - set(self._distro_info.all), set()) def test_devel(self): """Test: Get latest development Debian distribution.""" self.assertEqual(self._distro_info.devel(self._date), "sid") def test_old(self): """Test: Get old (stable) Debian distribution.""" self.assertEqual(self._distro_info.old(self._date), "etch") def test_stable(self): """Test: Get latest stable Debian distribution.""" self.assertEqual(self._distro_info.stable(self._date), "lenny") def test_supported(self): """Test: List all supported Debian distribution.""" self.assertEqual(self._distro_info.supported(self._date), ["lenny", "squeeze", "sid", "experimental"]) def test_testing(self): """Test: Get latest testing Debian distribution.""" self.assertEqual(self._distro_info.testing(self._date), "squeeze") def test_valid(self): """Test: Check for valid Debian distribution.""" self.assertTrue(self._distro_info.valid("sid")) self.assertTrue(self._distro_info.valid("stable")) self.assertFalse(self._distro_info.valid("foobar")) def test_unsupported(self): """Test: List all unsupported Debian distribution.""" unsupported = ["buzz", "rex", "bo", "hamm", "slink", "potato", "woody", "sarge", "etch"] self.assertEqual(self._distro_info.unsupported(self._date), unsupported) def test_codename(self): """Test: Codename decoding""" self.assertIsNone(self._distro_info.codename('foobar')) self.assertEqual(self._distro_info.codename('testing', self._date), self._distro_info.testing(self._date)) def test_codename_result(self): """Test: Check result set to codename.""" self.assertEqual(self._distro_info.old(self._date, "codename"), "etch") self.assertEqual(self._distro_info.devel(self._date, result="codename"), "sid") def test_fullname(self): """Test: Check result set to fullname.""" self.assertEqual(self._distro_info.stable(self._date, "fullname"), 'Debian 5.0 "Lenny"') result = self._distro_info.testing(self._date, result="fullname") self.assertEqual(result, 'Debian 6.0 "Squeeze"') def test_release(self): """Test: Check result set to release.""" self.assertEqual(self._distro_info.devel(self._date, "release"), "") self.assertEqual(self._distro_info.testing(self._date, "release"), "6.0") self.assertEqual(self._distro_info.stable(self._date, result="release"), "5.0")
def setUp(self): # pylint: disable=invalid-name self._distro_info = DebianDistroInfo() self._date = datetime.date(2011, 1, 10)
def backport_suffix(release): distro_info = DebianDistroInfo() version = distro_info.version(release) return "bpo%s" % version
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: