diff --git a/rust2rpm/__main__.py b/rust2rpm/__main__.py index b22de61..cbb3a22 100644 --- a/rust2rpm/__main__.py +++ b/rust2rpm/__main__.py @@ -72,10 +72,21 @@ def detect_editor(): return editor def detect_packager(): + # If we're forcing the fallback... + if os.getenv("RUST2RPM_NO_DETECT_PACKAGER") is not None: + return None + + # If we're supplying packager identity through an environment variable... + packager_identity = os.getenv("RUST2RPM_PACKAGER") + if packager_identity is not None: + return packager_identity + + # If we're detecting packager identity through rpmdev-packager... rpmdev_packager = shutil.which("rpmdev-packager") if rpmdev_packager is not None: return subprocess.check_output(rpmdev_packager, universal_newlines=True).strip() + # If we're detecting packager identity through git configuration... git = shutil.which("git") if git is not None: name = subprocess.check_output([git, "config", "user.name"], universal_newlines=True).strip()