예제 #1
0
def make_sources_list(cfg, target, suite):
    section = 'debrepos'
    aptdir = os.path.join(target, 'etc', 'apt')
    makepaths(aptdir)
    sources_list = file(os.path.join(aptdir, 'sources.list'), 'w')
    source = RepositorySource()
    source.uri = cfg.get(section, 'http_mirror')
    source.suite = suite
    source.set_path()
    sources_list.write(str(source) +'\n')
    source.type = 'deb-src'
    sources_list.write(str(source) +'\n')
    source.type = 'deb'
    if suite == 'woody' or cfg.has_option(section, '%s_nonus' % suite):
        source.suite += '/non-US'
        sources_list.write(str(source) +'\n')
        source.type = 'deb-src'
        sources_list.write(str(source) +'\n')
    loption = suite + '_local'
    if cfg.has_option(section, loption) and cfg[loption] == 'true':
        sources_list.write('deb %s/local %s/\n' % (source.uri, suite))
        sources_list.write('deb-src %s/local %s/\n' % (source.uri, suite))
    coption = suite + '_common'
    if cfg.has_option(section, coption) and cfg[coption] == 'true':
        sources_list.write('deb %s/local common/\n' % source.uri)
        sources_list.write('deb-src %s/local common/\n' % source.uri)
    sources_list.write('\n')
    sources_list.close()
예제 #2
0
 def export(self, mtypepath):
     mtype = self.getAttribute("name")
     path = join(mtypepath, mtype)
     makepaths(path)
     xfile = file(join(path, "machine_type.xml"), "w")
     xfile.write(self.toprettyxml())
     xfile.close()
예제 #3
0
def make_sources_list(cfg, target, suite):
    section = 'debrepos'
    aptdir = os.path.join(target, 'etc', 'apt')
    makepaths(aptdir)
    sources_list = file(os.path.join(aptdir, 'sources.list'), 'w')
    source = RepositorySource()
    source.uri = cfg.get('installer', 'http_mirror')
    source.suite = suite
    source.set_path()
    sources_list.write(str(source) +'\n')
    source.type = 'deb-src'
    sources_list.write(str(source) +'\n')
    source.type = 'deb'
    if suite == 'woody' or cfg.has_option(section, '%s_nonus' % suite):
        source.suite += '/non-US'
        sources_list.write(str(source) +'\n')
        source.type = 'deb-src'
        sources_list.write(str(source) +'\n')
    loption = suite + '_local'
    if _is_option_true(cfg, section, loption):
        sources_list.write('deb %s/local %s/\n' % (source.uri, suite))
        sources_list.write('deb-src %s/local %s/\n' % (source.uri, suite))
    coption = suite + '_common'
    if _is_option_true(cfg, section, coption):
        sources_list.write('deb %s/local common/\n' % source.uri)
        sources_list.write('deb-src %s/local common/\n' % source.uri)
    secopt = suite + '_updates'
    if _is_option_true(cfg, section, secopt):
        sline = ['deb', source.uri, '%s/updates' % suite, 'main contrib non-free']
        sources_list.write(' '.join(sline) + '\n')
        sline[0] = 'deb-src'
        sources_list.write(' '.join(sline) + '\n')
    sources_list.write('\n')
    sources_list.close()
예제 #4
0
 def ready_target(self):
     self._check_target()
     makepaths(self.target)
     device = self.machine.array_hack(self.machine.current.machine_type)
     clause = Eq('filesystem', self.machine.current.filesystem)
     clause &= Gt('partition', '0')
     table = 'filesystem_mounts natural join mounts'
     mounts = self.cursor.select(table=table,
                                 clause=clause,
                                 order='mnt_point')
     if mounts[0].mnt_point != '/':
         raise Error, 'bad set of mounts', mounts
     mddev = False
     mdnum = 0
     if device == '/dev/md':
         mddev = True
         pdev = '/dev/md0'
         mdnum += 1
     else:
         pdev = self._pdev(device, mounts[0].partition)
     print 'mounting target', pdev, self.target
     clause &= Neq('mnt_point', '/')
     mounts = self.cursor.select(table=table, clause=clause, order='ord')
     runlog('mount %s %s' % (pdev, self.target))
     for mnt in mounts:
         tpath = os.path.join(self.target, mnt.mnt_point[1:])
         makepaths(tpath)
         if mddev:
             pdev = '/dev/md%d' % mdnum
         else:
             pdev = self._pdev(device, mnt.partition)
         mdnum += 1
         runlog('mount %s %s' % (pdev, tpath))
     self._mounted = True
