示例#1
0
 def update_conf_file(self):
     """
         Ensure that the schroot configuration file is correct.
     """
     conf_file = '[%s]\n' % self.name
     for conf, value in self['conf'].items():
         if conf == 'personality' and value == PERSONALITY:
             value = None
         elif issubclass(type(value), list):
             value = ','.join(value)
         if value:
             conf_file += "%s=%s\n" % (conf, value)
     file_loc = os.path.join('/etc/schroot/chroot.d/', self.name)
     if not os.path.exists(file_loc) or file(file_loc, "r").read() != conf_file:
         create_root_file(file_loc, conf_file)
示例#2
0
    def update_packages(self):
        """
            Ensure that the schroot is properly built and has the latest packages.
        """

        # If /etc/ isn't in the VM then we don't have a proper install yet
        if not os.path.exists(os.path.join(self['conf']['directory'], 'etc/')):
            bootstrap = ["debootstrap"]
            if self.has_key('variant'):
                bootstrap.append("--variant=%s" % self["variant"])
            bootstrap.append("--arch=%s" % ARCH[self['conf']['personality']])
            bootstrap.append(self['release'])
            bootstrap.append(self['conf']['directory'])
            bootstrap.append(self.source)
            if self.http_proxy:
                bootstrap.insert(0, 'http_proxy="%s"' % self.http_proxy)
            sudo(*bootstrap)
            is_new = True
        else:
            is_new = False

        source_apt_conf = '/etc/apt/apt.conf'
        schroot_apt_conf = os.path.join(self['conf']['directory'],
                                        'etc/apt/apt.conf')

        do_update = False
        if os.path.exists(source_apt_conf) and (
                not os.path.exists(schroot_apt_conf) or
                file(source_apt_conf).read() != file(schroot_apt_conf).read()):
            sudo('cp', source_apt_conf, schroot_apt_conf)
            do_update = True

        for source, location in self['sources'].items():
            source_path = os.path.join(self['conf']['directory'],
                                       'etc/apt/sources.list.d/',
                                       source + '.list')
            if not os.path.exists(source_path):
                create_root_file(
                    source_path, "deb %s %s %s\n" %
                    (location['source'], self['release'], source))
                do_update = True

        if do_update or not is_new:
            self.sudo(['apt-get', 'update'])
        if not is_new:
            self.sudo(['apt-get', 'dist-upgrade', '-y', '--auto-remove'])
        self.sudo(['apt-get', 'install', '-y', '--auto-remove'] +
                  self['packages'])
示例#3
0
 def update_conf_file(self):
     """
         Ensure that the schroot configuration file is correct.
     """
     conf_file = '[%s]\n' % self.name
     for conf, value in self['conf'].items():
         if conf == 'personality' and value == PERSONALITY:
             value = None
         elif issubclass(type(value), list):
             value = ','.join(value)
         if value:
             conf_file += "%s=%s\n" % (conf, value)
     file_loc = os.path.join('/etc/schroot/chroot.d/', self.name)
     if not os.path.exists(file_loc) or file(file_loc,
                                             "r").read() != conf_file:
         create_root_file(file_loc, conf_file)
示例#4
0
    def update_packages(self):
        """
            Ensure that the schroot is properly built and has the latest packages.
        """

        # If /etc/ isn't in the VM then we don't have a proper install yet
        if not os.path.exists(os.path.join(self['conf']['directory'], 'etc/')):
            bootstrap = ["debootstrap"]
            if self.has_key('variant'):
                bootstrap.append("--variant=%s" % self["variant"])
            bootstrap.append("--arch=%s" % ARCH[self['conf']['personality']])
            bootstrap.append(self['release'])
            bootstrap.append(self['conf']['directory'])
            bootstrap.append(self.source)
            if self.http_proxy:
                bootstrap.insert(0, 'http_proxy="%s"' % self.http_proxy)
            sudo(*bootstrap)
            is_new = True
        else:
            is_new = False

        source_apt_conf = '/etc/apt/apt.conf'
        schroot_apt_conf = os.path.join(
                self['conf']['directory'], 'etc/apt/apt.conf')

        do_update = False
        if os.path.exists(source_apt_conf) and (
                not os.path.exists(schroot_apt_conf) or
                file(source_apt_conf).read() != file(schroot_apt_conf).read()):
            sudo('cp', source_apt_conf, schroot_apt_conf)
            do_update = True

        for source, location in self['sources'].items():
            source_path = os.path.join(self['conf']['directory'],
                'etc/apt/sources.list.d/', source +'.list')
            if not os.path.exists(source_path):
                create_root_file(source_path,
                    "deb %s %s %s\n" % (location['source'],
                        self['release'], source))
                do_update = True

        if do_update or not is_new:
            self.sudo(['apt-get', 'update'])
        if not is_new:
            self.sudo(['apt-get', 'dist-upgrade', '-y', '--auto-remove'])
        self.sudo(['apt-get', 'install', '-y', '--auto-remove'] +
                  self['packages'])