mirror of
https://github.com/facebook/proxygen.git
synced 2025-08-10 05:22:59 +03:00
Summary: From the outset, we wanted to be sure that getdeps was able to source and build the dependencies so that we knew that we'd have a repeatable build. This came at the cost of build times: having to build boost on each CI run is a bit of a chore. This commit adds three new elements to the manifest files: * `rpms` - a list of RPM names that are all required to be present in order to consider the dependency satisfied * `debs` - like `rpms` above, but scoped to debian package names * `preinstalled.env` - a list of environment variables that if they are all set and non-empty will satisfy the dependency. A new `--allow-system-packages` option to getdeps enables the new logic that looks for system packages; it is off by default, but enabled in the generated GitHub Actions workflows. A new `install-system-deps` subcommand is provided that will attempt to install the system packages needed to satisfy the build. This typically needs to be run via sudo and is thus broken out separately from the main getdeps build flow. I made a pass over the manifest files and added package names that satisfy the build on ubuntu-18 and fedora-31. shri-khare: I renamed the `Python3.7.6` manifest to just `python` as part of this change; the version of python that it pulls in through the normal build is the same and I believe that an equal or newer version of python3 is available in the GH actions builder. The `preinstalled.env` is used only by the boost manifest: it references the name of an environment variable that is set by the github windows hosts and that points to a pre-built and pre-installed copy of boost. Since there is no package manager that we can easily query for this sort of thing, probing from the environment seems like a reasonable and fast way to check for this. We may need to evolve this over time to become more feature rich, but this seems like a good starting point. This commit has the potential to save 20 minutes of build time from each public CI build just due to the boost dependency alone! Refs: https://github.com/facebook/watchman/pull/797 Reviewed By: yfeldblum Differential Revision: D20740410 fbshipit-source-id: 6c38019449c54465127656c3d18a6ff1f30adaea
110 lines
2.9 KiB
Python
110 lines
2.9 KiB
Python
# Copyright (c) Facebook, Inc. and its affiliates.
|
|
#
|
|
# This source code is licensed under the MIT license found in the
|
|
# LICENSE file in the root directory of this source tree.
|
|
|
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
|
|
|
import re
|
|
import shlex
|
|
import sys
|
|
|
|
|
|
def is_windows():
|
|
""" Returns true if the system we are currently running on
|
|
is a Windows system """
|
|
return sys.platform.startswith("win")
|
|
|
|
|
|
def get_linux_type():
|
|
try:
|
|
with open("/etc/os-release") as f:
|
|
data = f.read()
|
|
except EnvironmentError:
|
|
return (None, None)
|
|
|
|
os_vars = {}
|
|
for line in data.splitlines():
|
|
parts = line.split("=", 1)
|
|
if len(parts) != 2:
|
|
continue
|
|
key = parts[0].strip()
|
|
value_parts = shlex.split(parts[1].strip())
|
|
if not value_parts:
|
|
value = ""
|
|
else:
|
|
value = value_parts[0]
|
|
os_vars[key] = value
|
|
|
|
name = os_vars.get("NAME")
|
|
if name:
|
|
name = name.lower()
|
|
name = re.sub("linux", "", name)
|
|
name = name.strip()
|
|
|
|
version_id = os_vars.get("VERSION_ID")
|
|
if version_id:
|
|
version_id = version_id.lower()
|
|
|
|
return "linux", name, version_id
|
|
|
|
|
|
class HostType(object):
|
|
def __init__(self, ostype=None, distro=None, distrovers=None):
|
|
if ostype is None:
|
|
distro = None
|
|
distrovers = None
|
|
if sys.platform.startswith("linux"):
|
|
ostype, distro, distrovers = get_linux_type()
|
|
elif sys.platform.startswith("darwin"):
|
|
ostype = "darwin"
|
|
elif is_windows():
|
|
ostype = "windows"
|
|
distrovers = str(sys.getwindowsversion().major)
|
|
else:
|
|
ostype = sys.platform
|
|
|
|
# The operating system type
|
|
self.ostype = ostype
|
|
# The distribution, if applicable
|
|
self.distro = distro
|
|
# The OS/distro version if known
|
|
self.distrovers = distrovers
|
|
|
|
def is_windows(self):
|
|
return self.ostype == "windows"
|
|
|
|
def is_darwin(self):
|
|
return self.ostype == "darwin"
|
|
|
|
def is_linux(self):
|
|
return self.ostype == "linux"
|
|
|
|
def as_tuple_string(self):
|
|
return "%s-%s-%s" % (
|
|
self.ostype,
|
|
self.distro or "none",
|
|
self.distrovers or "none",
|
|
)
|
|
|
|
def get_package_manager(self):
|
|
if not self.is_linux():
|
|
return None
|
|
if self.distro in ("fedora", "centos"):
|
|
return "rpm"
|
|
if self.distro in ("debian", "ubuntu"):
|
|
return "deb"
|
|
return None
|
|
|
|
@staticmethod
|
|
def from_tuple_string(s):
|
|
ostype, distro, distrovers = s.split("-")
|
|
return HostType(ostype=ostype, distro=distro, distrovers=distrovers)
|
|
|
|
def __eq__(self, b):
|
|
return (
|
|
self.ostype == b.ostype
|
|
and self.distro == b.distro
|
|
and self.distrovers == b.distrovers
|
|
)
|