mirror of
https://github.com/facebook/sapling.git
synced 2025-01-07 22:21:40 +03:00
4c76d686a8
Summary: Automatic upgrade to remove `version` override and silence errors. Reviewed By: grievejia Differential Revision: D17956249 fbshipit-source-id: d5c8b5aa73151b3fea67aec35d70f332030da2c9
44 lines
1.3 KiB
Python
44 lines
1.3 KiB
Python
#!/usr/bin/env python3
|
|
# Copyright (c) Facebook, Inc. and its affiliates.
|
|
#
|
|
# This software may be used and distributed according to the terms of the
|
|
# GNU General Public License version 2.
|
|
|
|
import subprocess
|
|
from typing import Optional, Tuple, cast
|
|
|
|
from .config import EdenInstance
|
|
|
|
|
|
def get_installed_eden_rpm_version() -> str:
|
|
proc = subprocess.run(
|
|
["rpm", "-q", "fb-eden", "--queryformat", "%{version}-%{release}"],
|
|
stdout=subprocess.PIPE,
|
|
encoding="utf-8",
|
|
)
|
|
if proc.returncode != 0:
|
|
return "<Not Installed>"
|
|
# pyre-fixme[22]: The cast is redundant.
|
|
return cast(str, proc.stdout)
|
|
|
|
|
|
# returns (runing_version, release) tuple
|
|
def get_running_eden_version_parts(
|
|
instance: EdenInstance
|
|
) -> Tuple[Optional[str], Optional[str]]:
|
|
bi = instance.get_server_build_info()
|
|
return (bi.get("build_package_version"), bi.get("build_package_release"))
|
|
|
|
|
|
def format_running_eden_version(parts: Tuple[Optional[str], Optional[str]]) -> str:
|
|
running_version, release = parts
|
|
if running_version is None:
|
|
running_version = ""
|
|
if release is None:
|
|
release = ""
|
|
return f"{running_version}-{release}"
|
|
|
|
|
|
def get_running_eden_version(instance: EdenInstance) -> str:
|
|
return format_running_eden_version(get_running_eden_version_parts(instance))
|