예제 #5
0
def mount_target(target, mounts, device):
    mounts = [m for m in mounts if int(m.partition)]
    if mounts[0].mnt_point != '/':
        raise RuntimeError, 'bad set of mounts', mounts
    mddev = False
    mdnum = 0
    if device == '/dev/md':
        mddev = True
        pdev = '/dev/md0'
        mdnum += 1
    else:
        pdev = '%s%d' % (device, mounts[0].partition)
    runlog('echo mounting target %s to %s' % (pdev, target))
    runlog('mount %s %s' % (pdev, target))
    mounts = mounts[1:]
    mountable = [m for m in mounts if m.fstype != 'swap']
    for mnt in mountable:
        tpath = os.path.join(target, mnt.mnt_point[1:])
        makepaths(tpath)
        if mddev:
            pdev = '/dev/md%d' % mdnum
        else:
            pdev = '%s%d' % (device, mnt.partition)
        mdnum += 1
        runlog('echo mounting target %s to %s' % (pdev, tpath))
        runlog('mount %s %s' % (pdev, tpath))
예제 #6
0
 def export_trait(self, suite_path):
     #print "----Begin export trait", self.current_trait
     #print "start xml", self.current_trait
     #xmldata = TraitElement(self.conn, self.suite)
     xmldata = self._xmldata
     #print 'set xml data'
     xmldata.set(self.current_trait)
     #print 'xml data set'
     bkup_path = os.path.join(suite_path, self.current_trait)
     makepaths(bkup_path)
     #print 'render xml'
     xmlfile = file(os.path.join(bkup_path, 'trait.xml'), 'w')
     xmlfile.write(xmldata.toprettyxml())
     xmlfile.close()
     #print 'xml rendered'
     #print "end xml", self.current_trait
     row = self._traits.select_row(clause=Eq('trait', self.current_trait))
     if row['description'] is not None:
         print 'export description', self.current_trait
         descfile = file(os.path.join(bkup_path, 'description.txt'), 'w')
         descfile.write(row['description'])
         descfile.close()
     #print "start templates,scripts", self.current_trait
     self._templates.export_templates(bkup_path)
     self._scripts.export_scripts(bkup_path)
     #print "end templates,scripts", self.current_trait
     #print 'all exported', os.listdir(bkup_path)
     print 'trait', self.current_trait, 'exported in suite', self.suite
예제 #7
0
 def ready_base_for_install(self):
     self._check_bootstrap()
     self._check_installer()
     fstab = self.machine.make_fstab()
     ready_base_for_install(self.target, self.cfg, self.suite, fstab)
     if self.cfg.is_it_true('installer', 'use_devices_tarball'):
         runlog('echo extracting devices tarball')
         self._extract_devices_tarball()
     else:
         runlog('echo using MAKEDEV to make devices')
         self.make_generic_devices()
     self.make_disk_devices()
     if self._raid_setup:
         mdpath = join(self.target, 'etc/mdadm')
         makepaths(mdpath)
         mdconfname = join(mdpath, 'mdadm.conf')
         mdconf = file(mdconfname, 'w')
         for diskname in self._raid_drives:
             devices = ['%s*' % d for d in self._raid_drives[diskname]]
             line = 'DEVICE %s' % ' '.join(devices)
             mdconf.write(line + '\n')
         mdconf.close()
         mdconf = file(mdconfname, 'a')
         arrdata = commands.getoutput('mdadm -E --config=%s -s' %
                                      mdconfname)
         mdconf.write(arrdata + '\n')
         mdconf.write('\n')
         mdconf.close()
     self._mount_target_proc()
