Esempio n. 1
0
def getDependencies(category, package, runtimeOnly=False):
    """returns the dependencies of this package as list of strings:
    category/package"""

    subpackage, package = getSubPackage(category, package)
    if subpackage:
        EmergeDebug.debug(
            "solving package %s/%s/%s %s" %
            (category, subpackage, package, getFilename(category, package)))
    else:
        EmergeDebug.debug("solving package %s/%s %s" %
                          (category, package, getFilename(category, package)))

    deps = []
    info = _getSubinfo(category, package)
    if not info is None:
        depDict = info.dependencies
        depDict.update(info.runtimeDependencies)
        if not runtimeOnly:
            depDict.update(info.buildDependencies)

        for line in depDict:
            (category, package) = line.split("/")
            version = PortageInstance.getNewestVersion(category, package)
            deps.append([category, package, version, depDict[line]])
    return deps
Esempio n. 2
0
    def cleanBuild( self ):
        """cleanup currently used build dir"""
        if os.path.exists( self.buildDir() ):
            utils.cleanDirectory( self.buildDir() )
            EmergeDebug.debug("cleaning build dir: %s" % self.buildDir(), 1)

        return True
Esempio n. 3
0
def getHttpFile( host, path, destdir, filename ):
    """download file from a http host specified by 'host' and 'path' into 'destdir' using 'filename' as file name"""
    # FIXME check return values here (implement useful error handling)...
    EmergeDebug.debug("getHttpFile called. %s %s" % (host, path), 1)

    conn = http.client.HTTPConnection( host )
    conn.request( "GET", path )
    r1 = conn.getresponse()
    EmergeDebug.debug("status: %s; reason: %s" % (str(r1.status), str(r1.reason)))

    count = 0
    while r1.status == 302:
        if count > 10:
            EmergeDebug.debug("Redirect loop")
            return False
        count += 1
        _, host, path, _, _, _ = urllib.parse.urlparse( r1.getheader( "Location" ) )
        EmergeDebug.debug("Redirection: %s %s" % (host, path), 1)
        conn = http.client.HTTPConnection( host )
        conn.request( "GET", path )
        r1 = conn.getresponse()
        EmergeDebug.debug("status: %s; reason: %s" % (str(r1.status), str(r1.reason)))


    data = r1.read()

    with open( os.path.join( destdir, filename ), "wb" ) as f:
        f.write( data )
    return True
Esempio n. 4
0
 def compile(self):
     if not ("Paths", "Python27") in emergeSettings:
         EmergeDebug.die(
             "Please make sure Paths/Python27 is set in your kdesettings.ini"
         )
     utils.prependPath(emergeSettings.get("Paths", "PYTHON27", ""))
     return Qt5CorePackageBase.compile(self)
Esempio n. 5
0
 def buildDir(self):
     EmergeDebug.debug("EmergeBase.buildDir() called", 2)
     builddir = os.path.join(self.workDir(), self.workDirPattern())
     if self.subinfo.options.unpack.unpackIntoBuildDir and self.subinfo.hasTargetSourcePath():
         builddir = os.path.join(builddir, self.subinfo.targetSourcePath())
     EmergeDebug.debug("package builddir is: %s" % builddir, 2)
     return self.__adjustPath(builddir)
Esempio n. 6
0
    def _defaulVersions( self ):
        if self.__defaulVersions is None:
            name = self.subinfo.parent.filename
            if name in VersionInfo._VERSION_INFOS_HINTS:
                if VersionInfo._VERSION_INFOS_HINTS[ name ] == None:
                    return None
                else:
                    #utils.debug("Using cached version info for %s in %s" % (name, _VERSION_INFOS_HINTS[ name ]))
                    return VersionInfo._VERSION_INFOS[ VersionInfo._VERSION_INFOS_HINTS[ name ] ]
            root = os.path.dirname( name )

            if self._fileName is None:
                possibleInis= [ os.path.join( root, "version.ini" ), os.path.join( root, "..", "version.ini" ),
                         os.path.join( root, "..", "..", "version.ini" ) ]
            else:
                possibleInis = [self._fileName]

            for iniPath in possibleInis:
                iniPath = os.path.abspath( iniPath )
                if iniPath in VersionInfo._VERSION_INFOS.keys( ):
                    VersionInfo._VERSION_INFOS_HINTS[ name ] = iniPath
                    EmergeDebug.debug("Found a version info for %s in cache" % name, 2)
                    return VersionInfo._VERSION_INFOS[ iniPath ]
                elif os.path.exists( iniPath ):
                    config = configparser.ConfigParser( )
                    config.read( iniPath )
                    VersionInfo._VERSION_INFOS[ iniPath ] = config
                    VersionInfo._VERSION_INFOS_HINTS[ name ] = iniPath
                    EmergeDebug.debug("Found a version info for %s in %s" % (name, iniPath), 2)
                    return config
            VersionInfo._VERSION_INFOS_HINTS[ name ] = None
        return self.__defaulVersions
