コード例 #1
0
ファイル: reprepro.py プロジェクト: pombredanne/paella-svn
 def create_config(self):
     basedirs = self._get_basedirs()
     for basedir in basedirs:
         bd = path(basedir)
         if not bd.isdir():
             bd.makedirs()
     confdirs = self._get_confdirs()
     for confdir in confdirs:
         cfd = path(confdir)
         if not cfd.isdir():
             cfd.makedirs()
     # handling too many confdirs is irritating
     # the commented line below uses the same list
     # for all the keys.  This is not immediately apparent
     # and was the cause of much confusion.
     #confdir_map = dict().fromkeys(confdirs, [])
     confdir_map = dict().fromkeys(confdirs)
     # use another method to initialize the dictionary
     # with *separate* empty lists
     for confdir in confdir_map:
         confdir_map[confdir] = []
     for section in self.config.sections():
         confdir = self.config.get(section, 'confdir')
         confdir_map[confdir].append(section)
     for confdir in confdir_map:
         sections = confdir_map[confdir]
         distlines, updatelines = self._generate_section_configs(sections)
         self._write_config(confdir, distlines, updatelines)
コード例 #2
0
ファイル: reprepro.py プロジェクト: pombredanne/paella-svn
 def _update_configfile(self, filename, lines):
     configfile = path(filename)
     origlines = configfile.lines()
     marker = self._comment_lines()[0]
     line = origlines.pop(0)
     while not line.startswith(marker):
         line = origlines.pop(0)
     all_lines = lines + ['', line] + origlines
     configfile.write_lines(all_lines)
コード例 #3
0
ファイル: base.py プロジェクト: BackupTheBerlios/paella-svn
 def seturl(self, url):
     """Uses urlparse to set the attributes for url"""
     url = str(url)
     protocol, host, path_, parameters, query, frag_id = urlparse.urlparse(url)
     self.protocol = protocol
     self.host = host
     self.path = path(path_)
     self.parameters = parameters
     self.query = query
     self.frag_id = frag_id
コード例 #4
0
ファイル: base.py プロジェクト: pombredanne/paella-svn
 def seturl(self, url):
     """Uses urlparse to set the attributes for url"""
     url = str(url)
     protocol, host, path_, parameters, query, frag_id = urlparse.urlparse(
         url)
     self.protocol = protocol
     self.host = host
     self.path = path(path_)
     self.parameters = parameters
     self.query = query
     self.frag_id = frag_id
コード例 #5
0
def make_simple_seed_files(packages, listname='mypacks'):
    tmpdir = tempfile.mkdtemp('seeds', 'repserve')
    tmpdir = path(tmpdir)
    blacklist = tmpdir / 'blacklist'
    blacklist.write_bytes('')
    structure = tmpdir / 'STRUCTURE'
    structure.write_lines(['%s:' % listname])
    package_lines = make_seed_contents(packages)
    package_list = tmpdir / listname
    package_list.write_lines(package_lines)
    return tmpdir
コード例 #6
0
ファイル: reprepro.py プロジェクト: pombredanne/paella-svn
 def _write_config(self, confdir, distlines, updatelines):
     confdir = path(confdir)
     distfile = confdir / 'distributions'
     updatesfile = confdir / 'updates'
     if not distfile.isfile():
         print "creating new distributions file: %s" % distfile
         self._new_configfile(distfile, distlines)
     else:
         self._update_configfile(distfile, distlines)
     if not updatesfile.isfile():
         print "creating new updates file: %s" % updatesfile
         self._new_configfile(updatesfile, updatelines)
     else:
         self._update_configfile(updatesfile, updatelines)
コード例 #7
0
ファイル: base.py プロジェクト: pombredanne/paella-svn
def unzip_list_file(filename):
    filename = path(filename)
    cmd = ['gzip', '-cd', filename]
    proc = subprocess.Popen(cmd, stdout=subprocess.PIPE)
    tmpfile = tempfile.TemporaryFile()
    block = proc.stdout.read(BLOCK_SIZE)
    while block:
        tmpfile.write(block)
        block = proc.stdout.read(BLOCK_SIZE)
    retval = proc.wait()
    if retval:
        raise CalledProcessError, "Problem reading/unzipping %s" % filename
    tmpfile.seek(0)
    return tmpfile