예제 #8
0
 def _make_template_common(self, template, tmpl):
     sub = self.traittemplate.template.sub()
     newpath = join(self.target, template.template)
     bkuppath = join(self.target, self.paelladir, 'original_files', template.template)
     makepaths(dirname(newpath), dirname(bkuppath))
     self.log.info('target template %s' % newpath)
     if tmpl != sub:
         self.log.info('%s %s subbed' % (template.package, template.template))
     if isfile(newpath):
         if not isfile(bkuppath):
             os.system('mv %s %s' % (newpath, dirname(bkuppath)))
             self.log.info('%s backed up' % template.template)
         else:
             self.log.info('overwriting previously installed template %s' % template.template)
     else:
         self.log.info('installing new template %s' % template.template)
     newfile = file(newpath, 'w')
     newfile.write(sub)
     newfile.close()
     mode = template.mode
     
     # a simple attempt to insure mode is a valid octal string
     # this is one of the very rare places eval is used
     # there are a few strings with 8's and 9's that will pass
     # the if statement, but the eval will raise SyntaxError then.
     # If the mode is unusable the install will fail at this point.
     if mode[0] == '0' and len(mode) <= 7 and mode.isdigit():
         mode = eval(mode)
         os.chmod(newpath, mode)
     else:
         raise InstallError, 'bad mode %s, please use octal prefixed by 0' % mode
     
     own = ':'.join([template.owner, template.grp_owner])
     os.system(self.command('chown', "%s '%s'" %(own, join('/', template.template))))
예제 #9
0
    def install_template(self, template, text):
        target_filename = self.target / template.template
        makepaths(target_filename.dirname())
        if target_filename.isfile():
            backup_filename = self.target / path('root/paella') / template.template
            if not backup_filename.isfile():
                makepaths(backup_filename.dirname())
                target_filename.copy(backup_filename)
        target_filename.write_bytes(text)

        mode = template.mode
        # a simple attempt to insure mode is a valid octal string
        # this is one of the very rare places eval is used
        # there are a few strings with 8's and 9's that will pass
        # the if statement, but the eval will raise SyntaxError then.
        # If the mode is unusable the install will fail at this point.
        if mode[0] == '0' and len(mode) <= 7 and mode.isdigit():
            mode = eval(mode)
            target_filename.chmod(mode)
        else:
            raise InstallError, 'bad mode %s, please use octal prefixed by 0' % mode
        
        own = ':'.join([template.owner, template.grp_owner])
        # This command is run in a chroot to make the correct uid, gid
        os.system(self.command('chown', "%s '%s'" %(own, join('/', template.template))))
예제 #10
0
 def ready_target(self):
     self._check_target()
     makepaths(self.target)
     device = self.machine.array_hack(self.machine.current.machine_type)
     clause = Eq('filesystem', self.machine.current.filesystem)
     clause &= Gt('partition', '0')
     table = 'filesystem_mounts natural join mounts'
     mounts = self.cursor.select(table=table, clause=clause, order='mnt_point')
     if mounts[0].mnt_point != '/':
         raise Error, 'bad set of mounts', mounts
     mddev = False
     mdnum = 0
     if device == '/dev/md':
         mddev = True
         pdev = '/dev/md0'
         mdnum += 1
     else:
         pdev = self._pdev(device, mounts[0].partition)
     print 'mounting target', pdev, self.target
     clause &= Neq('mnt_point', '/')
     mounts = self.cursor.select(table=table, clause=clause, order='ord')
     runlog('mount %s %s' % (pdev, self.target))
     for mnt in mounts:
         tpath = os.path.join(self.target, mnt.mnt_point[1:])
         makepaths(tpath)
         if mddev:
             pdev = '/dev/md%d' % mdnum
         else:
             pdev = self._pdev(device, mnt.partition)
         mdnum += 1
         runlog('mount %s %s' % (pdev, tpath))
     self._mounted = True