Esempio n. 7
0
 def __init__(self):
     EmergeDebug.debug("SetupPackageBase.__init__ called", 2)
     PackageBase.__init__(self)
     MultiSource.__init__(self)
     BuildSystemBase.__init__(self)
     PackagerBase.__init__(self)
     self.subinfo.options.unpack.runInstaller = True
Esempio n. 8
0
def getDependencies( category, package, runtimeOnly = False ):
    """returns the dependencies of this package as list of strings:
    category/package"""

    subpackage, package = getSubPackage( category, package )
    if subpackage:
        EmergeDebug.debug("solving package %s/%s/%s %s" % (category, subpackage, package,
                                                           getFilename( category, package )))
    else:
        EmergeDebug.debug("solving package %s/%s %s" % (category, package, getFilename(category, package)))
        subpackage = package

    deps = []
    for pkg in [ subpackage ]:
        info = _getSubinfo(category, pkg)
        if not info is None:
            depDict = info.dependencies
            depDict.update( info.runtimeDependencies )
            if not runtimeOnly:
                depDict.update( info.buildDependencies )

            for line in list(depDict.keys()):
                (category, package) = line.split( "/" )
                version = PortageInstance.getNewestVersion( category, package )
                deps.append( [ category, package, version, depDict[ line ] ] )
    return deps
Esempio n. 9
0
def getPackagesCategories(packageName, defaultCategory = None):
    EmergeDebug.trace("getPackagesCategories for package name %s" % packageName)
    if defaultCategory is None:
        defaultCategory = emergeSettings.get("General","EMERGE_DEFAULTCATEGORY","kde")

    packageList, categoryList = [], []
    if len( packageName.split( "/" ) ) == 1:
        if PortageInstance.isCategory( packageName ):
            EmergeDebug.debug("isCategory=True", 2)
            packageList = PortageInstance.getAllPackages( packageName )
            categoryList = [ packageName ] * len(packageList)
        else:
            EmergeDebug.debug("isCategory=False", 2)
            if PortageInstance.isCategory( defaultCategory ) and PortageInstance.isPackage( defaultCategory, packageName ):
                # prefer the default category
                packageList = [ packageName ]
                categoryList = [ defaultCategory ]
            else:
                if PortageInstance.getCategory( packageName ):
                    packageList = [ packageName ]
                    categoryList = [ PortageInstance.getCategory( packageName ) ]
    elif len( packageName.split( "/" ) ) == 2:
        [ cat, pac ] = packageName.split( "/" )
        if PortageInstance.isCategory( cat ):
            categoryList = [ cat ]
        else:
            return packageList, categoryList
        if len( categoryList ) > 0 and PortageInstance.isPackage( categoryList[0], pac ):
            packageList = [ pac ]
        if len( categoryList ) and len( packageList ):
            EmergeDebug.debug("added package %s/%s" % (categoryList[0], pac), 2)
    else:
        EmergeDebug.error("unknown packageName")

    return packageList, categoryList
Esempio n. 10
0
 def unpack(self):
     EmergeDebug.trace("MultiSource unpack", 2)
     # pylint: disable=E1101
     # multiple inheritance: MultiSource is never the only
     # superclass, others define self.buildSystemType.
     self.source.buildSystemType = self.buildSystemType
     return self.source.unpack()
Esempio n. 11
0
 def getPackageInstance(self, category, package):
     """return instance of class Package from package file"""
     fileName =  getFilename( category, package )
     pack = None
     mod = None
     if fileName.endswith(".py") and os.path.isfile(fileName):
         if not fileName in self._packageDict:
             EmergeDebug.debug("module to import: %s" % fileName, 2)
             if not os.path.isfile( fileName ):
                 try:
                     mod = builtins.__import__( fileName )
                 except ImportError as e:
                     EmergeDebug.warning('import failed for module %s: %s' % (fileName, str(e)))
                     mod =  None
             else:
                 modulename = os.path.basename( fileName )[:-3].replace('.', '_')
                 loader = importlib.machinery.SourceFileLoader(modulename, fileName)
                 try:
                     mod = loader.load_module()
                 except Exception as e:
                     raise PortageException("Failed to load file %s" % fileName, category, package, e)
             if not mod is None:
                 subpackage, package = getSubPackage( category, package )
                 self._CURRENT_MODULE  = ( fileName, category,subpackage, package, mod )
                 pack = mod.Package( )
                 self._packageDict[ fileName ] = pack
             else:
                 raise PortageException("Failed to find package", category, package)
         else:
             pack = self._packageDict[ fileName ]
         return pack
Esempio n. 12
0
    def fetch( self, repopath=None ):
        """try to clone or update the repository"""
        EmergeDebug.trace("HgSource.fetch called", 2)

        # get the path where the repositories should be stored to
        if repopath == None:
            repopath = self.repositoryUrl()

        # in case you need to move from a read only Url to a writeable one, here it gets replaced
