Revision 71b0ab28 image_creator/os_type/unix.py
b/image_creator/os_type/unix.py | ||
---|---|---|
47 | 47 |
'.kamaki.history' |
48 | 48 |
] |
49 | 49 |
|
50 |
def __init__(self, rootdev, ghandler, output): |
|
51 |
super(Unix, self).__init__(rootdev, ghandler, output) |
|
50 |
def _mountpoints(self): |
|
51 |
"""Return mountpoints in the correct order. |
|
52 |
/ should be mounted before /boot or /usr, /usr befor /usr/bin ... |
|
53 |
""" |
|
54 |
mps = self.g.inspect_get_mountpoints(self.root) |
|
55 |
|
|
56 |
def compare(a, b): |
|
57 |
if len(a[0]) > len(b[0]): |
|
58 |
return 1 |
|
59 |
elif len(a[0]) == len(b[0]): |
|
60 |
return 0 |
|
61 |
else: |
|
62 |
return -1 |
|
63 |
mps.sort(compare) |
|
64 |
|
|
65 |
for mp in mps: |
|
66 |
yield mp |
|
67 |
|
|
68 |
def _do_mount(self, readonly): |
|
69 |
"""Mount partitions in the correct order""" |
|
70 |
|
|
71 |
critical_mpoints = ('/', '/etc', '/root', '/home', '/var') |
|
72 |
|
|
73 |
mopts = 'ro' if readonly else 'rw' |
|
74 |
for mp, dev in self._mountpoints(): |
|
75 |
try: |
|
76 |
self.g.mount_options(mopts, dev, mp) |
|
77 |
except RuntimeError as msg: |
|
78 |
if mp in critical_mpoint: |
|
79 |
self.out.warn('unable to mount %s. Reason: %s' % (mp, msg)) |
|
80 |
return False |
|
81 |
else: |
|
82 |
self.out.warn('%s (ignored)' % msg) |
|
83 |
|
|
84 |
return True |
|
52 | 85 |
|
53 | 86 |
@sysprep() |
54 | 87 |
def cleanup_cache(self, print_header=True): |
Also available in: Unified diff