コード例 #8
0
ファイル: base.py プロジェクト: BackupTheBerlios/paella-svn
def unzip_list_file(filename):
    filename = path(filename)
    cmd = ['gzip', '-cd', filename]
    proc = subprocess.Popen(cmd, stdout=subprocess.PIPE)
    tmpfile = tempfile.TemporaryFile()
    block = proc.stdout.read(BLOCK_SIZE)
    while block:
        tmpfile.write(block)
        block = proc.stdout.read(BLOCK_SIZE)
    retval = proc.wait()
    if retval:
        raise CalledProcessError , "Problem reading/unzipping %s" % filename
    tmpfile.seek(0)
    return tmpfile
コード例 #9
0
ファイル: base.py プロジェクト: pombredanne/paella-svn
def parse_sources_list(filename='/etc/apt/sources.list', arch=None):
    if arch is None:
        arch = get_architecture()
    debarch = {'deb': arch, 'deb-src': 'source'}
    parsed_sources = []
    source_lines = path(filename).lines()
    for line in source_lines:
        line = line.strip()
        if line.startswith('deb'):
            parsed = parse_aptsource_line(line)
            if parsed['arch'] in debarch:
                parsed['arch'] = debarch[parsed['arch']]
            else:
                raise RuntimeError, "can't handle debtype %s" % parsed['arch']
            parsed_sources.append(parsed)
    return parsed_sources
コード例 #10
0
ファイル: base.py プロジェクト: BackupTheBerlios/paella-svn
def parse_sources_list(filename='/etc/apt/sources.list', arch=None):
    if arch is None:
        arch = get_architecture()
    debarch = {'deb':arch, 'deb-src':'source'}
    parsed_sources = []
    source_lines = path(filename).lines()
    for line in source_lines:
        line = line.strip()
        if line.startswith('deb'):
            parsed = parse_aptsource_line(line)
            if parsed['arch'] in debarch:
                parsed['arch'] = debarch[parsed['arch']]
            else:
                raise RuntimeError , "can't handle debtype %s" % parsed['arch']
            parsed_sources.append(parsed)
    return parsed_sources
コード例 #11
0
ファイル: main.py プロジェクト: BackupTheBerlios/paella-svn
 def add_filterlist(self, opts, args):
     sections = self._determine_sections(opts)
     filename = None
     if len(args) != 1:
         raise ImproperArgumentsError , "Need a name/filename argument"
     arg = path(args[0])
     if not arg.isfile():
         name = arg
         filename = use_stdin_instead_of_filename()
     else:
         name = arg.basename()
         filename = arg
     flist = self.flmanager.make_filterlist(name, filename=filename)
     self.flmanager.write_filterlist_to_confdirs(flist, sections)
     for section in sections:
         self.flmanager.add_filterlist_to_section(section, flist)
コード例 #12
0
 def add_filterlist(self, opts, args):
     sections = self._determine_sections(opts)
     filename = None
     if len(args) != 1:
         raise ImproperArgumentsError, "Need a name/filename argument"
     arg = path(args[0])
     if not arg.isfile():
         name = arg
         filename = use_stdin_instead_of_filename()
     else:
         name = arg.basename()
         filename = arg
     flist = self.flmanager.make_filterlist(name, filename=filename)
     self.flmanager.write_filterlist_to_confdirs(flist, sections)
     for section in sections:
         self.flmanager.add_filterlist_to_section(section, flist)
コード例 #13
0
ファイル: gpg.py プロジェクト: BackupTheBerlios/paella-svn
 def initialize(self):
     outparent = self.config.getpath('DEFAULT', 'reprepro_parent_outdir')
     here = self._pushd_home()
     gnupg_confdir = path('.gnupg')
     if gnupg_confdir.isdir():
         print "It appears that repserve's ~/.gnupg has already been initialized"
         return
     fullname = self.config.get('DEFAULT', 'fullname')
     email = self.config.get('DEFAULT', 'email')
     if not email:
         email = None
     make_default_signing_key(fullname=fullname, email=email)
     keyid = get_gpg_keyid(fullname)
     #print "found key id", keyid
     self.config.set('DEFAULT', 'signwith', keyid)
     self.config.write_file()
     self.export_archive_key(keyid=keyid, outdir=outparent)
     os.chdir(here)
