Exemplo n.º 1
0
 def get_missing_prerequisites(self, packages):
     prerequisites = list(self.get_prerequisites(packages))
     for pkgline in prerequisites:
         pkgname = packageline_split(pkgline)[4]
         result = local("brew list %s &>/dev/null; echo $?" % pkgname)
         if not result.strip() == '0':
             yield pkgline
Exemplo n.º 2
0
 def get_missing_prerequisites(self, packages):        
     prerequisites = list(self.get_prerequisites(packages))
     
     for pkgline in prerequisites:
         (name, pkgtype, platform, resource, url, opt1, opt2) = packageline_split(pkgline)
 
         if opt1 == "unzipflat" or opt1 == "unzipflatroot" or opt1 == "unzipflatsecond":
             if not len(list(which(opt2))):
                 yield pkgline
         
         elif opt1 in ['exec', 'msiexec']:
             full_path = None
             warn("Information: searching c:\ for %s, this may take a while" % opt2)
             for root, dirs, files in os.walk("C:\\"):
                 for file in files:
                     if file == opt2:
                         full_path = os.path.join(root, file)
                         warn("Information: found %s at %s" % (opt2, full_path))
                         break
                 if full_path:
                     break
             if not full_path:
                 yield pkgline
         else:
             raise NotImplementedError
Exemplo n.º 3
0
Arquivo: base.py Projeto: emulbreh/ecs
 def get_prerequisites(self, packages):
     for packageline in packages.splitlines():
         (name, pkgtype, platform, resource, _, _, _) = packageline_split(packageline)
         if name is None:
             continue
         if pkgtype == 'req' and re.match(self.platform, platform) and re.match(self.resource, resource):
             yield packageline
Exemplo n.º 4
0
Arquivo: apt.py Projeto: emulbreh/ecs
 def get_missing_prerequisites(self, packages):
     prerequisites = list(self.get_prerequisites(packages))
     for pkgline in prerequisites:
         pkgname = ' '.join(packageline_split(pkgline)[4].split(','))
         with settings(warn_only=True):
             result = local("dpkg -l %s >/dev/null 2>/dev/null" % pkgname)
         if result.failed:
             yield pkgline
Exemplo n.º 5
0
Arquivo: base.py Projeto: emulbreh/ecs
 def get_packages(self, packages):
     for pkgline in packages.splitlines():
         (name, pkgtype, platform, resource, url, opt1, opt2) = packageline_split(pkgline)
         if name is None:
             continue
         if re.match(self.platform, platform):
             if pkgtype == 'inst' or pkgtype == 'instbin':
                 yield pkgline
Exemplo n.º 6
0
 def get_missing_prerequisites(self, packages):
     prerequisites = list(self.get_prerequisites(packages))
     for pkgline in prerequisites:
         pkgname = packageline_split(pkgline)[4]
         with settings(warn_only=True):
             # using the rpm tool directly is much faster then using zypper
             result = local("rpm -q %s >/dev/null 2>/dev/null" % pkgname)
         if result.failed:
             yield pkgline
Exemplo n.º 7
0
 def get_missing_prerequisites(self, packages):
     prerequisites = list(self.get_prerequisites(packages))
     cmd = "pkg_info|sed -r 's/^(.*)-[0123456789]+.*/\\1/'"
     installed_packages = local(cmd).splitlines()
     for pkgline in prerequisites:
         pkgname = packageline_split(pkgline)[4]
         if "--" in pkgname:
             pkgname, flavor = pkgname.split("--", 1)
         if not pkgname in installed_packages:
             yield pkgline
Exemplo n.º 8
0
Arquivo: base.py Projeto: emulbreh/ecs
 def install_prerequisites(self, packages, use_sudo=True):
     sudooption = "sudo" if use_sudo else ""
     pkg_list = ' '.join([packageline_split(x)[4] for x in self.get_missing_prerequisites(packages)])
     if pkg_list:
         with settings(warn_only=True):
             result = local("%s %s %s %s %s" % (sudooption, self.env_vars, self.pkgmanager, self.pkgmanageroptions, pkg_list))
         print(result.stdout)
         if result.failed:
             print(result.stderr)
             abort("Install of prerequisites failed")