예제 #11
0
 def _make_template_common(self, template, tmpl):
     sub = self.traittemplate.template.sub()
     newpath = join(self.target, template.template)
     bkuppath = join(self.target, self.paelladir, 'original_files', template.template)
     makepaths(dirname(newpath), dirname(bkuppath))
     self.log.info('target template %s' % newpath)
     if tmpl != sub:
         self.log.info('%s %s subbed' % (template.package, template.template))
     if isfile(newpath):
         if not isfile(bkuppath):
             os.system('mv %s %s' % (newpath, dirname(bkuppath)))
             self.log.info('%s backed up' % template.template)
         else:
             self.log.info('overwriting previously installed template %s' % template.template)
     else:
         self.log.info('installing new template %s' % template.template)
     newfile = file(newpath, 'w')
     newfile.write(sub)
     newfile.close()
     mode = template.mode
     if mode[0] == '0' and len(mode) <= 7 and mode.isdigit():
         mode = eval(mode)
     os.chmod(newpath, mode)
     own = ':'.join([template.owner, template.grp_owner])
     os.system(self.command('chown', "%s '%s'" %(own, join('/', template.template))))
예제 #12
0
 def ready_base_for_install(self):
     self._check_bootstrap()
     self._check_installer()
     fstab = self.machine.make_fstab()
     ready_base_for_install(self.target, self.cfg, self.suite, fstab)
     if self.cfg.is_it_true('installer', 'use_devices_tarball'):
         runlog('echo extracting devices tarball')
         self._extract_devices_tarball()
     else:
         runlog('echo using MAKEDEV to make devices')
         self.make_generic_devices()
     self.make_disk_devices()
     if self._raid_setup:
         mdpath = join(self.target, 'etc/mdadm')
         makepaths(mdpath)
         mdconfname = join(mdpath, 'mdadm.conf')
         mdconf = file(mdconfname, 'w')
         for diskname in self._raid_drives:
             devices = ['%s*' % d for d in self._raid_drives[diskname]]
             line = 'DEVICE %s' % ' '.join(devices)
             mdconf.write(line + '\n')
         mdconf.close()
         mdconf = file(mdconfname, 'a')
         arrdata = commands.getoutput('mdadm -E --config=%s -s' % mdconfname)
         mdconf.write(arrdata + '\n')
         mdconf.write('\n')
         mdconf.close()
     self._mount_target_proc()
예제 #13
0
 def export_all_diskconfigs(self, dirname=None):
     if dirname is None:
         dirname = self.db_export_path / 'diskconfig'
     makepaths(dirname)
     for row in self.diskconfig.cursor.select():
         filename = row.name
         diskconfig = dirname / filename
         diskconfig.write_text(row.content)
예제 #14
0
 def export_all_diskconfigs(self, dirname=None):
     if dirname is None:
         dirname = self.db_export_path / 'diskconfig'
     makepaths(dirname)
     for row in self.diskconfig.cursor.select():
         filename = row.name
         diskconfig = dirname / filename
         diskconfig.write_text(row.content)
예제 #15
0
 def mount_target(self):
     "this is a default process"
     self._check_target()
     makepaths(self.target)
     device = self.machine.array_hack()
     #mounts = self.machine.get_ordered_fsmounts()
     mounts = self.machine.get_installable_fsmounts()
     mount_target(self.target, mounts, device)
     self._mounted = True
예제 #16
0
 def install(self, machine, target):
     self.set_machine(machine)
     self.setup_installer()
     self.set_target(target)
     makepaths(target)
     self.log.info('Installer set to install %s to %s' % (machine, target))
     self.helper = MachineInstallerHelper(self)
     self.helper.curenv = self.curenv
     self.process()
예제 #17
0
 def setup_initial_paellainfo_files(self, traits):
     makepaths(self.paelladir)
     traitlist = file(join(self.paelladir, 'traitlist'), 'w')
     for trait in traits:
         traitlist.write('%s\n' % trait)
     traitlist.close()
     itraits = file(join(self.paelladir, 'installed_traits'), 'w')
     itraits.write('Installed Traits:\n')
     itraits.close()
