def version_decrement(version):
    """ Guess the lower version of the one given. """

    major, minor, patch, *dev = map(int, version.split("."))

    if dev:
        dev[0] -= 1
        if dev[0] < 0:
            dev[0] = 0
            patch -= 1
    else:
        patch -= 1

    if patch < 0:
        patch = 9
        minor -= 1
    if minor < 0:
        minor = 9
        major -= 1

    numbers = [major, minor, patch]
    if dev:
        numbers.append(dev[0])

    return ".".join(map(str, numbers))
Example #2
0
def version_decrement(version):
    """ Guess the lower version of the one given. """

    major, minor, patch, *dev = map(int, version.split("."))

    if dev:
        dev[0] -= 1
        if dev[0] < 0:
            dev[0] = 0
            patch -= 1
    else:
        patch -= 1

    if patch < 0:
        patch = 9
        minor -= 1
    if minor < 0:
        minor = 9
        major -= 1

    numbers = [major, minor, patch]
    if dev:
        numbers.append(dev[0])

    return ".".join(map(str, numbers))
Example #3
0
    def get_package_real(self, obs_name, upstream_name):
        m = Message()
        f = Fetcher()

        base = "%s/%s" % (self.base_url, upstream_name)
        url = "%s/cache.json" % base
        fp = f.get(url)
        j = json.load(fp)

        stable = []
        unstable = []

        if upstream_name in PackageSource.no_odd_even_rule:
            versions = j[2][upstream_name]
        else:
            for version in j[2][upstream_name]:
                v = version.split(".")
                major = int(v[0])
                minor = int(v[1])

                if obs_name in self.gnome2 and (major != 2 or minor >= 90):
                    continue

                if minor % 2 == 0:
                    stable.append(version)
                else:
                    unstable.append(version)

            versions = stable

        if len(versions) == 0:
            m.warn("could not parse json data: %s" % j[2])
            return None

        return Package(obs_name, versions)
Example #4
0
    def get_package_real(self, obs_name, upstream_name):
        m = Message()
        f = Fetcher()

        base = "%s/%s" % (self.base_url, upstream_name)
        url = "%s/cache.json" % base
        fp = f.get(url)
        j = json.load(fp)

        stable = []
        unstable = []

        if upstream_name in PackageSource.no_odd_even_rule:
            versions = j[2][upstream_name]
        else:
            for version in j[2][upstream_name]:
                v = version.split(".")
                major = int(v[0])
                minor = int(v[1])

                if obs_name in self.gnome2 and (major != 2 or minor >= 90):
                    continue

                if minor % 2 == 0:
                    stable.append(version)
                else:
                    unstable.append(version)

            versions = stable

        if len(versions) == 0:
            m.warn("could not parse json data: %s" % j[2])
            return None

        return Package(obs_name, versions)
def _get_virtio_urls(baseurl, version):
    want = [
        "virtio-win-prewhql-%s.zip" % version.split("-")[0],
        "virtio-win-prewhql-%s-sources.zip" % version
    ]
    skip = ["virtio-win-prewhql-%s-spec.zip" % version]
    return _distill_links(baseurl + "win/", "zip", want, skip)
Example #6
0
 def __init__(self):
     ua = flask.request.headers.get('user-agent', '')
     m = _re_docker_version.search(ua)
     if not m:
         raise RuntimeError('toolkit.DockerVersion: cannot parse version')
     version = m.group(1)
     if '-' in version:
         version = version.split('-')[0]
     distutils.version.StrictVersion.__init__(self, version)
def version_decrement(version):
    """ Guess the lower version of the one given. """

    major, minor, patch = map(int, version.split('.'))

    patch -= 1
    if patch < 0:
        patch = 9
        minor -= 1
    if minor < 0:
        minor = 9
        major -= 1

    return '.'.join(map(str, [major, minor, patch]))
def version_decrement(version):
    """ Guess the lower version of the one given. """

    major, minor, patch = map(int, version.split('.'))

    patch -= 1
    if patch < 0:
        patch = 9
        minor -= 1
    if minor < 0:
        minor = 9
        major -= 1

    return '.'.join(map(str, [major, minor, patch]))