コード例 #14
0
 def initialize(self):
     outparent = self.config.getpath('DEFAULT', 'reprepro_parent_outdir')
     here = self._pushd_home()
     gnupg_confdir = path('.gnupg')
     if gnupg_confdir.isdir():
         print "It appears that repserve's ~/.gnupg has already been initialized"
         return
     fullname = self.config.get('DEFAULT', 'fullname')
     email = self.config.get('DEFAULT', 'email')
     if not email:
         email = None
     make_default_signing_key(fullname=fullname, email=email)
     keyid = get_gpg_keyid(fullname)
     #print "found key id", keyid
     self.config.set('DEFAULT', 'signwith', keyid)
     self.config.write_file()
     self.export_archive_key(keyid=keyid, outdir=outparent)
     os.chdir(here)
コード例 #15
0
 def _write_file(self, filename):
     filename = path(filename)
     lines = self._create_lines()
     filename.write_lines(lines)
コード例 #16
0
ファイル: base.py プロジェクト: BackupTheBerlios/paella-svn
 def set_path(self, path_):
     """Method for setting the path attribute, and coercing it to be
     a path instance."""
     if not isinstance(path_, path):
         path_ = path(path_)            
     self.path = path_
コード例 #17
0
ファイル: filterlist.py プロジェクト: pombredanne/paella-svn
 def parse_file(self, filename):
     lines = path(filename).lines()
     return self.parse_lines(lines)
コード例 #18
0
 def write_file(self, confdir):
     filename = path(confdir) / self.name
     if filename.isfile():
         print "Overwriting previous filterlist", str(filename)
     self._write_file(filename)
コード例 #19
0
import sys
import tempfile

import apt_pkg

from repserve.base import get_architecture
from repserve.base import unzip_list_file
from repserve.path import path

germsite = path('/usr/lib/germinate')
if not germsite.isdir():
    raise RuntimeError , "You need to have germinate installed to use this module."
sys.path.append(germsite)

from Germinate import Germinator
import Germinate.seeds

# a function to add " * " to each package
# and return a list of lines
def make_seed_contents(packages):
    lines = []
    for package in packages:
        lines.append(' * %s' % package)
    return lines

# a function to make simple seed files
# from a list of packages
# returns the path to the temporary directory
# it creates (which will be used as the
# --seed-dist option for the germinate command
def make_simple_seed_files(packages, listname='mypacks'):
コード例 #20
0
ファイル: base.py プロジェクト: pombredanne/paella-svn
 def set_path(self, path_):
     """Method for setting the path attribute, and coercing it to be
     a path instance."""
     if not isinstance(path_, path):
         path_ = path(path_)
     self.path = path_
コード例 #21
0
ファイル: reprepro.py プロジェクト: pombredanne/paella-svn
 def _new_configfile(self, filename, lines):
     configfile = path(filename)
     all_lines = lines + [''] + self._comment_lines()
     configfile.write_lines(all_lines)
コード例 #22
0
ファイル: gpg.py プロジェクト: BackupTheBerlios/paella-svn
 def _pushd_home(self):
     here = path.getcwd()
     homedir = path('~/').expand()
     os.chdir(homedir)
     return here
コード例 #23
0
ファイル: config.py プロジェクト: pombredanne/paella-svn
 def getpath(self, section, option):
     return path(self.get(section, option))
コード例 #24
0
 def parse_filterlist(self, confdir):
     filename = path(confdir) / self.name
     return self.parse_file(filename)
コード例 #25
0
ファイル: filterlist.py プロジェクト: pombredanne/paella-svn
 def _write_file(self, filename):
     filename = path(filename)
     lines = self._create_lines()
     filename.write_lines(lines)
コード例 #26
0
ファイル: filterlist.py プロジェクト: pombredanne/paella-svn
 def parse_filterlist(self, confdir):
     filename = path(confdir) / self.name
     return self.parse_file(filename)
コード例 #27
0
 def parse_file(self, filename):
     lines = path(filename).lines()
     return self.parse_lines(lines)
コード例 #28
0
ファイル: config.py プロジェクト: BackupTheBerlios/paella-svn
 def getpath(self, section, option):
     return path(self.get(section, option))
コード例 #29
0
 def _pushd_home(self):
     here = path.getcwd()
     homedir = path('~/').expand()
     os.chdir(homedir)
     return here
コード例 #30
0
ファイル: filterlist.py プロジェクト: pombredanne/paella-svn
 def write_file(self, confdir):
     filename = path(confdir) / self.name
     if filename.isfile():
         print "Overwriting previous filterlist", str(filename)
     self._write_file(filename)