#        repoString = utils.replaceVCSUrl( repopath )
        repopath = repopath.replace("[hg]", "")
        repoUrl, repoBranch, _ = utils.splitVCSUrl( repopath )
        ret = True

        # only run if wanted (e.g. no --offline is given on the commandline) or no hg support is given by the python installation
        if ( not self.noFetch and self.enableHg ):
            # question whether mercurial stuff uses these proxies
            self.setProxy()
            checkoutDir = self.checkoutDir()

            # check corrupted checkout dir
            if os.path.exists( checkoutDir ) and not os.path.exists( checkoutDir + "\.hg" ):
                os.rmdir( checkoutDir )
            
            if not os.path.exists( checkoutDir ):
                os.makedirs( checkoutDir )
                os.chdir( checkoutDir )
                ret = self.system( "%s clone %s ." % ( self.hgExecutable, repoUrl ) ) # TODO: check return code for success
            
            if os.path.exists( checkoutDir ):
                os.chdir( checkoutDir )
                ret = self.system( "%s update %s" % ( self.hgExecutable, repoBranch ) ) # TODO: check return code for success
        else:
            EmergeDebug.debug("skipping hg fetch (--offline)")
        return ret
Esempio n. 13
0
    def fetch( self, dummyRepopath = None ):
        """fetch normal tarballs"""
        EmergeDebug.debug("ArchiveSource.fetch called", 2)

        filenames = self.localFileNames()

        if ( self.noFetch ):
            EmergeDebug.debug("skipping fetch (--offline)")
            return True

        self.setProxy()
        if self.subinfo.hasTarget():
            if self.__checkFilesPresent(filenames):
                EmergeDebug.debug("files and digests available, no need to download files", 1)
                return True

            result = utils.getFiles( self.subinfo.target(), EmergeStandardDirs.downloadDir() , filenames = self.subinfo.archiveName() )
            if not result:
                EmergeDebug.debug("failed to download files", 1)
                return False
            if result and self.subinfo.hasTargetDigestUrls():
                if type(self.subinfo.targetDigestUrl()) == tuple:
                    url, alg = self.subinfo.targetDigestUrl()
                    return utils.getFiles(url, EmergeStandardDirs.downloadDir(),
                                          filenames = self.subinfo.archiveName()[0]
                                                        + EmergeHash.HashAlgorithm.fileEndings().get(alg))
                else:
                    return utils.getFiles( self.subinfo.targetDigestUrl(), EmergeStandardDirs.downloadDir(), filenames = '' )
            else:
                EmergeDebug.debug("no digestUrls present", 2)
                return True
        else:
            return utils.getFiles( "", EmergeStandardDirs.downloadDir() )
Esempio n. 14
0
    def unpack(self):
        """unpacking all zipped(gz, zip, bz2) tarballs"""
        EmergeDebug.debug("ArchiveSource.unpack called", 2)

        filenames = self.localFileNames()

        # TODO: this might delete generated patches
        utils.cleanDirectory(self.workDir())

        if not self.checkDigest():
            return False

        binEndings = (".exe", ".bat", ".msi")
        for filename in filenames:
            if filename.endswith(binEndings):
                filePath = os.path.abspath( os.path.join(EmergeStandardDirs.downloadDir(), filename) )
                if self.subinfo.options.unpack.runInstaller:
                    _, ext = os.path.splitext( filename )
                    if ext == ".exe":
                        return utils.system("%s" % filePath )
                    elif ( ext == ".msi" ):
                        return utils.system("msiexec /package %s" % filePath )
                if not utils.copyFile( filePath, os.path.join(self.workDir(), filename) ):
                    return False
            else:
                if not utils.unpackFile( EmergeStandardDirs.downloadDir(), filename, self.workDir()):
                    return False

        ret = self.applyPatches()
        if emergeSettings.getboolean("General","EMERGE_HOLD_ON_PATCH_FAIL",False):
            return ret
        return True
