~ubuntu-branches/ubuntu/utopic/curtin/utopic

« back to all changes in this revision

Viewing changes to curtin/block/__init__.py

  • Committer: Package Import Robot
  • Author(s): Scott Moser
  • Date: 2014-07-22 18:53:38 UTC
  • mfrom: (1.1.13)
  • Revision ID: package-import@ubuntu.com-20140722185338-2nm6ekaottq6ldge
Tags: 0.1.0~bzr142-0ubuntu1
* New upstream snapshot.
  * add utility for parsing /etc/network/interfaces
  * aarm64 support [Newell Jensen]
    * run update-initramfs in aarm64
    * create boot partition when necessary (LP: #1338851 LP: #1340942)
  * know kernel mapping for utopic (3.16)
  * properly write fstype into /etc/fstab per provided fstype
  * add support for disk images as type 'dd-tgz'
  * correctly call finalize in target (LP: #1328521)
  * support invoking tar with --xattrs if available (LP: #1307636)
  * increase size of uefi partition to 512M (LP: #1306164)

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
import os
20
20
import stat
21
21
import shlex
 
22
import tempfile
22
23
 
23
24
from curtin import util
24
25
 
154
155
    return (diskdevpath, ptnum)
155
156
 
156
157
 
 
158
def get_pardevs_on_blockdevs(devs):
 
159
    if devs is None:
 
160
        devs = []
 
161
    devs = [get_dev_name_entry(d)[1] for d in devs]
 
162
    found = _lsblock(devs)
 
163
    ret = {}
 
164
    for short in found:
 
165
        if found[short]['device_path'] not in devs:
 
166
            ret[short] = found[short]
 
167
    return ret
 
168
 
 
169
 
 
170
def get_root_device(dev):
 
171
    """
 
172
    Get root partition for specified device
 
173
    """
 
174
    partitions = get_pardevs_on_blockdevs(dev)
 
175
    target = None
 
176
    for i in partitions:
 
177
        dev_path = partitions[i]['device_path']
 
178
        tmp_mount = tempfile.mkdtemp()
 
179
        try:
 
180
            util.do_mount(dev_path, tmp_mount)
 
181
            curtin_dir = os.path.join(tmp_mount, 'curtin')
 
182
            if os.path.isdir(curtin_dir) is False:
 
183
                continue
 
184
            target = dev_path
 
185
            util.do_umount(tmp_mount)
 
186
        except:
 
187
            util.do_umount(tmp_mount)
 
188
    if target is None:
 
189
        raise ValueError("Could not find root device")
 
190
    return target
 
191
 
157
192
# vi: ts=4 expandtab syntax=python