Exemplo n.º 9
0
 def install_prerequisites(self, packages, use_sudo=True):
     prerequisites = list(self.get_missing_prerequisites(packages))
     if not prerequisites:
         return
         
     for pkgline in prerequisites:
         (name, pkgtype, platform, resource, url, opt1, opt2) = packageline_split(pkgline)
             
         if resource in ["http", "https", "ftp"]:
             url = "".join((resource,":",url))
         elif resource in ["file", "dir"]:
             url = os.path.join(fabdir(), url)
         
         # try to take windows prerequisite package from the fridge (externals/frozen)
         resource, url = try_frozen(resource, url)
                         
         if opt1 in ["unzipflat", "unzipflatroot", "unzipflatsecond"]:        
             print("Information: installing prerequisite %s" % opt2)
             if resource == "file":
                 filename = url
             else:
                 filename, headers = urlretrieve(url)
             C_extract_levels = {'unzipflat': -1, 'unzipflatroot': 0, 'unzipflatsecond': 1}
             self._zip_flatextract(filename, os.path.dirname(get_pythonexe()), C_extract_levels[opt1])
             if resource != "file":
                 os.remove(filename)
     
         elif opt1 in ['exec', 'msiexec']:
             print("Information: installing prerequisite %s" % opt2)
             if resource == "file":
                 filename = url
             else:
                 filename, headers = urlretrieve(url)
             with settings(warn_only=True):
                 if opt1 == "exec":
                     result = local(filename)
                 elif opt1 == "msiexec":
                     result = local("msiexec /i %s" % filename)
                 print(result.stdout)
                 if result.failed:
                     print(result.stderr)
                     abort("Install of prerequisites failed")
             if resource != "file":
                 os.remove(filename)
         else:
             abort("Unimplemented requirement type in line %s" % pkgline)
Exemplo n.º 10
0
Arquivo: base.py Projeto: emulbreh/ecs
    def install_packages(self, packages, upgrade=False):
        upgradeoption = ""
        if upgrade: upgradeoption= "--upgrade"
        
        for packageline in self.get_packages(packages):
            (name, pkgtype, platform, resource, url, opt1, opt2) = packageline_split(packageline)
            if resource in ["pypi"]:
                pass
            elif resource in ["http", "https", "ftp"]:
                url = "".join((resource,":",url))
            elif resource in ["file", "dir"]:
                url = os.path.join(fabdir(), url)
            else:
                abort("unimplemented resource %s" % (resource))        

            # try to take package from the fridge (externals/frozen)
            resource, url = try_frozen(resource,url)
            
            if pkgtype == "inst":
                print("Information: installing %s from %s on matching platform %s" % (name, resource, platform))
                if resource in ["pypi", "http", "https", "ftp"]:        
                    with settings(warn_only=True):
                        if resource == "pypi":
                            if sys.platform == "win32":
                                url=url.replace('\\','^')
                            else:
                                url="".join(('"',url,'"'))
                                url=url.replace('\\','')
                        result=local('pip install --no-deps %s %s' % (upgradeoption, url))
                elif resource in ["file", "dir"]:
                    with settings(warn_only=True):
                        result=local('%s --always-copy --always-unzip --no-deps %s' % (self.easy_install, url))
                else:
                    abort("unimplemented resource %s" % (resource))
                _abort_failed(result)
                
            elif pkgtype == "instbin":
                if resource in ["http", "https", "ftp", "file"]:    
                    with settings(warn_only=True):
                        result=local('%s --always-copy --always-unzip --no-deps %s' % (self.easy_install, url))                    
                    _abort_failed(result)
                else:
                    abort("unimplemented resource %s" % (resource))

            else:
                warn("unimplemented package type %s in line: %s" % (pkgtype, packageline))
Exemplo n.º 11
0
def fridge_refill(appname, flavor="default", refill_behavior= RB_IGNORE):
    '''
    refill fridge: appname, flavor, refill_behavior
    
    refill_behavior= 
    "abort-if-existing" abort if file to be downloaded already exists
    "ignore-if-existing" ignore file to be downloaded if already exists 
    "update-if-different" update file if file to be downloaded is unequal stored file 
    "overwrite-existing" download file and overwrite regardless if already there and equal 
    '''
    if refill_behavior not in REFILL_BEHAVIOR:
        abort("refill behavior can be only one of %s" % str(REFILL_BEHAVIOR))
    
    if not os.path.exists(_fridgedir()):
        os.makedirs(_fridgedir())

    appconfigfile = os.path.join(fabdir(), appname, 'application.py')
    appconfig = import_from(appconfigfile)
    try:
        package_bundles = appconfig.package_bundles
    except AttributeError:
        abort('package_bundles is not defined')  
    try:
        package_bundle = package_bundles[flavor]
    except KeyError:
        abort('No flavor "%s"\n' % flavor)
    
    package_bundle= package_merge(package_bundle)
   
    for line in package_bundle.splitlines():       
        (name, pkgtype, platform, resource, url, opt1, opt2) = packageline_split(line)
        if name is None:
            continue
        if resource not in ['https', 'http', 'ftp', 'pypi']:
            continue
        if resource == "pypi":
            url = url.replace('\\','')
        elif resource in ["http", "https", "ftp"]:
            url = "".join((resource,":",url))

        print "freezing ", name, pkgtype, platform, resource, url, opt1, opt2, " as ", _frozenname(resource, url)
        _transfer_to_fridge(resource, url, refill_behavior)