예제 #18
0
def unpack_kernel(kernel, target):
    isolinux_dir = join(target, 'isolinux')
    dp = DpkgDeb()
    tmp = join(target, 'tmp')
    if isdir(tmp):
        os.system('rm %s -fr' % tmp)
    makepaths(tmp)
    os.system('dpkg-deb -x %s %s' % (kernel, tmp))
    os.system('cp %s/boot/vmlinuz-* %s/vmlinuz' % (tmp, isolinux_dir))
    os.system('rm %s -fr' % tmp)
예제 #19
0
def select_a_file(action, path, ok_function):
        filesel = FileSelection(title='__select_a_file__')
        filesel.cancel_button.connect('clicked',
                                      lambda x: filesel.destroy())
        makepaths(dirname(path))
        filesel.show()
        filesel.ok_button.connect('clicked', ok_function, filesel)
        filesel.set_data('action', action)
        filesel.set_filename(path)
        return filesel
예제 #20
0
파일: main.py 프로젝트: joelsefus/paella
 def export_machine(self, machine, dirname=None):
     if dirname is None:
         dirname = self.db_export_path
     dirname = path(dirname)
     makepaths(dirname)
     current_machine = self.machines.current_machine
     self.machines.set_machine(machine)
     self.machines.export_machine(dirname)
     if current_machine is not None:
         self.machines.set_machine(current_machine)
예제 #21
0
파일: main.py 프로젝트: joelsefus/paella
 def export_aptkey(self, name=None, dirname=None, row=None):
     dirname = path(dirname)
     makepaths(dirname)
     if name is None and row is None:
         raise RuntimeError, "need to set either row or name"
     if row is None:
         row = self.aptkeys.get_row(name)
     basename = '%s.gpg' % row.name
     filename = dirname / basename
     filename.write_text(row.data)
예제 #22
0
파일: main.py 프로젝트: joelsefus/paella
 def export_machine_database(self, exportdir):
     element = MachineDatabaseElement(self.conn)
     exportdir = path(exportdir)
     makepaths(exportdir)
     filename = exportdir / 'machine_database.xml'
     xmlfile = file(filename, 'w')
     xmlfile.write(element.toprettyxml())
     xmlfile.close()
     machine_dir = exportdir / 'machines'
     self.export_all_machines(machine_dir)
예제 #23
0
 def export_all_profiles(self, dirname=None):
     if dirname is None:
         dirname = self.db_export_path / 'profiles'
     makepaths(dirname)
     profiles = self.profile.get_profile_list()
     self.report_total_profiles(len(profiles))
     env = self.profile.make_environment_object()
     for profile in profiles:
         env.set_profile(profile)
         self.profile.export_profile(dirname, profile=profile, env=env)
         self.report_profile_exported(profile)
예제 #24
0
 def backup_target_nfs(self, name):
     self.mount_backup('/mnt', 'nfs')
     tarname = os.path.join('/mnt', '%s.tar' % name)
     dirname = os.path.dirname(tarname)
     if not os.path.isdir(dirname):
         print dirname, "doesn't exist.  Creating now."
         makepaths(dirname)
     tarcmd = backup_target_command(self.target, tarname)
     print tarcmd
     shell(tarcmd)
     shell('umount /mnt')
예제 #25
0
 def __init__(self, filename):
     format = '%(name)s - %(asctime)s - %(levelname)s: %(message)s'
     filename = path(filename)
     logdir = filename.dirname()
     if not logdir.isdir():
         makepaths(logdir)
     MainLog.__init__(self, filename, logformat=format)
     self._basename = 'paella-installer'
     self.add_logger(self._basename)
     sys.paella_logger = self.loggers[self._basename]
     os.environ['PAELLA_LOGFILE'] = self.filename