Esempio n. 15
0
def getFile( url, destdir , filename='' ):
    """download file from 'url' into 'destdir'"""
    EmergeDebug.debug("getFile called. url: %s" % url, 1)
    if url == "":
        EmergeDebug.error("fetch: no url given")
        return False

    if UtilsCache.findApplication("wget"):
        return wgetFile( url, destdir , filename )


    if not filename:
        _, _, path, _, _, _ = urllib.parse.urlparse( url )
        filename = os.path.basename( path )

    if os.path.exists(os.path.join( destdir, filename )):
        return True

    width, _ =  shutil.get_terminal_size((80,20))
    def dlProgress(count, blockSize, totalSize):
        percent = int(count * blockSize * 100 / totalSize)
        times = int((width - 20)/100 * percent)
        sys.stdout.write(("\r%s%3d%%" % ("#" * times, percent)))
        sys.stdout.flush()

    urllib.request.urlretrieve(url, filename =  os.path.join( destdir, filename ), reporthook= dlProgress if EmergeDebug.verbose() >= 0 else None )

    if EmergeDebug.verbose()>=0:
        sys.stdout.write("\n")
        sys.stdout.flush()
    return True
    def make( self ):
        """implements the make step for cmake projects"""

        self.enterBuildDir()
        utils.prependPath(self.rootdir, self.envPath)

        if self.subinfo.options.cmake.openIDE:
            if compiler.isMSVC2008():
                command = "start %s" % self.__slnFileName()
            elif compiler.isMSVC2010():
                command = "start vcexpress %s" % self.__slnFileName()
        elif self.subinfo.options.cmake.useIDE:
            if compiler.isMSVC2008():
                command = "vcbuild /M1 %s \"%s|WIN32\"" % (self.__slnFileName(), self.buildType())
            elif compiler.isMSVC2015():
                command = "msbuild /maxcpucount %s /t:ALL_BUILD /p:Configuration=\"%s\"" % (self.__slnFileName(), self.buildType())
            elif compiler.isMSVC2010():
                EmergeDebug.die("has to be implemented");
        elif self.subinfo.options.cmake.useCTest:
            # first make clean
            self.system( self.makeProgramm + " clean", "make clean" )
            command = "ctest -M " + "Nightly" + " -T Start -T Update -T Configure -T Build -T Submit"
        else:
            command = ' '.join([self.makeProgramm, self.makeOptions()])


        return self.system( command, "make" )
Esempio n. 17
0
    def cleanBuild( self ) -> bool:
        """cleanup currently used build dir"""
        if os.path.exists( self.buildDir() ):
            utils.cleanDirectory( self.buildDir() )
            EmergeDebug.debug("cleaning build dir: %s" % self.buildDir(), 1)

        return True
 def __makeFileGenerator(self):
     """return cmake related make file generator"""
     if self.supportsNinja and emergeSettings.getboolean("Compile","UseNinja", False):
         return "Ninja"
     if compiler.isMSVC2015():
         if self.subinfo.options.cmake.useIDE or self.subinfo.options.cmake.openIDE:
             return "Visual Studio 14 2015" + " Win64" if compiler.isX64() else ""
         else:
             return "NMake Makefiles"
     if compiler.isMSVC2010():
         if self.subinfo.options.cmake.useIDE or self.subinfo.options.cmake.openIDE:
             return "Visual Studio 10"
         else:
             return "NMake Makefiles"
     elif compiler.isMSVC2008():
         if self.subinfo.options.cmake.useIDE or self.subinfo.options.cmake.openIDE:
             return "Visual Studio 9 2008"
         else:
             return "NMake Makefiles"
     elif compiler.isMSVC() or compiler.isIntel():
         return "NMake Makefiles"
     elif compiler.isMinGW():
         return "MinGW Makefiles"
     else:
         EmergeDebug.die("unknown %s compiler" % self.compiler())
Esempio n. 19
0
def PackagerFactory(parent, packagerType):
    """provides multi packager type api
    return PackagerBase derived instance for recent settings"""
    EmergeDebug.debug("PackagerFactory called", 2)
    packagers = []

    if packagerType:
        for packagerClass in packagerType:
            if not issubclass(packagerClass, PackagerBase):
                EmergeDebug.die("PackagerFactory: unsupported packager %s" % packagerClass)
            else:
                packager = packagerClass()
                init(packager, parent)
                packagers.append(packager)
    else:
        # automatic detection
        packager = InnoSetupPackager()
        init(packager, parent)

        if packager.configFile() != None:
            packagers.append(packager)

        # default packager
        if len(packagers) == 0:
            packager = KDEWinPackager()
            init(packager, parent)
            packagers.append(packager)
    return packagers
 def _fixCmakeImageDir(self, imagedir, rootdir ):
     """
     when using DESTDIR=foo under windows, it does not _replace_
     CMAKE_INSTALL_PREFIX with it, but prepends destdir to it.
     so when we want to be able to install imagedir into KDEROOT,
     we have to move things around...
     """
     EmergeDebug.debug("fixImageDir: %s %s" % (imagedir, rootdir), 1)
     # imagedir = e:\foo\thirdroot\tmp\dbus-0\image
     # rootdir  = e:\foo\thirdroot
     # files are installed to
     # e:\foo\thirdroot\tmp\dbus-0\image\foo\thirdroot
     _, rootpath = os.path.splitdrive( rootdir )
     #print "rp:", rootpath
     if ( rootpath.startswith( os.path.sep ) ):
         rootpath = rootpath[1:]
     # CMAKE_INSTALL_PREFIX = X:\
     # -> files are installed to
     # x:\build\foo\dbus\image\
     # --> all fine in this case
     #print("rp:", rootpath)
     if len(rootpath) == 0:
         return
     
     tmp = os.path.join( imagedir, rootpath )
     EmergeDebug.debug("tmp: %s" % tmp, 1)
     tmpdir = os.path.join( imagedir, "tMpDiR" )
     if ( not os.path.isdir( tmpdir ) ):
         os.mkdir( tmpdir )
     utils.moveEntries( tmp, tmpdir )
     os.chdir( imagedir )
     os.removedirs( rootpath )
     utils.moveEntries( tmpdir, imagedir )
     utils.cleanDirectory( tmpdir )
     os.rmdir( tmpdir )
    def __getImageDirectories( self ):
        """ return the image directories where the files are stored """
        imageDirs = []
        runtimeDependencies = portage.getDependencies(self.category, self.package)

        depList = []
        for ( category, package, _, _ ) in runtimeDependencies:
            # we only want runtime dependencies since we want to build a binary installer
            portage.solveDependencies(category, package, depList = depList,
                                      depType = DependencyType.Runtime, ignoredPackages = self.ignoredPackages)
        depList.reverse()

        # make sure current package is added to the list, too
        if not self.package.endswith("-package"):
            depList.append(DependencyPackage(self.category, self.package))

        for x in depList:
            if portage.PortageInstance.isVirtualPackage(x.category, x.package):
                EmergeDebug.debug("Ignoring package b/c it is virtual: %s/%s" % (x.category, x.package))
                continue

            _package = portage.getPackageInstance( x.category, x.package )

            imageDirs.append(( os.path.join( self.rootdir, "build", x.category, x.package,
                    self.__imageDirPattern( _package, _package.buildTarget )), _package.subinfo.options.merge.destinationPath , _package.subinfo.options.package.disableStriping ) )
            # this loop collects the files from all image directories
            EmergeDebug.debug("__getImageDirectories: category: %s, package: %s, version: %s, defaultTarget: %s" % (_package.category, x.package, _package.version, _package.buildTarget), 2)

        if emergeSettings.getboolean("QtSDK", "Enabled", "false"):
            imageDirs.append((os.path.join( emergeSettings.get("QtSDK", "Path") , emergeSettings.get("QtSDK", "Version"), emergeSettings.get("QtSDK", "Compiler")), None, False))

        return imageDirs
