Allow controlling packager identity through environment variables
In order to support more flexible automation mechanisms, allow injecting the packager identity through environment variables as an override from the regular detection mechanisms. Moreover, there are cases where we want to force the fallback identity, so we now have a way to force that through an environment variable. These are intended to be used with multi-user automation systems so that the correct identity is set regardless of what the host system is actually configured with. Signed-off-by: Neal Gompa <ngompa13@gmail.com>
This commit is contained in:
parent
c57afa88aa
commit
f83b3dd937
1 changed files with 11 additions and 0 deletions
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue