O instalador do Ubuntu é chamado ubiquity . O changelog de ubiquidade 2.3.18 menciona
"Use dmidecode to get a more unique suffix for the hostname (LP: #628087)."
O código exato do python é:
def dmimodel():
model = ''
kwargs = {}
if os.geteuid() != 0:
# Silence annoying warnings during the test suite.
kwargs['stderr'] = open('/dev/null', 'w')
try:
proc = subprocess.Popen(
['dmidecode', '--quiet', '--string', 'system-manufacturer'],
stdout=subprocess.PIPE, universal_newlines=True, **kwargs)
manufacturer = proc.communicate()[0]
if not manufacturer:
return
manufacturer = manufacturer.lower()
if 'to be filled' in manufacturer:
# Don't bother with products in development.
return
if 'bochs' in manufacturer or 'vmware' in manufacturer:
model = 'virtual machine'
# VirtualBox sets an appropriate system-product-name.
else:
if 'lenovo' in manufacturer or 'ibm' in manufacturer:
key = 'system-version'
else:
key = 'system-product-name'
proc = subprocess.Popen(
['dmidecode', '--quiet', '--string', key],
stdout=subprocess.PIPE,
universal_newlines=True)
model = proc.communicate()[0]
if 'apple' in manufacturer:
# MacBook4,1 - strip the 4,1
model = re.sub('[^a-zA-Z\s]', '', model)
# Replace each gap of non-alphanumeric characters with a dash.
# Ensure the resulting string does not begin or end with a dash.
model = re.sub('[^a-zA-Z0-9]+', '-', model).rstrip('-').lstrip('-')
if model.lower() == 'not-available':
return
if model.lower() == "To be filled by O.E.M.".lower():
return
except Exception:
syslog.syslog(syslog.LOG_ERR, 'Unable to determine the model from DMI')
finally:
if 'stderr' in kwargs:
kwargs['stderr'].close()
return model
Editar: Você pode navegar pelo código baixando-o com:
cd /tmp
apt-get source ubiquity