예제 #26
0
파일: main.py 프로젝트: joelsefus/paella
 def export_profile(self, profile, dirname=None):
     if dirname is None:
         dirname = path('.')
     dirname = path(dirname)
     makepaths(dirname)
     # this env object should be handled
     # inside the profile object instead
     # of being handled here.
     env = self.profile.make_environment_object()
     env.set_profile(profile)
     self.profile.export_profile(dirname, profile=profile, env=env)
예제 #27
0
 def __init__(self, filename):
     format = '%(name)s - %(asctime)s - %(levelname)s: %(message)s'
     filename = path(filename)
     logdir = filename.dirname()
     if not logdir.isdir():
         makepaths(logdir)
     MainLog.__init__(self, filename, logformat=format)
     self._basename = 'paella-installer'
     self.add_logger(self._basename)
     sys.paella_logger = self.loggers[self._basename]
     os.environ['PAELLA_LOGFILE'] = self.filename
예제 #28
0
def make_base_filesystem(suite, name, cfg=None, size=3000, mkfs='mke2fs'):
    if cfg is None:
        cfg = UmlConfig()
    bfpath = path(cfg.get('umlmachines', 'bootstrap_basepath')) / name
    bfpath = bfpath.expand()
    #path = join(cfg.get('umlmachines', 'bootstrap_basepath'), name)
    dirname = bfpath.dirname()
    print 'bfpath dirname', dirname
    makepaths(dirname)
    create_sparse_file(bfpath, size=size)
    return bfpath
예제 #29
0
def make_base_filesystem(suite, name, cfg=None, size=3000, mkfs='mke2fs'):
    if cfg is None:
        cfg = UmlConfig()
    bfpath = path(cfg.get('umlmachines', 'bootstrap_basepath')) / name
    bfpath = bfpath.expand()
    #path = join(cfg.get('umlmachines', 'bootstrap_basepath'), name)
    dirname = bfpath.dirname()
    print 'bfpath dirname', dirname
    makepaths(dirname)
    create_sparse_file(bfpath, size=size)
    return bfpath
예제 #30
0
 def export_trait(self, suite_path):
     xmldata = TraitElement(self.conn, self.suite)
     xmldata.set(self.current_trait)
     bkup_path = join(suite_path, self.current_trait)
     makepaths(bkup_path)
     xmlfile = file(join(bkup_path, 'trait.xml'), 'w')
     xmlfile.write(xmldata.toprettyxml())
     xmlfile.close()
     self._templates.export_templates(bkup_path)
     self._scripts.export_scripts(bkup_path)
     #print 'all exported', os.listdir(bkup_path)
     print 'trait', self.current_trait, 'exported in suite', self.suite
예제 #31
0
 def insert_new_template(self, package, template, path):
     newfile = readfile(path)
     filename = self.template_filename(package, template)
     makepaths(dirname(filename))
     writefile(filename, newfile)
     try:
         self.traittemplate.insert_template(dict(package=package, template=template),
                                            file(path))
     except OperationalError:
         dialogs.Message('template already exists')
     self.set_template(package, template)
     self.reset_rows()
예제 #32
0
def update_local_packagelist(repos, localdist, localsuite):
    repos.source.sections = []
    repos.local.source.sections = []
    update_remote_uri(repos, localdist)
    repos.source.suite = localsuite
    repos.local.source.suite = localsuite
    rurl = os.path.join(repos.source.uri, repos.source.suite, 'Packages.gz')
    lpath = os.path.join(repos.local.source.uri, repos.local.source.suite, 'Packages.gz')[5:]
    makepaths(os.path.dirname(lpath))
    if not os.path.isfile(lpath):
        print rurl, lpath, 'rurl, lpath'
        wget(rurl, lpath)
예제 #33
0
 def backup_trait(self, tball_path):
     print 'this needs to be called export_trait'
     xmldata = TraitElement(self.conn, self.suite)
     xmldata.set(self.current_trait)
     bkup_path = join(tball_path, self.current_trait)
     makepaths(bkup_path)
     xmlfile = file(join(bkup_path, 'trait.xml'), 'w')
     xmlfile.write(xmldata.toprettyxml())
     xmlfile.close()
     self._templates.export_templates(bkup_path)
     self._scripts.export_scripts(bkup_path)
     print 'all exported', os.listdir(bkup_path)
