Add is_debian()
convenience function
This commit is contained in:
parent
e8821b3395
commit
7471dd1bf5
|
@ -2,7 +2,7 @@
|
||||||
################################################################################
|
################################################################################
|
||||||
#
|
#
|
||||||
# Rattail -- Retail Software Framework
|
# Rattail -- Retail Software Framework
|
||||||
# Copyright © 2010-2019 Lance Edgar
|
# Copyright © 2010-2020 Lance Edgar
|
||||||
#
|
#
|
||||||
# This file is part of Rattail.
|
# This file is part of Rattail.
|
||||||
#
|
#
|
||||||
|
@ -28,6 +28,7 @@ Fabric deployment and maintenance.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from .core import (
|
from .core import (
|
||||||
|
is_debian,
|
||||||
get_debian_version,
|
get_debian_version,
|
||||||
get_ubuntu_version,
|
get_ubuntu_version,
|
||||||
Deployer,
|
Deployer,
|
||||||
|
|
|
@ -64,6 +64,27 @@ def is_link(c, path, use_sudo=False):
|
||||||
return False if result.failed else True
|
return False if result.failed else True
|
||||||
|
|
||||||
|
|
||||||
|
def get_os_release_id(c):
|
||||||
|
"""
|
||||||
|
Return the "ID" field from `/etc/os-release` file
|
||||||
|
"""
|
||||||
|
contents = c.run('cat /etc/os-release').stdout.strip()
|
||||||
|
data = {}
|
||||||
|
for line in contents.split('\n'):
|
||||||
|
field, value = line.split('=')
|
||||||
|
data[field] = value
|
||||||
|
return data['ID']
|
||||||
|
|
||||||
|
|
||||||
|
def is_debian(c):
|
||||||
|
"""
|
||||||
|
Return boolean indicating if this machine is Debian (proper, as opposed to
|
||||||
|
some derivative).
|
||||||
|
"""
|
||||||
|
release_id = get_os_release_id(c)
|
||||||
|
return release_id == 'debian'
|
||||||
|
|
||||||
|
|
||||||
def get_debian_version(c):
|
def get_debian_version(c):
|
||||||
"""
|
"""
|
||||||
Fetch the version of Debian running on the target system.
|
Fetch the version of Debian running on the target system.
|
||||||
|
|
Loading…
Reference in a new issue