summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta/classes/useradd-staticids.bbclass30
1 files changed, 17 insertions, 13 deletions
diff --git a/meta/classes/useradd-staticids.bbclass b/meta/classes/useradd-staticids.bbclass
index a9b506d05d..440c0e3846 100644
--- a/meta/classes/useradd-staticids.bbclass
+++ b/meta/classes/useradd-staticids.bbclass
@@ -4,6 +4,7 @@ def update_useradd_static_config(d):
4 import argparse 4 import argparse
5 import itertools 5 import itertools
6 import re 6 import re
7 import errno
7 8
8 class myArgumentParser( argparse.ArgumentParser ): 9 class myArgumentParser( argparse.ArgumentParser ):
9 def _print_message(self, message, file=None): 10 def _print_message(self, message, file=None):
@@ -30,19 +31,22 @@ def update_useradd_static_config(d):
30 are set).""" 31 are set)."""
31 id_table = dict() 32 id_table = dict()
32 for conf in file_list.split(): 33 for conf in file_list.split():
33 if os.path.exists(conf): 34 try:
34 f = open(conf, "r") 35 with open(conf, "r") as f:
35 for line in f: 36 for line in f:
36 if line.startswith('#'): 37 if line.startswith('#'):
37 continue 38 continue
38 # Make sure there always are at least exp_fields elements in 39 # Make sure there always are at least exp_fields
39 # the field list. This allows for leaving out trailing 40 # elements in the field list. This allows for leaving
40 # colons in the files. 41 # out trailing colons in the files.
41 fields = list_extend(line.rstrip().split(":"), exp_fields) 42 fields = list_extend(line.rstrip().split(":"), exp_fields)
42 if fields[0] not in id_table: 43 if fields[0] not in id_table:
43 id_table[fields[0]] = fields 44 id_table[fields[0]] = fields
44 else: 45 else:
45 id_table[fields[0]] = list(itertools.imap(lambda x, y: x or y, fields, id_table[fields[0]])) 46 id_table[fields[0]] = list(itertools.imap(lambda x, y: x or y, fields, id_table[fields[0]]))
47 except IOError as e:
48 if e.errno == errno.ENOENT:
49 pass
46 50
47 return id_table 51 return id_table
48 52