Esempio n. 22
0
    def make(self):
        """implements the make step for cmake projects"""

        self.enterBuildDir()
        utils.prependPath(self.rootdir, self.envPath)

        if self.subinfo.options.cmake.openIDE:
            if compiler.isMSVC2008():
                command = "start %s" % self.__slnFileName()
            elif compiler.isMSVC2010():
                command = "start vcexpress %s" % self.__slnFileName()
        elif self.subinfo.options.cmake.useIDE:
            if compiler.isMSVC2008():
                command = "vcbuild /M1 %s \"%s|WIN32\"" % (
                    self.__slnFileName(), self.buildType())
            elif compiler.isMSVC2015():
                command = "msbuild /maxcpucount %s /t:ALL_BUILD /p:Configuration=\"%s\"" % (
                    self.__slnFileName(), self.buildType())
            elif compiler.isMSVC2010():
                EmergeDebug.die("has to be implemented")
        elif self.subinfo.options.cmake.useCTest:
            # first make clean
            self.system(self.makeProgramm + " clean", "make clean")
            command = "ctest -M " + "Nightly" + " -T Start -T Update -T Configure -T Build -T Submit"
        else:
            command = ' '.join([self.makeProgramm, self.makeOptions()])

        return self.system(command, "make")
Esempio n. 23
0
 def unpack(self):
     EmergeDebug.trace("MultiSource unpack", 2)
     # pylint: disable=E1101
     # multiple inheritance: MultiSource is never the only
     # superclass, others define self.buildSystemType.
     self.source.buildSystemType = self.buildSystemType
     return self.source.unpack()
Esempio n. 24
0
 def __makeFileGenerator(self):
     """return cmake related make file generator"""
     if self.supportsNinja and emergeSettings.getboolean(
             "Compile", "UseNinja", False):
         return "Ninja"
     if compiler.isMSVC2015():
         if self.subinfo.options.cmake.useIDE or self.subinfo.options.cmake.openIDE:
             return "Visual Studio 14 2015" + " Win64" if compiler.isX64(
             ) else ""
         else:
             return "NMake Makefiles"
     if compiler.isMSVC2010():
         if self.subinfo.options.cmake.useIDE or self.subinfo.options.cmake.openIDE:
             return "Visual Studio 10"
         else:
             return "NMake Makefiles"
     elif compiler.isMSVC2008():
         if self.subinfo.options.cmake.useIDE or self.subinfo.options.cmake.openIDE:
             return "Visual Studio 9 2008"
         else:
             return "NMake Makefiles"
     elif compiler.isMSVC() or compiler.isIntel():
         return "NMake Makefiles"
     elif compiler.isMinGW():
         return "MinGW Makefiles"
     else:
         EmergeDebug.die("unknown %s compiler" % self.compiler())
Esempio n. 25
0
 def cleanImage( self ):
     """cleanup before install to imagedir"""
     if ( os.path.exists( self.imageDir() ) ):
         EmergeDebug.debug("cleaning image dir: %s" % self.imageDir(), 1)
         utils.cleanDirectory( self.imageDir() )
         os.rmdir(self.imageDir())
     return True
