~ubuntu-virt/vmbuilder/trunk

« back to all changes in this revision

Viewing changes to VMBuilder/builder.py

  • Committer: Soren Hansen
  • Date: 2008-06-27 12:47:26 UTC
  • Revision ID: soren.hansen@canonical.com-20080627124726-kj690sepircudc3h
Import python rewrite.. It's not quite at a useful point yet (only cli+kvm+hardy is in a usable state), but it's getting there..

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import VMBuilder
 
2
import util
 
3
 
 
4
rootmnt = None
 
5
tmproot = None
 
6
 
 
7
def create_directory_structure():
 
8
    VMBuilder.workdir = create_workdir()
 
9
    add_clean_cmd('rm', '-rf', workdir)
 
10
 
 
11
    logging.debug('Temporary directory: %s', workdir)
 
12
 
 
13
    # rootmnt is where the disk images will be mounted
 
14
    rootmnt = '%s/target' % workdir
 
15
    logging.debug('Creating the root mount directory: %s', rootmnt)
 
16
    os.mkdir(rootmnt)
 
17
 
 
18
    # tmproot it where we build up the guest filesystem
 
19
    tmproot = '%s/root' % workdir
 
20
    logging.debug('Creating temporary root: %s', tmproot)
 
21
    os.mkdir(tmproot)
 
22
 
 
23
    logging.debug('Creating destination directory: %s', options.destdir)
 
24
    os.mkdir(options.destdir)
 
25
    util.give_to_caller(options.destdir)
 
26
 
 
27
    disks = disk_layout()
 
28
 
 
29
def create_workdir():
 
30
    if options.tmp is not None:
 
31
        workdir = tempfile.mkdtemp('', 'vmbuilder', options.tmp)
 
32
    else:
 
33
        workdir = tempfile.mkdtemp('', 'vmbuilder')
 
34
 
 
35
    return workdir
 
36
 
 
37