Exemple #1
0
 def importExistingDatabase( self ):
     """ imports from the previous installation database system """
     for category, package, version in portage.PortageInstance.getInstallables():
         # FIXME: we need to adapt this to use prefixes as well
         utils.debug( "importing package %s/%s-%s ..." % ( category, package, version ) )
         if self.isPkgInstalled( category, package, version ):
             utils.debug( 'adding installed package %s/%s-%s' % ( category, package, version ), 1 )
             packageObject = self.addInstalled( category, package, version, "" )
             packageObject.addFiles( utils.getFileListFromManifest( os.getenv( "KDEROOT" ), package ) )
             packageObject.install()
             if emergePlatform.isCrossCompilingEnabled():
                 targetObject = self.addInstalled( category, package, version, os.getenv( "EMERGE_TARGET_PLATFORM" ) )
                 targetObject.addFiles( utils.getFileListFromManifest( os.path.join( os.getenv( "KDEROOT" ),
                         os.getenv( "EMERGE_TARGET_PLATFORM" ) ), package ) )
                 targetObject.install()
Exemple #2
0
def main():
    """ Testing the class"""

    # add two databases
    tempdbpath1 = os.path.join( os.getenv("KDEROOT"), "tmp", "temp1.db" )
    tempdbpath2 = os.path.join( os.getenv("KDEROOT"), "tmp", "temp2.db" )

    if not os.path.exists( os.path.join( os.getenv( "KDEROOT" ), "tmp" ) ):
        os.makedirs( os.path.join( os.getenv( "KDEROOT" ), "tmp" ) )

    if os.path.exists( tempdbpath1 ):
        os.remove( tempdbpath1 )
    if os.path.exists( tempdbpath2 ):
        os.remove( tempdbpath2 )

    db_temp = InstallDB( tempdbpath1 )
    db = InstallDB( tempdbpath2 )

    utils.debug( 'testing installation database' )

    utils.debug( 'testing if package win32libs/dbus-src with version 1.4.0 is installed: %s' %
                 db.isPkgInstalled( 'win32libs', 'dbus-src', '1.4.0' ) )

    # in case the package is still installed, remove it first silently
    if db.isInstalled( 'win32libs', 'dbus-src', '1.4.0' ):
        packageList = db.remInstalled( 'win32libs', 'dbus-src', '1.4.0' )
        # really commit uninstall
        for package in packageList:
            package.uninstall()
    utils.debug_line()

    utils.new_line()
    # add a package
    utils.debug( 'installing package win32libs/dbus-src-1.4.0 (release)' )
    package = db.addInstalled( 'win32libs', 'dbus-src', '1.4.0', 'release' )
    package.addFiles( dict().fromkeys( [ 'test', 'test1', 'test2' ], 'empty hash' ) )
    # now really commit the package
    package.install()

    # add another package in a different prefix
    utils.debug( 'installing package win32libs/dbus-src-1.4.0 (debug)' )
    package = db.addInstalled( 'win32libs', 'dbus-src', '1.4.0', 'debug' )
    package.addFiles( dict().fromkeys( [ 'test', 'test1', 'test2' ], 'empty hash' ) )
    # now really commit the package
    package.install()
    utils.debug_line()

    utils.new_line()
    utils.debug( 'checking installed packages' )
    utils.debug( 'get installed package (release): %s' % db.getInstalled( 'win32libs', 'dbus-src', 'release' ) )
    utils.debug( 'get installed package (debug):   %s' % db.getInstalled( 'win32libs', 'dbus-src', 'debug' ) )

    utils.new_line()
    utils.debug( 'now trying to remove package & revert it again later' )
    # remove the package again
    packageList = db.remInstalled( 'win32libs', 'dbus-src', '1.4.0' )
    for pac in packageList:
        for line in pac.getFiles(): # pylint: disable=W0612
            # we could remove the file here
            # print line
            pass
    utils.debug_line()

    utils.new_line()
    utils.debug( 'checking installed packages' )
    utils.debug( 'get installed package (release): %s' % db.getInstalled( 'win32libs', 'dbus-src', 'release' ) )
    utils.debug( 'get installed package (debug):   %s' % db.getInstalled( 'win32libs', 'dbus-src', 'debug' ) )
    utils.debug_line()

    utils.new_line()
    utils.debug( 'reverting removal' )
    # now instead of completing the removal, revert it
    for pac in packageList:
        pac.revert()

    utils.debug( 'checking installed packages' )
    utils.debug( 'get installed package (release): %s' % db.getInstalled( 'win32libs', 'dbus-src', 'release' ) )
    utils.debug( 'get installed package (debug):   %s' % db.getInstalled( 'win32libs', 'dbus-src', 'debug' ) )
    utils.debug_line()

    db.getInstalled()
    db.getInstalled( category='win32libs', prefix='debug' )
    db.getInstalled( package='dbus-src' )

    utils.new_line()
    utils.debug( 'now really remove the package' )
    packageList = db.remInstalled( 'win32libs', 'dbus-src', '1.4.0')
    for pac in packageList:
        utils.debug( 'removing %s files' % len( pac.getFiles() ) )
        pac.uninstall()

    utils.debug( 'get installed package (release): %s' % db.getInstalled( 'win32libs', 'dbus-src', 'release' ) )
    utils.debug( 'get installed package (debug):   %s' % db.getInstalled( 'win32libs', 'dbus-src', 'debug' ) )
    utils.debug_line()

    # test the import from the old style (manifest based) databases
    utils.new_line()
    db_temp.importExistingDatabase()
    print("getInstalled:", db_temp.getInstalled())
    print("findInstalled:", portage.findInstalled( 'win32libs', 'dbus-src' ))
    print("getFileListFromManifest:", len( utils.getFileListFromManifest( os.getenv( "KDEROOT" ), 'dbus-src' ) ))