Esempio n. 26
0
    def dumpCMakeDependencies(self):
        """dump package dependencies as pdf (requires installed dot)"""

        srcDir = self.sourceDir()
        outDir = self.buildDir()
        self.enterBuildDir()
        outFile = os.path.join(outDir, self.package + '-cmake.dot')
        a = CMakeDependencies()
        if not a.parse(srcDir):
            EmergeDebug.debug(
                "could not find source files for generating cmake dependencies"
            )
            return False
        title = "%s cmake dependency chart - version %s" % (self.package,
                                                            self.version)
        a.toPackageList(title, srcDir)
        if not a.toDot(title, srcDir, outFile):
            EmergeDebug.debug("could not create dot file")
            return False

        graphviz = GraphViz(self)

        if not graphviz.runDot(outFile, outFile + '.pdf', 'pdf'):
            return False

        return graphviz.openOutput()
Esempio n. 27
0
def SourceFactory(settings):
    """ return sourceBase derived instance for recent settings"""
    EmergeDebug.trace("SourceFactory called", 1)
    source = None

    if settings.hasTarget():
        if settings.hasMultipleTargets():
            url = settings.targetAt(0)
        else:
            url = settings.target()
        source = ArchiveSource(settings)

    ## \todo move settings access into info class
    if settings.hasSvnTarget():
        url = settings.svnTarget()
        sourceType = utils.getVCSType( url )
        if sourceType == "svn":
            source = SvnSource(settings)
        elif sourceType == "hg":
            source = HgSource(settings)
        elif sourceType == "git":
            source = GitSource(settings)

    if source == None:
        EmergeDebug.die("none or unsupported source system set")
    if not source.subinfo:
        source.subinfo = settings
    source.url = url
    return source
Esempio n. 28
0
    def _fixCmakeImageDir(self, imagedir, rootdir):
        """
        when using DESTDIR=foo under windows, it does not _replace_
        CMAKE_INSTALL_PREFIX with it, but prepends destdir to it.
        so when we want to be able to install imagedir into KDEROOT,
        we have to move things around...
        """
        EmergeDebug.debug("fixImageDir: %s %s" % (imagedir, rootdir), 1)
        # imagedir = e:\foo\thirdroot\tmp\dbus-0\image
        # rootdir  = e:\foo\thirdroot
        # files are installed to
        # e:\foo\thirdroot\tmp\dbus-0\image\foo\thirdroot
        _, rootpath = os.path.splitdrive(rootdir)
        #print "rp:", rootpath
        if (rootpath.startswith(os.path.sep)):
            rootpath = rootpath[1:]
        # CMAKE_INSTALL_PREFIX = X:\
        # -> files are installed to
        # x:\build\foo\dbus\image\
        # --> all fine in this case
        #print("rp:", rootpath)
        if len(rootpath) == 0:
            return

        tmp = os.path.join(imagedir, rootpath)
        EmergeDebug.debug("tmp: %s" % tmp, 1)
        tmpdir = os.path.join(imagedir, "tMpDiR")
        if (not os.path.isdir(tmpdir)):
            os.mkdir(tmpdir)
        utils.moveEntries(tmp, tmpdir)
        os.chdir(imagedir)
        os.removedirs(rootpath)
        utils.moveEntries(tmpdir, imagedir)
        utils.cleanDirectory(tmpdir)
        os.rmdir(tmpdir)
Esempio n. 29
0
def renameDir(src, dest):
    """ rename a directory """
    EmergeDebug.debug("rename directory from %s to %s" % (src, dest), 2)
    if os.rename( src, dest ) == 0:
        return False
    else:
        return True
Esempio n. 30
0
 def cleanImage( self ) -> bool:
     """cleanup before install to imagedir"""
     if ( os.path.exists( self.imageDir() ) ):
         EmergeDebug.debug("cleaning image dir: %s" % self.imageDir(), 1)
         utils.cleanDirectory( self.imageDir() )
         os.rmdir(self.imageDir())
     return True
Esempio n. 31
0
    def fetch( self, dummyRepopath = None ):
        """fetch normal tarballs"""
        EmergeDebug.debug("ArchiveSource.fetch called", 2)

        filenames = self.localFileNames()

        if ( self.noFetch ):
            EmergeDebug.debug("skipping fetch (--offline)")
            return True

        self.setProxy()
        if self.subinfo.hasTarget():
            if self.__checkFilesPresent(filenames):
                EmergeDebug.debug("files and digests available, no need to download files", 1)
                return True

            result = utils.getFiles( self.subinfo.target(), EmergeStandardDirs.downloadDir() , filenames = self.subinfo.archiveName() )
            if not result:
                EmergeDebug.debug("failed to download files", 1)
                return False
            if result and self.subinfo.hasTargetDigestUrls():
                if type(self.subinfo.targetDigestUrl()) == tuple:
                    url, alg = self.subinfo.targetDigestUrl()
                    return utils.getFiles(url, EmergeStandardDirs.downloadDir(),
                                          filenames = self.subinfo.archiveName()
                                                        + EmergeHash.HashAlgorithm.fileEndings().get(alg))
                else:
                    return utils.getFiles( self.subinfo.targetDigestUrl(), EmergeStandardDirs.downloadDir(), filenames = '' )
            else:
                EmergeDebug.debug("no digestUrls present", 2)
                return True
        else:
            return utils.getFiles( "", EmergeStandardDirs.downloadDir() )
