コード例 #1
0
ファイル: upgrader.py プロジェクト: toxinu/ubik
 def download(self):
     stream_logger.info(" :: Download")
     for package in self.packages:
         logger.info("Download %s" % package.name)
         get_package(package)
         if not checkmd5(package):
             logger.info("%s md5 invalid" % package.name)
             stream_logger.info("   | Md5 invalid, package corrumpt")
             raise UpgraderException("Invalid Md5")
コード例 #2
0
ファイル: upgrader.py プロジェクト: toxinu/ubik
 def download(self):
     stream_logger.info(' :: Download')
     for package in self.packages:
         logger.info('Download %s' % package.name)
         get_package(package)
         if not checkmd5(package):
             logger.info('%s md5 invalid' % package.name)
             stream_logger.info('   | Md5 invalid, package corrumpt')
             raise UpgraderException('Invalid Md5')
コード例 #3
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()
コード例 #4
0
ファイル: tools.py プロジェクト: 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()
コード例 #5
0
ファイル: installer.py プロジェクト: toxinu/ubik
 def download(self):
     stream_logger.info(' :: Download')
     for package in self.packages:
         logger.info('Download %s' % package.name)
         # Not cached
         if not cached(package):
             logger.info('%s not cached' % package.name)
             get_package(package)
             # Invalid Md5
             if not checkmd5(package):
                 logger.info('%s md5 invalid' % package.name)
                 stream_logger.info('   | Md5 invalid, package corrumpt')
                 raise InstallerException('Invalid Md5')
         # Cached
         else:
             logger.info('%s already in cache' % package.name)
             # Invalid Md5, redownload
             if not checkmd5(package):
                 logger.info('%s cache package md5 invalid' % package.name)
                 get_package(package)
                 if not checkmd5(package):
                     logger.info('%s md5 invalid' % package.name)
                     stream_logger.info(
                         '   | Md5 invalid, package corrumpt')
                     raise InstallerException('Invalid Md5')
             else:
                 stream_logger.info('    | %s already in cache' %
                                    package.name)
コード例 #6
0
ファイル: reinstaller.py プロジェクト: toxinu/ubik
	def download(self):
		stream_logger.info(' :: Download')	
		for package in self.packages:
			logger.info('Download %s' % package.name)
			# Not cached
			if not cached(package):
				logger.info('%s not cached' % package.name)
				get_package(package)
				# Invalid Md5
				if not checkmd5(package):
					logger.info('%s md5 invalid' % package.name)
					stream_logger.info('   | Md5 invalid, package corrumpt')	
					raise ReinstallerException('Invalid Md5')
			# Cached
			else:
				logger.info('%s already in cache' % package.name)
				# Invalid Md5, redownload
				if not checkmd5(package):
					logger.info('%s cache package md5 invalid' % package.name)
					get_package(package)
					if not checkmd5(package):
						logger.info('%s md5 invalid' % package.name)
						stream_logger.info('   | Md5 invalid, package corrumpt')	
						raise ReinstallerException('Invalid Md5')
				else:
					stream_logger.info('    | %s already in cache' % package.name)