def get_pkg_version(package):
    """ get major, minor version of package """
    command = "pkg-config --modversion " + package
    status, output = getstatusoutput(command)
    if status != 0:
        print("setup.py: get_pkg_version({}): "
              "pkg-config returned exit code {}" \
              .format(repr(package), status), file=sys.stderr)
        sys.exit(2)

    version = re.search('(?:(?:\d+)\.)+\d+', output).group()
    components = version.split(".")
    major, minor = int(components[0]), int(components[1])
    revision = int(components[2]) if len(components) >= 3 else 0
    return major, minor, revision
Example #10
0
def get_pkg_version(package):
    """ get major, minor version of package """
    command = "pkg-config --modversion " + package
    status, output = getstatusoutput(command)
    if status != 0:
        print("setup.py: get_pkg_version({}): "
              "pkg-config returned exit code {}" \
              .format(repr(package), status), file=sys.stderr)
        sys.exit(2)

    version = re.search('(?:(?:\d+)\.)+\d+', output).group()
    components = version.split(".")
    major, minor = int(components[0]), int(components[1])
    revision = int(components[2]) if len(components) >= 3 else 0
    return major, minor, revision
Example #11
0
    def GetDefaultVersion(self):
        """Get the default SDK version to use.

    If we are in an existing SDK shell, use the SDK version of the shell.
    Otherwise, use what we defaulted to last time.  If there was no last time,
    returns None.
    """
        if os.environ.get(self.SDK_BOARD_ENV) == self.board:
            sdk_version = os.environ.get(self.SDK_VERSION_ENV)
            if sdk_version is not None:
                return sdk_version

        with self.misc_cache.Lookup((self.board, 'latest')) as ref:
            if ref.Exists(lock=True):
                version = osutils.ReadFile(ref.path).strip()
                # Deal with the old version format.
                if version.startswith('R'):
                    version = version.split('-')[1]
                return version
            else:
                return None
Example #12
0
    def GetDefaultVersion(self):
        """Get the default SDK version to use.

    If we are in an existing SDK shell, the default version will just be
    the current version. Otherwise, we will try to calculate the
    appropriate version to use based on the checkout.
    """
        if os.environ.get(self.SDK_BOARD_ENV) == self.board:
            sdk_version = os.environ.get(self.SDK_VERSION_ENV)
            if sdk_version is not None:
                return sdk_version

        with self.misc_cache.Lookup((self.board, 'latest')) as ref:
            if ref.Exists(lock=True):
                version = osutils.ReadFile(ref.path).strip()
                # Deal with the old version format.
                if version.startswith('R'):
                    version = version.split('-')[1]
                return version
            else:
                return None
Example #13
0
  def GetDefaultVersion(self):
    """Get the default SDK version to use.

    If we are in an existing SDK shell, use the SDK version of the shell.
    Otherwise, use what we defaulted to last time.  If there was no last time,
    returns None.
    """
    if os.environ.get(self.SDK_BOARD_ENV) == self.board:
      sdk_version = os.environ.get(self.SDK_VERSION_ENV)
      if sdk_version is not None:
        return sdk_version

    with self.misc_cache.Lookup((self.board, 'latest')) as ref:
      if ref.Exists(lock=True):
        version = osutils.ReadFile(ref.path).strip()
        # Deal with the old version format.
        if version.startswith('R'):
          version = version.split('-')[1]
        return version
      else:
        return None
  def GetDefaultVersion(self):
    """Get the default SDK version to use.

    If we are in an existing SDK shell, the default version will just be
    the current version. Otherwise, we will try to calculate the
    appropriate version to use based on the checkout.
    """
    if os.environ.get(self.SDK_BOARD_ENV) == self.board:
      sdk_version = os.environ.get(self.SDK_VERSION_ENV)
      if sdk_version is not None:
        return sdk_version

    with self.misc_cache.Lookup((self.board, 'latest')) as ref:
      if ref.Exists(lock=True):
        version = osutils.ReadFile(ref.path).strip()
        # Deal with the old version format.
        if version.startswith('R'):
          version = version.split('-')[1]
        return version
      else:
        return None