Esempio n. 32
0
 def __init__(self):
     EmergeDebug.debug("SetupPackageBase.__init__ called", 2)
     PackageBase.__init__(self)
     MultiSource.__init__(self)
     BuildSystemBase.__init__(self)
     PackagerBase.__init__(self)
     self.subinfo.options.unpack.runInstaller = True
Esempio n. 33
0
 def __init__(self,
              defaultType=eval(
                  emergeSettings.get("Packager", "PackageType",
                                     "SevenZipPackager"))):
     EmergeDebug.debug("TypePackager __init__ %s" % defaultType, 2)
     PackagerBase.__init__(self)
     self.__packager = defaultType
Esempio n. 34
0
    def unpack(self):
        """unpacking all zipped(gz, zip, bz2) tarballs"""
        EmergeDebug.debug("ArchiveSource.unpack called", 2)

        filenames = self.localFileNames()

        # TODO: this might delete generated patches
        utils.cleanDirectory(self.workDir())

        if not self.checkDigest():
            return False

        binEndings = (".exe", ".bat", ".msi")
        for filename in filenames:
            if filename.endswith(binEndings):
                filePath = os.path.abspath( os.path.join(EmergeStandardDirs.downloadDir(), filename) )
                if self.subinfo.options.unpack.runInstaller:
                    _, ext = os.path.splitext( filename )
                    if ext == ".exe":
                        return utils.system("%s" % filePath )
                    elif ( ext == ".msi" ):
                        return utils.system("msiexec /package %s" % filePath )
                if not utils.copyFile( filePath, os.path.join(self.workDir(), filename) ):
                    return False
            else:
                if not utils.unpackFile( EmergeStandardDirs.downloadDir(), filename, self.workDir()):
                    return False

        ret = self.applyPatches()
        if emergeSettings.getboolean("General","EMERGE_HOLD_ON_PATCH_FAIL",False):
            return ret
        return True
Esempio n. 35
0
    def sourceVersion(self):
        """ return the revision of the repository """
        EmergeDebug.trace("HgSource.sourceVersion called", 2)

        if self.enableHg:

            # open a temporary file - do not use generic tmpfile because this doesn't give a good file object with python
            with open(
                    os.path.join(self.checkoutDir().replace('/', '\\'),
                                 ".emergehgtip.tmp"), "wb+") as tempfile:

                # run the command
                utils.system("%s tip" % self.hgExecutable, stdout=tempfile)
                # TODO: check return value for success
                tempfile.seek(os.SEEK_SET)

                # read the temporary file and grab the first line
                revision = tempfile.readline().replace("changeset:",
                                                       "").strip()

            os.remove(
                os.path.join(self.checkoutDir().replace('/', '\\'),
                             ".emergehgtip.tmp"))
        # always return True to not break something serious
        return revision
def PackagerFactory(parent, packagerType):
    """provides multi packager type api
    return PackagerBase derived instance for recent settings"""
    EmergeDebug.debug("PackagerFactory called", 2)
    packagers = []

    if packagerType:
        for packagerClass in packagerType:
            if not issubclass(packagerClass, PackagerBase):
                EmergeDebug.die("PackagerFactory: unsupported packager %s" %
                                packagerClass)
            else:
                packager = packagerClass()
                init(packager, parent)
                packagers.append(packager)
    else:
        # automatic detection
        packager = InnoSetupPackager()
        init(packager, parent)

        if packager.configFile() != None:
            packagers.append(packager)

        # default packager
        if len(packagers) == 0:
            packager = KDEWinPackager()
            init(packager, parent)
            packagers.append(packager)
    return packagers
Esempio n. 37
0
    def inner(*args, **argv):
        logdir = emergeSettings.get( "General", "EMERGE_LOG_DIR", "" )

        if logdir == "":
            return fn(*args, **argv)

        if os.path.isfile(logdir):
            EmergeDebug.die("EMERGE_LOG_DIR %s is a file" % logdir)

        if not os.path.exists(logdir):
            try:
                os.mkdir(logdir)
            except OSError:
                EmergeDebug.die("EMERGE_LOG_DIR %s can not be created" % logdir)

        logfile = ""
        for a in args:
            logfile += "%s-" % a
        logfile = logfile[:-1]#drop last -
        logfile = "%s.log" % logfile.replace("/","_").replace("\\","_")

        logfile = os.path.join(logdir, logfile)
        f = open(logfile, "at")
        try:
            old_out = sys.stdout
            old_err = sys.stderr
            sys.stdout = f
            sys.stderr = f
            return fn(*args, **argv)
        finally:
            sys.stdout = old_out
            sys.stderr = old_err
            f.close()
