@ -604,6 +604,10 @@ class Distribution(object):
This is unit tested . Please extend the tests to cover all distributions if you have them available .
"""
# every distribution name mentioned here, must have one of
# - allowempty == True
# - be listed in SEARCH_STRING
# - have a function get_distribution_DISTNAME implemented
OSDIST_LIST = (
{ ' path ' : ' /etc/oracle-release ' , ' name ' : ' OracleLinux ' } ,
{ ' path ' : ' /etc/slackware-version ' , ' name ' : ' Slackware ' } ,
@ -687,11 +691,11 @@ class Distribution(object):
if not os . path . exists ( path ) :
continue
if os . path . getsize ( path ) == 0 :
# if allowempty is set, we only check for file existance but not content
if ' allowempty ' in ddict and ddict [ ' allowempty ' ] :
self . facts [ ' distribution ' ] = name
break
else :
if os . path . getsize ( path ) == 0 :
continue
data = get_file_content ( path )
@ -707,6 +711,7 @@ class Distribution(object):
break
else :
# call a dedicated function for parsing the file content
try :
distfunc = getattr ( self , ' get_distribution_ ' + name )
parsed = distfunc ( name , data , path )
if parsed is None or parsed :
@ -714,6 +719,11 @@ class Distribution(object):
# break only if parsing was succesful
# otherwise continue with other distributions
break
except AttributeError :
# this should never happen, but if it does fail quitely and not with a traceback
pass
# to debug multiple matching release files, one can use:
# self.facts['distribution_debug'].append({path + ' ' + name:
@ -780,10 +790,6 @@ class Distribution(object):
if release :
self . facts [ ' distribution_release ' ] = release . groups ( ) [ 0 ]
def get_distribution_Archlinux ( self , name , data , path ) :
self . facts [ ' distribution ' ] = ' Archlinux '
self . facts [ ' distribution_version ' ] = data
def get_distribution_Alpine ( self , name , data , path ) :
self . facts [ ' distribution ' ] = ' Alpine '
self . facts [ ' distribution_version ' ] = data