Example #15
0
def default_build_triple(verbose):
    """Build triple as in LLVM"""
    # If the user already has a host build triple with an existing `rustc`
    # install, use their preference. This fixes most issues with Windows builds
    # being detected as GNU instead of MSVC.
    default_encoding = sys.getdefaultencoding()
    try:
        version = subprocess.check_output(["rustc", "--version", "--verbose"],
                                          stderr=subprocess.DEVNULL)
        version = version.decode(default_encoding)
        host = next(x for x in version.split('\n') if x.startswith("host: "))
        triple = host.split("host: ")[1]
        if verbose:
            print("detected default triple {}".format(triple))
        return triple
    except Exception as e:
        if verbose:
            print("rustup not detected: {}".format(e))
            print("falling back to auto-detect")

    required = sys.platform != 'win32'
    ostype = require(["uname", "-s"], exit=required)
    cputype = require(['uname', '-m'], exit=required)

    # If we do not have `uname`, assume Windows.
    if ostype is None or cputype is None:
        return 'x86_64-pc-windows-msvc'

    ostype = ostype.decode(default_encoding)
    cputype = cputype.decode(default_encoding)

    # The goal here is to come up with the same triple as LLVM would,
    # at least for the subset of platforms we're willing to target.
    ostype_mapper = {
        'Darwin': 'apple-darwin',
        'DragonFly': 'unknown-dragonfly',
        'FreeBSD': 'unknown-freebsd',
        'Haiku': 'unknown-haiku',
        'NetBSD': 'unknown-netbsd',
        'OpenBSD': 'unknown-openbsd'
    }

    # Consider the direct transformation first and then the special cases
    if ostype in ostype_mapper:
        ostype = ostype_mapper[ostype]
    elif ostype == 'Linux':
        os_from_sp = subprocess.check_output(
            ['uname', '-o']).strip().decode(default_encoding)
        if os_from_sp == 'Android':
            ostype = 'linux-android'
        else:
            ostype = 'unknown-linux-gnu'
    elif ostype == 'SunOS':
        ostype = 'sun-solaris'
        # On Solaris, uname -m will return a machine classification instead
        # of a cpu type, so uname -p is recommended instead.  However, the
        # output from that option is too generic for our purposes (it will
        # always emit 'i386' on x86/amd64 systems).  As such, isainfo -k
        # must be used instead.
        cputype = require(['isainfo', '-k']).decode(default_encoding)
    elif ostype.startswith('MINGW'):
        # msys' `uname` does not print gcc configuration, but prints msys
        # configuration. so we cannot believe `uname -m`:
        # msys1 is always i686 and msys2 is always x86_64.
        # instead, msys defines $MSYSTEM which is MINGW32 on i686 and
        # MINGW64 on x86_64.
        ostype = 'pc-windows-gnu'
        cputype = 'i686'
        if os.environ.get('MSYSTEM') == 'MINGW64':
            cputype = 'x86_64'
    elif ostype.startswith('MSYS'):
        ostype = 'pc-windows-gnu'
    elif ostype.startswith('CYGWIN_NT'):
        cputype = 'i686'
        if ostype.endswith('WOW64'):
            cputype = 'x86_64'
        ostype = 'pc-windows-gnu'
    elif sys.platform == 'win32':
        # Some Windows platforms might have a `uname` command that returns a
        # non-standard string (e.g. gnuwin32 tools returns `windows32`). In
        # these cases, fall back to using sys.platform.
        return 'x86_64-pc-windows-msvc'
    else:
        err = "unknown OS type: {}".format(ostype)
        sys.exit(err)

    if cputype == 'powerpc' and ostype == 'unknown-freebsd':
        cputype = subprocess.check_output(['uname', '-p'
                                           ]).strip().decode(default_encoding)
    cputype_mapper = {
        'BePC': 'i686',
        'aarch64': 'aarch64',
        'amd64': 'x86_64',
        'arm64': 'aarch64',
        'i386': 'i686',
        'i486': 'i686',
        'i686': 'i686',
        'i786': 'i686',
        'powerpc': 'powerpc',
        'powerpc64': 'powerpc64',
        'powerpc64le': 'powerpc64le',
        'ppc': 'powerpc',
        'ppc64': 'powerpc64',
        'ppc64le': 'powerpc64le',
        's390x': 's390x',
        'x64': 'x86_64',
        'x86': 'i686',
        'x86-64': 'x86_64',
        'x86_64': 'x86_64'
    }

    # Consider the direct transformation first and then the special cases
    if cputype in cputype_mapper:
        cputype = cputype_mapper[cputype]
    elif cputype in {'xscale', 'arm'}:
        cputype = 'arm'
        if ostype == 'linux-android':
            ostype = 'linux-androideabi'
        elif ostype == 'unknown-freebsd':
            cputype = subprocess.check_output(
                ['uname', '-p']).strip().decode(default_encoding)
            ostype = 'unknown-freebsd'
    elif cputype == 'armv6l':
        cputype = 'arm'
        if ostype == 'linux-android':
            ostype = 'linux-androideabi'
        else:
            ostype += 'eabihf'
    elif cputype in {'armv7l', 'armv8l'}:
        cputype = 'armv7'
        if ostype == 'linux-android':
            ostype = 'linux-androideabi'
        else:
            ostype += 'eabihf'
    elif cputype == 'mips':
        if sys.byteorder == 'big':
            cputype = 'mips'
        elif sys.byteorder == 'little':
            cputype = 'mipsel'
        else:
            raise ValueError("unknown byteorder: {}".format(sys.byteorder))
    elif cputype == 'mips64':
        if sys.byteorder == 'big':
            cputype = 'mips64'
        elif sys.byteorder == 'little':
            cputype = 'mips64el'
        else:
            raise ValueError('unknown byteorder: {}'.format(sys.byteorder))
        # only the n64 ABI is supported, indicate it
        ostype += 'abi64'
    elif cputype == 'sparc' or cputype == 'sparcv9' or cputype == 'sparc64':
        pass
    else:
        err = "unknown cpu type: {}".format(cputype)
        sys.exit(err)

    return "{}-{}".format(cputype, ostype)