Esempio n. 38
0
def doExec(package, action, continueFlag=False):
    with EmergeTimer.Timer("%s for %s" % (action, package), 1):
        EmergeDebug.info("Action: %s for %s" % (action, package))
        ret = package.execute(action)
        if not ret:
            EmergeDebug.warning("Action: %s for %s FAILED" % (action, package))
        return ret or continueFlag
Esempio n. 39
0
def getFiles( urls, destdir, suffix='' , filenames = ''):
    """download files from 'url' into 'destdir'"""
    EmergeDebug.debug("getfiles called. urls: %s, filenames: %s, suffix: %s" % (urls, filenames, suffix), 1)
    # make sure distfiles dir exists
    if ( not os.path.exists( destdir ) ):
        os.makedirs( destdir )

    if type(urls) == list:
        urlList = urls
    else:
        urlList = urls.split()

    if filenames == '':
        filenames = [ os.path.basename(x) for x in urlList ]

    if type(filenames) == list:
        filenameList = filenames
    else:
        filenameList = filenames.split()
        
    dlist = list(zip( urlList , filenameList ))
    
    for url,filename in dlist:
        if ( not getFile( url + suffix, destdir , filename ) ):
            return False

    return True
Esempio n. 40
0
def deleteFile(fileName):
    """delete file """
    if not os.path.exists( fileName ):
        return False
    EmergeDebug.debug("delete file %s " % (fileName), 2)
    os.remove( fileName )
    return True
Esempio n. 41
0
 def getNightlyVersionsFromUrl(url, pattern, timeout = 10) -> [str]:
     """
     Returns a list of possible version number matching the regular expression in pattern.
     :param url: The url to look for the nightly builds.
     :param pattern: A regular expression to match the version.
     :param timeout:
     :return: A list of matching strings or [None]
     """
     if emergeSettings.getboolean("General", "WorkOffline"):
         EmergeDebug.info("Nightly builds unavailable for %s in offline mode." % url)
         return [None]
     if url in UtilsCache._NIGTHLY_URLS:
         return UtilsCache._NIGTHLY_URLS[url]
     else:
         try:
             with urllib.request.urlopen(url, timeout = timeout) as fh:
                 data = str(fh.read(), "UTF-8")
                 vers = re.findall( pattern , data)
                 if not vers:
                     print(data)
                     raise Exception("Pattern %s does not match." % pattern)
                 UtilsCache._NIGTHLY_URLS[url] = vers
                 return vers
         except Exception as e:
             EmergeDebug.warning("Nightly builds unavailable for %s: %s" % (url, e))
             return [None]
    def __repositoryBaseUrl( self ):
        """ this function return the base url to the KDE repository """
        EmergeDebug.trace("VersionSystemSourceBase __repositoryBaseUrl", 2)
        # @todo move to SvnSource
        server = emergeSettings.get("General", "KDESVNSERVER", "svn://anonsvn.kde.org")


        return server + '/home/kde/'
    def setDependencies( self ):
        EmergeDebug.debug("emergebuildsystem:subinfo.setDependencies not implemented yet", 1)
        # we need at least qmake
        #self.dependencies['libs/qt'] = 'default'
        self.buildDependencies['dev-util/jom'] = 'default'

        if compiler.isMinGW():
            self.buildDependencies['dev-util/mingw-w64']    = 'default'
Esempio n. 44
0
 def applyPatch(self, fileName, patchdepth, unusedSrcDir=None):
     """apply a patch to a svn repository checkout"""
     EmergeDebug.trace("SvnSource.applyPatch", 2)
     if fileName:
         return utils.applyPatch(self.sourceDir(),
                                 os.path.join(self.packageDir(), fileName),
                                 patchdepth)
     return True
Esempio n. 45
0
def notify(title,message,alertClass = None):
    EmergeDebug.info("%s: %s" % (title, message))
    backends = emergeSettings.get( "General","EMERGE_USE_NOTIFY", "")
    if backends == "":
        return
    backends = Notifier.NotificationLoader.load(backends.split(";"))
    for backend in backends.values():
        backend.notify(title,message,alertClass)
Esempio n. 46
0
def applyPatch(sourceDir, f, patchLevel='0'):
    """apply single patch"""
    cmd = 'patch -d "%s" -p%s -i "%s"' % (sourceDir, patchLevel, f)
    EmergeDebug.debug("applying %s" % cmd)
    result = system( cmd )
    if not result:
        EmergeDebug.warning("applying %s failed!" % f)
    return result
Esempio n. 47
0
def systemWithoutShell(cmd, **kw):
    """execute cmd. All keywords are passed to Popen. stdout and stderr
    might be changed depending on the chosen logging options."""

    EmergeDebug.debug("executing command: %s" % cmd, 1)
    if EmergeDebug.verbose() == -1 and not 'stdout' in kw and not 'stderr' in kw:
        kw['stdout'] = kw['stderr'] = subprocess.DEVNULL
    return subprocess.call(cmd, **kw) == 0