From: Tollef Fog Heen Date: Mon, 7 Apr 2014 08:53:52 +0000 (+0200) Subject: Ignore failure to set host name X-Git-Url: https://git.siccegge.de//index.cgi?a=commitdiff_plain;h=a2198ae35b2ed0332580f11829a860ce9d31100d;p=forks%2Fvmdebootstrap.git Ignore failure to set host name At least minbase does not end up with an /etc/hosts file, so ignore IOErrors for the hosts file. --- diff --git a/vmdebootstrap b/vmdebootstrap index 3344a59..a9f9e9b 100755 --- a/vmdebootstrap +++ b/vmdebootstrap @@ -292,13 +292,16 @@ class VmDebootstrap(cliapp.Application): f.write('%s\n' % hostname) etc_hosts = os.path.join(rootdir, 'etc', 'hosts') - with open(etc_hosts, 'r') as f: - data = f.read() - with open(etc_hosts, 'w') as f: - for line in data.splitlines(): - if line.startswith('127.0.0.1'): - line += ' %s' % hostname - f.write('%s\n' % line) + try: + with open(etc_hosts, 'r') as f: + data = f.read() + with open(etc_hosts, 'w') as f: + for line in data.splitlines(): + if line.startswith('127.0.0.1'): + line += ' %s' % hostname + f.write('%s\n' % line) + except IOError, e: + pass def create_fstab(self, rootdir, rootdev, roottype, bootdev, boottype): def fsuuid(device):