new: Apply the locale to the default login class.

This commit is contained in:
Harm Weites 2013-12-18 23:36:16 +00:00
parent 46fa10f70c
commit 17ff0e7da2

View File

@ -210,10 +210,32 @@ class Distro(distros.Distro):
def _write_network(self, settings): def _write_network(self, settings):
return return
def apply_locale(): def apply_locale(self, locale, out_fn=None):
return loginconf = '/etc/login.conf'
newloginconf = '/tmp/login.conf.new'
backupconf = '/etc/login.conf.orig'
newconf = open(newloginconf, 'w')
origconf = open(loginconf, 'r')
for line in origconf:
newconf.write(re.sub('^default:', r'default:lang=%s:' % locale, line))
newconf.close()
origconf.close()
# Make a backup of login.conf.
copyfile(loginconf, backupconf)
# And copy the new login.conf.
copyfile(newloginconf, loginconf)
try:
util.logexc("Running cap_mkdb for %s", locale)
util.subp(['cap_mkdb', '/etc/login.conf'])
except:
# cap_mkdb failed, so restore the backup.
util.logexc("Failed to apply locale %s", locale)
copyfile(backupconf, loginconf)
def install_packages(): def install_packages():
return return