1
0
mirror of https://github.com/facebook/proxygen.git synced 2025-08-07 07:02:53 +03:00

add dry-run option to install-system-deps

Summary: Useful to be able to see what packages would be installed without doing it, and to see rpm vs deb packages

Reviewed By: Croohand

Differential Revision: D32693528

fbshipit-source-id: a01257e7192f2f0299d57f6f8f7ee93452a6f3e4
This commit is contained in:
Alex Hornby
2021-12-02 09:33:00 -08:00
committed by Facebook GitHub Bot
parent 50d6ae6438
commit b26c89fe2a

View File

@@ -339,6 +339,18 @@ class InstallSysDepsCmd(ProjectCmdBase):
action="store_true", action="store_true",
default=False, default=False,
) )
parser.add_argument(
"--dry-run",
action="store_true",
default=False,
help="Don't install, just print the commands specs we would run",
)
parser.add_argument(
"--package-type",
choices=["rpm", "deb"],
default=None,
help="Allow overriding the package type so can see deb from centos",
)
def run_project_cmd(self, args, loader, manifest): def run_project_cmd(self, args, loader, manifest):
if args.recursive: if args.recursive:
@@ -346,7 +358,6 @@ class InstallSysDepsCmd(ProjectCmdBase):
else: else:
projects = [manifest] projects = [manifest]
cache = cache_module.create_cache()
all_packages = {} all_packages = {}
for m in projects: for m in projects:
ctx = loader.ctx_gen.get_context(m.name) ctx = loader.ctx_gen.get_context(m.name)
@@ -356,20 +367,34 @@ class InstallSysDepsCmd(ProjectCmdBase):
merged += v merged += v
all_packages[k] = merged all_packages[k] = merged
manager = loader.build_opts.host_type.get_package_manager() if args.package_type:
manager = args.package_type
else:
manager = loader.build_opts.host_type.get_package_manager()
cmd_args = None
if manager == "rpm": if manager == "rpm":
packages = sorted(list(set(all_packages["rpm"]))) packages = sorted(list(set(all_packages["rpm"])))
if packages: if packages:
run_cmd(["dnf", "install", "-y"] + packages) cmd_args = ["dnf", "install", "-y"] + packages
elif manager == "deb": elif manager == "deb":
packages = sorted(list(set(all_packages["deb"]))) packages = sorted(list(set(all_packages["deb"])))
if packages: if packages:
run_cmd(["apt", "install", "-y"] + packages) cmd_args = ["apt", "install", "-y"] + packages
else: else:
host_tuple = loader.build_opts.host_type.as_tuple_string() host_tuple = loader.build_opts.host_type.as_tuple_string()
print( print(
f"I don't know how to install any packages on this system {host_tuple}" f"I don't know how to install any packages on this system {host_tuple}"
) )
return
if cmd_args:
if args.dry_run:
print(" ".join(cmd_args))
else:
run_cmd(cmd_args)
else:
print("no packages to install")
@cmd("list-deps", "lists the transitive deps for a given project") @cmd("list-deps", "lists the transitive deps for a given project")