Example #16
0
 def ValidateVersion(version):
     if version.startswith('R') or len(version.split('.')) != 3:
         raise argparse.ArgumentTypeError(
             '--version should be in the format 3912.0.0')
     return version
Example #17
0
def find_builds_from_tags():
    session = get_session()

    with futures.ThreadPoolExecutor(requests.adapters.DEFAULT_POOLSIZE) as e:
        archive_fs = []
        seen_tags = set()

        # Need to process in order because we only process each tag once.
        for repo, channel in TAGS_REPOS:
            url = 'https://hg.mozilla.org/%s/json-tags' % repo

            r = session.get(url)
            if r.status_code != 200:
                raise Exception('unexpected non-200 from %s' % url)

            for entry in r.json()['tags']:
                m = RE_TAG.match(entry['tag'])
                if not m:
                    continue

                if entry['tag'] in seen_tags:
                    continue
                seen_tags.add(entry['tag'])

                version = m.group('version')

                if 'a' in version:
                    sep = 'a'
                    major, sub = version.split('a')
                elif 'b' in version:
                    sep = 'b'
                    major, sub = version.split('b')
                else:
                    major = version
                    sub = None

                major = major.replace('_', '.')
                app_version = major
                if sub:
                    app_version += '%s%s' % (sep, sub)

                # Some releases are tagged but were never released. Skip them.
                if app_version in MISSING_RELEASES:
                    continue

                # There are no build ids for release builds. Construct a
                # dummy one from the tag date.
                td = datetime.timedelta(seconds=entry['date'][0])
                dt = datetime.datetime(1970, 1, 1) + td
                day = dt.date()

                build_id = dt.strftime('%Y%m%d%H%M%S')

                for platform, archive_platform in RELEASES_PLATFORMS.items():
                    # win64 not produced until release 42.
                    if platform == 'win64':
                        v = distutils.version.StrictVersion
                        ours = v(major) if '.' in major else v('%s.0' % major)

                        if ours < v('42.0'):
                            continue

                    archive_url = '%s/%s/%s/' % (RELEASES_ARCHIVE_URL,
                                                 app_version, archive_platform)

                    build = {
                        'revision': entry['node'],
                        'tag': entry['tag'],
                        'channel': channel,
                        'app_version': app_version,
                        'platform': platform,
                        'archive_url': archive_url,
                        'build_id': build_id,
                        'day': day,
                    }

                    archive_fs.append((build,
                                       e.submit(session.get, archive_url)))

        for build, f in archive_fs:
            r = f.result()
            if r.status_code != 200:
                # We shouldn't hit this.
                print('could not find release %s %s from tag %s' % (
                    build['app_version'], build['platform'], build['tag']))
                continue

            yield build
Example #18
0
 def ValidateVersion(version):
   if version.startswith('R') or len(version.split('.')) != 3:
     raise argparse.ArgumentTypeError(
         '--version should be in the format 3912.0.0')
   return version
Example #19
0
def parse_version(version):
  return tuple(map(int, version.split(".")))