Esempio n. 1
0
def unpacker(package):
    archive = tarfile.open(os.path.join(conf.get('settings', 'cache'),
                                        package.name, 'files.bz2'),
                           'r:bz2',
                           ignore_zeros=True)
    root_content = os.path.join(conf.get('settings', 'cache'), package.name,
                                'content')
    if os.path.exists(root_content):
        shutil.rmtree(root_content)
    os.makedirs(root_content)
    archive.extractall(root_content)

    for (path, dirs, files) in os.walk(root_content):
        for _dir in dirs:
            src = os.path.join(path, _dir)
            dst = '%s' % src.replace(root_content,
                                     conf.get('settings', 'packages'))
            if os.path.islink(src):
                linkto = os.readlink(src)
                os.remove(dst)
                os.symlink(linkto, dst)
            elif not os.path.exists(dst):
                os.makedirs(dst)

        for _file in files:
            src = os.path.join(path, _file)
            dst = '%s' % src.replace(root_content,
                                     conf.get('settings', 'packages'))
            # If safe_conf
            if conf.get('packages', 'safe_conf') == 'True':
                # Is etc
                if path.replace(root_content, '')[1:].split('/')[0] == 'etc':
                    # Is file in etc
                    if os.path.isfile(os.path.join(path, _file)):
                        # If file already exist
                        if os.path.exists(dst):
                            if filecmp.cmp(src, dst):
                                logger.info('CONFIG: config file not modified')
                                continue
                            logger.info('CONFIG: config file conflict: %s' %
                                        os.path.join(path, _file))
                            dst += '.new'
            logger.debug(" :: %s - %s" % (src, dst))
            if os.path.islink(src):
                linkto = os.readlink(src)

                if os.path.lexists(dst):
                    os.remove(dst)
                os.symlink(linkto, dst)

            else:
                shutil.copy2(src, dst)

    shutil.rmtree(root_content)
    archive.close()
Esempio n. 2
0
	def deps_resolve(self, package, resolved, unresolved, level=0):
		logger.debug("[%s] %s: %s" % (level, package.name ,package.requires))
		self.unresolved = unresolved
		self.unresolved.append(package)
		for dep in db.get(package.requires, regexp = False):
			if dep.name not in [_dep.name for _dep in self.resolved]:
				if dep.name in [_dep.name for _dep in self.unresolved]:
					raise InstallerException('Circular reference detected: %s -> %s' % (package.name, dep.name))
				self.deps_resolve(dep, self.resolved, self.unresolved, level+1)
		self.resolved.append(package)
		self.unresolved.remove(package)
Esempio n. 3
0
 def deps_resolve(self, package, resolved, unresolved, level=0):
     logger.debug("[%s] %s: %s" % (level, package.name, package.requires))
     self.unresolved = unresolved
     self.unresolved.append(package)
     for dep in db.get(package.requires, regexp=False):
         if dep.name not in [_dep.name for _dep in self.resolved]:
             if dep.name in [_dep.name for _dep in self.unresolved]:
                 raise InstallerException(
                     'Circular reference detected: %s -> %s' %
                     (package.name, dep.name))
             self.deps_resolve(dep, self.resolved, self.unresolved,
                               level + 1)
     self.resolved.append(package)
     self.unresolved.remove(package)
Esempio n. 4
0
File: tools.py Progetto: toxinu/ubik
def unpacker(package):
    archive = tarfile.open(os.path.join(conf.get('settings', 'cache'), package.name, 'files.bz2'), 'r:bz2', ignore_zeros=True)
    root_content = os.path.join(conf.get('settings', 'cache'), package.name, 'content')
    if os.path.exists(root_content):
        shutil.rmtree(root_content)
    os.makedirs(root_content)
    archive.extractall(root_content)

    for (path, dirs, files) in os.walk(root_content):
        for _dir in dirs:
            src = os.path.join(path, _dir)
            dst = '%s' % src.replace(root_content, conf.get('settings', 'packages'))
            if os.path.islink(src):
                linkto = os.readlink(src)
                os.remove(dst)
                os.symlink(linkto, dst)
            elif not os.path.exists(dst):
                os.makedirs(dst)

        for _file in files:
            src = os.path.join(path, _file)
            dst = '%s' % src.replace(root_content, conf.get('settings', 'packages'))
            # If safe_conf
            if conf.get('packages', 'safe_conf') == 'True':
                # Is etc
                if path.replace(root_content, '')[1:].split('/')[0] == 'etc':
                    # Is file in etc
                    if os.path.isfile(os.path.join(path, _file)):
                        # If file already exist
                        if os.path.exists(dst):
                            if filecmp.cmp(src, dst):
                                logger.info('CONFIG: config file not modified')
                                continue
                            logger.info('CONFIG: config file conflict: %s' % os.path.join(path, _file))
                            dst += '.new'
            logger.debug(" :: %s - %s" % (src, dst))
            if os.path.islink(src):
                linkto = os.readlink(src)

                if os.path.lexists(dst):
                    os.remove(dst)
                os.symlink(linkto, dst)

            else:
                shutil.copy2(src, dst)

    shutil.rmtree(root_content)
    archive.close()
Esempio n. 5
0
	def feed(self, packages):
		if not isinstance(packages, list):
			packages = [packages]

		for package in packages:
			if not isinstance(package, Package):
				packages += db.get(package)
				del packages[packages.index(package)]

		for package in packages:
			if package not in self.packages:
				if package.status in ['10']:
					self.packages.append(package)
				else:
					stream_logger.info('    - %s already installed' % package.name)
			else:
				logger.debug('%s ignored' % package.name)
Esempio n. 6
0
    def feed(self, packages):
        if not isinstance(packages, list):
            packages = [packages]

        for package in packages:
            if not isinstance(package, Package):
                packages += db.get(package)
                del packages[packages.index(package)]

        for package in packages:
            if package not in self.packages:
                if package.status in ['10']:
                    self.packages.append(package)
                else:
                    stream_logger.info('    - %s already installed' %
                                       package.name)
            else:
                logger.debug('%s ignored' % package.name)
Esempio n. 7
0
 def resolve(self, package):
     self.package = package
     self.tree = [self.package]
     self.resolved = []
     logger.debug("Resolv deps for '%s':" % package.name)
     self.deps_resolve(self.package, self.resolved, [])
Esempio n. 8
0
File: tools.py Progetto: toxinu/ubik
def clean():
    files = os.listdir(conf.get('settings', 'cache'))
    for f in files:
        logger.debug(f)
        if not '.tar' in f and os.path.isdir(f):
            shutil.rmtree(f)
Esempio n. 9
0
	def resolve(self, package):
		self.package = package
		self.tree = [self.package]
		self.resolved = []
		logger.debug("Resolv deps for '%s':" % package.name)
		self.deps_resolve(self.package, self.resolved, [])
Esempio n. 10
0
def clean():
    files = os.listdir(conf.get('settings', 'cache'))
    for f in files:
        logger.debug(f)
        if not '.tar' in f and os.path.isdir(f):
            shutil.rmtree(f)