예제 #34
0
 def _get_packages_file(self, repos):
     if repos.source.has_release():
         repos.update()
     else:
         rpath = os.path.join(repos.source.uri, repos.source.suite, 'Packages.gz')
         # the [5:] slice is to remove file: from local uri
         lpath = os.path.join(repos.local.source.uri, repos.source.suite, 'Packages.gz')[5:]
         if not os.path.isfile(lpath):
             debug('lpath is --->', lpath)
             makepaths(os.path.dirname(lpath))
             debug(rpath, lpath, 'getting now')
             wget(rpath, lpath)
예제 #35
0
def make_official_sources_list(cfg, target, suite):
    section = 'debrepos'
    aptdir = os.path.join(target, 'etc', 'apt')
    makepaths(aptdir)
    sources_list = file(os.path.join(aptdir, 'sources.list'), 'w')
    _sections = 'main contrib non-free'
    main = cfg.get(section, 'official_main')
    nonus = None
    security = None
    if _is_option_true(cfg, section, '%s_nonus' % suite) or suite == 'woody':
        nonus = cfg.get(section, 'official_nonus')
    if _is_option_true(cfg, section, '%s_updates' % suite):
        security = cfg.get(section, 'official_security')
    loption = suite + '_local'
    coption = suite + '_local'
    local = None
    common = None
    if _is_option_true(cfg, section, loption):
        local = cfg.get(section, 'official_local_mirror')
    if _is_option_true(cfg, section, coption):
        common = cfg.get(section, 'official_local_mirror')
    sline = ['deb', main, suite, _sections]
    sources_list.write(_make_source_line(sline))
    sline[0] = 'deb-src'
    sources_list.write(_make_source_line(sline))
    sline[0]  = 'deb'
    if security is not None:
        sline[1] = security
        sline[2] = '%s/updates' % suite
        sources_list.write(_make_source_line(sline))
        sline[0]  = 'deb-src'
        sources_list.write(_make_source_line(sline))
        sline[0] = 'deb'
        sline[2] = suite
    if local is not None:
        sline[1] = '%s/local' % local
        sline[2] = '%s/' % suite
        sources_list.write(_make_source_line(sline[:-1]))
        sline[0] = 'deb-src'
        sources_list.write(_make_source_line(sline[:-1]))
        sline[0] = 'deb'
        sline[2] = suite
    if common is not None:
        sline[1] = '%s/local' % common
        sline[2] = 'common/'
        sources_list.write(_make_source_line(sline[:-1]))
        sline[0] = 'deb-src'
        sources_list.write(_make_source_line(sline[:-1]))
        sline[0] = 'deb'
        sline[2] = suite
    sources_list.write('\n')
    sources_list.close()
예제 #36
0
파일: main.py 프로젝트: joelsefus/paella
 def export_diskconfig(self, name=None, dirname=None, row=None):
     if dirname is None:
         dirname = self.db_export_path / 'diskconfig'
     dirname = path(dirname)
     makepaths(dirname)
     if name is None and row is None:
         raise RuntimeError , 'either name or row must be passed to export_diskconfig'
     if name is not None:
         row = self.diskconfig.get(name)
     filename = row.name
     content = row.content
     diskconfig = dirname / filename
     diskconfig.write_text(content)
예제 #37
0
    def set_logfile(self, logfile):
        self.logfile = path(logfile)
        format = '%(name)s - %(asctime)s - %(levelname)s: %(message)s'
        logdir = self.logfile.dirname()
        if not logdir.isdir():
            makepaths(logdir)
        self.log = Log('paella-installer', self.logfile, format)

        # the mailserver trait used to somehow erase the logfile
        # so a bkup is generated here.
        bkup = self.logfile + '.bkup'
        if not bkup.exists():
            self.logfile.link(bkup)